summaryrefslogtreecommitdiffstats
path: root/module/plugins/Container.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 03:08:19 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 03:08:19 +0100
commitbd8259220ab4d56ab419b7b32045b08cc9b0a7c8 (patch)
tree92f1c69d4280f8f57021083dbf878e62033eb502 /module/plugins/Container.py
parentCookie support for getURL method (diff)
downloadpyload-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.py8
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)