-#!/usr/bin/env python
+#!/usr/bin/env python3
# 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')
+sys.path.insert(0, os.environ['HOME']+'/tld-ftp-admin/modules')
from config import incoming_dir, default_to, ftp_archs
from config import value as cval
import config
from ftptree import FtpTree, Pkg
import ftpio
-os.umask(022)
+os.umask(0o022)
def rm(file):
os.remove(file)
if not config.separate_debuginfo:
return False
pkg = nvr.split('-')[:-2]
- return pkg[-1] == 'debuginfo'
+ return pkg[-1] == 'debuginfo' or pkg[-1] == 'debugsource'
def findfiles(dir):
def filterinfos(x):
if files_differ:
f=open("%s/files.diff" % tmpdir, 'r')
sm.write("Difference between %s (currently in %s) and %s FILES\n" %
- (pkg.noarch_arch[rpmfile], `ftptree`, arch)),
- for line in f.readlines(True)[2:]:
+ (pkg.noarch_arch[rpmfile], repr(ftptree), arch)),
+ for line in f.readlines()[2:]:
sm.write(line)
f.close()
if reqs_differ:
f=open("%s/reqs.diff" % tmpdir, 'r')
sm.write("Difference between %s (currently in %s) and %s REQS\n" %
- (pkg.noarch_arch[rpmfile], `ftptree`, arch)),
- for line in f.readlines(True)[2:]:
+ (pkg.noarch_arch[rpmfile], repr(ftptree), arch)),
+ for line in f.readlines()[2:]:
sm.write(line)
f.close()
sm.close()
def move_noarch(f, arch, rpmfile, dstpkg):
- if dstpkg.noarch_arch.has_key(rpmfile):
+ if rpmfile in dstpkg.noarch_arch:
os.system("LC_ALL=C rpm -qlp %s | LC_ALL=C sort > %s/files.new" %
(incoming_dir + arch + '/' + rpmfile, tmpdir))
os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/reqs.new" %
(incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/%s.reqlist" %
(incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
- if not dstpkg.files.has_key(arch):
+ if arch not in dstpkg.files:
f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpmfile, rpmfile, arch))
mv(incoming_dir + arch + '/' + rpmfile, default_to + 'noarch/RPMS')
sm.write(msg)
sm.write("Difference between %s SRPM (currently in %s) and %s RPM NVR:\n\n" %
- (snvr[0], `ftptree`, arch)),
+ (snvr[0], repr(ftptree), arch)),
sm.write("Expected (%s):\nV: %s\nR: %s\n\n" % snvr)
sm.write("RPM:\nN: %s\nV: %s\nR: %s\n" % anvr)
sm.write('\n')
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
ftpio.log("%s file missing; skipping move until next round" % (srpm))
continue
- if ftptree.has_key(`pkg`):
+ if ftptree.has_key(repr(pkg)):
ftpio.log("%s already present in %s; removing older files" % (srpm, ftptree))
rm(default_to + 'SRPMS/RPMS/' + srpm)
f = open(default_to + 'SRPMS/.metadata/' + srpm+'.info', 'a')
- bid = pkg.build.keys()[0]
+ bid = list(pkg.build.keys())[0]
build = pkg.build[bid]
f.write("info:build:%s:requester:%s\ninfo:build:%s:requester_email:%s\n"
% (bid, build.requester, bid, build.requester_email))
srcpkg = BasePkg(uploadinfo[:-19], content = content)
srpm = srcpkg.files['SRPMS'][0]
- if not ftptree.has_key(`srcpkg`):
+ if not ftptree.has_key(repr(srcpkg)):
continue # We require the src.rpm to be present
renvr = re.compile(r'(.*)-(.*)-(.*)\.[^.]*\.rpm')
ftpio.log("%s file missing; skipping move until next round" % (filem))
continue
- dstpkg = BasePkg(`srcpkg`, ftptree)
+ dstpkg = BasePkg(repr(srcpkg), ftptree)
- if dstpkg.files.has_key(arch):
- ftpio.log("files from %s for arch %s already present in %s; removing older files" % (`srcpkg`, arch, ftptree))
+ if arch in dstpkg.files:
+ ftpio.log("files from %s for arch %s already present in %s; removing older files" % (repr(srcpkg), arch, ftptree))
for rpmfile in dstpkg.files[arch]:
if is_debuginfo(rpmfile):
dstfile = default_to + arch + '/debuginfo'
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
+ print(l)
f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'a')
for rpmfile in srcpkg.files['ARCH']:
if rpmfile[-11:] == '.noarch.rpm' and config.separate_noarch:
move_noarch(f, arch, rpmfile, dstpkg)
else:
- if not dstpkg.files.has_key(arch):
+ if arch not in dstpkg.files:
f.write("file:%s:%s\n" % (arch, rpmfile))
srcfile = incoming_dir + arch + '/' + rpmfile
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
+ print(l)
f.close()
rm(incoming_dir + arch + '/' + uploadinfo)
ftpio.unlock(cval['default_to'])
if moved_anything:
- os.system("%s/pld-ftp-admin/bin/pfa-genindex --quiet test > /dev/null" % (os.getenv("HOME")))
+ os.system("%s/tld-ftp-admin/bin/pfa-genindex --quiet test > /dev/null" % (os.getenv("HOME")))