diff --git a/.gitignore b/.gitignore index 37825920..b481045f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ .idea *.iml -.DS_Store -*.db data diff --git a/apiclient.py b/apiclient.py index 2e28e9d2..cd772423 100644 --- a/apiclient.py +++ b/apiclient.py @@ -10,7 +10,10 @@ class ApiClient: return newclient def __call__(self, *args, **kwargs): - return requests.get(self.url, params=kwargs) + try: + return requests.get(self.url, params=kwargs) + except requests.exceptions.ConnectionError: + return None client = ApiClient('http://127.0.0.1:5000/openqq') diff --git a/app.py b/app.py index ebcce585..e55290cd 100644 --- a/app.py +++ b/app.py @@ -91,7 +91,7 @@ def _index(): return '', 204 -def load_commands(): +def _load_commands(): command_mod_files = filter( lambda filename: filename.endswith('.py') and not filename.startswith('_'), os.listdir(get_commands_dir()) @@ -106,5 +106,5 @@ def load_commands(): if __name__ == '__main__': - load_commands() + _load_commands() app.run(host='127.0.0.1', port=8888) diff --git a/command.py b/command.py index 6712cd06..e429d4fe 100644 --- a/command.py +++ b/command.py @@ -7,15 +7,15 @@ from little_shit import SkipException, get_command_name_separators _command_name_seps = get_command_name_separators() -class CommandNotExistsError(BaseException): +class CommandNotExistsError(Exception): pass -class CommandPermissionError(BaseException): +class CommandPermissionError(Exception): pass -class CommandScopeError(BaseException): +class CommandScopeError(Exception): def __init__(self, msg_type): self.msg_type = msg_type diff --git a/little_shit.py b/little_shit.py index fb537f5b..9a956a1f 100644 --- a/little_shit.py +++ b/little_shit.py @@ -3,7 +3,7 @@ import os from config import config -class SkipException(BaseException): +class SkipException(Exception): pass @@ -25,7 +25,7 @@ def get_db_dir(): def get_default_db_path(): - return os.path.join(get_db_dir(), 'default.db') + return os.path.join(get_db_dir(), 'default.sqlite') def get_tmp_dir(): diff --git a/requirements.txt b/requirements.txt index 5576ba5d..bbe71122 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +apscheduler requests cachetools pytz