summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BuildManager/build.py5
-rw-r--r--BuildManager/fileutil.py16
-rw-r--r--BuildManager/package.py31
-rwxr-xr-xbm2
-rwxr-xr-xbmclean2
5 files changed, 28 insertions, 28 deletions
diff --git a/BuildManager/build.py b/BuildManager/build.py
index 4efe006..600d883 100644
--- a/BuildManager/build.py
+++ b/BuildManager/build.py
@@ -7,6 +7,7 @@ import sys, os
import time
import shutil
import glob
+import codecs
__all__ = ["PackageBuilder"]
@@ -203,7 +204,7 @@ def buildpkg(pkg, stage, unpack_dir, passtrough="", show_log=0, dryrun=0):
(stagechar,pkg.builddir,tmppath,passtrough,pkg.spec)
logger.debug("rpmbuild command: "+cmd)
if not dryrun:
- log = open(pkg.log, "w")
+ log = codecs.open(pkg.log, "w", 'utf-8', errors = "replace")
pop = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
of = pop.stdout.fileno()
@@ -211,7 +212,7 @@ def buildpkg(pkg, stage, unpack_dir, passtrough="", show_log=0, dryrun=0):
status = pop.poll()
if status is not None:
break
- data = os.read(of, 8192)
+ data = os.read(of, 8192).decode(sys.getfilesystemencoding())
log.write(data)
log.flush()
if show_log:
diff --git a/BuildManager/fileutil.py b/BuildManager/fileutil.py
index aeba0eb..05126da 100644
--- a/BuildManager/fileutil.py
+++ b/BuildManager/fileutil.py
@@ -25,21 +25,21 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error as xxx_todo_changeme2:
- (errno, errstr) = xxx_todo_changeme2.args
+ except os.error as e:
+ (errno, errstr) = e.args
raise Error("could not open %s: %s" % (src, errstr))
try:
fdst = open(dst, 'wb')
- except os.error as xxx_todo_changeme3:
- (errno, errstr) = xxx_todo_changeme3.args
+ except os.error as e:
+ (errno, errstr) = e.args
raise Error("could not create %s: %s" % (dst, errstr))
while 1:
try:
buf = fsrc.read(buffer_size)
- except os.error as xxx_todo_changeme:
- (errno, errstr) = xxx_todo_changeme.args
+ except os.error as e:
+ (errno, errstr) = e.args
raise Error("could not read from %s: %s" % (src, errstr))
if not buf:
@@ -47,8 +47,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
fdst.write(buf)
- except os.error as xxx_todo_changeme1:
- (errno, errstr) = xxx_todo_changeme1.args
+ except os.error as e:
+ (errno, errstr) = e.args
raise Error("could not write to %s: %s" % (dst, errstr))
finally:
diff --git a/BuildManager/package.py b/BuildManager/package.py
index 140562d..b9646a5 100644
--- a/BuildManager/package.py
+++ b/BuildManager/package.py
@@ -2,7 +2,6 @@ from BuildManager import *
from BuildManager.rpmver import rpmVersionCompare
from collections import UserList
import subprocess
-import string
import os
import re
@@ -74,25 +73,25 @@ class _package:
self.log = subst(self.log, substdict)
class _package_spec(_package):
- def _rpm_vars(self, str, vars):
+ def _rpm_vars(self, s, vars):
end = -1
ret = []
while 1:
- start = string.find(str, "%{", end+1)
+ start = s.find("%{", end+1)
if start == -1:
- ret.append(str[end+1:])
+ ret.append(s[end+1:])
break
- ret.append(str[end+1:start])
- end = string.find(str, "}", start)
+ ret.append(s[end+1:start])
+ end = s.find("}", start)
if end == -1:
- ret.append(str[start:])
+ ret.append(s[start:])
break
- varname = str[start+2:end]
+ varname = s[start+2:end]
if varname in vars:
ret.append(vars[varname])
else:
- ret.append(str[start:end+1])
- return string.join(ret,"")
+ ret.append(s[start:end+1])
+ return "".join(ret)
def _init(self):
self.spec = self.absfile
@@ -104,15 +103,15 @@ class _package_spec(_package):
raise BuildManagerFileError("couldn't open spec file %s" % self.absfile)
defines = {}
for line in f.readlines():
- lowerline = string.lower(line)
+ lowerline = line.lower()
if not self.name and lowerline[:5] == "name:":
- self.name = self._rpm_vars(string.strip(line[5:]), defines)
+ self.name = self._rpm_vars((line[5:]).strip(), defines)
elif not self.version and lowerline[:8] == "version:":
- self.version = self._rpm_vars(string.strip(line[8:]), defines)
+ self.version = self._rpm_vars((line[8:]).strip(), defines)
elif not self.release and lowerline[:8] == "release:":
- self.release = self._rpm_vars(string.strip(line[8:]), defines)
+ self.release = self._rpm_vars((line[8:]).strip(), defines)
elif lowerline[:7] == "%define":
- token = string.split(line[7:])
+ token = (line[7:]).split()
if len(token) == 2:
defines[token[0]] = self._rpm_vars(token[1], defines)
if self.name and self.version and self.release:
@@ -131,7 +130,7 @@ class _package_rpm(_package):
if status != 0:
raise BuildManagerPackageError("error querying rpm file %s" % self.file)
else:
- tokens = string.split(output, " ")
+ tokens = output.split(" ")
if len(tokens) != 5:
raise Error("unexpected output querying rpm file %s: %s" % \
(self.file, output))
diff --git a/bm b/bm
index 0a0cbdb..6124d60 100755
--- a/bm
+++ b/bm
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
from BuildManager.optionparser import *
from BuildManager.build import *
from BuildManager import *
diff --git a/bmclean b/bmclean
index 8c9426a..a8fb6e6 100755
--- a/bmclean
+++ b/bmclean
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
from BuildManager.optionparser import *
from BuildManager.clean import *
from BuildManager import *