Skip to content

Commit

Permalink
Retry hdiutil create if it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
def- authored and Robyt3 committed Sep 30, 2021
1 parent f35da54 commit fdaf31a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/dmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shlex
import subprocess
import tempfile
import time

ConfigDmgtools = namedtuple('Config', 'dmg hfsplus newfs_hfs verbose')
ConfigHdiutil = namedtuple('Config', 'hdiutil verbose')
Expand Down Expand Up @@ -71,9 +72,18 @@ def _hdiutil(self, *args):
def create(self, dmg, volume_name, directory, symlinks):
if symlinks:
raise NotImplementedError("symlinks are not yet implemented")
if os.path.exists(volume_name + '.dmg'):
os.remove(volume_name + '.dmg')
self._hdiutil('create', '-volname', volume_name, '-srcdir', directory, dmg)
for i in range(5):
if os.path.exists(volume_name + '.dmg'):
os.remove(volume_name + '.dmg')
try:
self._hdiutil('create', '-volname', volume_name, '-srcdir', directory, dmg)
except subprocess.CalledProcessError as e:
if i == 4:
raise e
print("Retrying hdiutil create")
time.sleep(5)
else:
break

def main():
import argparse
Expand Down

0 comments on commit fdaf31a

Please sign in to comment.