FIX Exception as ex for python<=2.5.

+ Fix also minor ident error.
This commit is contained in:
Kostis Anagnostopoulos 2015-12-21 16:18:10 +01:00
parent d02123dbf1
commit 7036c04ee2
2 changed files with 6 additions and 4 deletions

@ -190,8 +190,9 @@ def main(argv=None):
if k in ("-p", "--port"):
try:
c.port = int(v)
except Exception as ex:
sys.exit("Invalid port(%r) due to: %s" % (v, ex))
except Exception:
err = sys.exc_info()[1]
sys.exit("Invalid port(%r) due to: %s" % (v, err))
elif k in ("-a", "--authenticate"):
c.authenticated = [a.lower()
for a in re.split("[, ]+", v.strip(" ,"))

@ -33,7 +33,8 @@ def configure(**kwds):
os.listdir(r)
except OSError:
err = sys.exc_info()[1]
sys.exit("Error: while trying to list root(%s): %s" % (r, err))
msg = "Error: while trying to list root(%s): %s"
sys.exit(msg % (r, err))
packages = lambda: itertools.chain(*[listdir(r) for r in roots])
packages.root = roots[0]
@ -70,7 +71,7 @@ def configure(**kwds):
try:
halgos = hashlib.algorithms_available
except AttributeError:
halgos = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
halgos = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
if c.hash_algo not in halgos:
sys.exit('Hash-algorithm %s not one of: %s' % (c.hash_algo, halgos))