Bug 1218554 - Handled the error while attaching the DMG(macOS). r=whimboo draft bug_1218554
authorVedant Chakravadhanula <vedantc98@gmail.com>
Fri, 27 Oct 2017 22:16:55 +0530
branchbug_1218554
changeset 687746 b0dd78f3895bb34c4e916bc0441dd9ae5e643dfc
parent 680024 196dadb2fe500e75c6fbddcac78106648676cf10
child 737725 6ad8173e13f29561ecced8a32f1c5293b48ca945
push id86587
push userbmo:vedantc98@gmail.com
push dateFri, 27 Oct 2017 17:20:27 +0000
reviewerswhimboo
bugs1218554
milestone58.0a1
Bug 1218554 - Handled the error while attaching the DMG(macOS). r=whimboo Variable appDir was being referenced before assignment. Changed the try-except-finally blocks to handle the error. MozReview-Commit-ID: AHEeVhmPfQI
testing/mozbase/mozinstall/mozinstall/mozinstall.py
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -272,16 +272,17 @@ def _install_url(url, dest):
 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
 
     """
+    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,
@@ -300,18 +301,19 @@ 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:
-        subprocess.call('hdiutil detach %s -quiet' % appDir,
-                        shell=True)
+        if appDir:
+            subprocess.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.