--- a/testing/docker/recipes/run-task
+++ b/testing/docker/recipes/run-task
@@ -23,25 +23,25 @@ import os
import pwd
import re
import subprocess
import sys
def print_line(prefix, m):
now = datetime.datetime.utcnow()
- print('[%s %sZ] %s' % (prefix, now.isoformat(), m), end='')
+ print(b'[%s %sZ] %s' % (prefix, now.isoformat(), m), end=b'')
def run_and_prefix_output(prefix, args):
"""Runs a process and prefixes its output with the time.
Returns the process exit code.
"""
- print_line(prefix, 'executing %s\n' % args)
+ print_line(prefix, b'executing %s\n' % args)
# Note: TaskCluster's stdin is a TTY. This attribute is lost
# when we pass sys.stdin to the invoked process. If we cared
# to preserve stdin as a TTY, we could make this work. But until
# someone needs it, don't bother.
p = subprocess.Popen(args,
# Disable buffering because we want to receive output
# as it is generated so timestamps in logs are
@@ -52,17 +52,17 @@ def run_and_prefix_output(prefix, args):
stdin=sys.stdin.fileno(),
cwd='/',
# So \r in progress bars are rendered as multiple
# lines, preserving progress indicators.
universal_newlines=True)
while True:
data = p.stdout.readline()
- if data == '':
+ if data == b'':
break
print_line(prefix, data)
return p.wait()
def vcs_checkout(args):
@@ -107,17 +107,17 @@ def vcs_checkout(args):
b'--template', b'{node}'],
cwd=args.vcs_checkout)
assert re.match('^[a-f0-9]{40}$', revision)
os.environ['GECKO_HEAD_REV'] = revision
def main(args):
- print_line('setup', 'run-task started\n')
+ print_line(b'setup', b'run-task started\n')
if os.getuid() != 0:
print('assertion failed: not running as root')
return 1
# Arguments up to '--' are ours. After are for the main task
# to be executed.
try:
@@ -167,34 +167,34 @@ def main(args):
# And that it is owned by the appropriate user/group.
os.chown('/home/worker/hg-shared', uid, gid)
os.chown(os.path.dirname(checkout), uid, gid)
# Drop permissions to requested user.
# This code is modeled after what `sudo` was observed to do in a Docker
# container. We do not bother calling setrlimit() because containers have
# their own limits.
- print_line('setup', 'running as %s:%s\n' % (args.user, args.group))
+ print_line(b'setup', b'running as %s:%s\n' % (args.user, args.group))
os.setgroups(gids)
os.umask(022)
os.setresgid(gid, gid, gid)
os.setresuid(uid, uid, uid)
# Checkout the repository, setting the GECKO_HEAD_REV to the current
# revision hash. Revision hashes have priority over symbolic revisions. We
# disallow running tasks with symbolic revisions unless they have been
# resolved by a checkout.
if checkout:
vcs_checkout(args)
elif not os.environ.get('GECKO_HEAD_REV') and \
os.environ.get('GECKO_HEAD_REF'):
print('task should be defined in terms of non-symbolic revision')
return 1
- return run_and_prefix_output('task', task_args)
+ return run_and_prefix_output(b'task', task_args)
if __name__ == '__main__':
# Unbuffer stdio.
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
sys.exit(main(sys.argv[1:]))