Bug 1404480 - Manage hdiutil output when the volume name contains a space r?whimboo
MozReview-Commit-ID: lntjhP8QdT
--- 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)