From 01d957c3e45d7e140e5addfde54062513c7fd0d6 Mon Sep 17 00:00:00 2001 From: Christian Goetze Date: Tue, 1 Sep 2009 00:55:00 +0000 Subject: Add retry logic on certain exit codes --- indra/develop.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'indra/develop.py') 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) -- cgit v1.2.3 From cbad737f59572c9616920fbfb0a54877ade03f8a Mon Sep 17 00:00:00 2001 From: Christian Goetze Date: Tue, 1 Sep 2009 01:46:05 +0000 Subject: Fix syntax error introduced by your's truely into develop.py --- indra/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/develop.py') diff --git a/indra/develop.py b/indra/develop.py index 4daa85ba3b..b2b494d1b3 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -593,7 +593,7 @@ class WindowsSetup(PlatformSetup): 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)) + print "Retrying... the command %r %s" % (name, error) else: raise CommandError('the command %r %s' % (name, error)) -- cgit v1.2.3