From af30ba4ef713d2042fdd23d0969844c504dd1005 Mon Sep 17 00:00:00 2001 From: William Lachance Date: Wed, 2 Jan 2019 09:53:20 +0000 Subject: [PATCH] Bug 1471641 - Use subprocess check_call and check_output in mozinstall r=davehunt We were using more primitive methods before to support python 2.4, but that's obviously no longer required. Differential Revision: https://phabricator.services.mozilla.com/D15539 --HG-- extra : moz-landing-system : lando --- .../mozinstall/mozinstall/mozinstall.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/testing/mozbase/mozinstall/mozinstall/mozinstall.py b/testing/mozbase/mozinstall/mozinstall/mozinstall.py index bb8df76b7396..9e7bf782d9a7 100755 --- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py +++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py @@ -285,13 +285,10 @@ def _install_dmg(src, dest): # According to the Apple doc, the hdiutil output is stable and is based on the tab # separators # Therefor, $3 should give us the mounted path - proc = subprocess.Popen('hdiutil attach -nobrowse -noautoopen "%s"' - '|grep /Volumes/' - '|awk \'BEGIN{FS="\t"} {print $3}\'' % src, - shell=True, - stdout=subprocess.PIPE) - - appDir = proc.communicate()[0].strip() + appDir = subprocess.check_output('hdiutil attach -nobrowse -noautoopen "%s"' + '|grep /Volumes/' + '|awk \'BEGIN{FS="\t"} {print $3}\'' % str(src), + shell=True).strip() for appFile in os.listdir(appDir): if appFile.endswith('.app'): @@ -310,8 +307,8 @@ def _install_dmg(src, dest): finally: if appDir: - subprocess.call('hdiutil detach "%s" -quiet' % appDir, - shell=True) + subprocess.check_call('hdiutil detach "%s" -quiet' % appDir, + shell=True) return dest @@ -334,11 +331,7 @@ def _install_exe(src, dest): os.environ['__compat_layer'] = 'RunAsInvoker' cmd = '"%s" /extractdir=%s' % (src, os.path.realpath(dest)) - # As long as we support Python 2.4 check_call will not be available. - result = subprocess.call(cmd) - - if result is not 0: - raise Exception('Execution of installer failed.') + subprocess.check_call(cmd) return dest