summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Rękorajski2021-01-16 19:48:05 (GMT)
committerJan Rękorajski2021-01-16 19:48:05 (GMT)
commit9c170c6153b10298811a5de004899f912d8b1e4d (patch)
tree6a4d5a90e853de8077ddb44a7f5b863ce10b313b
parent2ec96333835d67384921c863d3b4250d42165142 (diff)
downloadpld-ftp-admin-9c170c6153b10298811a5de004899f912d8b1e4d.zip
pld-ftp-admin-9c170c6153b10298811a5de004899f912d8b1e4d.tar.gz
Fix exception handling syntax (python3 compat)
-rwxr-xr-xbin/pfa-checktree2
-rwxr-xr-xbin/pfa-from-incoming4
-rwxr-xr-xbin/pfa-lintpkg2
-rwxr-xr-xbin/pfa-maintainer2
-rwxr-xr-xbin/pfa-mvpkg2
-rwxr-xr-xbin/pfa-signpkg2
-rw-r--r--modules/cmds.py8
-rw-r--r--modules/ftptree.py8
-rw-r--r--modules/sign.py6
-rwxr-xr-xwwwbin/clean-dups-archive.py4
-rwxr-xr-xwwwbin/clean-dups.py8
-rwxr-xr-xwwwbin/dump-packagenames.py2
12 files changed, 25 insertions, 25 deletions
diff --git a/bin/pfa-checktree b/bin/pfa-checktree
index d9bd1b6..888fa3f 100755
--- a/bin/pfa-checktree
+++ b/bin/pfa-checktree
@@ -262,7 +262,7 @@ class Screen:
self.pkgliststartpad = 0
def __do_quit(self):
- raise DoQuit
+ raise DoQuit()
def __do_mark(self):
pkg=self.elements[self.pkglistselected]
diff --git a/bin/pfa-from-incoming b/bin/pfa-from-incoming
index 92b75d1..450fc84 100755
--- a/bin/pfa-from-incoming
+++ b/bin/pfa-from-incoming
@@ -239,7 +239,7 @@ for arch in ftp_archs:
dstfile = default_to + arch + '/RPMS'
try:
rm(dstfile + '/' + rpmfile)
- except OSError, e:
+ except OSError as e:
l = "Removing %s problem: %s" % (dstfile + '/' + rpmfile, e)
ftpio.log(l)
print(l)
@@ -267,7 +267,7 @@ for arch in ftp_archs:
try:
mv(srcfile, dstfile)
- except OSError, e:
+ except OSError as e:
l = "Moving %s to %s problem: %s" % (srcfile, dstfile, e)
ftpio.log(l)
print(l)
diff --git a/bin/pfa-lintpkg b/bin/pfa-lintpkg
index 2387a44..716cd88 100755
--- a/bin/pfa-lintpkg
+++ b/bin/pfa-lintpkg
@@ -65,7 +65,7 @@ try:
tree.mark4moving(packages)
files = tree.rpmfiles(debugfiles = debugfiles, sourcefiles = False)
-except (ftptree.SomeError, KeyboardInterrupt), e:
+except (ftptree.SomeError, KeyboardInterrupt) as e:
# In case of problems we need to unlock the tree before exiting
ftpio.unlock(treename)
sys.exit(1)
diff --git a/bin/pfa-maintainer b/bin/pfa-maintainer
index 0d2ea04..14c84d6 100755
--- a/bin/pfa-maintainer
+++ b/bin/pfa-maintainer
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
import sys, os
diff --git a/bin/pfa-mvpkg b/bin/pfa-mvpkg
index 9b85f5c..b12779c 100755
--- a/bin/pfa-mvpkg
+++ b/bin/pfa-mvpkg
@@ -94,7 +94,7 @@ for pkg in srctree.marked4moving:
ftpadmin = "(unknown)"
try:
ftpadmin = os.environ['FTPADM']
-except KeyError, e:
+except KeyError as e:
pass
m = Message()
m.set_headers(
diff --git a/bin/pfa-signpkg b/bin/pfa-signpkg
index 88cd8db..796b394 100755
--- a/bin/pfa-signpkg
+++ b/bin/pfa-signpkg
@@ -113,6 +113,6 @@ try:
for x in chunk(sign, 512):
print("Signing %d files" % len(x))
signpkgs(x, password)
-except OSError, e:
+except OSError as e:
print("ERR: %s" % e, file=sys.stderr)
exit(1)
diff --git a/modules/cmds.py b/modules/cmds.py
index 6a71c13..d82b35a 100644
--- a/modules/cmds.py
+++ b/modules/cmds.py
@@ -17,7 +17,7 @@ def parse(con):
con.data=con.data[len(cmd)+1:]
cmdname=cmd[:4]
if not con.authorized and cmdname not in ('linp', 'linc', 'name'):
- raise BailOut
+ raise BailOut()
# TODO: log unauthorized access
if cmdname in cmdlist_noargs:
if len(cmd)==4:
@@ -32,7 +32,7 @@ def parse(con):
pass
# TODO: log malicious msg
else:
- raise BailOut
+ raise BailOut()
# TODO: log this
def lock(con, arg, hard):
@@ -112,7 +112,7 @@ def write_cookies():
def cmd_login_passwd(con, data):
tmp=data.split('\n')
if len(tmp)!=2:
- raise BailOut
+ raise BailOut()
login=tmp[0]
passwd=tmp[1]
md5pass=md5.new(passwd).hexdigest()
@@ -126,7 +126,7 @@ def cmd_login_passwd(con, data):
else:
# TODO: log this
con.sock.send('FAIL')
- raise BailOut
+ raise BailOut()
def cmd_login_cookie(con, cookie):
if cookie in cookies:
diff --git a/modules/ftptree.py b/modules/ftptree.py
index 10fe86b..e5b33c6 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -20,7 +20,7 @@ class SomeError(Exception):
def bailoutonerror():
if not errnum == 0:
print("%d error(s) encountered... aborting" % errnum)
- raise SomeError
+ raise SomeError()
def pinfo(msg):
print('INFO: ' + msg)
@@ -40,7 +40,7 @@ def rm(file, test = False):
else:
try:
os.remove(file)
- except OSError, e:
+ except OSError as e:
pinfo("os.remove(%s): %s" % (file, e))
#raise
@@ -55,7 +55,7 @@ def mv(src, dst, test = False):
else:
try:
os.rename(fsrc, fdst)
- except OSError, e:
+ except OSError as e:
pinfo("os.rename(%s, %s): %s" % (fsrc, fdst, e))
raise
@@ -282,7 +282,7 @@ class FtpTree(BaseFtpTree):
self.loadedpkgs[key]=pkg
return pkg
else:
- raise KeyError, key
+ raise KeyError(key)
def has_key(self, key):
if key in self.pkgnames:
diff --git a/modules/sign.py b/modules/sign.py
index 377ee51..3a82c5b 100644
--- a/modules/sign.py
+++ b/modules/sign.py
@@ -40,9 +40,9 @@ def is_signed(rpm_file):
def signpkgs(files, password):
if not os.path.isfile('/usr/bin/gpg'):
- raise OSError, 'Missing gnupg binary'
+ raise OSError('Missing gnupg binary')
if not os.path.isfile('/bin/rpm'):
- raise OSError, 'Missing rpm binary'
+ raise OSError('Missing rpm binary')
os.putenv('LC_ALL', 'C')
args = ['--resign', '--define', '_signature gpg', '--define', '_gpg_name ' + sign_key] + files
@@ -54,6 +54,6 @@ def signpkgs(files, password):
child.close()
rc = child.exitstatus
if rc != 0:
- raise OSError, 'package signing failed'
+ raise OSError('package signing failed')
for rpm in files:
os.chmod(rpm, 0644)
diff --git a/wwwbin/clean-dups-archive.py b/wwwbin/clean-dups-archive.py
index 293e2ee..4f0c9c6 100755
--- a/wwwbin/clean-dups-archive.py
+++ b/wwwbin/clean-dups-archive.py
@@ -19,13 +19,13 @@ ts = rpm.TransactionSet("", (rpm.RPMVSF_NOHDRCHK or rpm.RPMVSF_NEEDPAYLOAD))
def compare(f1, f2):
try:
fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
- except Exception, e:
+ except Exception as e:
print(e)
# ignore non-files
return 0
try:
fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
- except Exception, e:
+ except Exception as e:
print(e)
# ignore non-files
return 0
diff --git a/wwwbin/clean-dups.py b/wwwbin/clean-dups.py
index 2806915..ff9d65f 100755
--- a/wwwbin/clean-dups.py
+++ b/wwwbin/clean-dups.py
@@ -50,19 +50,19 @@ ts = rpm.TransactionSet("", (rpm.RPMVSF_NOHDRCHK or rpm.RPMVSF_NEEDPAYLOAD))
def compare(f1, f2):
try:
fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
- except Exception, e:
+ except Exception as e:
print(e)
# ignore non-files
return 0
try:
fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
- except Exception, e:
+ except Exception as e:
print(e)
# ignore non-files
return 0
try:
h1 = ts.hdrFromFdno(fd1)
- except Exception, e:
+ except Exception as e:
print("hdrFromFdno for %s failed: %s" % (f1, e))
os.close(fd1)
os.close(fd2)
@@ -70,7 +70,7 @@ def compare(f1, f2):
try:
h2 = ts.hdrFromFdno(fd2)
- except Exception, e:
+ except Exception as e:
print("hdrFromFdno for %s failed: %s" % (f2, e))
os.close(fd1)
os.close(fd2)
diff --git a/wwwbin/dump-packagenames.py b/wwwbin/dump-packagenames.py
index 963026f..61e890b 100755
--- a/wwwbin/dump-packagenames.py
+++ b/wwwbin/dump-packagenames.py
@@ -37,7 +37,7 @@ for dir in dirs:
fdno = os.open(rpm_file, os.O_RDONLY)
try:
hdr = ts.hdrFromFdno(fdno)
- except Exception, e:
+ except Exception as e:
print("hdrFromFdno: %s: %s" % (rpm_file, e))
os.close(fdno)
continue