Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.toolbox
Commits
786d6380
Commit
786d6380
authored
Jul 29, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grammar nazi, string template
parent
6b2655a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
19 deletions
+14
-19
slapos/runner/utils.py
slapos/runner/utils.py
+10
-10
slapos/runner/views.py
slapos/runner/views.py
+4
-9
No files found.
slapos/runner/utils.py
View file @
786d6380
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
# vim: set et sts=2:
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
import
logging
import
logging
import
md5
import
md5
import
multiprocessing
import
multiprocessing
...
@@ -78,7 +77,7 @@ def saveSession(config, account):
...
@@ -78,7 +77,7 @@ def saveSession(config, account):
open
(
user
,
'w'
).
write
((
';'
.
join
(
account
)).
encode
(
"utf-8"
))
open
(
user
,
'w'
).
write
((
';'
.
join
(
account
)).
encode
(
"utf-8"
))
# Htpasswd file for cloud9
# Htpasswd file for cloud9
# XXX Cedric Le N order of account list values suppose to be fixed
# XXX Cedric Le N order of account list values suppose to be fixed
# Remove former file to avoid
a
outdated accounts
# Remove former file to avoid outdated accounts
if
os
.
path
.
exists
(
htpasswdfile
):
if
os
.
path
.
exists
(
htpasswdfile
):
os
.
remove
(
htpasswdfile
)
os
.
remove
(
htpasswdfile
)
passwd
=
HtpasswdFile
(
htpasswdfile
,
create
=
True
)
passwd
=
HtpasswdFile
(
htpasswdfile
,
create
=
True
)
...
@@ -218,7 +217,7 @@ def stopProxy(config):
...
@@ -218,7 +217,7 @@ def stopProxy(config):
def
removeProxyDb
(
config
):
def
removeProxyDb
(
config
):
"""Remove Slapproxy database, this is use to initialize proxy for example when
"""Remove Slapproxy database, this is use
d
to initialize proxy for example when
configuring new Software Release"""
configuring new Software Release"""
if
os
.
path
.
exists
(
config
[
'database_uri'
]):
if
os
.
path
.
exists
(
config
[
'database_uri'
]):
os
.
unlink
(
config
[
'database_uri'
])
os
.
unlink
(
config
[
'database_uri'
])
...
@@ -381,13 +380,13 @@ def getSlapStatus(config):
...
@@ -381,13 +380,13 @@ def getSlapStatus(config):
def
svcStopAll
(
config
):
def
svcStopAll
(
config
):
"""Stop all Instance process on this computer"""
"""Stop all Instance process
es
on this computer"""
return
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
return
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
'shutdown'
]).
communicate
()[
0
]
'shutdown'
]).
communicate
()[
0
]
def
removeInstanceRoot
(
config
):
def
removeInstanceRoot
(
config
):
"""Clean instance directory and stop all its running process"""
"""Clean instance directory and stop all its running process
es
"""
if
os
.
path
.
exists
(
config
[
'instance_root'
]):
if
os
.
path
.
exists
(
config
[
'instance_root'
]):
svcStopAll
(
config
)
svcStopAll
(
config
)
for
root
,
dirs
,
_
in
os
.
walk
(
config
[
'instance_root'
]):
for
root
,
dirs
,
_
in
os
.
walk
(
config
[
'instance_root'
]):
...
@@ -413,11 +412,11 @@ def getSvcStatus(config):
...
@@ -413,11 +412,11 @@ def getSvcStatus(config):
def getSvcTailProcess(config, process):
def getSvcTailProcess(config, process):
"""Get log for the specifie process
"""Get log for the specifie
d
process
Args:
Args:
config: Slaprunner configuration
config: Slaprunner configuration
process: process name. this value is pass to supervisord.
process: process name. this value is pass
ed
to supervisord.
Returns:
Returns:
a string that contains the log of the process.
a string that contains the log of the process.
"""
"""
...
@@ -453,7 +452,7 @@ def getFolderContent(config, folder):
...
@@ -453,7 +452,7 @@ def getFolderContent(config, folder):
folder: the directory to read.
folder: the directory to read.
Returns:
Returns:
Html formated string or error message when fail.
Html format
t
ed string or error message when fail.
"""
"""
r = ['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
r = ['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
try:
try:
...
@@ -492,7 +491,7 @@ def getFolder(config, folder):
...
@@ -492,7 +491,7 @@ def getFolder(config, folder):
folder: the directory to read.
folder: the directory to read.
Returns:
Returns:
Html formated string or error message when fail.
Html format
t
ed string or error message when fail.
"""
"""
r = ['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
r = ['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
try:
try:
...
@@ -687,7 +686,7 @@ def readFileFrom(f, lastPosition, limit=20000):
...
@@ -687,7 +686,7 @@ def readFileFrom(f, lastPosition, limit=20000):
"""
"""
Returns the last lines of file `f`, from position lastPosition.
Returns the last lines of file `f`, from position lastPosition.
and the last position
and the last position
limit = max number of c
aracter
to read
limit = max number of c
haracters
to read
"""
"""
BUFSIZ = 1024
BUFSIZ = 1024
f.seek(0, 2)
f.seek(0, 2)
...
@@ -738,6 +737,7 @@ def isText(file):
...
@@ -738,6 +737,7 @@ def isText(file):
def md5sum(file):
def md5sum(file):
"""Compute md5sum of `file` and return hexdigest value"""
"""Compute md5sum of `file` and return hexdigest value"""
# XXX-Marco: returning object or False boolean is an anti-pattern. better to return object or None
if os.path.isdir(file):
if os.path.isdir(file):
return False
return False
try:
try:
...
...
slapos/runner/views.py
View file @
786d6380
...
@@ -201,19 +201,14 @@ def supervisordStatus():
...
@@ -201,19 +201,14 @@ def supervisordStatus():
result
=
getSvcStatus
(
app
.
config
)
result
=
getSvcStatus
(
app
.
config
)
if
not
result
:
if
not
result
:
return
jsonify
(
code
=
0
,
result
=
""
)
return
jsonify
(
code
=
0
,
result
=
""
)
# XXX-Marco -> template
html
=
"<tr><th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th></tr>"
html
=
"<tr><th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th></tr>"
for
item
in
result
:
for
item
in
result
:
html
+=
"<tr>"
html
+=
"<tr>"
html
+=
"<td class='first'><b><a href='"
\
html
+=
"<td class='first'><b><a href='"
+
url_for
(
'tailProcess'
,
process
=
item
[
0
])
+
"'>"
+
item
[
0
]
+
"</a></b></td>"
+
url_for
(
'tailProcess'
,
process
=
item
[
0
])
+
"'>"
\
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
item
[
1
])
+
"'>"
+
item
[
1
]
+
"</a></td>"
+
item
[
0
]
+
"</a></b></td>"
html
+=
"<td align='center'><a href='"
\
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
item
[
1
])
\
+
"'>"
+
item
[
1
]
+
"</a></td>"
html
+=
"<td align='center'>"
+
item
[
3
]
+
"</td><td>"
+
item
[
5
]
+
"</td>"
html
+=
"<td align='center'>"
+
item
[
3
]
+
"</td><td>"
+
item
[
5
]
+
"</td>"
html
+=
"<td align='center'><a href='"
\
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
'RESTART'
)
+
"'>Restart</a></td>"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
'RESTART'
)
\
+
"'>Restart</a></td>"
html
+=
"</tr>"
html
+=
"</tr>"
return
jsonify
(
code
=
1
,
result
=
html
)
return
jsonify
(
code
=
1
,
result
=
html
)
...
...
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