X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=python%2Fcumulus%2Fstore%2Fsftp.py;h=bbc4aff4672f35f9064bcb81f6e04b77db82497a;hb=a5f66616b1ec0c38328ad5131bf1c889ccc43659;hp=4d19c8c9c17c5f1a3c3282d7022ad04ddc0c2920;hpb=3fc24f6535cc8ab481ace110cbfb977af12f9640;p=cumulus.git diff --git a/python/cumulus/store/sftp.py b/python/cumulus/store/sftp.py index 4d19c8c..bbc4aff 100644 --- a/python/cumulus/store/sftp.py +++ b/python/cumulus/store/sftp.py @@ -1,6 +1,23 @@ -# vim: ai ts=4 sts=4 et sw=4 +# Cumulus: Efficient Filesystem Backup to the Cloud +# Copyright (C) 2010 The Cumulus Developers +# See the AUTHORS file for a list of contributors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + #needed for python 2.5 -from __future__ import with_statement + from paramiko import Transport, SFTPClient, RSAKey, DSSKey from paramiko.config import SSHConfig @@ -57,18 +74,18 @@ class SFTPStore(Store): host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) try: - self.hostkey = host_keys[self.config['hostkeyalias']].values()[0] + self.hostkey = list(host_keys[self.config['hostkeyalias']].values())[0] except: - print str(self.config) + print(str(self.config)) raise - if(self.config.has_key('identityfile')): + if('identityfile' in self.config): key_file = os.path.expanduser(self.config['identityfile']) #not really nice but i don't see a cleaner way atm... try: self.auth_key = RSAKey (key_file) - except SSHException, e: + except SSHException as e: if e.message == 'Unable to parse file': self.auth_key = DSAKey (key_file) else: @@ -94,7 +111,7 @@ class SFTPStore(Store): return "%s/%s" % (self.path, name) def list(self, type): - return filter(type_patterns[type].match, self.client.listdir(self.path)) + return list(filter(type_patterns[type].match, self.client.listdir(self.path))) def get(self, type, name): return self.client.open(self.__build_fn(name), mode = 'rb')