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
Justin
slapos.toolbox
Commits
3e8bc280
Commit
3e8bc280
authored
Jan 30, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tail -f n implementation for 'runSoftware' logs
parent
ed69c295
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
slapos/runner/templates/viewLog.html
slapos/runner/templates/viewLog.html
+1
-1
slapos/runner/utils.py
slapos/runner/utils.py
+38
-6
slapos/runner/views.py
slapos/runner/views.py
+2
-2
No files found.
slapos/runner/templates/viewLog.html
View file @
3e8bc280
{% extends "layout.html" %}
{% block title %}View {{ type }} log{% endblock %}
{% block body %}
Currently running:
<span
class=
"message"
>
{{ running }}
</span><br>
<strong>
Note:
</strong>
You can refresh this page from time to time to have updates.
<br>
<h2>
Currently running:
<span
class=
"message"
>
{{ running }}
</span></h2><br>
<h2>
Result for {{ type }}
</h2>
<div
class=
"log_content"
><textarea
class=
"log"
readonly
>
{{ result }}
</textarea></div>
{% endblock %}
slapos/runner/utils.py
View file @
3e8bc280
...
...
@@ -219,6 +219,10 @@ def runBuildoutAnnotate(config):
return
False
def
svcStopAll
(
config
):
#stop all process running in supervisord
request
=
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
'stop'
,
'all'
])
request
.
wait
()
return
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
'shutdown'
]).
communicate
()[
0
]
...
...
@@ -257,7 +261,8 @@ def getFolderContent(folder):
try:
r=['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d=urllib.unquote(folder)
for f in os.listdir(d):
ldir = sorted(os.listdir(d), key=unicode.lower)
for f in ldir:
if f.startswith('
.
'): #do not displays this file/folder
continue
ff=os.path.join(d,f)
...
...
@@ -275,9 +280,10 @@ def getFolderContent(folder):
def getFolder(folder):
r=['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
try:
r=['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
r=['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d=urllib.unquote(folder)
for f in os.listdir(d):
ldir = sorted(os.listdir(d), key=unicode.lower)
for f in ldir:
if f.startswith('
.
'): #do not display this file/folder
continue
ff=os.path.join(d,f)
...
...
@@ -341,8 +347,7 @@ def checkSoftwareFolder(path, config):
tmp = path.split('
/
')
del tmp[len(tmp) - 1]
path = string.join(tmp, '
/
')
if os.path.exists(os.path.join(path, config['
software_profile
'])) and
\
os.path.exists(os.path.join(path, config['
instance_profile
'])):
if os.path.exists(os.path.join(path, config['
software_profile
'])):
return jsonify(result=path)
return jsonify(result="")
...
...
@@ -390,4 +395,31 @@ def removeSoftwareByName(config, folderName):
writeSoftwareData(config['
runner_workdir
'], data)
break
i = i+1
return jsonify(code=1, result=data)
\ No newline at end of file
return jsonify(code=1, result=data)
def tail(f, lines=20):
"""
Returns the last `lines` lines of file `f`. It is an implementation of tail -f n.
"""
BUFSIZ = 1024
f.seek(0, 2)
bytes = f.tell()
size = lines + 1
block = -1
data = []
while size > 0 and bytes > 0:
if bytes - BUFSIZ > 0:
# Seek back one whole BUFSIZ
f.seek(block * BUFSIZ, 2)
# read BUFFER
data.insert(0, f.read(BUFSIZ))
else:
# file too small, start from begining
f.seek(0,0)
# only read what was not read
data.insert(0, f.read(bytes))
linesFound = data[0].count('
\
n
')
size -= linesFound
bytes -= BUFSIZ
block -= 1
return string.join(''.join(data).splitlines()[-lines:], '
\
n
')
\ No newline at end of file
slapos/runner/views.py
View file @
3e8bc280
...
...
@@ -69,7 +69,7 @@ def runSoftwareProfile():
@
app
.
route
(
'/viewSoftwareLog'
,
methods
=
[
'GET'
])
def
viewSoftwareLog
():
if
os
.
path
.
exists
(
app
.
config
[
'software_log'
]):
result
=
open
(
app
.
config
[
'software_log'
],
'r'
).
read
(
)
result
=
tail
(
open
(
app
.
config
[
'software_log'
],
'r'
),
lines
=
1500
)
else
:
result
=
'Not found yet'
return
render_template
(
'viewLog.html'
,
type
=
'Software'
,
...
...
@@ -87,7 +87,7 @@ def updateSoftwareProfile():
def
editInstanceProfile
():
profile
=
getProfile
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'instance_profile'
])
if
profile
==
""
:
flash
(
'Error: can not open
profile, please select your project first
'
)
flash
(
'Error: can not open
instance profile for this Software Release
'
)
return
render_template
(
'updateInstanceProfile.html'
,
profile
=
profile
)
...
...
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