import os
import re
import random
+import util
try:
from hashlib import md5 as md5
% (config.sudo_chroot_wrapper, config.chroot, quote(cmd))
def popen(cmd, user = "builder", mode = "r"):
- f = os.popen(command(cmd, user), mode)
+ if mode == "r":
+ p = subprocess.Popen(command(cmd, user), shell=True, stdout=subprocess.PIPE, close_fds=True)
+ f = p.stdout
+ else:
+ p = subprocess.Popen(command(cmd, user), shell=True, stdin=subprocess.PIPE, close_fds=True)
+ f = p.stdin
return f
def run(cmd, user = "builder", logfile = None, logstdout = None):
def cp(file, outfile, user="builder", rm=False):
m = md5()
- m.update(str(random.sample(range(100000), 500)))
+ m.update(util.to_bytes(str(random.sample(range(100000), 500))))
digest = m.hexdigest()
marker_start = "--- FILE BEGIN DIGEST %s ---" % digest
me = l.find(marker_end)
if me != -1:
l = l[:me]
- f.write(l)
+ f.write(util.to_bytes(l))
marker = False
break
if marker:
- f.write(l)
+ f.write(util.to_bytes(l))
rp = p.close()
rf = f.close()
if rp == None: