Update md add exception traceback to the browser

This commit is contained in:
Hellowlol 2016-11-05 22:24:37 +01:00
parent 11c7342299
commit e881c32797
3 changed files with 44 additions and 16 deletions

36
API.md
View file

@ -37,11 +37,11 @@ Get to the chopper!
### backup_config ### backup_config
Create a manual backup of the `config.ini` file. Create a manual backup of the `config.ini` file.
### backup_db ### backup_db
Create a manual backup of the `plexpy.db` file. Create a manual backup of the `plexpy.db` file.
### delete_all_library_history ### 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_user
Delete a user from PlexPy. Also erases all history for the user. Delete a user from PlexPy. Also erases all history for the user.
@ -158,11 +170,11 @@ Returns:
### docs ### 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 ### docs_md
Return the api docs formatted with markdown. Return the api docs formatted with markdown.
### download_log ### download_log
@ -755,11 +767,11 @@ Optional parameters:
Returns: Returns:
json: json:
[{"loglevel": "DEBUG", [{"loglevel": "DEBUG",
"msg": "Latest version is 2d10b0748c7fa2ee4cf59960c3d3fffc6aa9512b", "msg": "Latest version is 2d10b0748c7fa2ee4cf59960c3d3fffc6aa9512b",
"thread": "MainThread", "thread": "MainThread",
"time": "2016-05-08 09:36:51 " "time": "2016-05-08 09:36:51 "
}, },
{...}, {...},
{...} {...}
] ]
@ -1814,15 +1826,15 @@ Returns:
### refresh_libraries_list ### refresh_libraries_list
Refresh the PlexPy libraries list. Refresh the PlexPy libraries list.
### refresh_users_list ### refresh_users_list
Refresh the PlexPy users list. Refresh the PlexPy users list.
### restart ### restart
Restart PlexPy. Restart PlexPy.
### search ### search
@ -1905,7 +1917,7 @@ Uninstalls the GeoLite2 database
### update ### update
Check for PlexPy updates on Github. Check for PlexPy updates on Github.
### update_metadata_details ### update_metadata_details

View file

@ -95,7 +95,7 @@ class API2:
self._api_msg = 'Parameter cmd is required. Possible commands are: %s' % ', '.join(self._api_valid_methods) 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: 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_callback = kwargs.pop('callback', None)
self._api_apikey = kwargs.pop('apikey', None) self._api_apikey = kwargs.pop('apikey', None)
@ -427,6 +427,9 @@ General optional parameters:
return data return data
def error(self, **kwargs):
return 1 / 0
def _api_responds(self, result_type='error', data=None, msg=''): def _api_responds(self, result_type='error', data=None, msg=''):
""" Formats the result to a predefined dict so we can hange it the to """ Formats the result to a predefined dict so we can hange it the to
the desired output by _api_out_as """ the desired output by _api_out_as """
@ -507,12 +510,15 @@ General optional parameters:
# We allow this to fail so we get a # We allow this to fail so we get a
# traceback in the browser # traceback in the browser
try: try:
result = call(**self._api_kwargs) result = call(**self._api_kwargs)
except Exception as e: 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)) 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 ret = None
# The api decorated function can return different result types. # The api decorated function can return different result types.

View file

@ -331,6 +331,16 @@ class WebInterface(object):
@requireAuth(member_of("admin")) @requireAuth(member_of("admin"))
@addtoapi() @addtoapi()
def delete_temp_sessions(self, **kwargs): 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() result = database.delete_sessions()