diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-11-09 03:08:19 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-11-09 03:08:19 +0100 |
commit | bd8259220ab4d56ab419b7b32045b08cc9b0a7c8 (patch) | |
tree | 92f1c69d4280f8f57021083dbf878e62033eb502 /module/plugins/Container.py | |
parent | Cookie support for getURL method (diff) | |
download | pyload-bd8259220ab4d56ab419b7b32045b08cc9b0a7c8.tar.xz |
Use with statement instead open method when accessing fod + handle i/o error
Diffstat (limited to 'module/plugins/Container.py')
-rw-r--r-- | module/plugins/Container.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/module/plugins/Container.py b/module/plugins/Container.py index 16d0045a6..913c80481 100644 --- a/module/plugins/Container.py +++ b/module/plugins/Container.py @@ -44,9 +44,11 @@ class Container(Crypter): self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] content = self.load(self.pyfile.url) self.pyfile.url = save_join(self.config['general']['download_folder'], self.pyfile.name) - f = open(self.pyfile.url, "wb" ) - f.write(content) - f.close() + try: + with open(self.pyfile.url, "wb") as f: + f.write(content) + except IOError, e: + self.fail(str(e)) else: self.pyfile.name = basename(self.pyfile.url) |