projects
/
cumulus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add some further documentation on the sftp backend
[cumulus.git]
/
python
/
cumulus
/
store
/
sftp.py
diff --git
a/python/cumulus/store/sftp.py
b/python/cumulus/store/sftp.py
index
5e6766e
..
4d19c8c
100644
(file)
--- a/
python/cumulus/store/sftp.py
+++ b/
python/cumulus/store/sftp.py
@@
-48,16
+48,11
@@
class SFTPStore(Store):
does not support password authentication or password
protected authentication keys"""
def __init__(self, url, **kw):
does not support password authentication or password
protected authentication keys"""
def __init__(self, url, **kw):
- if self.
path
.find('@') != -1:
+ if self.
netloc
.find('@') != -1:
user, self.netloc = self.netloc.split('@')
else:
user = None
user, self.netloc = self.netloc.split('@')
else:
user = None
-# if self.netloc.find(':') != -1:
-# host, self.path = self.netloc.split(':')
-# else:
-# host, self.path = self.netloc.split('/', 1)
-
self.config = SSHHostConfig(self.netloc, user)
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
self.config = SSHHostConfig(self.netloc, user)
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
@@
-72,20
+67,20
@@
class SFTPStore(Store):
key_file = os.path.expanduser(self.config['identityfile'])
#not really nice but i don't see a cleaner way atm...
try:
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 (
filename =
key_file)
+ self.auth_key = RSAKey (key_file)
except SSHException, e:
if e.message == 'Unable to parse file':
except SSHException, e:
if e.message == 'Unable to parse file':
- self.auth_key = DSAKey (
filename =
key_file)
+ self.auth_key = DSAKey (key_file)
else:
raise
else:
filename = os.path.expanduser('~/.ssh/id_rsa')
if os.path.exists(filename):
else:
raise
else:
filename = os.path.expanduser('~/.ssh/id_rsa')
if os.path.exists(filename):
- self.auth_key = RSAKey(filename
= filename
)
+ self.auth_key = RSAKey(filename)
else:
filename = os.path.expanduser('~/.ssh/id_dsa')
if (os.path.exists(filename)):
else:
filename = os.path.expanduser('~/.ssh/id_dsa')
if (os.path.exists(filename)):
- self.auth_key = DSSKey (filename
= filename
)
+ self.auth_key = DSSKey (filename)
self.__connect()
self.__connect()
@@
-102,10
+97,10
@@
class SFTPStore(Store):
return filter(type_patterns[type].match, self.client.listdir(self.path))
def get(self, type, name):
return filter(type_patterns[type].match, self.client.listdir(self.path))
def get(self, type, name):
- return self.client.open(
filename =
self.__build_fn(name), mode = 'rb')
+ return self.client.open(self.__build_fn(name), mode = 'rb')
def put(self, type, name, fp):
def put(self, type, name, fp):
- remote_file = self.client.open(
filename =
self.__build_fn(name), mode = 'wb')
+ remote_file = self.client.open(self.__build_fn(name), mode = 'wb')
buf = fp.read(4096)
while (len(buf) > 0):
remote_file.write(buf)
buf = fp.read(4096)
while (len(buf) > 0):
remote_file.write(buf)
@@
-113,11
+108,14
@@
class SFTPStore(Store):
remote_file.close()
def delete(self, type, name):
remote_file.close()
def delete(self, type, name):
- self.client.remove(
filename =
self.__build_fn(name))
+ self.client.remove(self.__build_fn(name))
def stat(self, type, name):
def stat(self, type, name):
- stat = self.client.stat(filename = self.__build_fn(name))
- return {'size': stat.st_size}
+ try:
+ stat = self.client.stat(self.__build_fn(name))
+ return {'size': stat.st_size}
+ except IOError:
+ raise NotFoundError
def close(self):
"""connection has to be explicitly closed, otherwise
def close(self):
"""connection has to be explicitly closed, otherwise