From bb3faaf2cdc8b2677c7ee7350726283d04928e74 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 20 Jan 2014 23:27:58 +0100 Subject: [PATCH] Exception cleanup --- couchpotato/core/downloaders/deluge/main.py | 12 ++++++------ couchpotato/core/downloaders/rtorrent/main.py | 6 +++--- couchpotato/core/downloaders/synology/main.py | 6 +++--- couchpotato/core/downloaders/transmission/main.py | 6 +++--- couchpotato/core/downloaders/utorrent/main.py | 8 ++++---- couchpotato/core/notifications/plex/client.py | 4 ++-- couchpotato/core/notifications/pushbullet/main.py | 2 +- couchpotato/core/plugins/renamer/main.py | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/couchpotato/core/downloaders/deluge/main.py b/couchpotato/core/downloaders/deluge/main.py index 53b87d91..c5f80167 100644 --- a/couchpotato/core/downloaders/deluge/main.py +++ b/couchpotato/core/downloaders/deluge/main.py @@ -188,7 +188,7 @@ class DelugeRPC(object): if torrent_id and options['label']: self.client.label.set_torrent(torrent_id, options['label']).get() - except Exception, err: + except Exception as err: log.error('Failed to add torrent magnet %s: %s %s', (torrent, err, traceback.format_exc())) finally: if self.client: @@ -206,7 +206,7 @@ class DelugeRPC(object): if torrent_id and options['label']: self.client.label.set_torrent(torrent_id, options['label']).get() - except Exception, err: + except Exception as err: log.error('Failed to add torrent file %s: %s %s', (filename, err, traceback.format_exc())) finally: if self.client: @@ -219,7 +219,7 @@ class DelugeRPC(object): try: self.connect() ret = self.client.core.get_torrents_status({'id': ids}, ('name', 'hash', 'save_path', 'move_completed_path', 'progress', 'state', 'eta', 'ratio', 'stop_ratio', 'is_seed', 'is_finished', 'paused', 'move_on_completed', 'files')).get() - except Exception, err: + except Exception as err: log.error('Failed to get all torrents: %s %s', (err, traceback.format_exc())) finally: if self.client: @@ -230,7 +230,7 @@ class DelugeRPC(object): try: self.connect() self.client.core.pause_torrent(torrent_ids).get() - except Exception, err: + except Exception as err: log.error('Failed to pause torrent: %s %s', (err, traceback.format_exc())) finally: if self.client: @@ -240,7 +240,7 @@ class DelugeRPC(object): try: self.connect() self.client.core.resume_torrent(torrent_ids).get() - except Exception, err: + except Exception as err: log.error('Failed to resume torrent: %s %s', (err, traceback.format_exc())) finally: if self.client: @@ -251,7 +251,7 @@ class DelugeRPC(object): try: self.connect() ret = self.client.core.remove_torrent(torrent_id, remove_local_data).get() - except Exception, err: + except Exception as err: log.error('Failed to remove torrent: %s %s', (err, traceback.format_exc())) finally: if self.client: diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index f934de5f..ff801db7 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -87,7 +87,7 @@ class rTorrent(Downloader): # Reset group action and disable it group.set_command() group.disable() - except MethodError, err: + except MethodError as err: log.error('Unable to set group options: %s', err.msg) return False @@ -155,7 +155,7 @@ class rTorrent(Downloader): torrent.start() return self.downloadReturnId(torrent_hash) - except Exception, err: + except Exception as err: log.error('Failed to send torrent to rTorrent: %s', err) return False @@ -203,7 +203,7 @@ class rTorrent(Downloader): return release_downloads - except Exception, err: + except Exception as err: log.error('Failed to get status from rTorrent: %s', err) return [] diff --git a/couchpotato/core/downloaders/synology/main.py b/couchpotato/core/downloaders/synology/main.py index 26a4558d..f964f37f 100644 --- a/couchpotato/core/downloaders/synology/main.py +++ b/couchpotato/core/downloaders/synology/main.py @@ -108,11 +108,11 @@ class SynologyRPC(object): if response['success']: log.info('Synology action successfull') return response - except requests.ConnectionError, err: + except requests.ConnectionError as err: log.error('Synology connection error, check your config %s', err) - except requests.HTTPError, err: + except requests.HTTPError as err: log.error('SynologyRPC HTTPError: %s', err) - except Exception, err: + except Exception as err: log.error('Exception: %s', err) finally: return response diff --git a/couchpotato/core/downloaders/transmission/main.py b/couchpotato/core/downloaders/transmission/main.py index d3f17598..2daeab46 100644 --- a/couchpotato/core/downloaders/transmission/main.py +++ b/couchpotato/core/downloaders/transmission/main.py @@ -187,10 +187,10 @@ class TransmissionRPC(object): else: log.debug('Unknown failure sending command to Transmission. Return text is: %s', response['result']) return False - except httplib.InvalidURL, err: + except httplib.InvalidURL as err: log.error('Invalid Transmission host, check your config %s', err) return False - except urllib2.HTTPError, err: + except urllib2.HTTPError as err: if err.code == 401: log.error('Invalid Transmission Username or Password, check your config') return False @@ -208,7 +208,7 @@ class TransmissionRPC(object): log.error('Unable to get Transmission Session-Id %s', err) else: log.error('TransmissionRPC HTTPError: %s', err) - except urllib2.URLError, err: + except urllib2.URLError as err: log.error('Unable to connect to Transmission %s', err) def get_session(self): diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py index e527230c..f8108492 100644 --- a/couchpotato/core/downloaders/utorrent/main.py +++ b/couchpotato/core/downloaders/utorrent/main.py @@ -231,14 +231,14 @@ class uTorrentAPI(object): return response else: log.debug('Unknown failure sending command to uTorrent. Return text is: %s', response) - except httplib.InvalidURL, err: + except httplib.InvalidURL as err: log.error('Invalid uTorrent host, check your config %s', err) - except urllib2.HTTPError, err: + except urllib2.HTTPError as err: if err.code == 401: log.error('Invalid uTorrent Username or Password, check your config') else: log.error('uTorrent HTTPError: %s', err) - except urllib2.URLError, err: + except urllib2.URLError as err: log.error('Unable to connect to uTorrent %s', err) return False @@ -304,7 +304,7 @@ class uTorrentAPI(object): #log.debug('uTorrent settings: %s', settings_dict) - except Exception, err: + except Exception as err: log.error('Failed to get settings from uTorrent: %s', err) return settings_dict diff --git a/couchpotato/core/notifications/plex/client.py b/couchpotato/core/notifications/plex/client.py index b873518e..8864230d 100644 --- a/couchpotato/core/notifications/plex/client.py +++ b/couchpotato/core/notifications/plex/client.py @@ -29,7 +29,7 @@ class PlexClientHTTP(PlexClientProtocol): try: self.plex.urlopen(url, headers = headers, timeout = 3, show_error = False) - except Exception, err: + except Exception as err: log.error("Couldn't sent command to Plex: %s", err) return False @@ -68,7 +68,7 @@ class PlexClientJSON(PlexClientProtocol): try: requests.post(url, headers = headers, timeout = 3, data = json.dumps(request)) - except Exception, err: + except Exception as err: log.error("Couldn't sent command to Plex: %s", err) return False diff --git a/couchpotato/core/notifications/pushbullet/main.py b/couchpotato/core/notifications/pushbullet/main.py index bc9fd64c..15120f0b 100644 --- a/couchpotato/core/notifications/pushbullet/main.py +++ b/couchpotato/core/notifications/pushbullet/main.py @@ -79,7 +79,7 @@ class Pushbullet(Notification): data = self.urlopen(self.url % method, headers = headers, data = kwargs) return json.loads(data) - except Exception, ex: + except Exception as ex: log.error('Pushbullet request failed') log.debug(ex) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 9ba1c09b..97e59bde 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -762,7 +762,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) except: log.error('Failed setting permissions for file: %s, %s', (dest, traceback.format_exc(1))) - except OSError, err: + except OSError as err: # Copying from a filesystem with octal permission to an NTFS file system causes a permission error. In this case ignore it. if not hasattr(os, 'chmod') or err.errno != errno.EPERM: raise