Commit 24c9d96c authored by Rafael Monnerat's avatar Rafael Monnerat

If update suceeded once, it is not required to repeat the command anymore.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44086 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ed75e1a1
...@@ -31,15 +31,18 @@ def updateMysql(args): ...@@ -31,15 +31,18 @@ def updateMysql(args):
mysql_command_list = args[0] mysql_command_list = args[0]
mysql_script = args[1] mysql_script = args[1]
sleep = 30 sleep = 30
is_succeed = False
while True: while True:
mysql = subprocess.Popen(mysql_command_list, stdin=subprocess.PIPE, if not is_succeed:
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) mysql = subprocess.Popen(mysql_command_list, stdin=subprocess.PIPE,
result = mysql.communicate(mysql_script)[0] stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if mysql.returncode is None: result = mysql.communicate(mysql_script)[0]
mysql.kill() if mysql.returncode is None:
if mysql.returncode != 0: mysql.kill()
print 'Script failed with: %s' % result if mysql.returncode != 0:
print 'Sleeping for %ss and retrying' % sleep print 'Script failed with: %s' % result
else: print 'Sleeping for %ss and retrying' % sleep
print 'Script succesfully run on database, exiting' else:
is_succeed = True
print 'Script succesfully run on database, exiting'
time.sleep(sleep) time.sleep(sleep)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment