Commit b7c111de authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

set up timezone database in mariab's mysql table so that we can use timezone conversion function.

parent a4f70eb6
......@@ -36,6 +36,7 @@ setup(name=name,
'xml_marshaller', # need to communication with slapgrid
'zc.buildout', # plays with buildout
'zc.recipe.egg', # for scripts generation
'pytz', # for timezone database
],
zip_safe=True,
entry_points={
......
......@@ -2,6 +2,7 @@ import os
import subprocess
import time
import sys
import pytz
def runMysql(args):
......@@ -65,6 +66,26 @@ def updateMysql(args):
print 'Command %r failed with:\n%s' % (mysql_list, result)
print 'Sleeping for %ss and retrying' % sleep
else:
# import timezone database
mysql_tzinfo_to_sql_binary = os.path.join(
os.path.dirname(conf['mysql_binary'].strip()), 'mysql_tzinfo_to_sql')
zoneinfo_directory = '%s/zoneinfo' % os.path.dirname(pytz.__file__)
mysql_tzinfo_to_sql_list = [mysql_tzinfo_to_sql_binary, zoneinfo_directory]
mysql_tzinfo_to_sql = subprocess.Popen(mysql_tzinfo_to_sql_list, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
timezone_sql = mysql_tzinfo_to_sql.communicate()[0]
if mysql.returncode != 0:
print 'Command %r failed with:\n%s' % (mysql_tzinfo_to_sql_list, result)
print 'Sleeping for %ss and retrying' % sleep
else:
mysql = subprocess.Popen(mysql_list + ['mysql',], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = mysql.communicate(timezone_sql)[0]
if mysql.returncode is None:
mysql.kill()
if mysql.returncode != 0:
print 'Command %r failed with:\n%s' % (mysql_list, result)
print 'Sleeping for %ss and retrying' % sleep
is_succeed = True
print 'SlapOS initialisation script succesfully applied on database.'
sys.stdout.flush()
......
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