diff options
author | Andrew Gaffney <agaffney@gentoo.org> | 2007-03-18 17:59:09 +0000 |
---|---|---|
committer | Andrew Gaffney <agaffney@gentoo.org> | 2007-03-18 17:59:09 +0000 |
commit | ddf7a47a432f8fed9f4eb3b33f3bc5fceb5e6600 (patch) | |
tree | 581b68cbe567f8914ca43726303686fd8a2585e7 /src/GLIUtility.py | |
parent | call exit_button() when clicking the X in the corner (diff) | |
download | gli-ddf7a47a432f8fed9f4eb3b33f3bc5fceb5e6600.tar.gz gli-ddf7a47a432f8fed9f4eb3b33f3bc5fceb5e6600.tar.bz2 gli-ddf7a47a432f8fed9f4eb3b33f3bc5fceb5e6600.zip |
let tee write to the logfile
use the /tmp/spawn_exitcode trick from quickstart to get return value
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/gli/branches/overhaul@1804 f8877401-5920-0410-a79b-8e2d7e04ca0d
Diffstat (limited to 'src/GLIUtility.py')
-rw-r--r-- | src/GLIUtility.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/GLIUtility.py b/src/GLIUtility.py index e3cc324..25338f2 100644 --- a/src/GLIUtility.py +++ b/src/GLIUtility.py @@ -302,19 +302,21 @@ def spawn(cmd, quiet=False, logfile=None, display_on_tty8=False, chroot=None, ap wrapper = open(chroot+"/var/tmp/spawn.sh", "w") wrapper.write("#!/bin/bash -l\n" + cmd + "\nexit $?\n") wrapper.close() - cmd = "chmod a+x " + chroot + "/var/tmp/spawn.sh && chroot " + chroot + " /var/tmp/spawn.sh 2>&1" - else: - cmd += " 2>&1 " + cmd = "chmod a+x " + chroot + "/var/tmp/spawn.sh && chroot " + chroot + " /var/tmp/spawn.sh" + if debug: print "Command: " + cmd output = "" + cmd = "(" + cmd + " 2>&1; echo $? > /tmp/spawn_exitcode)" if logfile: if append_log: - fd_logfile = open(logfile,'a') +# fd_logfile = open(logfile,'a') + cmd += " | tee -a " + logfile else: - fd_logfile = open(logfile,'w') +# fd_logfile = open(logfile,'w') + cmd += " | tee " + logfile if display_on_tty8: fd_tty = open('/dev/tty8','w') @@ -346,9 +348,9 @@ def spawn(cmd, quiet=False, logfile=None, display_on_tty8=False, chroot=None, ap # print "DEBUG: spawn(): data is " + str(len(data)) + " bytes long" - if logfile: - fd_logfile.write(data) -# fd_logfile.flush() +# if logfile: +# fd_logfile.write(data) +## fd_logfile.flush() if display_on_tty8: fd_tty.write(data) @@ -382,11 +384,12 @@ def spawn(cmd, quiet=False, logfile=None, display_on_tty8=False, chroot=None, ap # data = ro_pipe.readline() # close the file descriptors - if logfile: fd_logfile.close() +# if logfile: fd_logfile.close() if display_on_tty8: fd_tty.close() # close the pipe and save return value - ret = ro_pipe.close() or 0 + ro_pipe.close() + ret = int(open("/tmp/spawn_exitcode", "r").readline().strip()) if return_output: return ret, output |