self.pkgliststartpad = 0
def __do_quit(self):
- raise DoQuit
+ raise DoQuit()
def __do_mark(self):
pkg=self.elements[self.pkglistselected]
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)
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)
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)
-#!/usr/bin/env python
+#!/usr/bin/env python3
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
import sys, os
ftpadmin = "(unknown)"
try:
ftpadmin = os.environ['FTPADM']
-except KeyError, e:
+except KeyError as e:
pass
m = Message()
m.set_headers(
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)
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:
pass
# TODO: log malicious msg
else:
- raise BailOut
+ raise BailOut()
# TODO: log this
def lock(con, arg, hard):
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()
else:
# TODO: log this
con.sock.send('FAIL')
- raise BailOut
+ raise BailOut()
def cmd_login_cookie(con, cookie):
if cookie in cookies:
def bailoutonerror():
if not errnum == 0:
print("%d error(s) encountered... aborting" % errnum)
- raise SomeError
+ raise SomeError()
def pinfo(msg):
print('INFO: ' + msg)
else:
try:
os.remove(file)
- except OSError, e:
+ except OSError as e:
pinfo("os.remove(%s): %s" % (file, e))
#raise
else:
try:
os.rename(fsrc, fdst)
- except OSError, e:
+ except OSError as e:
pinfo("os.rename(%s, %s): %s" % (fsrc, fdst, e))
raise
self.loadedpkgs[key]=pkg
return pkg
else:
- raise KeyError, key
+ raise KeyError(key)
def has_key(self, key):
if key in self.pkgnames:
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
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)
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
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)
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)
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