Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
slapos
Commits
089f7638
Commit
089f7638
authored
Nov 17, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup.
parent
11f3290c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
32 deletions
+37
-32
slapos/recipe/generic_mysql/mysql.py
slapos/recipe/generic_mysql/mysql.py
+37
-32
No files found.
slapos/recipe/generic_mysql/mysql.py
View file @
089f7638
...
@@ -66,21 +66,24 @@ def updateMysql(args):
...
@@ -66,21 +66,24 @@ def updateMysql(args):
assert
'mysql_script'
not
in
conf
assert
'mysql_script'
not
in
conf
with
open
(
script_filename
)
as
script_file
:
with
open
(
script_filename
)
as
script_file
:
conf
[
'mysql_script'
]
=
script_file
.
read
()
conf
[
'mysql_script'
]
=
script_file
.
read
()
is_succeeded
=
False
while
True
:
while
True
:
while
True
:
mysql_upgrade_list
=
[
conf
[
'mysql_upgrade_binary'
],
'--user=root'
]
mysql_upgrade_list
=
[
conf
[
'mysql_upgrade_binary'
],
'--user=root'
]
if
'socket'
in
conf
:
if
'socket'
in
conf
:
mysql_upgrade_list
.
append
(
'--socket='
+
conf
[
'socket'
])
mysql_upgrade_list
.
append
(
'--socket='
+
conf
[
'socket'
])
mysql_upgrade
=
subprocess
.
Popen
(
mysql_upgrade_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
mysql_upgrade
=
subprocess
.
Popen
(
mysql_upgrade_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql_upgrade
.
communicate
()[
0
]
result
=
mysql_upgrade
.
communicate
()[
0
]
import
pdb
;
pdb
.
set_trace
()
if
mysql_upgrade
.
returncode
is
None
:
if
mysql_upgrade
.
returncode
is
None
:
mysql_upgrade
.
kill
()
mysql_upgrade
.
kill
()
if
mysql_upgrade
.
returncode
!=
0
and
not
'is already upgraded'
in
result
:
print
"Command %r failed with result:
\
n
%s"
%
(
mysql_upgrade_list
,
result
)
else
:
if
mysql_upgrade
.
returncode
==
0
:
if
mysql_upgrade
.
returncode
==
0
:
print
"MySQL database upgraded with result:
\
n
%s"
%
result
print
"MySQL database upgraded with result:
\
n
%s"
%
result
el
se
:
el
if
'is already upgraded'
in
result
:
print
"No need to upgrade MySQL database"
print
"No need to upgrade MySQL database"
else
:
print
"Command %r failed with result:
\
n
%s"
%
(
mysql_upgrade_list
,
result
)
break
mysql_list
=
[
conf
[
'mysql_binary'
].
strip
(),
'-B'
,
'--user=root'
]
mysql_list
=
[
conf
[
'mysql_binary'
].
strip
(),
'-B'
,
'--user=root'
]
if
'socket'
in
conf
:
if
'socket'
in
conf
:
mysql_list
.
append
(
'--socket='
+
conf
[
'socket'
])
mysql_list
.
append
(
'--socket='
+
conf
[
'socket'
])
...
@@ -91,7 +94,7 @@ def updateMysql(args):
...
@@ -91,7 +94,7 @@ def updateMysql(args):
mysql
.
kill
()
mysql
.
kill
()
if
mysql
.
returncode
!=
0
:
if
mysql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
else
:
break
# import timezone database
# import timezone database
mysql_tzinfo_to_sql_binary
=
os
.
path
.
join
(
mysql_tzinfo_to_sql_binary
=
os
.
path
.
join
(
os
.
path
.
dirname
(
conf
[
'mysql_binary'
].
strip
()),
'mysql_tzinfo_to_sql'
)
os
.
path
.
dirname
(
conf
[
'mysql_binary'
].
strip
()),
'mysql_tzinfo_to_sql'
)
...
@@ -100,9 +103,9 @@ def updateMysql(args):
...
@@ -100,9 +103,9 @@ def updateMysql(args):
mysql_tzinfo_to_sql
=
subprocess
.
Popen
(
mysql_tzinfo_to_sql_list
,
stdin
=
subprocess
.
PIPE
,
mysql_tzinfo_to_sql
=
subprocess
.
Popen
(
mysql_tzinfo_to_sql_list
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
timezone_sql
=
mysql_tzinfo_to_sql
.
communicate
()[
0
]
timezone_sql
=
mysql_tzinfo_to_sql
.
communicate
()[
0
]
if
my
sql
.
returncode
!=
0
:
if
mysql_tzinfo_to_
sql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_tzinfo_to_sql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_tzinfo_to_sql_list
,
result
)
else
:
break
mysql
=
subprocess
.
Popen
(
mysql_list
+
[
'mysql'
,],
stdin
=
subprocess
.
PIPE
,
mysql
=
subprocess
.
Popen
(
mysql_list
+
[
'mysql'
,],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql
.
communicate
(
timezone_sql
)[
0
]
result
=
mysql
.
communicate
(
timezone_sql
)[
0
]
...
@@ -110,8 +113,10 @@ def updateMysql(args):
...
@@ -110,8 +113,10 @@ def updateMysql(args):
mysql
.
kill
()
mysql
.
kill
()
if
mysql
.
returncode
!=
0
:
if
mysql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
is_succeed
=
True
break
if
is_succeed
:
is_succeeded
=
True
break
if
is_succeeded
:
print
'SlapOS initialisation script succesfully applied on database.'
print
'SlapOS initialisation script succesfully applied on database.'
break
break
print
'Sleeping for %ss and retrying'
%
sleep
print
'Sleeping for %ss and retrying'
%
sleep
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment