Skip to content
This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

Commit

Permalink
Fix backports, fixes #91
Browse files Browse the repository at this point in the history
  • Loading branch information
Procrat committed Apr 10, 2016
1 parent 49f89f3 commit 969c37a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
16 changes: 6 additions & 10 deletions battlebots/backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ def sp_run(*popenargs, input=None, timeout=None, check=False, **kwargs):
except sp.TimeoutExpired:
process.kill()
stdout, stderr = process.communicate()
raise sp.TimeoutExpired(process.args, timeout, output=stdout,
stderr=stderr)
err = sp.TimeoutExpired(process.args, timeout, output=stdout)
err.stderr = stderr
raise err
except:
process.kill()
process.wait()
raise
retcode = process.poll()
if check and retcode:
raise sp.CalledProcessError(retcode, process.args, output=stdout,
stderr=stderr)
err = sp.CalledProcessError(retcode, process.args, output=stdout)
err.stderr = stderr
raise err
return CompletedProcess(process.args, retcode, stdout, stderr)


Expand Down Expand Up @@ -77,9 +79,3 @@ def __repr__(self):
if self.stderr is not None:
args.append('stderr={!r}'.format(self.stderr))
return "{}({})".format(type(self).__name__, ', '.join(args))

def check_returncode(self):
"""Raise CalledProcessError if the exit code is non-zero."""
if self.returncode:
raise sp.CalledProcessError(self.returncode, self.args,
self.stdout, self.stderr)
6 changes: 3 additions & 3 deletions battlebots/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def compile(self, timeout=20):
self.compiled = True
return True
except sp.SubprocessError as error:
error = '{error}\nStdout: {stdout}Stderr: {stderr}'.format(
error = '{error}\nStdout: {stdout}\nStderr: {stderr}'.format(
error=error,
stdout=error.stdout.decode('utf8'),
stderr=error.stderr.decode('utf8'))
stdout=error.stdout.decode('utf8').rstrip(),
stderr=error.stderr.decode('utf8').rstrip())
logging.warning(error)
self.compile_errors = error
return False
Expand Down

0 comments on commit 969c37a

Please sign in to comment.