Skip to content

Commit

Permalink
Run all API v2 request functions async
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh5 committed Aug 31, 2024
1 parent 3b24873 commit 63978b8
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 68 deletions.
4 changes: 2 additions & 2 deletions unmanic/webserver/api_v2/base_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ async def action_route(self):
route.get("call_method"), params["path_args"],
params["path_kwargs"]), exc_info=True)

getattr(self, route.get("call_method"))(*params["path_args"], **params["path_kwargs"])
await getattr(self, route.get("call_method"))(*params["path_args"], **params["path_kwargs"])
return

# This route matches the current request URI and does not have any params.
# Set this route and call the configured method.
tornado.log.app_log.debug("Routing API to {}.{}()".format(self.__class__.__name__, route.get("call_method")),
exc_info=True)
self.route = route
getattr(self, route.get("call_method"))()
await getattr(self, route.get("call_method"))()
return

if matched_route_with_unsupported_method:
Expand Down
4 changes: 2 additions & 2 deletions unmanic/webserver/api_v2/docs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def initialize(self, **kwargs):
udq = UnmanicDataQueues()
self.unmanic_data_queues = udq.get_unmanic_data_queues()

def get_privacy_policy(self):
async def get_privacy_policy(self):
"""
Docs - read privacy policy
---
Expand Down Expand Up @@ -127,7 +127,7 @@ def get_privacy_policy(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_logs_as_zip(self):
async def get_logs_as_zip(self):
"""
Docs - get log files as zip
---
Expand Down
2 changes: 1 addition & 1 deletion unmanic/webserver/api_v2/filebrowser_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def initialize(self, **kwargs):
udq = UnmanicDataQueues()
self.unmanic_data_queues = udq.get_unmanic_data_queues()

