Skip to content

Commit 14aab7d

Browse files
Formatted Code
1 parent 6315965 commit 14aab7d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/backup/Backup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flake8: noqa F501
12
import pathlib
23
import shutil
34
import tempfile
@@ -25,19 +26,21 @@ def database(self):
2526
"""
2627
Backup the database.
2728
"""
28-
29+
2930
db_config = config("database.databases")
3031
default = db_config.get("default")
3132
connection = db_config.get(default)
3233
driver = connection.get("driver")
3334

34-
db_file_path = base_path("{}.gz".format("database-" + str(datetime.timestamp(datetime.now()))))
35+
db_file_path = base_path(
36+
"{}.gz".format("database-" + str(datetime.timestamp(datetime.now())))
37+
)
3538

3639
if driver == "sqlite":
3740
pass
3841
elif driver == "mysql":
3942
command_str = f"mysqldump -u {connection.get('user')} -p{connection.get('password')} {connection.get('database')}"
40-
43+
4144
elif driver == "postgres":
4245
command_str = f"pg_dump -U{connection.get('user')} -h{connection.get('host')} -p{connection.get('port')} -d{connection.get('database')}"
4346

@@ -49,7 +52,7 @@ def database(self):
4952

5053
elif driver == "oracle":
5154
command_str = f"sqlplus -S{connection.get('user')}/{connection.get('password')}@{connection.get('host')}:{connection.get('port')}/{connection.get('database')}"
52-
55+
5356
if command_str:
5457
with gzip.open(db_file_path, "wb") as f:
5558
popen = subprocess.Popen(
@@ -59,7 +62,7 @@ def database(self):
5962
universal_newlines=True,
6063
)
6164
for stdout_line in iter(popen.stdout.readline, ""):
62-
f.write(stdout_line.encode('utf-8'))
65+
f.write(stdout_line.encode("utf-8"))
6366
popen.stdout.close()
6467
popen.wait()
6568
return db_file_path

src/backup/config/backup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flake8: noqa F501
12
"""Backup Settings"""
23

34
from masonite.utils.location import base_path
@@ -11,8 +12,8 @@
1112
|
1213
"""
1314

14-
FILENAME = "backup" # The filename of the backup file. (without the extension)
15-
DIRECTORY = "backup" # storage/backup
15+
FILENAME = "backup" # The filename of the backup file. (without the extension)
16+
DIRECTORY = "backup" # storage/backup
1617
SOURCE = {
1718
"root": base_path(),
1819
"excludes": [

0 commit comments

Comments
 (0)