diff --git a/API.md b/API.md index 77344489..3b340ce1 100644 --- a/API.md +++ b/API.md @@ -37,11 +37,11 @@ Get to the chopper! ### backup_config -Create a manual backup of the `config.ini` file. +Create a manual backup of the `config.ini` file. ### backup_db -Create a manual backup of the `plexpy.db` file. +Create a manual backup of the `plexpy.db` file. ### delete_all_library_history @@ -142,6 +142,18 @@ Returns: ``` +### delete_temp_sessions +Flush out all of the temporary sessions in the database. + +``` +Required parameters: + None + +Required parameters: + None +``` + + ### delete_user Delete a user from PlexPy. Also erases all history for the user. @@ -158,11 +170,11 @@ Returns: ### docs -Return the api docs as a dict where commands are keys, docstring are value. +Return the api docs as a dict where commands are keys, docstring are value. ### docs_md -Return the api docs formatted with markdown. +Return the api docs formatted with markdown. ### download_log @@ -755,11 +767,11 @@ Optional parameters: Returns: json: - [{"loglevel": "DEBUG", - "msg": "Latest version is 2d10b0748c7fa2ee4cf59960c3d3fffc6aa9512b", - "thread": "MainThread", + [{"loglevel": "DEBUG", + "msg": "Latest version is 2d10b0748c7fa2ee4cf59960c3d3fffc6aa9512b", + "thread": "MainThread", "time": "2016-05-08 09:36:51 " - }, + }, {...}, {...} ] @@ -1814,15 +1826,15 @@ Returns: ### refresh_libraries_list -Refresh the PlexPy libraries list. +Refresh the PlexPy libraries list. ### refresh_users_list -Refresh the PlexPy users list. +Refresh the PlexPy users list. ### restart -Restart PlexPy. +Restart PlexPy. ### search @@ -1905,7 +1917,7 @@ Uninstalls the GeoLite2 database ### update -Check for PlexPy updates on Github. +Check for PlexPy updates on Github. ### update_metadata_details diff --git a/plexpy/api2.py b/plexpy/api2.py index e836e190..69fe99c4 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -95,7 +95,7 @@ class API2: self._api_msg = 'Parameter cmd is required. Possible commands are: %s' % ', '.join(self._api_valid_methods) elif 'cmd' in kwargs and kwargs.get('cmd') not in self._api_valid_methods: - self._api_msg = 'Unknown command: %s. Possible commands are: %s' % (kwargs.get('cmd', ''), ', '.join(self._api_valid_methods)) + self._api_msg = 'Unknown command: %s. Possible commands are: %s' % (kwargs.get('cmd', ''), ', '.join(sorted(self._api_valid_methods))) self._api_callback = kwargs.pop('callback', None) self._api_apikey = kwargs.pop('apikey', None) @@ -427,6 +427,9 @@ General optional parameters: return data + def error(self, **kwargs): + return 1 / 0 + def _api_responds(self, result_type='error', data=None, msg=''): """ Formats the result to a predefined dict so we can hange it the to the desired output by _api_out_as """ @@ -507,12 +510,15 @@ General optional parameters: # We allow this to fail so we get a # traceback in the browser try: + result = call(**self._api_kwargs) except Exception as e: - if self._api_debug: # check this with j - pass - #cherrypy.request.show_tracebacks = True logger.error(u'PlexPy APIv2 :: Failed to run %s %s %s' % (self._api_cmd, self._api_kwargs, e)) + if self._api_debug: + cherrypy.request.show_tracebacks = True + # Reraise the exception so the traceback hits the browser + raise + self._api_msg = 'Check the log' ret = None # The api decorated function can return different result types. diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 3643ea2d..e707a65b 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -331,6 +331,16 @@ class WebInterface(object): @requireAuth(member_of("admin")) @addtoapi() def delete_temp_sessions(self, **kwargs): + """ Flush out all of the temporary sessions in the database. + + ``` + Required parameters: + None + + Required parameters: + None + ``` + """ result = database.delete_sessions()