From 5e3c79160b332614abc75617c51d3ecf95fd4792 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Fri, 13 Jul 2018 14:10:21 +0300 Subject: [PATCH] Changed config.json path --- script.py | 5 +++-- src/searcher.py | 4 ++-- src/tools.py | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/script.py b/script.py index 9b0ec21..23ab573 100644 --- a/script.py +++ b/script.py @@ -609,8 +609,9 @@ def main(): print(err) sys.exit() - GLOBAL.config = getConfig("config.json") - + if not Path(GLOBAL.configDirectory).is_dir(): + os.makedirs(GLOBAL.configDirectory) + GLOBAL.config = getConfig(GLOBAL.configDirectory / "config.json") if GLOBAL.arguments.log is not None: logDir = Path(GLOBAL.arguments.log) diff --git a/src/searcher.py b/src/searcher.py index 06ccb70..86f6d94 100644 --- a/src/searcher.py +++ b/src/searcher.py @@ -89,7 +89,7 @@ def beginPraw(config,user_agent = str(socket.gethostname())): authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes) reddit = authorizedInstance[0] refresh_token = authorizedInstance[1] - jsonFile("config.json").add({ + jsonFile(GLOBAL.configDirectory / "config.json").add({ "reddit_refresh_token":refresh_token }) else: @@ -98,7 +98,7 @@ def beginPraw(config,user_agent = str(socket.gethostname())): authorizedInstance = GetAuth(reddit,port).getRefreshToken(*scopes) reddit = authorizedInstance[0] refresh_token = authorizedInstance[1] - jsonFile("config.json").add({ + jsonFile(GLOBAL.configDirectory / "config.json").add({ "reddit_refresh_token":refresh_token }) return reddit diff --git a/src/tools.py b/src/tools.py index 16af577..e8a1c42 100644 --- a/src/tools.py +++ b/src/tools.py @@ -14,6 +14,7 @@ class GLOBAL: config = None arguments = None directory = None + configDirectory = Path.home() / "Bulk Downloader for Reddit" reddit_client_id = "BSyphDdxYZAgVQ" reddit_client_secret = "bfqNJaRh8NMh-9eAr-t4TRz-Blk" printVanilla = print