def fetch_directory_listing(self):
async def fetch_directory_listing(self):
"""
Filebrowser - List files and/or subdirectories in a given directory
---
Expand Down
8 changes: 4 additions & 4 deletions unmanic/webserver/api_v2/history_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def initialize(self, **kwargs):
self.unmanic_data_queues = udq.get_unmanic_data_queues()
self.config = config.Config()

def get_completed_tasks(self):
async def get_completed_tasks(self):
"""
History - list tasks
---
Expand Down Expand Up @@ -159,7 +159,7 @@ def get_completed_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def delete_completed_tasks(self):
async def delete_completed_tasks(self):
"""
History - delete
---
Expand Down Expand Up @@ -220,7 +220,7 @@ def delete_completed_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def add_completed_tasks_to_pending_list(self):
async def add_completed_tasks_to_pending_list(self):
"""
History - reprocess
---
Expand Down Expand Up @@ -291,7 +291,7 @@ def add_completed_tasks_to_pending_list(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_completed_task_log(self):
async def get_completed_task_log(self):
"""
History - details
---
Expand Down
4 changes: 2 additions & 2 deletions unmanic/webserver/api_v2/notifications_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize(self, **kwargs):
self.unmanic_data_queues = udq.get_unmanic_data_queues()
self.config = config.Config()

def get_notifications(self):
async def get_notifications(self):
"""
Notifications - read
---
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_notifications(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def remove_notifications(self):
async def remove_notifications(self):
"""
Notifications - delete
---
Expand Down
20 changes: 10 additions & 10 deletions unmanic/webserver/api_v2/pending_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def initialize(self, **kwargs):
udq = UnmanicDataQueues()
self.unmanic_data_queues = udq.get_unmanic_data_queues()

def get_pending_tasks(self):
async def get_pending_tasks(self):
"""
Pending - list tasks
---
Expand Down Expand Up @@ -182,7 +182,7 @@ def get_pending_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def delete_pending_tasks(self):
async def delete_pending_tasks(self):
"""
Pending - delete
---
Expand Down Expand Up @@ -243,7 +243,7 @@ def delete_pending_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def trigger_library_rescan(self):
async def trigger_library_rescan(self):
"""
Pending - trigger a library scan
---
Expand Down Expand Up @@ -300,7 +300,7 @@ def trigger_library_rescan(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def reorder_pending_tasks(self):
async def reorder_pending_tasks(self):
"""
Pending - reorder
---
Expand Down Expand Up @@ -361,7 +361,7 @@ def reorder_pending_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def create_task_from_path(self):
async def create_task_from_path(self):
"""
Pending - create
---
Expand Down Expand Up @@ -445,7 +445,7 @@ def create_task_from_path(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_pending_status_of_tasks(self):
async def get_pending_status_of_tasks(self):
"""
Pending - get status of tasks
---
Expand Down Expand Up @@ -513,7 +513,7 @@ def get_pending_status_of_tasks(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def set_pending_status_as_ready(self):
async def set_pending_status_as_ready(self):
"""
Pending - set status as ready
---
Expand Down Expand Up @@ -574,7 +574,7 @@ def set_pending_status_as_ready(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def set_pending_library_by_name(self):
async def set_pending_library_by_name(self):
"""
Pending - set the library of a list of given tasks
---
Expand Down Expand Up @@ -638,7 +638,7 @@ def set_pending_library_by_name(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def gen_download_link_pending_task_file(self, task_id=None):
async def gen_download_link_pending_task_file(self, task_id=None):
"""
Pending - request a link for downloading a task file
---
Expand Down Expand Up @@ -709,7 +709,7 @@ def gen_download_link_pending_task_file(self, task_id=None):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def gen_download_link_pending_task_data(self, task_id=None):
async def gen_download_link_pending_task_data(self, task_id=None):
"""
Pending - request a link for downloading a task data
---
Expand Down
34 changes: 17 additions & 17 deletions unmanic/webserver/api_v2/plugins_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def initialize(self, **kwargs):
udq = UnmanicDataQueues()
self.unmanic_data_queues = udq.get_unmanic_data_queues()

def get_installed_plugins(self):
async def get_installed_plugins(self):
"""
Plugins - list installed plugins
---
Expand Down Expand Up @@ -218,7 +218,7 @@ def get_installed_plugins(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def enable_plugins(self):
async def enable_plugins(self):
"""
Plugins - enable
---
Expand Down Expand Up @@ -271,7 +271,7 @@ def enable_plugins(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def disable_plugins(self):
async def disable_plugins(self):
"""
Plugins - disable
---
Expand Down Expand Up @@ -324,7 +324,7 @@ def disable_plugins(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def update_plugins(self):
async def update_plugins(self):
"""
Plugins - update
---
Expand Down Expand Up @@ -385,7 +385,7 @@ def update_plugins(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def remove_plugins(self):
async def remove_plugins(self):
"""
Plugins - remove
---
Expand Down Expand Up @@ -446,7 +446,7 @@ def remove_plugins(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_plugin_info(self):
async def get_plugin_info(self):
"""
Plugins - return a requested plugin's metadata and settings
---
Expand Down Expand Up @@ -525,7 +525,7 @@ def get_plugin_info(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def update_plugin_settings(self):
async def update_plugin_settings(self):
"""
Plugins - Save the settings of a single plugin
---
Expand Down Expand Up @@ -590,7 +590,7 @@ def update_plugin_settings(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def reset_plugin_settings(self):
async def reset_plugin_settings(self):
"""
Plugins - Reset the settings of a single plugin
---
Expand Down Expand Up @@ -654,7 +654,7 @@ def reset_plugin_settings(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_installable_plugin_list(self):
async def get_installable_plugin_list(self):
"""
Plugins - Read all installable plugins
---
Expand Down Expand Up @@ -709,7 +709,7 @@ def get_installable_plugin_list(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def install_plugin_by_id(self):
async def install_plugin_by_id(self):
"""
Plugins - Install a single plugin by its Plugin ID
---
Expand Down Expand Up @@ -770,7 +770,7 @@ def install_plugin_by_id(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_plugin_types_with_flows(self):
async def get_plugin_types_with_flows(self):
"""
Plugins - Get a list of all plugin types that have flows
---
Expand Down Expand Up @@ -824,7 +824,7 @@ def get_plugin_types_with_flows(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_enabled_plugins_flow_by_type(self):
async def get_enabled_plugins_flow_by_type(self):
"""
Plugins - Get the plugin flow for a requested plugin type
---
Expand Down Expand Up @@ -888,7 +888,7 @@ def get_enabled_plugins_flow_by_type(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def save_enabled_plugin_flow(self):
async def save_enabled_plugin_flow(self):
"""
Plugins - Save the plugin flow for a requested plugin type
---
Expand Down Expand Up @@ -951,7 +951,7 @@ def save_enabled_plugin_flow(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def update_repo_list(self):
async def update_repo_list(self):
"""
Plugins - Update the plugin repo list
---
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def update_repo_list(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_repo_list(self):
async def get_repo_list(self):
"""
Plugins - Read all configured plugin repos
---
Expand Down Expand Up @@ -1067,7 +1067,7 @@ def get_repo_list(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def reload_repo_data(self):
async def reload_repo_data(self):
"""
Plugins - Reload plugin repositories remote data
---
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def reload_repo_data(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def get_enabled_panel_plugins_list(self):
async def get_enabled_panel_plugins_list(self):
"""
Plugins - Read all enabled "data panel" type plugins
---
Expand Down
6 changes: 3 additions & 3 deletions unmanic/webserver/api_v2/session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def initialize(self, **kwargs):
udq = UnmanicDataQueues()
self.unmanic_data_queues = udq.get_unmanic_data_queues()

def get_session_state(self):
async def get_session_state(self):
"""
Session - state
---
Expand Down Expand Up @@ -132,7 +132,7 @@ def get_session_state(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def session_reload(self):
async def session_reload(self):
"""
Session - reload
---
Expand Down Expand Up @@ -184,7 +184,7 @@ def session_reload(self):
self.set_status(self.STATUS_ERROR_INTERNAL, reason=str(e))
self.write_error()

def session_logout(self):
async def session_logout(self):
"""
Session - log out of session
---
Expand Down
Loading

0 comments on commit 63978b8

Please sign in to comment.