diff options
author | Christian Goetze <cg@lindenlab.com> | 2009-09-01 00:55:00 +0000 |
---|---|---|
committer | Christian Goetze <cg@lindenlab.com> | 2009-09-01 00:55:00 +0000 |
commit | 01d957c3e45d7e140e5addfde54062513c7fd0d6 (patch) | |
tree | e46ad96ecec104d4429d3610c408ee6eee42f0d6 /indra | |
parent | e20ac4718ee53e18cb5c301ce5b79a44d1930a8e (diff) |
Add retry logic on certain exit codes
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/develop.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/indra/develop.py b/indra/develop.py index 249b6519fc..4daa85ba3b 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -579,19 +579,23 @@ class WindowsSetup(PlatformSetup): return ('"%sdevenv.com" %s.sln /build %s' % (self.find_visual_studio(), self.project_name, self.build_type)) - def run(self, command, name=None): + def run(self, command, name=None, retry_on=None, retries=1): '''Run a program. If the program fails, raise an exception.''' - ret = os.system(command) - if ret: - if name is None: - name = command.split(None, 1)[0] - path = self.find_in_path(name) - if not path: - ret = 'was not found' - else: - ret = 'exited with status %d' % ret - raise CommandError('the command %r %s' % - (name, ret)) + while retries: + retries = retries - 1 + ret = os.system(command) + if ret: + if name is None: + name = command.split(None, 1)[0] + path = self.find_in_path(name) + if not path: + error = 'was not found' + else: + error = 'exited with status %d' % ret + if retry_on is not None and retry_on == ret: + print "Retrying... the command %r %s" % (name, error)) + else: + raise CommandError('the command %r %s' % (name, error)) def run_cmake(self, args=[]): '''Override to add the vstool.exe call after running cmake.''' @@ -629,11 +633,11 @@ class WindowsSetup(PlatformSetup): for t in targets: cmd = '%s /project %s %s' % (build_cmd, t, ' '.join(opts)) print 'Running %r in %r' % (cmd, d) - self.run(cmd) + self.run(cmd, retry_on=4, retries=3) else: cmd = '%s %s' % (build_cmd, ' '.join(opts)) print 'Running %r in %r' % (cmd, d) - self.run(cmd) + self.run(cmd, retry_on=4, retries=3) finally: os.chdir(cwd) |