[projects/pld-ftp-admin] more python3 readiness
baggins
baggins at pld-linux.org
Sun Oct 25 09:42:49 CET 2020
commit 2ec96333835d67384921c863d3b4250d42165142
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Oct 25 09:42:30 2020 +0100
more python3 readiness
bin/pfa-checksign | 20 +++++++++++---------
bin/pfa-checktree | 10 ++++++----
bin/pfa-dump-locks | 4 +++-
bin/pfa-from-incoming | 10 ++++++----
bin/pfa-genindex | 32 +++++++++++++++++---------------
bin/pfa-lintpkg | 26 ++++++++++++++------------
bin/pfa-mvpkg | 20 +++++++++++---------
bin/pfa-rmpkg | 8 +++++---
bin/pfa-signpkg | 30 ++++++++++++++++--------------
bin/pfa-testmvpkg | 12 +++++++-----
bin/pfa-unlocktree | 8 +++++---
cgi-bin/index.py | 8 +++++---
modules/cmds.py | 2 +-
modules/common.py | 4 +++-
modules/ftptree.py | 12 +++++++-----
modules/user.py | 8 +++++---
modules/wwwiface.py | 24 +++++++++++++-----------
17 files changed, 135 insertions(+), 103 deletions(-)
---
diff --git a/bin/pfa-checksign b/bin/pfa-checksign
index 14060e2..5c8197d 100755
--- a/bin/pfa-checksign
+++ b/bin/pfa-checksign
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
import getopt
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
@@ -14,17 +16,17 @@ from sign import is_signed, signpkgs
try:
opts, args = getopt.getopt(sys.argv[1:], '')
except getopt.GetoptError:
- print >>sys.stderr, "ERR: options error"
- print >>sys.stderr, "checksign.py tree package1 [package2...]"
+ print("ERR: options error", file=sys.stderr)
+ print("checksign.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
if len(args) < 1:
- print >>sys.stderr, "ERR: missing tree name"
- print >>sys.stderr, "checksign.py tree package1 [package2...]"
+ print("ERR: missing tree name", file=sys.stderr)
+ print("checksign.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
if sign_key == None:
- print >>sys.stderr, "ERR: sign_key not defined in config"
+ print("ERR: sign_key not defined in config", file=sys.stderr)
sys.exit(1)
treename = args[0]
@@ -35,7 +37,7 @@ checkdir(treename)
ftpio.connect('sign')
if not ftpio.lock(treename, True):
- print >>sys.stderr, "ERR: %s tree already locked" % treename
+ print("ERR: %s tree already locked" % treename, file=sys.stderr)
sys.exit(1)
files = []
@@ -60,7 +62,7 @@ except ftptree.SomeError:
ftpio.unlock(treename)
-print "Checking signatures of %d packages" % len(tree.loadedpkgs)
+print("Checking signatures of %d packages" % len(tree.loadedpkgs))
sign = []
for pkg in tree.marked4moving:
unsigned = 0
@@ -69,8 +71,8 @@ for pkg in tree.marked4moving:
unsigned += 1
if unsigned != 0:
- print '%s: %d files NOT signed' % (pkg.nvr, unsigned)
+ print('%s: %d files NOT signed' % (pkg.nvr, unsigned))
else:
- print '%s signed' % pkg.nvr
+ print('%s signed' % pkg.nvr)
sys.exit(0)
diff --git a/bin/pfa-checktree b/bin/pfa-checktree
index 226e4df..d9bd1b6 100755
--- a/bin/pfa-checktree
+++ b/bin/pfa-checktree
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -13,8 +15,8 @@ cval=config.value
import curses
if len(sys.argv) != 3:
- print "ERR: wrong number of arguments"
- print "check-tree.py srctree dsttree"
+ print("ERR: wrong number of arguments")
+ print("check-tree.py srctree dsttree")
sys.exit(1)
checkdir(sys.argv[1])
@@ -22,12 +24,12 @@ checkdir(sys.argv[1])
ftpio.connect('check-tree')
if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
+ print("ERR: %s tree already locked" % sys.argv[1])
sys.exit(1)
if not ftpio.lock(sys.argv[2], True):
ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % sys.argv[2]
+ print("ERR: %s tree already locked" % sys.argv[2])
sys.exit(1)
srctree=ftptree.FtpTree(sys.argv[1], loadall=True)
diff --git a/bin/pfa-dump-locks b/bin/pfa-dump-locks
index 32fdfdf..17f07a3 100755
--- a/bin/pfa-dump-locks
+++ b/bin/pfa-dump-locks
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -8,4 +10,4 @@ import ftpio
import config
ftpio.connect()
-print ftpio.locks_dump()
+print(ftpio.locks_dump())
diff --git a/bin/pfa-from-incoming b/bin/pfa-from-incoming
index 6523ea1..92b75d1 100755
--- a/bin/pfa-from-incoming
+++ b/bin/pfa-from-incoming
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os, stat, time, re
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
from config import incoming_dir, default_to, ftp_archs
@@ -164,13 +166,13 @@ Subject: %s
try:
ftpio.connect('from-incoming-pid-%s' % os.getpid())
except:
- print "Can't get ftpiod connection"
+ print("Can't get ftpiod connection")
sys.exit(1)
ftptree = BaseFtpTree(cval['default_to'])
if not ftpio.lock(cval['default_to']):
- print "Can't get lock: %s" % cval['default_to']
+ print("Can't get lock: %s" % cval['default_to'])
sys.exit(1)
moved_anything = False
@@ -240,7 +242,7 @@ for arch in ftp_archs:
except OSError, e:
l = "Removing %s problem: %s" % (dstfile + '/' + rpmfile, e)
ftpio.log(l)
- print l
+ print(l)
f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'a')
for rpmfile in srcpkg.files['ARCH']:
@@ -268,7 +270,7 @@ for arch in ftp_archs:
except OSError, e:
l = "Moving %s to %s problem: %s" % (srcfile, dstfile, e)
ftpio.log(l)
- print l
+ print(l)
f.close()
rm(incoming_dir + arch + '/' + uploadinfo)
diff --git a/bin/pfa-genindex b/bin/pfa-genindex
index de5afa7..feef173 100755
--- a/bin/pfa-genindex
+++ b/bin/pfa-genindex
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import getopt
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
@@ -18,8 +20,8 @@ try:
]
)
except getopt.GetoptError:
- print >>sys.stderr, "ERR: not enough parameters given"
- print >>sys.stderr, "gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]"
+ print("ERR: not enough parameters given", file=sys.stderr)
+ print("gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]", file=sys.stderr)
sys.exit(1)
do_poldek = True
@@ -58,10 +60,10 @@ for o, a in opts:
do_rpmrepo = True
if not quiet:
- print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
+ print("poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo))
if not do_poldek and not do_yum and not do_rpmrepo:
- print >>sys.stderr, "ERR: speciy at least one action"
+ print("ERR: speciy at least one action", file=sys.stderr)
sys.exit(1)
trees = args
@@ -77,7 +79,7 @@ for tree in trees:
if ftpio.lock(tree, True):
locked.append(tree)
else:
- print >>sys.stderr, "ERR: %s tree already locked" % tree
+ print("ERR: %s tree already locked" % tree, file=sys.stderr)
for i in locked:
ftpio.unlock(i)
sys.exit(1)
@@ -91,10 +93,10 @@ if do_poldek:
poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
for tree in trees:
- print '\n-------------------------- %s --------------------------' % tree
+ print('\n-------------------------- %s --------------------------' % tree)
for arch in all_ftp_archs:
- print '\ngenerate poldek index for %s' % arch
- print '%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch)
+ print('\ngenerate poldek index for %s' % arch)
+ print('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
if arch != 'noarch' and config.separate_debuginfo:
os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
@@ -104,20 +106,20 @@ if do_yum:
yum = '%s.stat/bin/createrepo -d -v --update --checkts --skip-stat --workers=12 -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
comps_file = '%s.stat/repodata/comps.xml' % ftp_dir
for tree in trees:
- print '\n-------------------------- %s --------------------------' % tree
+ print('\n-------------------------- %s --------------------------' % tree)
cachedir = '%s/tmp/createrepo/%s' % (home, tree)
treedir = "%s%s" % (ftp_dir, tree)
for arch in all_ftp_archs:
- print '\ngenerate repodata for %s using createrepo' % arch
+ print('\ngenerate repodata for %s using createrepo' % arch)
archdir = "%s/%s" % (treedir, arch)
poldek_idx = "%s/RPMS/packages.ndir.md" % archdir
repodata_idx = "%s/RPMS/repodata/repomd.xml" % archdir
if freshen and os.path.exists(poldek_idx) and os.path.exists(repodata_idx) \
and not os.path.getmtime(comps_file) > os.path.getmtime(repodata_idx) \
and not os.path.getmtime(poldek_idx) > os.path.getmtime(repodata_idx):
- print "repodata indexes already fresh"
+ print("repodata indexes already fresh")
continue
- print ('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
+ print('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
os.system('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
if arch != 'noarch' and config.separate_debuginfo:
os.system('%s %s --cache %s-%s %s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, archdir))
@@ -125,14 +127,14 @@ if do_yum:
if do_rpmrepo:
os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
for tree in trees:
- print '\n-------------------------- %s --------------------------' % tree
+ print('\n-------------------------- %s --------------------------' % tree)
for arch in all_ftp_archs:
dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
if not quiet:
- print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
+ print('\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir))
os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
if not quiet:
- print 'copy comps.xml'
+ print('copy comps.xml')
comps = '%s.stat/repodata/comps.xml' % ftp_dir
os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))
diff --git a/bin/pfa-lintpkg b/bin/pfa-lintpkg
index c9ae537..2387a44 100755
--- a/bin/pfa-lintpkg
+++ b/bin/pfa-lintpkg
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os, re
import getopt
import subprocess
@@ -12,8 +14,8 @@ import ftpio
try:
opts, args = getopt.getopt(sys.argv[1:], 'qsdo:', [ "quiet" ])
except getopt.GetoptError:
- print >>sys.stderr, "ERR: options error"
- print >>sys.stderr, "rpmlint.py tree package1 [package2...]"
+ print("ERR: options error", file=sys.stderr)
+ print("rpmlint.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
quiet = False
@@ -31,8 +33,8 @@ for o, a in opts:
outstream = open(a, 'w')
if len(args) < 1:
- print >>sys.stderr, "ERR: missing tree name"
- print >>sys.stderr, "rpmlint.py tree package1 [package2...]"
+ print("ERR: missing tree name", file=sys.stderr)
+ print("rpmlint.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
treename = args[0]
@@ -43,7 +45,7 @@ checkdir(treename)
ftpio.connect('rpmlint')
if not ftpio.lock(treename, True):
- print >>sys.stderr, "ERR: %s tree already locked" % treename
+ print("ERR: %s tree already locked" % treename, file=sys.stderr)
sys.exit(1)
files = []
@@ -129,13 +131,13 @@ class LintPkg:
def print_stats(self, file = None):
if file:
(dirname, filename) = os.path.split(file)
- print >>self.outstream, "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings. [%s]" % (self.packages, self.specfiles, self.errors, self.warnings, filename),
+ print("\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings. [%s]" % (self.packages, self.specfiles, self.errors, self.warnings, filename),, file=self.outstream)
else:
- print >>self.outstream, "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings." % (self.packages, self.specfiles, self.errors, self.warnings)
+ print("\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings." % (self.packages, self.specfiles, self.errors, self.warnings), file=self.outstream)
sys.stdout.flush()
def cat(self, file):
- print >>self.outstream, "".join(open(file, 'r').readlines())
+ print("".join(open(file, 'r').readlines()), file=self.outstream)
def show_results(self, file):
m = self.get_stats(file)
@@ -144,11 +146,11 @@ class LintPkg:
cachefile = self.cachefile(file)
if not os.path.exists(cachefile):
- print >>self.outsteram, "MISSING: report: %s" % file
+ print("MISSING: report: %s" % file, file=self.outstream)
if m['errors'] > 0 or m['warnings'] > 0:
(dirname, filename) = os.path.split(file)
- print >>self.outstream, "rpmlint: %s" % filename
+ print("rpmlint: %s" % filename, file=self.outstream)
self.cat(cachefile)
def rpmlint(self, file):
@@ -177,11 +179,11 @@ class LintPkg:
try:
lock = 'rpmlint:'+treename
if not ftpio.lock(lock, True):
- print >>sys.stderr, "ERR: %s tree already locked for rpmlint" % treename
+ print("ERR: %s tree already locked for rpmlint" % treename, file=sys.stderr)
sys.exit(1)
if not quiet:
- print >>outstream, "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
+ print("rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs)), file=outstream)
lint = LintPkg("~/tmp/rpmlint")
lint.outstream = outstream
for file in files:
diff --git a/bin/pfa-mvpkg b/bin/pfa-mvpkg
index 5693465..9b85f5c 100755
--- a/bin/pfa-mvpkg
+++ b/bin/pfa-mvpkg
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -17,10 +19,10 @@ if len(sys.argv) > 4 and sys.argv[1] == '-nb':
sys.argv = sys.argv[1:]
if len(sys.argv) < 4:
- print >>sys.stderr, "ERR: not enough parameters given"
- print >>sys.stderr, "move.py [options] src-tree dst-tree package [package2 package3 ...]"
- print >>sys.stderr, "\nOptions:"
- print >>sys.stderr, " -nb Do not check if builds are finished.\n"
+ print("ERR: not enough parameters given", file=sys.stderr)
+ print("move.py [options] src-tree dst-tree package [package2 package3 ...]", file=sys.stderr)
+ print("\nOptions:", file=sys.stderr)
+ print(" -nb Do not check if builds are finished.\n", file=sys.stderr)
sys.exit(1)
checkdir(sys.argv[1])
@@ -35,18 +37,18 @@ else:
ftpio.connect('move')
if not ftpio.lock(sys.argv[1], True):
- print >>sys.stderr, "ERR: %s tree already locked" % sys.argv[1]
+ print("ERR: %s tree already locked" % sys.argv[1], file=sys.stderr)
sys.exit(1)
if not ftpio.lock(sys.argv[2], True):
ftpio.unlock(sys.argv[1])
- print >>sys.stderr, "ERR: %s tree already locked" % sys.argv[2]
+ print("ERR: %s tree already locked" % sys.argv[2], file=sys.stderr)
sys.exit(1)
if archivetreename != None and archivetreename != sys.argv[1] and not ftpio.lock(archivetreename, True):
ftpio.unlock(sys.argv[2])
ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % archivetreename
+ print("ERR: %s tree already locked" % archivetreename, file=sys.stderr)
sys.exit(1)
try:
@@ -78,7 +80,7 @@ if archivetreename != None and archivetreename != sys.argv[1]:
if logs_list == None:
sys.exit(0)
-print 'Sending mail notification to %s...' % logs_list
+print('Sending mail notification to %s...' % logs_list)
pkgs = {}
@@ -117,4 +119,4 @@ for nvr in sorted(pkgs.keys()):
m.send()
-print 'done.'
+print('done.')
diff --git a/bin/pfa-rmpkg b/bin/pfa-rmpkg
index 8054135..9aa7b7b 100755
--- a/bin/pfa-rmpkg
+++ b/bin/pfa-rmpkg
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -8,8 +10,8 @@ from common import checkdir
import ftpio
if len(sys.argv) < 3:
- print "ERR: not enough parameters given"
- print "remove.py tree package1 [package2...]"
+ print("ERR: not enough parameters given")
+ print("remove.py tree package1 [package2...]")
sys.exit(1)
checkdir(sys.argv[1])
@@ -17,7 +19,7 @@ checkdir(sys.argv[1])
ftpio.connect('remove')
if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
+ print("ERR: %s tree already locked" % sys.argv[1])
sys.exit(1)
try:
diff --git a/bin/pfa-signpkg b/bin/pfa-signpkg
index d45fc7c..88cd8db 100755
--- a/bin/pfa-signpkg
+++ b/bin/pfa-signpkg
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
import getopt
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
@@ -16,17 +18,17 @@ os.umask(022)
try:
opts, args = getopt.getopt(sys.argv[1:], '')
except getopt.GetoptError:
- print >>sys.stderr, "ERR: options error"
- print >>sys.stderr, "sign.py tree package1 [package2...]"
+ print("ERR: options error", file=sys.stderr)
+ print("sign.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
if len(args) < 1:
- print >>sys.stderr, "ERR: missing tree name"
- print >>sys.stderr, "sign.py tree package1 [package2...]"
+ print("ERR: missing tree name", file=sys.stderr)
+ print("sign.py tree package1 [package2...]", file=sys.stderr)
sys.exit(1)
if sign_key == None:
- print >>sys.stderr, "ERR: sign_key not defined in config"
+ print("ERR: sign_key not defined in config", file=sys.stderr)
sys.exit(1)
treename = args[0]
@@ -37,7 +39,7 @@ checkdir(treename)
ftpio.connect('sign')
if not ftpio.lock(treename, True):
- print >>sys.stderr, "ERR: %s tree already locked" % treename
+ print("ERR: %s tree already locked" % treename, file=sys.stderr)
sys.exit(1)
files = []
@@ -63,7 +65,7 @@ except ftptree.SomeError:
ftpio.unlock(treename)
-print "Checking signatures of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
+print("Checking signatures of %d files from %d packages" % (len(files), len(tree.loadedpkgs)))
sign = []
n = c = 0
for file in files:
@@ -71,12 +73,12 @@ for file in files:
sign.append(file)
c += 1
n += 1
- print "\r%d/%d %s\033[0K" % (n, c, file),
+ print("\r%d/%d %s\033[0K" % (n, c, file))
-print ""
+print()
if len(sign) == 0:
- print "No files to sign"
+ print("No files to sign")
sys.exit(0)
# http://mail.python.org/pipermail/python-list/2009-February/700658.html
@@ -95,7 +97,7 @@ def chunk(seq, size, pad=None):
[[1], [2], [3], [4], [5], [6], [7], [8], [9]]
>>> list(chunk(range(1,10),9))
[[1, 2, 3, 4, 5, 6, 7, 8, 9]]
- >>> for X in chunk([],3): print X
+ >>> for X in chunk([],3): print(X)
>>>
'''
n = len(seq)
@@ -105,12 +107,12 @@ def chunk(seq, size, pad=None):
if mod:
yield seq[-mod:]
-print "Total %d files to sign" % len(sign)
+print("Total %d files to sign" % len(sign))
password = getpass.getpass("Enter signing password: ")
try:
for x in chunk(sign, 512):
- print "Signing %d files" % len(x)
+ print("Signing %d files" % len(x))
signpkgs(x, password)
except OSError, e:
- print >>sys.stderr, "ERR: %s" % e
+ print("ERR: %s" % e, file=sys.stderr)
exit(1)
diff --git a/bin/pfa-testmvpkg b/bin/pfa-testmvpkg
index 53a0e48..bda05a9 100755
--- a/bin/pfa-testmvpkg
+++ b/bin/pfa-testmvpkg
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -9,8 +11,8 @@ import ftpio
from config import archived_trees, logs_list
if len(sys.argv) < 4:
- print "ERR: not enough parameters given"
- print "test-move.py src-tree dst-tree package [package2 package3 ...]"
+ print("ERR: not enough parameters given")
+ print("test-move.py src-tree dst-tree package [package2 package3 ...]")
sys.exit(1)
checkdir(sys.argv[1])
@@ -25,18 +27,18 @@ else:
ftpio.connect('test-move')
if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
+ print("ERR: %s tree already locked" % sys.argv[1])
sys.exit(1)
if not ftpio.lock(sys.argv[2], True):
ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % sys.argv[2]
+ print("ERR: %s tree already locked" % sys.argv[2])
sys.exit(1)
if archivetreename != None and archivetreename != sys.argv[1] and not ftpio.lock(archivetreename, True):
ftpio.unlock(sys.argv[2])
ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % archivetreename
+ print("ERR: %s tree already locked" % archivetreename)
sys.exit(1)
try:
diff --git a/bin/pfa-unlocktree b/bin/pfa-unlocktree
index 43acb09..a498132 100755
--- a/bin/pfa-unlocktree
+++ b/bin/pfa-unlocktree
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
import ftptree
@@ -8,10 +10,10 @@ import ftpio
import config
if len(sys.argv) < 2:
- print "ERR: not enough parameters given"
- print "unlock.py tree"
+ print("ERR: not enough parameters given")
+ print("unlock.py tree")
sys.exit(1)
for tree in sys.argv[1:]:
ftpio.connect()
- print "Unlock %s: %s" % (tree, ftpio.unlock(sys.argv[1]))
+ print("Unlock %s: %s" % (tree, ftpio.unlock(sys.argv[1])))
diff --git a/cgi-bin/index.py b/cgi-bin/index.py
index 208a66a..70845ae 100755
--- a/cgi-bin/index.py
+++ b/cgi-bin/index.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
# Printing errors (no SyntaxErrors though, but that's not a problem)
import sys, os
sys.stderr=sys.stdout
@@ -9,11 +11,11 @@ contenttypesent=False
def myexceptionhandler(type, value, traceback):
if contenttypesent:
- print '<pre>'
+ print('<pre>')
sys.__excepthook__(type, value, traceback)
- print '</pre>'
+ print('</pre>')
else:
- print "Content-Type: text/plain\n"
+ print("Content-Type: text/plain\n")
sys.__excepthook__(type, value, traceback)
sys.exit(1)
diff --git a/modules/cmds.py b/modules/cmds.py
index 192dbf6..6a71c13 100644
--- a/modules/cmds.py
+++ b/modules/cmds.py
@@ -61,7 +61,7 @@ def cmd_show_locks(con):
cmd_log(con, "Dumping locks data:");
if len(locks):
res = ""
- for lockdata in locks.iteritems():
+ for lockdata in locks.items():
tree, data = lockdata
msg = "Tree: %s, Conn name: %s, Hard Lock: %s, Time: %s" % (
tree, data['name'], data['hard'], time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['time'])))
diff --git a/modules/common.py b/modules/common.py
index 19f3aa8..2429749 100644
--- a/modules/common.py
+++ b/modules/common.py
@@ -1,5 +1,7 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import os, sys, config
def fileexists(path):
@@ -11,7 +13,7 @@ def fileexists(path):
def checkdir(dir):
if not fileexists(dir):
- print >>sys.stderr, 'ERR: ' + config.value['ftp_dir']+'/' + dir + " does not exist"
+ print('ERR: ' + config.value['ftp_dir']+'/' + dir + " does not exist", file=sys.stderr)
sys.exit(1)
if 'HOME' in os.environ:
diff --git a/modules/ftptree.py b/modules/ftptree.py
index e228331..10fe86b 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -1,5 +1,7 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import os, config, string, urllib, re, rpm
from common import fileexists, noarchcachedir
from baseftptree import BasePkg, BaseFtpTree
@@ -13,23 +15,23 @@ class SomeError(Exception):
return
def __str__(self):
- print "","An Error occured!"
+ return "An Error occured!"
def bailoutonerror():
if not errnum == 0:
- print "%d error(s) encountered... aborting" % errnum
+ print("%d error(s) encountered... aborting" % errnum)
raise SomeError
def pinfo(msg):
- print 'INFO: ' + msg
+ print('INFO: ' + msg)
def perror(msg):
global errnum
errnum = errnum + 1
- print 'ERR: ' + msg
+ print('ERR: ' + msg)
def pwarning(msg):
- print 'WARN: ' + msg
+ print('WARN: ' + msg)
def rm(file, test = False):
if test:
diff --git a/modules/user.py b/modules/user.py
index 2b31f1a..7f41958 100644
--- a/modules/user.py
+++ b/modules/user.py
@@ -1,5 +1,7 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import Cookie, time, ftpio
UserNotLoggedIn="UserNotLoggedIn"
@@ -31,8 +33,8 @@ class User:
#C['ftpsessid']['expires']=time.strftime(
#"%a, %d-%b-%y %H:%M:%S GMT",
#time.gmtime(time.time()+86400))
- print C
-
+ print(C)
+
def logout(self):
self.loggedin=False
ftpio.logout()
@@ -40,5 +42,5 @@ class User:
C['ftpsessid']=''
C['ftpsessid']['expires']=time.strftime("%a, %d-%b-%y %H:%M:%S GMT",
time.gmtime(time.time()-31536000))
- print C
+ print(C)
diff --git a/modules/wwwiface.py b/modules/wwwiface.py
index bc215ae..12b1a25 100644
--- a/modules/wwwiface.py
+++ b/modules/wwwiface.py
@@ -1,5 +1,7 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import cgi, Cookie, os
menu=[]
@@ -14,11 +16,11 @@ def getfile(file):
def catfile(file):
f=open("../html/" + file + ".html", 'r')
- print f.read()
+ print(f.read())
f.close()
def sendhttpheaders():
- print "Content-Type: text/html\n"
+ print("Content-Type: text/html\n")
def getopts():
form = cgi.FieldStorage()
@@ -39,21 +41,21 @@ def getopts():
def sendhtml():
catfile('header')
- print '<div id="Header">'
+ print('<div id="Header">')
for i in header:
- print i
- print '</div>'
+ print(i)
+ print('</div>')
- print '<div id="Menu">'
+ print('<div id="Menu">')
for i in menu:
- print i
+ print(i)
catfile('menufooter')
- print '</div>'
+ print('</div>')
- print '<div id="Content">'
+ print('<div id="Content">')
for i in content:
- print i
- print '</div>'
+ print(i)
+ print('</div>')
catfile('footer')
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/2ec96333835d67384921c863d3b4250d42165142
More information about the pld-cvs-commit
mailing list