diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-01-11 15:48:37 +0000 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2017-01-11 22:56:05 +0000 |
commit | af76abb038660857da0d9a533e8a208dc0285335 (patch) | |
tree | 38cebb422d8e65d5be57999630dcb89008a1e9df | |
parent | bf01b53bda7b8ce8f8701d8c6270cab9c4968b09 (diff) | |
download | deluge-af76abb038660857da0d9a533e8a208dc0285335.tar.gz deluge-af76abb038660857da0d9a533e8a208dc0285335.tar.bz2 deluge-af76abb038660857da0d9a533e8a208dc0285335.zip |
[UI] Fix usage of 'with Image.open' in trackericons
* Revert changes made to fix 'too many files open' as Image.open does
not return a file descriptor and generated the following error:
exceptions.AttributeError: 'NoneType' object has no attribute 'startswith'
* Also fix style for raising an exception.
-rw-r--r-- | deluge/ui/tracker_icons.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index e3a69fe78..27e3de0e9 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -359,13 +359,12 @@ class TrackerIcons(Component): if PIL_INSTALLED: try: - with Image.open(icon_name): - pass + Image.open(icon_name) except IOError, e: raise InvalidIconError(e) else: if os.stat(icon_name).st_size == 0L: - raise InvalidIconError, "empty icon" + raise InvalidIconError("empty icon") return icon_name @@ -434,14 +433,14 @@ class TrackerIcons(Component): """ if icon: filename = icon.get_filename() - with Image.open(filename) as img: - if img.size > (16, 16): - new_filename = filename.rpartition('.')[0]+".png" - img = img.resize((16, 16), Image.ANTIALIAS) - img.save(new_filename) - if new_filename != filename: - os.remove(filename) - icon = TrackerIcon(new_filename) + img = Image.open(filename) + if img.size > (16, 16): + new_filename = filename.rpartition('.')[0]+".png" + img = img.resize((16, 16), Image.ANTIALIAS) + img.save(new_filename) + if new_filename != filename: + os.remove(filename) + icon = TrackerIcon(new_filename) return icon def store_icon(self, icon, host): |