diff options
author | Rider Linden <rider@lindenlab.com> | 2017-09-22 09:18:34 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2017-09-22 09:18:34 -0700 |
commit | 5d3599f5d155dc112c8f05197c8fc73397084e71 (patch) | |
tree | 1b67cdb5944a222c1de6de3b974caea78a019762 /indra/lib | |
parent | 150fba7c5cd24ad9ab343e762bfd15032e6a9462 (diff) | |
parent | 38d9454cbf30f470a723d912be2080f63ae3fa47 (diff) |
Merge
Diffstat (limited to 'indra/lib')
-rwxr-xr-x | indra/lib/python/indra/util/llmanifest.py | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py index 0a39db2b21..d4e61aedd1 100755 --- a/indra/lib/python/indra/util/llmanifest.py +++ b/indra/lib/python/indra/util/llmanifest.py @@ -43,7 +43,9 @@ import subprocess class ManifestError(RuntimeError): """Use an exception more specific than generic Python RuntimeError""" - pass + def __init__(self, msg): + self.msg = msg + super(ManifestError, self).__init__(self.msg) class MissingError(ManifestError): """You specified a file that doesn't exist""" @@ -309,8 +311,11 @@ def main(): continue if touch: print 'Creating additional package for "', package_id, '" in ', args['dest'] - wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args) - wm.do(*args['actions']) + try: + wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args) + wm.do(*args['actions']) + except Exception as err: + sys.exit(str(err)) if touch: print 'Created additional package ', wm.package_file, ' for ', package_id faketouch = base_touch_prefix + '/' + package_id + '/' + base_touch_postfix @@ -449,29 +454,17 @@ class LLManifest(object): return path def run_command(self, command): - """ Runs an external command, and returns the output. Raises - an exception if the command returns a nonzero status code. For - debugging/informational purposes, prints out the command's - output as it is received.""" + """ + Runs an external command. + Raises ManifestError exception if the command returns a nonzero status. + """ print "Running command:", command sys.stdout.flush() - child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - shell=True) - lines = [] - while True: - lines.append(child.stdout.readline()) - if lines[-1] == '': - break - else: - print lines[-1], - output = ''.join(lines) - child.stdout.close() - status = child.wait() - if status: - raise ManifestError( - "Command %s returned non-zero status (%s) \noutput:\n%s" - % (command, status, output) ) - return output + try: + subprocess.check_call(command, shell=True) + except subprocess.CalledProcessError as err: + raise ManifestError( "Command %s returned non-zero status (%s)" + % (command, err.returncode) ) def created_path(self, path): """ Declare that you've created a path in order to @@ -621,7 +614,7 @@ class LLManifest(object): if self.includes(src, dst): try: os.unlink(dst) - except OSError, err: + except OSError as err: if err.errno != errno.ENOENT: raise @@ -642,7 +635,7 @@ class LLManifest(object): dstname = os.path.join(dst, name) try: self.ccopymumble(srcname, dstname) - except (IOError, os.error), why: + except (IOError, os.error) as why: errors.append((srcname, dstname, why)) if errors: raise ManifestError, errors |