[project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-75]
fix a few windows bugs (and broken str() on SFTPAttributes) reported by grzegorz makarewicz
This commit is contained in:
parent
e57c4baab5
commit
25d55e6089
|
@ -105,8 +105,11 @@ except:
|
|||
# the above will likely fail on Windows - fall back to non-persistent random pool
|
||||
randpool = RandomPool()
|
||||
|
||||
randpool.randomize()
|
||||
|
||||
try:
|
||||
randpool.randomize()
|
||||
except:
|
||||
# earlier versions of pyCrypto (pre-2.0) don't have randomize()
|
||||
pass
|
||||
|
||||
import sys
|
||||
if sys.version_info < (2, 3):
|
||||
|
|
|
@ -43,6 +43,9 @@ class logger (object):
|
|||
def addHandler(self, h):
|
||||
self.handlers.append(h)
|
||||
|
||||
def addFilter(self, filter):
|
||||
pass
|
||||
|
||||
def log(self, level, text):
|
||||
if level >= self.level:
|
||||
for h in self.handlers:
|
||||
|
|
|
@ -171,8 +171,8 @@ class SFTPAttributes (object):
|
|||
|
||||
def __str__(self):
|
||||
"create a unix-style long description of the file (like ls -l)"
|
||||
if hasattr(self, 'permissions'):
|
||||
kind = self.permissions & stat.S_IFMT
|
||||
if hasattr(self, 'st_mode'):
|
||||
kind = stat.S_IFMT(self.st_mode)
|
||||
if kind == stat.S_IFIFO:
|
||||
ks = 'p'
|
||||
elif kind == stat.S_IFCHR:
|
||||
|
@ -189,15 +189,15 @@ class SFTPAttributes (object):
|
|||
ks = 's'
|
||||
else:
|
||||
ks = '?'
|
||||
ks += _rwx((self.permissions & 0700) >> 6, self.permissions & stat.S_ISUID)
|
||||
ks += _rwx((self.permissions & 070) >> 3, self.permissions & stat.S_ISGID)
|
||||
ks += _rwx(self.permissions & 7, self.permissions & stat.S_ISVTX, True)
|
||||
ks += self._rwx((self.st_mode & 0700) >> 6, self.st_mode & stat.S_ISUID)
|
||||
ks += self._rwx((self.st_mode & 070) >> 3, self.st_mode & stat.S_ISGID)
|
||||
ks += self._rwx(self.st_mode & 7, self.st_mode & stat.S_ISVTX, True)
|
||||
else:
|
||||
ks = '?---------'
|
||||
uid = getattr(self, 'uid', -1)
|
||||
gid = getattr(self, 'gid', -1)
|
||||
size = getattr(self, 'size', -1)
|
||||
mtime = getattr(self, 'mtime', 0)
|
||||
uid = getattr(self, 'st_uid', -1)
|
||||
gid = getattr(self, 'st_gid', -1)
|
||||
size = getattr(self, 'st_size', -1)
|
||||
mtime = getattr(self, 'st_mtime', 0)
|
||||
# compute display date
|
||||
if abs(time.time() - mtime) > 15552000:
|
||||
# (15552000 = 6 months)
|
||||
|
|
Loading…
Reference in New Issue