]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
Make ftp tools python3 ready
authorJan Rękorajski <baggins@pld-linux.org>
Sun, 25 Oct 2020 07:49:06 +0000 (08:49 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Sun, 25 Oct 2020 07:49:06 +0000 (08:49 +0100)
wwwbin/clean-dups-archive.py
wwwbin/clean-dups-old.py
wwwbin/clean-dups.py
wwwbin/dump-packagenames.py
wwwbin/ftp-freshness.py

index 4961c399c94ea84b817d0917bf20f50fa70079f8..293e2eec42c5b77bcd8a8c4de3b1a62374b1da1b 100755 (executable)
@@ -2,6 +2,8 @@
 # arekm, 2008
 # remove 
 
+from __future__ import print_function
+
 import os
 import re
 import time
@@ -18,13 +20,13 @@ def compare(f1, f2):
        try:
                fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
        except Exception, e:
-               print e
+               print(e)
                # ignore non-files
                return 0
        try:
                fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
        except Exception, e:
-               print e
+               print(e)
                # ignore non-files
                return 0
        h1 = ts.hdrFromFdno(fd1)
@@ -53,7 +55,7 @@ for file in os.listdir(dir):
 
        m = re_nvr.match(file)
        if not m:
-               print "problem with: %s" % file
+               print("problem with: %s" % file)
                sys.exit(1)
 
        if len(sys.argv) == 0:
@@ -73,6 +75,6 @@ for file in os.listdir(dir):
        else:
                files[name] = file
 
-for i in dupes.iterkeys():
+for i in iter(dupes.keys()):
        for old in find_old(dupes[i])[1:]:
                os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py .archive/PLD %s" % old)
index e0ba2a0dc6bc40eceb92a1414e0203775d2a99ec..27a8e9352eea7eeb6e78d240efeebf83bffee759 100755 (executable)
@@ -2,6 +2,8 @@
 # arekm, 2008
 # remove 
 
+from __future__ import print_function
+
 import os
 import re
 import time
@@ -44,7 +46,7 @@ for file in os.listdir(dir):
 
        m = re_nvr.match(file)
        if not m:
-               print "problem with: %s" % file
+               print("problem with: %s" % file)
                sys.exit(1)
 
        if len(sys.argv) == 0:
@@ -64,6 +66,6 @@ for file in os.listdir(dir):
        else:
                files[name] = file
 
-for i in dupes.iterkeys():
+for i in iter(dupes.keys()):
        for old in find_old(dupes[i])[1:]:
                os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py test %s" % old)
index 003b538a072024bad92a62f1d3583e5d1a9e953a..280691586bf30a7c64b866802e6f4ff267abc9f1 100755 (executable)
@@ -2,6 +2,8 @@
 # arekm, 2008
 # remove 
 
+from __future__ import print_function
+
 import os
 import re
 import time
@@ -49,19 +51,19 @@ def compare(f1, f2):
        try:
                fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
        except Exception, e:
-               print e
+               print(e)
                # ignore non-files
                return 0
        try:
                fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
        except Exception, e:
-               print e
+               print(e)
                # ignore non-files
                return 0
        try:
                h1 = ts.hdrFromFdno(fd1)
        except Exception, e:
-               print "hdrFromFdno for %s failed: %s" % (f1, e)
+               print("hdrFromFdno for %s failed: %s" % (f1, e))
                os.close(fd1)
                os.close(fd2)
                return 0
@@ -69,7 +71,7 @@ def compare(f1, f2):
        try:
                h2 = ts.hdrFromFdno(fd2)
        except Exception, e:
-               print "hdrFromFdno for %s failed: %s" % (f2, e)
+               print("hdrFromFdno for %s failed: %s" % (f2, e))
                os.close(fd1)
                os.close(fd2)
                return 0
@@ -101,7 +103,7 @@ for file in os.listdir(dir):
 
        m = re_nvr.match(file)
        if not m:
-               print "problem with: %s" % file
+               print("problem with: %s" % file)
                sys.exit(1)
 
        if len(sys.argv) == 0:
@@ -121,7 +123,7 @@ for file in os.listdir(dir):
        else:
                files[name] = file
 
-for i in dupes.iterkeys():
+for i in iter(dupes.keys()):
        for old in find_old(dupes[i])[1:]:
-               print "removing: %s" % old
+               print("removing: %s" % old)
                os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py test %s" % old)
index 59f9e89e5d52258af0534530a876ec11d9880930..963026f71686dbc62bdf0a72142a1e0b3702ebc1 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+from __future__ import print_function
+
 import os
 import re
 
@@ -36,7 +38,7 @@ for dir in dirs:
                try:
                        hdr = ts.hdrFromFdno(fdno)
                except Exception, e:
-                       print "hdrFromFdno: %s: %s" % (rpm_file, e)
+                       print("hdrFromFdno: %s: %s" % (rpm_file, e))
                        os.close(fdno)
                        continue
                os.close(fdno)
@@ -45,13 +47,13 @@ for dir in dirs:
                sourcerpm = hdr[rpm.RPMTAG_SOURCERPM]
                m = re_nvr.match(sourcerpm)
                if not m:
-                       print "%s: doesn't match src.rpm file name" % (sourcerpm)
+                       print("%s: doesn't match src.rpm file name" % (sourcerpm))
                        continue
                srcname = m.group(1)
                pkgs[name] = srcname
 
 f = open(outname + ".tmp", "w")
-for (pkg, spkg) in pkgs.iteritems():
+for (pkg, spkg) in iter(pkgs.items()):
        f.write("%s:%s\n" % (pkg, spkg))
 f.close()
 os.chmod(outname + ".tmp", 0644)
index 3208269c239f8d8483914ef1feb165ca21e28eb7..ddfe53f6c59fe2ebd66976876b161deebbd060ad 100755 (executable)
@@ -1,6 +1,8 @@
 #!/usr/bin/python
 # arekm, 2007
 
+from __future__ import print_function
+
 import os
 import rpm
 import subprocess
@@ -41,16 +43,16 @@ class Pkgs(object):
         for macro in ['rel', '_rel', 'snap', '_snap', 'rc', '_rc', 'subver', 'githash']:
             rpm.delMacro(macro)
         macros = rpm.getMacros()
-        for macro in macros.iterkeys():
+        for macro in iter(macros.keys()):
             if macro[:5] == 'with_' or macro[:8] == 'without_':
                 rpm.delMacro(macro.split()[0])
 
     def __get_from_cvs(self, name):
         spec = os.path.join(specsdir, name + '.spec')
         if not os.path.isfile(spec):
-            print >>sys.stderr, 'Spec file does not exist: %s' % spec
+            print('Spec file does not exist: %s' % spec, file=sys.stderr)
             return ('','','')
-        print >>sys.stderr, 'Processing: %s.spec' % name
+        print('Processing: %s.spec' % name, file=sys.stderr)
         self.__clean_macros()
         try:
             s = self.ts.parseSpec(spec)
@@ -60,7 +62,7 @@ class Pkgs(object):
             release = header[rpm.RPMTAG_RELEASE].partition('@')[0]
             return (name, version, release)
         except rpm.error:
-            print >>sys.stderr, 'Failed to parse: %s.spec' % name
+            print('Failed to parse: %s.spec' % name, file=sys.stderr)
             return ('','','')
 
     def __update_cvs(self, name):
@@ -113,8 +115,8 @@ class Pkgs(object):
                 ver_frac += msg
             else:
                 ver_int += msg
-        print ver_int
-        print ver_frac
+        print(ver_int)
+        print(ver_frac)
 
     def print_nv(self):
         ver_int = "*** VERSION COMPARE ONLY ***\n"
@@ -128,8 +130,8 @@ class Pkgs(object):
                 ver_frac += msg
             else:
                 ver_int += msg
-        print ver_int
-        print ver_frac
+        print(ver_int)
+        print(ver_frac)
 
 p = Pkgs()
 
@@ -141,5 +143,5 @@ for d in dirs:
 p.prepare()
 
 p.print_nv()
-print "\n\n"
+print("\n\n")
 p.print_nvr()
This page took 0.178168 seconds and 4 git commands to generate.