From 2683421c34cdcedc63721af697682f1723c8f3fc Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Sun, 12 May 2019 15:20:10 -0400 Subject: [PATCH] Fix startup and create db path Fix for listen args and create db path if it doesn't exist --- bumper/__init__.py | 8 ++++++-- start_bumper.py | 13 ++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bumper/__init__.py b/bumper/__init__.py index 88fd4fe..cd21a05 100644 --- a/bumper/__init__.py +++ b/bumper/__init__.py @@ -82,11 +82,15 @@ def db_file(): def os_db_path(): + db_path = "" if platform.system() == "Windows": - return os.path.join(os.getenv("APPDATA"), "bumper.db") + + db_path = os.path.join(os.getenv("APPDATA")) else: - return os.path.expanduser("~/.config/bumper.db") + db_path = os.path.expanduser("~/.config") + os.makedirs(db_path, exist_ok=True) #Ensure db_path directory exists or create + return os.path.join(db_path, "bumper.db") def db_get(): try: diff --git a/start_bumper.py b/start_bumper.py index 1b0c9d4..a6796f8 100644 --- a/start_bumper.py +++ b/start_bumper.py @@ -10,6 +10,7 @@ import asyncio def main(): args = sys.argv + listen_host = "" if len(args) > 0: if "--debug" in args: @@ -24,16 +25,14 @@ def main(): ) # format="[%(asctime)s] :: %(levelname)s :: %(name)s :: %(module)s :: %(funcName)s :: %(lineno)d :: %(message)s") - listen_host = args.index("--listen") - if (len(args) - 1) >= (listen_host + 1): - listen_host = args[listen_host+1] - else: + if "--listen" in args: + listen_host = args[args.index("--listen") + 1] + + if listen_host == "": if platform.system() == "Darwin": # If a Mac, use 0.0.0.0 for listening listen_host = "0.0.0.0" else: - listen_host = socket.gethostbyname(socket.gethostname()) - #listen_host = "localhost" # Try this if the above doesn't work - + listen_host = socket.gethostbyname(socket.gethostname()) conf_address_443 = (listen_host, 443) conf_address_8007 = (listen_host, 8007)