diff options
author | Samuel Smoker <classicsc@users.noreply.github.com> | 2017-03-13 13:28:50 -0700 |
---|---|---|
committer | Samuel Smoker <classicsc@users.noreply.github.com> | 2017-03-13 13:28:50 -0700 |
commit | 17d8bfa5ce911a8551dc1328476ca8cdac7511b7 (patch) | |
tree | 21d71acb70dd4360c578884f0a5a08594c58b988 | |
parent | c85f9d0f359131d9824de58c69d9d4ad00fa4698 (diff) | |
download | syncthingmanager-17d8bfa5ce911a8551dc1328476ca8cdac7511b7.tar.xz syncthingmanager-17d8bfa5ce911a8551dc1328476ca8cdac7511b7.zip |
Use python-syncthing pause/resume
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | syncthingmanager/__init__.py | 37 |
2 files changed, 3 insertions, 36 deletions
@@ -20,7 +20,7 @@ setup( ], keywords='syncthing', packages=['syncthingmanager'], - install_requires=['syncthing'], + install_requires=['syncthing>=2.0.2'], extras_require={ 'test': ['pytest'] }, diff --git a/syncthingmanager/__init__.py b/syncthingmanager/__init__.py index 4b0f7ff..e5cd405 100644 --- a/syncthingmanager/__init__.py +++ b/syncthingmanager/__init__.py @@ -50,38 +50,6 @@ class SyncthingManagerError(Exception): class SyncthingManager(Syncthing): - def pause(self, device): - """ Pause the given device. - - Args: - device (str): Device ID. - - Returns: - dict: with keys ``success`` and ``error``. - """ - resp = self.system.post('pause', params={'device': device}, return_response=True) - error = resp.text - if not error: - error = None - return {'success': resp.status_code == requests.codes.ok, - 'error': error} - - def resume(self, device): - """ Resume the given device. - - Args: - device (str): Device ID. - - Returns: - dict: with keys ``success`` and ``error``. - """ - resp = self.system.post('resume', params={'device': device}, return_response=True) - error = resp.text - if not error: - error = None - return {'success': resp.status_code == requests.codes.ok, - 'error': error} - def device_info(self, devicestr): """ A helper for finding a device ID from a user string that may be a deviceID a device name. @@ -184,11 +152,10 @@ class SyncthingManager(Syncthing): Returns: None """ device_id = self.device_info(device)['id'] - r = self.pause(device_id) + r = self.system.pause(device_id) if r['error']: raise SyncthingManagerError(r['error']) - def daemon_resume(self, device): """ Resume one or all devices. @@ -198,7 +165,7 @@ class SyncthingManager(Syncthing): Returns: None """ device_id = self.device_info(device)['id'] - r = self.resume(device_id) + r = self.system.resume(device_id) if r['error']: raise SyncthingManagerError(r['error']) |