Bug 1404480 - Manage hdiutil output when the volume name contains a space r?whimboo draft
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 02 Oct 2017 13:07:53 +0200
changeset 676461 b7bdad940e71602fafe93bf3cb9de3a976e2fd6a
parent 673017 d42ec088c7761e4da0f4b25ffb4f7f90e0085ef9
child 676469 1e7b0333c369343a9b430329df1806ccbdf25d36
child 676471 025f4161ab298f689e707548fe3b3ff51a79e4ff
push id83487
push userbmo:sledru@mozilla.com
push dateSat, 07 Oct 2017 15:18:50 +0000
reviewerswhimboo
bugs1404480
milestone57.0a1
Bug 1404480 - Manage hdiutil output when the volume name contains a space r?whimboo MozReview-Commit-ID: lntjhP8QdT
testing/mozbase/mozinstall/mozinstall/mozinstall.py
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -273,24 +273,26 @@ def _install_dmg(src, dest):
     """Extract a dmg file into the destination folder and return the
     application folder.
 
     src -- DMG image which has to be extracted
     dest -- the path to extract to
 
     """
     try:
-        proc = subprocess.Popen('hdiutil attach -nobrowse -noautoopen "%s"' % src,
+        # 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)
 
-        for data in proc.communicate()[0].split():
-            if data.find('/Volumes/') != -1:
-                appDir = data
-                break
+        appDir = proc.communicate()[0].strip()
 
         for appFile in os.listdir(appDir):
             if appFile.endswith('.app'):
                 appName = appFile
                 break
 
         mounted_path = os.path.join(appDir, appName)