extras-buildsys/common ExecUtils.py,1.1,1.2 Makefile,1.8,1.9
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Wed Aug 31 01:56:40 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22735/common
Modified Files:
Makefile
Added Files:
ExecUtils.py
Log Message:
2005-08-30 Dan Williams <dcbw at redhat.com>
* builder/builder.py
common/ExecUtils.py
- To execute mock, we now fork() and execv() the mock process
so that we can more reliably gather its output
- Correctly clean up the mock root directory
- Rename builder.log -> job.log so it can't get confused
with build.log from mock
Index: ExecUtils.py
===================================================================
RCS file: ExecUtils.py
diff -N ExecUtils.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ExecUtils.py 31 Aug 2005 01:56:38 -0000 1.2
@@ -0,0 +1,74 @@
+#
+# executil.py - generic utility functions for executing programs
+#
+# Erik Troan <ewt at redhat.com>
+#
+# Copyright 1999-2002 Red Hat, Inc.
+#
+# This software may be freely redistributed under the terms of the GNU
+# library public license.
+#
+# You should have received a copy of the GNU Library Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+import os
+import sys
+import types
+import select
+
+def getfd(filespec, readOnly = 0):
+ if type(filespec) == types.IntType:
+ return filespec
+ if filespec == None:
+ filespec = "/dev/null"
+
+ flags = os.O_RDWR | os.O_CREAT
+ if (readOnly):
+ flags = os.O_RDONLY
+ return os.open(filespec, flags, 0644)
+
+def exec_with_redirect(cmd, argv, stdin=0, stdout=1, stderr=2):
+ stdin = getfd(stdin)
+ if stdout == stderr:
+ stdout = getfd(stdout)
+ stderr = stdout
+ else:
+ stdout = getfd(stdout)
+ stderr = getfd(stderr)
+
+ cmd = os.path.abspath(cmd)
+ if not os.access (cmd, os.X_OK):
+ raise RuntimeError(cmd + " can not be run")
+
+ childpid = os.fork()
+ if (not childpid):
+ if stdin != 0:
+ os.dup2(stdin, 0)
+ os.close(stdin)
+ if stdout != 1:
+ os.dup2(stdout, 1)
+ if stdout != stderr:
+ os.close(stdout)
+ if stderr != 2:
+ os.dup2(stderr, 2)
+ os.close(stderr)
+
+ try:
+ os.execv(cmd, argv)
+ except OSError, e:
+ print "Could not execute command '%s'. Reason: %s" % (cmd, e)
+ sys.exit(1)
+
+ return childpid
+
+
+def foo():
+ status = -1
+ try:
+ (pid, status) = os.waitpid(childpid, 0)
+ except OSError, (errno, msg):
+ print __name__, "waitpid:", msg
+
+ return status
+
Index: Makefile
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/Makefile,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Makefile 25 Aug 2005 18:15:13 -0000 1.8
+++ Makefile 31 Aug 2005 01:56:38 -0000 1.9
@@ -9,8 +9,9 @@
FILES = \
ArchUtils.py \
- BaseConfig.py \
+ BaseConfig.py \
CommonErrors.py \
+ ExecUtils.py \
FileDownloader.py \
HTTPSURLopener.py \
HTTPServer.py \
More information about the fedora-extras-commits
mailing list