Bug 1471641 - Use subprocess check_call and check_output in mozinstall r=davehunt
authorWilliam Lachance <wlachance@mozilla.com>
Wed, 02 Jan 2019 09:53:20 +0000
changeset 509366 4ceb73d7896fe04d377b0eb5bd4980302907f569
parent 509365 5d16d586f9cdd00544bd5d29ac02b145e9041c48
child 509367 17049f612abe7a62b454add8c110e0993f84e5a6
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavehunt
bugs1471641
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/mozbase/mozinstall/mozinstall/mozinstall.py
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -280,23 +280,20 @@ def _install_dmg(src, dest):
     dest -- the path to extract to
 
     """
     appDir = None
     try:
         # 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'):
                 appName = appFile
                 break
 
         mounted_path = os.path.join(appDir, appName)
 
@@ -305,18 +302,18 @@ def _install_dmg(src, dest):
         # copytree() would fail if dest already exists.
         if os.path.exists(dest):
             raise InstallError('App bundle "%s" already exists.' % dest)
 
         shutil.copytree(mounted_path, dest, False)
 
     finally:
         if appDir:
-            subprocess.call('hdiutil detach "%s" -quiet' % appDir,
-                            shell=True)
+            subprocess.check_call('hdiutil detach "%s" -quiet' % appDir,
+                                  shell=True)
 
     return dest
 
 
 def _install_exe(src, dest):
     """Run the MSI installer to silently install the application into the
     destination folder. Return the folder path.
 
@@ -329,21 +326,17 @@ def _install_exe(src, dest):
     # best name from the src file name
     filename = os.path.basename(src)
     dest = os.path.join(dest, filename.split('.')[0])
 
     # possibly gets around UAC in vista (still need to run as administrator)
     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
 
 
 def install_cli(argv=sys.argv[1:]):
     parser = OptionParser(usage="usage: %prog [options] installer")
     parser.add_option('-d', '--destination',
                       dest='dest',