summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-07-29 12:26:43 +0100
committerLars Wirzenius <liw@liw.fi>2011-07-29 12:26:43 +0100
commit540253a762559ae66e459aaed7477faa5fb29eca (patch)
tree4db4a6a5d254ddf84948bab2b561d294142bbbb3
parent631d17eadd2b7712a2607579217a4156d308b33f (diff)
downloadobnam-540253a762559ae66e459aaed7477faa5fb29eca.tar.gz
Change use of "with fs.open(...)" to not use with.
Paramiko's SFTPClient does not support the "with" protocol, at least in the version in Debian squeeze, so we can't use it.
-rw-r--r--obnamlib/plugins/backup_plugin.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py
index 443164bf..66f74b55 100644
--- a/obnamlib/plugins/backup_plugin.py
+++ b/obnamlib/plugins/backup_plugin.py
@@ -213,9 +213,11 @@ class BackupPlugin(obnamlib.ObnamPlugin):
tag_contents = 'Signature: 8a477f597d28d172789f06886806bc55'
tag_path = os.path.join(pathname, 'CACHEDIR.TAG')
if self.fs.exists(tag_path):
- with self.fs.open(tag_path, 'rb') as f:
- data = f.read(len(tag_contents))
- return data != tag_contents
+ # Can't use with, because Paramiko's SFTPFile does not work.
+ f = self.fs.open(tag_path, 'rb')
+ data = f.read(len(tag_contents))
+ f.close()
+ return data != tag_contents
return True