Skip to content

Commit

Permalink
Remove error cmd from API
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyWong16 committed Nov 11, 2016
1 parent 21d9091 commit 960b601
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
8 changes: 0 additions & 8 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@ 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.
Expand Down
23 changes: 10 additions & 13 deletions plexpy/api2.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def _api_docs(self, md=False):
return docs

def docs_md(self):
""" Return the api docs formatted with markdown. """
""" Return the api docs formatted with markdown."""

return self._api_make_md()

def docs(self):
""" 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."""

return self._api_docs()

Expand Down Expand Up @@ -298,44 +298,44 @@ def sql(self, query=''):
return rows

def backup_config(self):
""" Create a manual backup of the `config.ini` file. """
""" Create a manual backup of the `config.ini` file."""

data = config.make_backup()
self._api_result_type = 'success' if data else 'error'

return data

def backup_db(self):
""" Create a manual backup of the `plexpy.db` file. """
""" Create a manual backup of the `plexpy.db` file."""

data = database.make_backup()
self._api_result_type = 'success' if data else 'error'

return data

def restart(self, **kwargs):
""" Restart PlexPy. """
""" Restart PlexPy."""

plexpy.SIGNAL = 'restart'
self._api_msg = 'Restarting plexpy'
self._api_result_type = 'success'

def update(self, **kwargs):
""" Check for PlexPy updates on Github. """
""" Check for PlexPy updates on Github."""

plexpy.SIGNAL = 'update'
self._api_msg = 'Updating plexpy'
self._api_result_type = 'success'

def refresh_libraries_list(self, **kwargs):
""" Refresh the PlexPy libraries list. """
""" Refresh the PlexPy libraries list."""
data = pmsconnect.refresh_libraries()
self._api_result_type = 'success' if data else 'error'

return data

def refresh_users_list(self, **kwargs):
""" Refresh the PlexPy users list. """
""" Refresh the PlexPy users list."""
data = plextv.refresh_users()
self._api_result_type = 'success' if data else 'error'

Expand Down Expand Up @@ -427,9 +427,6 @@ def get_apikey(self, username='', password=''):

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 """
Expand Down Expand Up @@ -513,12 +510,12 @@ def _api_run(self, *args, **kwargs):

result = call(**self._api_kwargs)
except Exception as e:
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 with %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'
self._api_msg = 'Check the logs'

ret = None
# The api decorated function can return different result types.
Expand Down
11 changes: 1 addition & 10 deletions plexpy/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,7 @@ def get_recently_added(self, count='0', **kwargs):
@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
```
"""
""" Flush out all of the temporary sessions in the database."""

result = database.delete_sessions()

Expand Down

0 comments on commit 960b601

Please sign in to comment.