import os
import re
import logging
+import subprocess
+import exceptions
import rsutil.globals
import rsutil.par2parser
-# Global constants
-(SUCCESS, ECHECK, EEXTRACT, EDELETE, ECREATE, EDETECT, EPARSE) = range(7)
-
def find_matches (regex, li, ignorecase=True):
if ignorecase:
# Runs the specified command-line in the directory given (or, in the current directory
# if none is given). It returns the status code given by the application.
- pwd = os.getcwd ()
-
- if indir != None:
+ if indir == None:
+ indir = os.getcwd()
+ else:
assert os.path.isdir (indir) # MUST be a directory!
- os.chdir (indir)
- ret = os.system (cmd)
- os.chdir (pwd)
+ print 'RUNNING COMMAND'
+ print 'Directory: %s' % indir
+ print 'Command: %s' % cmd[0]
+ for f in cmd[1:]:
+ print '-> %s' % f
+
+ ret = subprocess.Popen(cmd, cwd=indir).wait()
+
+ if ret != 0:
+ raise RuntimeError
+
return ret
def full_abspath (p):
if len(l1) != len(l2):
return False
- for e in l1:
- if e not in l2:
- return False
-
- return True
+ return set(l1) == set(l2)
# Convience functions for the config