From 3d999b0948b07b0ba2213f7904b241725e682c16 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 28 Nov 2019 10:11:12 +0200 Subject: Change: port to Python3 --- yarn | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'yarn') diff --git a/yarn b/yarn index d67c115..4b4db34 100755 --- a/yarn +++ b/yarn @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2013 Lars Wirzenius # # This program is free software: you can redistribute it and/or modify @@ -116,8 +116,6 @@ class YarnRunner(cliapp.Application): self._write(sys.stderr, msg) def _write(self, output, msg): - if isinstance(msg, unicode): - msg = msg.encode(locale.getpreferredencoding()) output.write(msg) output.flush() @@ -332,7 +330,7 @@ class YarnRunner(cliapp.Application): started = time.time() self.info(0, 'Running scenario %s' % scenario.name) - self.ts['scenario_name'] = scenario.name.encode('utf-8') + self.ts['scenario_name'] = scenario.name self.ts.flush() self.scenarios_run += 1 @@ -450,7 +448,7 @@ class YarnRunner(cliapp.Application): self.info(1, 'Running step "%s %s"' % (step.what, step.text)) self.ts['current_step'] = step - self.ts['step_name'] = '%s %s' % (step.what, step.text.encode('utf8')) + self.ts['step_name'] = '%s %s' % (step.what, step.text) self.ts.flush() self.steps_run += 1 @@ -461,7 +459,7 @@ class YarnRunner(cliapp.Application): env['SRCDIR'] = os.getcwd() env['HOME'] = self.homedir(datadir) for i, match in enumerate(m.groups('')): - env['MATCH_%d' % (i+1)] = match.encode('utf-8') + env['MATCH_%d' % (i+1)] = match self.add_srcdir_to_pythonpath(env, env['SRCDIR']) if self.settings['cd-datadir']: @@ -487,11 +485,11 @@ class YarnRunner(cliapp.Application): logging.debug('Exit code: %d' % exit) if stdout: - logging.debug('Standard output:\n%s' % self.indent(stdout)) + logging.debug('Standard output:\n%s' % self.indent(stdout.decode())) else: logging.debug('Standard output: empty') if stderr: - logging.debug('Standard error:\n%s' % self.indent(stderr)) + logging.debug('Standard error:\n%s' % self.indent(stderr.decode())) else: logging.debug('Standard error: empty') @@ -500,9 +498,9 @@ class YarnRunner(cliapp.Application): self.error('step "%s %s" failed,' % (step.what, step.text)) self.error('with exit code %d:' % exit) self.error('Standard output from shell command:\n%s' % - self.indent(stdout)) + self.indent(stdout.decode())) self.error('Standard error from shell command:\n%s' % - self.indent(stderr)) + self.indent(stderr.decode())) self.remember_step_timing( '%s %s' % (step.what, step.text), time.time() - started) @@ -541,7 +539,9 @@ class YarnRunner(cliapp.Application): exit, out, err = cliapp.runcmd_unchecked( ['cp', '-ax', datadir, snapshot]) if exit != 0: - logging.warning('Snapshot copy failed:\n%s\n%s' % (out, err)) + logging.warning( + 'Snapshot copy failed:\n%s\n%s' % + (out.decode(), err.decode ())) def nice(self, name): # Quote a scenario or step name so it forms a nice filename. -- cgit v1.2.1