Skip to content

Commit

Permalink
Config.py fixes
Browse files Browse the repository at this point in the history
Fixed config.py to ensure there is a database keyword and also to check for args
  • Loading branch information
moyito2604 committed Oct 14, 2024
1 parent e80ef7b commit 60c3dfb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
location = os.environ.get("config", "config.yaml")
# Set yaml config as conf
conf = config.importConfig(location)
# Import Standalone Arguments
args = conf["args"]


Expand Down
21 changes: 13 additions & 8 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ def importConfig(filename):
conf["databases"][database]["excluded_tables"] = 0
if not conf["databases"][database].get("driver", None):
conf["databases"][database]["driver"] = "postgres"
if not conf["args"].get("backup_interval", None):
conf["args"]["backup_interval"] = -1
if not conf["args"].get("backup_count", None):
conf["args"]["backup_count"] = -1
if not conf["args"].get("backup_location", None):
conf["args"]["backup_location"] = str(os.getcwd())+"/Backups"
if not conf["args"].get("tz", None):
conf["args"]["tz"] = 'America/New_York'
else:
print("No Databases Provided, exiting...")
error.exit_program()
if not conf.get("args", None):
conf["args"] = {}
if not conf["args"].get("backup_interval", None):
conf["args"]["backup_interval"] = -1
if not conf["args"].get("backup_count", None):
conf["args"]["backup_count"] = -1
if not conf["args"].get("backup_location", None):
conf["args"]["backup_location"] = str(os.getcwd())+"/Backups"
if not conf["args"].get("tz", None):
conf["args"]["tz"] = 'America/New_York'
else:
print("databases Keyword is necessary to add a database")
return conf
Expand Down
10 changes: 5 additions & 5 deletions modules/error.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Contains errors for program

# import sys
#
# def exit_program():
# print("Exiting the program...")
# sys.exit(0)
import sys

def exit_program():
print("Exiting the program...")
sys.exit(0)

class SQLServerError(Exception):
def __init__(self, message=None):
Expand Down

0 comments on commit 60c3dfb

Please sign in to comment.