diff --git a/.gitignore b/.gitignore index 4899128..789ef31 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,12 @@ test.py *.yaml *.db +## user file +token_cache.bin + +### plugin file +custom_plugins/* + ### venv template # Virtualenv # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ diff --git a/util/config.py b/util/config.py index 3311559..431faad 100644 --- a/util/config.py +++ b/util/config.py @@ -3,6 +3,7 @@ import os class Config: + __BASE_PATH = os.getcwd() __CONFIG_PATH = os.path.join(__BASE_PATH, 'config') __CONFIG_NAME = 'test.yaml' @@ -61,3 +62,14 @@ class Config: self.__CONFIG_DICT['PROXY'] = new_proxy with open(os.path.join(self.__CONFIG_PATH, self.__CONFIG_NAME), 'w') as f: f.write(yaml.safe_dump(self.__CONFIG_DICT, sort_keys=False)) + + def get_config(self, config_name, default=None): + try: + return self.__CONFIG_DICT[config_name] + except: + return default + + def set_config(self, config_name, value): + self.__CONFIG_DICT[config_name] = value + with open(os.path.join(self.__CONFIG_PATH, self.__CONFIG_NAME), 'w') as f: + f.write(yaml.safe_dump(self.__CONFIG_DICT, sort_keys=False)) \ No newline at end of file diff --git a/util/requests_with_proxy.py b/util/requests_with_proxy.py index f068a73..c8e7e45 100644 --- a/util/requests_with_proxy.py +++ b/util/requests_with_proxy.py @@ -34,7 +34,7 @@ class RequestWithProxy: def get(self, url, headers=None): try: - if url.replace("https://", "").replace("http://", "") in self.__no_proxy: + if url.replace("https://", "").replace("http://", "").splice('/')[0] in self.__no_proxy: r = requests.get(url=url, headers=headers) else: r = requests.get(url=url, headers=headers, proxies=self.__proxies)