- # Strip all stuf after command,
- # deal with "((latex ) >& 1 ) .." too
- cmd = re.match ('([\(\)]*)([^\\\ ]*)', cmd).group (2)
- return os.path.basename (cmd)
-
-def system (cmd,
- ignore_error=False,
- progress_p=True,
- be_verbose=False,
- log_file=None):
-
- show_progress= progress_p
- name = command_name (cmd)
- error_log_file = ''
-
- if be_verbose:
- show_progress = 1
- progress (_ ("Invoking `%s\'") % cmd)
+ # 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"