[gnome-ostree] ostbuild: Avoid using python global statement
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree] ostbuild: Avoid using python global statement
- Date: Mon, 9 Jul 2012 02:04:45 +0000 (UTC)
commit 4a859661805c9c8f3df403f608831a2814012482
Author: Colin Walters <walters verbum org>
Date: Sun Jul 8 19:21:39 2012 -0400
ostbuild: Avoid using python global statement
I'm not sure how this ever worked...running into some problems with it
now.
src/ostbuild/pyostbuild/builtin_build.py | 7 ++++---
src/ostbuild/pyostbuild/subprocess_helpers.py | 17 ++++++++++-------
2 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index 1fb1efc..ca3a87e 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -71,7 +71,7 @@ class OstbuildBuild(builtins.Builtin):
subproc_env = dict(os.environ)
subproc_env['GIT_PAGER'] = 'cat'
run_sync(git_args, cwd=component_srcdir, stdin=open('/dev/null'),
- stdout=sys.stdout)
+ stdout=sys.stdout, env=subproc_env, log_success=False)
else:
log("No previous build; skipping source diff")
@@ -100,6 +100,7 @@ class OstbuildBuild(builtins.Builtin):
'rev-parse', build_ref],
stderr=open('/dev/null', 'w'),
none_on_error=True)
+ previous_vcs_version = None
previous_metadata = None
if previous_build_version is not None:
@@ -164,8 +165,8 @@ class OstbuildBuild(builtins.Builtin):
log("Logging to %s" % (log_path, ))
f = open(log_path, 'w')
chroot_args = self._get_ostbuild_chroot_args(architecture, component, component_resultdir)
- ecode = run_sync_monitor_log_file(chroot_args, log_path, cwd=component_src, fatal_on_error=False)
- if ecode != 0:
+ success = run_sync_monitor_log_file(chroot_args, log_path, cwd=component_src, fatal_on_error=False)
+ if not success:
if self.buildopts.shell_on_failure:
self._launch_debug_shell(architecture, component, component_resultdir, cwd=component_src)
self._analyze_build_failure(architecture, component, component_src,
diff --git a/src/ostbuild/pyostbuild/subprocess_helpers.py b/src/ostbuild/pyostbuild/subprocess_helpers.py
index 3754900..0ff2db6 100755
--- a/src/ostbuild/pyostbuild/subprocess_helpers.py
+++ b/src/ostbuild/pyostbuild/subprocess_helpers.py
@@ -20,6 +20,7 @@
import os
import sys
import subprocess
+import functools
from .ostbuildlog import log, fatal
from .warningfilter import WarningFilter
@@ -128,18 +129,20 @@ def run_sync_monitor_log_file(args, logfile, cwd=None, env=None,
loop = Mainloop.get(None)
- proc_estatus = None
+ # This lame bit is to avoid using global
+ succeeded = {'succeeded': None}
def _on_pid_exited(pid, estatus):
- global proc_estatus
- proc_estatus = estatus
- failed = estatus != 0
- warnfilter.finish(not failed)
+ success = os.WIFEXITED(estatus) and os.WEXITSTATUS(estatus) == 0
+ succeeded['succeeded'] = success
+ warnfilter.finish(success)
if fatal_on_error and failed:
logfn = fatal
else:
logfn = log
- logfn("pid %d exited with code %d" % (pid, estatus))
+ logfn("pid %d exited with STATUS %d" % (pid, estatus))
loop.quit()
loop.watch_pid(proc.pid, _on_pid_exited)
loop.run()
- return proc_estatus
+ success = succeeded['succeeded']
+ assert success is not None
+ return success
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]