- # Strip all stuf after command,
- # deal with "((latex ) >& 1 ) .." too
- cmd = re.match ('([\(\)]*)([^\\\ ]*)', cmd).group (2)
- return os.path.basename (cmd)
-
-def error_log (name):
- name = re.sub('[^a-z]','x', name)
- return tempfile.mktemp ('%s.errorlog' % name)
-
-
-def system (cmd, ignore_error = 0, progress_p = 0, be_verbose=0):
-
- '''System CMD. If IGNORE_ERROR, do not complain when CMD
-returns non zero. If PROGRESS_P, always show progress.
-
-RETURN VALUE
+ # Strip all stuf after command,
+ # deal with "((latex ) >& 1 ) .." too
+ cmd = re.match ('([\(\)]*)([^\\\ ]*)', cmd).group (2)
+ return os.path.basename (cmd)
+
+def subprocess_system (cmd,
+ ignore_error=False,
+ progress_p=True,
+ be_verbose=False,
+ log_file=None):
+ import subprocess
+
+ show_progress= progress_p
+ name = command_name (cmd)
+ error_log_file = ''
+
+ if be_verbose:
+ show_progress = 1
+ progress (_ ("Invoking `%s\'") % cmd)
+ else:
+ progress ( _("Running %s...") % name)
+
+
+ stdout_setting = None
+ if not show_progress:
+ stdout_setting = subprocess.PIPE
+
+ proc = subprocess.Popen (cmd,
+ shell=True,
+ universal_newlines=True,
+ stdout=stdout_setting,
+ stderr=stdout_setting)
+
+ log = ''
+
+ if show_progress:
+ retval = proc.wait()
+ else:
+ log = proc.communicate ()
+ retval = proc.returncode
+
+
+ if retval:
+ print >>sys.stderr, 'command failed:', cmd
+ if retval < 0:
+ print >>sys.stderr, "Child was terminated by signal", -retval
+ elif retval > 0:
+ print >>sys.stderr, "Child returned", retval
+
+ if ignore_error:
+ print >>sys.stderr, "Error ignored"
+ else:
+ if not show_progress:
+ print log[0]
+ print log[1]
+ sys.exit (1)
+
+ return abs (retval)
+
+def ossystem_system (cmd,
+ ignore_error=False,
+ progress_p=True,
+ be_verbose=False,
+ log_file=None):
+
+
+ name = command_name (cmd)
+ if be_verbose:
+ show_progress = 1
+ progress (_ ("Invoking `%s\'") % cmd)
+ else:
+ progress ( _("Running %s...") % name)
+
+ retval = os.system (cmd)
+ if retval:
+ print >>sys.stderr, 'command failed:', cmd
+ if retval < 0:
+ print >>sys.stderr, "Child was terminated by signal", -retval
+ elif retval > 0:
+ print >>sys.stderr, "Child returned", retval
+
+ if ignore_error:
+ print >>sys.stderr, "Error ignored"
+ else:
+ sys.exit (1)