summaryrefslogtreecommitdiffstats
path: root/BuildManager
diff options
context:
space:
mode:
Diffstat (limited to 'BuildManager')
-rw-r--r--BuildManager/build.py10
-rw-r--r--BuildManager/fileutil.py48
-rw-r--r--BuildManager/optionparser.py2
-rw-r--r--BuildManager/package.py44
4 files changed, 53 insertions, 51 deletions
diff --git a/BuildManager/build.py b/BuildManager/build.py
index 73a1442..4efe006 100644
--- a/BuildManager/build.py
+++ b/BuildManager/build.py
@@ -1,7 +1,7 @@
from BuildManager.fileutil import *
from BuildManager.package import *
from BuildManager import *
-import thread
+import _thread
import subprocess
import sys, os
import time
@@ -10,7 +10,7 @@ import glob
__all__ = ["PackageBuilder"]
-GLOBAL_PKGLIST_LOCK = thread.allocate_lock()
+GLOBAL_PKGLIST_LOCK = _thread.allocate_lock()
STAGE_UNPACK = 0
STAGE_PREP = 1
@@ -56,12 +56,12 @@ class PackageBuilder:
return True
elif self.pkgsleft > 1 and self.pkgsleft % 10 != 0:
logger.info("package list has %d packages" % pkgsleft)
- self.pkglist_lock = thread.allocate_lock()
+ self.pkglist_lock = _thread.allocate_lock()
self.failures = 0
if self.opts.parallel != 1:
logger.info("starting threads")
for i in range(self.opts.parallel-1):
- thread.start_new_thread(self_processlist, ())
+ _thread.start_new_thread(self_processlist, ())
self._processlist()
while self.pkgsleft > 0:
time.sleep(2)
@@ -163,7 +163,7 @@ def filterpkglist(pkglist, directory, rule):
filterfunc = lambda x: not filterfunc_tmp(x)
else:
filterfunc = getattr(filterlist, rule)
- pkglist[:] = filter(filterfunc, pkglist)
+ pkglist[:] = list(filter(filterfunc, pkglist))
def buildpkglist(pkglist, stage, unpack_dir, passtrough="",
diff --git a/BuildManager/fileutil.py b/BuildManager/fileutil.py
index 93dd09d..aeba0eb 100644
--- a/BuildManager/fileutil.py
+++ b/BuildManager/fileutil.py
@@ -25,27 +25,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error, (errno, errstr):
- raise Error, "could not open %s: %s" % (src, errstr)
+ except os.error as xxx_todo_changeme2:
+ (errno, errstr) = xxx_todo_changeme2.args
+ raise Error("could not open %s: %s" % (src, errstr))
try:
fdst = open(dst, 'wb')
- except os.error, (errno, errstr):
- raise Error, "could not create %s: %s" % (dst, errstr)
+ except os.error as xxx_todo_changeme3:
+ (errno, errstr) = xxx_todo_changeme3.args
+ raise Error("could not create %s: %s" % (dst, errstr))
while 1:
try:
buf = fsrc.read(buffer_size)
- except os.error, (errno, errstr):
- raise Error, "could not read from %s: %s" % (src, errstr)
+ except os.error as xxx_todo_changeme:
+ (errno, errstr) = xxx_todo_changeme.args
+ raise Error("could not read from %s: %s" % (src, errstr))
if not buf:
break
try:
fdst.write(buf)
- except os.error, (errno, errstr):
- raise Error, "could not write to %s: %s" % (dst, errstr)
+ except os.error as xxx_todo_changeme1:
+ (errno, errstr) = xxx_todo_changeme1.args
+ raise Error("could not write to %s: %s" % (dst, errstr))
finally:
if fdst:
@@ -80,8 +84,8 @@ def copy_file (src, dst, preserve_mode=1, preserve_times=1, link=None,
from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE
if not os.path.isfile(src):
- raise Error, "can't copy '%s': " \
- "doesn't exist or not a regular file" % src
+ raise Error("can't copy '%s': " \
+ "doesn't exist or not a regular file" % src)
if os.path.isdir(dst):
dir = dst
@@ -92,7 +96,7 @@ def copy_file (src, dst, preserve_mode=1, preserve_times=1, link=None,
try:
action = _copy_action[link]
except KeyError:
- raise ValueError, "invalid value '%s' for 'link' argument" % link
+ raise ValueError("invalid value '%s' for 'link' argument" % link)
if os.path.basename(dst) == os.path.basename(src):
logger.info("%s %s to %s" % (action, src, dir))
else:
@@ -141,38 +145,40 @@ def move_file (src, dst, dryrun=False):
return dst
if not isfile(src):
- raise Error, "can't move %s: not a regular file" % src
+ raise Error("can't move %s: not a regular file" % src)
if isdir(dst):
dst = os.path.join(dst, basename(src))
elif exists(dst):
- raise Error, "can't move %s: destination %s already exists" % \
- (src, dst)
+ raise Error("can't move %s: destination %s already exists" % \
+ (src, dst))
if not isdir(dirname(dst)):
- raise Error, "can't move %s: destination %s not a valid path" % \
- (src, dst)
+ raise Error("can't move %s: destination %s not a valid path" % \
+ (src, dst))
copy_it = 0
try:
os.rename(src, dst)
- except os.error, (num, msg):
+ except os.error as xxx_todo_changeme5:
+ (num, msg) = xxx_todo_changeme5.args
if num == errno.EXDEV:
copy_it = 1
else:
- raise Error, "couldn't move %s to %s: %s" % (src, dst, msg)
+ raise Error("couldn't move %s to %s: %s" % (src, dst, msg))
if copy_it:
copy_file(src, dst)
try:
os.unlink(src)
- except os.error, (num, msg):
+ except os.error as xxx_todo_changeme4:
+ (num, msg) = xxx_todo_changeme4.args
try:
os.unlink(dst)
except os.error:
pass
- raise Error, "couldn't move %s to %s by copy/delete: " \
- "delete %s failed: %s" % (src, dst, src, msg)
+ raise Error("couldn't move %s to %s by copy/delete: " \
+ "delete %s failed: %s" % (src, dst, src, msg))
return dst
diff --git a/BuildManager/optionparser.py b/BuildManager/optionparser.py
index ea1ae68..795848a 100644
--- a/BuildManager/optionparser.py
+++ b/BuildManager/optionparser.py
@@ -29,6 +29,6 @@ class OptionParser(optparse.OptionParser):
return optparse.OptionParser.format_help(self, formatter)
def error(self, msg):
- raise Error, msg
+ raise Error(msg)
# vim:et:ts=4:sw=4
diff --git a/BuildManager/package.py b/BuildManager/package.py
index 0adfc10..140562d 100644
--- a/BuildManager/package.py
+++ b/BuildManager/package.py
@@ -1,7 +1,7 @@
from BuildManager import *
from BuildManager.rpmver import rpmVersionCompare
-from UserList import UserList
-import commands
+from collections import UserList
+import subprocess
import string
import os
import re
@@ -22,17 +22,17 @@ def subst(s, vars):
return str(vars[name])
try:
return re.sub(r'\$([a-zA-Z]+)', _subst, s)
- except KeyError, var:
- raise Error, "variable $%s not declared" % var
+ except KeyError as var:
+ raise Error("variable $%s not declared" % var)
class Package:
def __init__(self, file, log=None):
self._package = None
ext = self._filename_extension(file)
if not ext:
- raise Error, "unknown file extension of "+file
- if not globals().has_key("_package_"+ext):
- raise Error, "unknown package extension of "+file
+ raise Error("unknown file extension of "+file)
+ if "_package_"+ext not in globals():
+ raise Error("unknown package extension of "+file)
self._package = globals()["_package_"+ext](file, log)
def __getattr__(self, name):
@@ -88,7 +88,7 @@ class _package_spec(_package):
ret.append(str[start:])
break
varname = str[start+2:end]
- if vars.has_key(varname):
+ if varname in vars:
ret.append(vars[varname])
else:
ret.append(str[start:end+1])
@@ -100,9 +100,8 @@ class _package_spec(_package):
ret = os.system("mkdir -p %s/{SOURCES,SPECS,BUILD,SRPMS,RPMS,BUILDROOT}" % self.builddir)
try:
f = open(self.spec,"r")
- except IOError, e:
- raise BuildManagerFileError, \
- "couldn't open spec file %s" % self.absfile
+ except IOError as e:
+ raise BuildManagerFileError("couldn't open spec file %s" % self.absfile)
defines = {}
for line in f.readlines():
lowerline = string.lower(line)
@@ -119,8 +118,8 @@ class _package_spec(_package):
if self.name and self.version and self.release:
break
else:
- raise Error, "spec file %s doesn't define name, " \
- "version or release" % self.file
+ raise Error("spec file %s doesn't define name, " \
+ "version or release" % self.file)
self.type = "spec"
self._expand_log()
@@ -128,16 +127,14 @@ class _package_rpm(_package):
def _init(self):
if not rpm:
cmd = "rpm -qp --queryformat='%%{NAME} %%{EPOCH} %%{VERSION} %%{RELEASE} %%{SOURCERPM}' %s"%self.file
- status, output = commands.getstatusoutput(cmd)
+ status, output = subprocess.getstatusoutput(cmd)
if status != 0:
- raise BuildManagerPackageError, \
- "error querying rpm file %s" % self.file
+ raise BuildManagerPackageError("error querying rpm file %s" % self.file)
else:
tokens = string.split(output, " ")
if len(tokens) != 5:
- raise Error, \
- "unexpected output querying rpm file %s: %s" % \
- (self.file, output)
+ raise Error("unexpected output querying rpm file %s: %s" % \
+ (self.file, output))
else:
self.name, self.epoch, self.version, self.release, srpm = tokens
if self.epoch == "(none)":
@@ -176,16 +173,15 @@ class _package_rpm(_package):
builddir = "%s/%s-%s-%s-topdir" % (unpackdir, self.name, self.version, self.release)
ret = os.system("mkdir -p %s/{SOURCES,SPECS,BUILD,SRPMS,RPMS,BUILDROOT}" % builddir)
if ret != 0:
- raise BuildManagerPackageError, \
- "error creating builddir at %s" % builddir
+ raise BuildManagerPackageError("error creating builddir at %s" % builddir)
else:
return builddir
def _install_srpm(self):
cmd = "rpm -i --define '_topdir %s' %s &> %s"%(self.builddir,self.file,self.log)
- status, output = commands.getstatusoutput(cmd)
+ status, output = subprocess.getstatusoutput(cmd)
if status != 0:
- raise Error, "error installing package "+self.file
+ raise Error("error installing package "+self.file)
else:
spec = self.builddir+"/SPECS/"+self.name+".spec"
if not os.path.isfile(spec):
@@ -194,7 +190,7 @@ class _package_rpm(_package):
if file[-5:] != ".spec":
listdir.remove(file)
if len(listdir) != 1:
- raise Error, "can't guess spec file for "+self.file
+ raise Error("can't guess spec file for "+self.file)
else:
self.spec = self.builddir+"/SPECS/"+listdir[0]
return 1