]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
Fix exception handling syntax (python3 compat)
authorJan Rękorajski <baggins@pld-linux.org>
Sat, 16 Jan 2021 19:48:05 +0000 (20:48 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Sat, 16 Jan 2021 19:48:05 +0000 (20:48 +0100)
12 files changed:
bin/pfa-checktree
bin/pfa-from-incoming
bin/pfa-lintpkg
bin/pfa-maintainer
bin/pfa-mvpkg
bin/pfa-signpkg
modules/cmds.py
modules/ftptree.py
modules/sign.py
wwwbin/clean-dups-archive.py
wwwbin/clean-dups.py
wwwbin/dump-packagenames.py

index d9bd1b6e68b7d6876828a4718f3abce82b271cc3..888fa3fd6dce136c441f9b5ecd8e3d476b129521 100755 (executable)
@@ -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]
index 92b75d1c740037b37bd53588d8d603e550df7e0f..450fc8466f37020deac3c6189287be8fb95ae685 100755 (executable)
@@ -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)
index 2387a44ac78cfbe95aaf28f5ea33e736c11d5214..716cd88040cdaee03dae58fb875cabf9ef4317ec 100755 (executable)
@@ -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)
index 0d2ea04d6f450800b5504771fed2df828e53f34e..14c84d63e5e82370551c9502537cae7ca4ec512b 100755 (executable)
@@ -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
index 9b85f5c110b6a6205a97e3ee64755a7b28422b4a..b12779c49d84960998e8a6d1c76f72f00c06b96f 100755 (executable)
@@ -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(
index 88cd8db51c9808fe80f7a48479f9ab9e8b44cdda..796b39493647d491ccc4bc6ac1a9804feda36e9f 100755 (executable)
@@ -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)
index 6a71c13436e771838501f5d4bab3ccf1ab61097f..d82b35aa2d30c5e37e5eeb4ff2e2ab1a31ca7dbe 100644 (file)
@@ -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:
index 10fe86b1eb7fd8289d9d05c35cd690dd75e23066..e5b33c62347fb0fcb680de0f5df2fc0098681cc3 100644 (file)
@@ -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:
index 377ee5109635c647ae45a3ae7e488e9c3147af9c..3a82c5b3fc367723dda5b63d471056ac60338061 100644 (file)
@@ -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)
index 293e2eec42c5b77bcd8a8c4de3b1a62374b1da1b..4f0c9c635c2501e1f9465abf35e1285d854706fe 100755 (executable)
@@ -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
index 280691586bf30a7c64b866802e6f4ff267abc9f1..ff9d65f6bd26a78a87c7abf72686a66bc714abcc 100755 (executable)
@@ -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)
index 963026f71686dbc62bdf0a72142a1e0b3702ebc1..61e890bcf1de3e6de34f9c4aac745e782e797174 100755 (executable)
@@ -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
This page took 0.214235 seconds and 4 git commands to generate.