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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.toolbox
Commits
a3c09a4b
Commit
a3c09a4b
authored
Jul 27, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: grammar nazi
parent
ab224625
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
29 deletions
+28
-29
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+10
-10
slapos/runner/gittools.py
slapos/runner/gittools.py
+5
-5
slapos/runner/process.py
slapos/runner/process.py
+4
-4
slapos/runner/runnertest.py
slapos/runner/runnertest.py
+5
-5
slapos/runner/utils.py
slapos/runner/utils.py
+3
-3
slapos/runner/views.py
slapos/runner/views.py
+1
-2
No files found.
slapos/runner/fileBrowser.py
View file @
a3c09a4b
...
...
@@ -15,7 +15,7 @@ from slapos.runner.utils import realpath, tail, isText
class
FileBrowser
(
object
):
"""This class contain all base functions for file browser"""
"""This class contain
s
all base functions for file browser"""
def
__init__
(
self
,
config
):
self
.
config
=
config
...
...
@@ -115,7 +115,7 @@ class FileBrowser(object):
details = realfile.split('/')
dest = os.path.join(realdir, details[-1])
if os.path.exists(dest):
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist
s
')
if os.path.isdir(realfile):
shutil.copytree(realfile, dest)
if del_source:
...
...
@@ -138,7 +138,7 @@ class FileBrowser(object):
if not os.path.exists(tofile):
os.rename(realfile, tofile)
return "
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist
s
')
def copyAsFile(self, dir, filename, newfilename):
"""Copy file or directory to dir/filename"""
...
...
@@ -146,14 +146,14 @@ class FileBrowser(object):
fromfile = os.path.join(realdir, filename)
tofile = os.path.join(realdir, newfilename)
if not os.path.exists(fromfile):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory
does
not exist')
if not os.path.exists(tofile):
shutil.copy(fromfile, tofile)
return "
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist
s
')
def uploadFile(self, dir, files):
"""Upload a list of file in directory dir"""
"""Upload a list of file
s
in directory dir"""
realdir = self._realdir(dir)
for file in files:
if files[file]:
...
...
@@ -177,7 +177,7 @@ class FileBrowser(object):
tozip = os.path.join(realdir, newfilename)
fromzip = os.path.join(realdir, filename)
if not os.path.exists(fromzip):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory
does
not exist')
if not os.path.exists(tozip):
zip = zipfile.ZipFile(tozip, 'w', zipfile.ZIP_DEFLATED)
if os.path.isdir(fromzip):
...
...
@@ -190,7 +190,7 @@ class FileBrowser(object):
zip.write(fromzip)
zip.close()
return "
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist
s
')
def unzipFile(self, dir, filename, newfilename):
"""Extract a zipped archive"""
...
...
@@ -198,7 +198,7 @@ class FileBrowser(object):
target = os.path.join(realdir, newfilename)
archive = os.path.join(realdir, filename)
if not os.path.exists(archive):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory
does
not exist')
if not os.path.exists(target):
zip = zipfile.ZipFile(archive)
#member = zip.namelist()
...
...
@@ -208,7 +208,7 @@ class FileBrowser(object):
#else:
# zip.extract(member[0], newfilename)
return "
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist
s
')
def readFile(self, dir, filename, truncate=False):
"""Read file dir/filename and return content"""
...
...
slapos/runner/gittools.py
View file @
a3c09a4b
...
...
@@ -12,19 +12,19 @@ from flask import jsonify
def
cloneRepo
(
data
):
"""Clon
n
e a repository
"""Clone a repository
Args:
data: a dictionary of parameters to use:
data['path'] is the path of the new project
data['repo'] is the url of the repository to be cloned
data['email'] is the user email
data['email'] is the user
's
email
data['user'] is the name of the user
Returns:
a jsonify data"""
workDir
=
data
[
'path'
]
if
not
workDir
:
return
jsonify
(
code
=
0
,
result
=
"Can
not create project folder: Permission Denied"
)
result
=
"Cannot create project folder: Permission Denied"
)
code
=
0
json
=
""
try
:
...
...
@@ -46,7 +46,7 @@ def cloneRepo(data):
def
gitStatus
(
project
):
"""Run git status and return status of specified project folder
Args:
project: path of the projet t
i
get status
project: path of the projet t
o
get status
Returns:
a parsed string that contains the result of git status"""
code
=
0
...
...
@@ -146,7 +146,7 @@ def gitPush(project, msg):
git
.
push
(
'origin'
,
current_branch
)
code
=
1
else
:
json
=
"Nothing to
be commited
"
json
=
"Nothing to
commit
"
code
=
1
except
Exception
as
e
:
if
undo_commit
:
...
...
slapos/runner/process.py
View file @
a3c09a4b
...
...
@@ -9,7 +9,7 @@ SLAPRUNNER_PROCESS_LIST = []
class
Popen
(
subprocess
.
Popen
):
"""
Extension of Popen to launch and kill process in a clean way
Extension of Popen to launch and kill process
es
in a clean way
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
...
...
@@ -28,7 +28,7 @@ class Popen(subprocess.Popen):
def
kill
(
self
,
sig
=
signal
.
SIGTERM
,
recursive
=
False
):
"""
Kill process and all its descendant if recursive
Kill process and all its descendant
s
if recursive
"""
if
self
.
poll
()
is
None
:
if
recursive
:
...
...
@@ -83,7 +83,7 @@ def isRunning(name):
def
killRunningProcess
(
name
,
recursive
=
False
):
"""
Kill all process
with
name
Kill all process
es with a given
name
"""
for
process
in
SLAPRUNNER_PROCESS_LIST
:
if
process
.
name
==
name
:
...
...
@@ -92,7 +92,7 @@ def killRunningProcess(name, recursive=False):
def
handler
(
sig
,
frame
):
"""
Signal handler to kill all process
Signal handler to kill all process
es
"""
pid
=
os
.
getpid
()
os
.
kill
(
-
pid
,
sig
)
...
...
slapos/runner/runnertest.py
View file @
a3c09a4b
...
...
@@ -5,12 +5,12 @@
import
argparse
import
ConfigParser
import
datetime
import
hashlib
import
json
import
os
import
shutil
import
time
import
unittest
import
hashlib
from
slapos.runner.utils
import
(
getProfilePath
,
getSession
,
isInstanceRunning
,
isSoftwareRunning
,
startProxy
)
...
...
@@ -174,7 +174,7 @@ class SlaprunnerTestCase(unittest.TestCase):
self
.
assertEqual
(
proxy
,
status
)
def
setupProjectFolder
(
self
,
withSoftware
=
False
):
"""Helper
for
create a project folder as for slapos.git"""
"""Helper
to
create a project folder as for slapos.git"""
base
=
os
.
path
.
join
(
self
.
app
.
config
[
'workspace'
],
'slapos'
)
software
=
os
.
path
.
join
(
base
,
'software'
)
os
.
mkdir
(
base
)
...
...
@@ -193,7 +193,7 @@ class SlaprunnerTestCase(unittest.TestCase):
'w'
).
write
(
sr
)
def
setupSoftwareFolder
(
self
):
"""Helper
for
setup compiled software release dir"""
"""Helper
to
setup compiled software release dir"""
self
.
setupProjectFolder
(
withSoftware
=
True
)
md5
=
hashlib
.
md5
(
os
.
path
.
join
(
self
.
app
.
config
[
'workspace'
],
"slapos/software/slaprunner-test"
,
...
...
@@ -218,7 +218,7 @@ class SlaprunnerTestCase(unittest.TestCase):
#Begin test case here
def
test_wrong_login
(
self
):
"""Test Login user before create session. This should return error value"""
"""Test Login user before create session. This should return
an
error value"""
response
=
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
])
#redirect to config account page
assert
"<h2 class='title'>Your personal information</h2><br/>"
in
response
.
data
...
...
@@ -249,7 +249,7 @@ class SlaprunnerTestCase(unittest.TestCase):
assert
"<h2>Login to Slapos Web Runner</h2>"
in
result
.
data
def
test_updateAccount
(
self
):
"""test Update accound, this need
user to login
g in"""
"""test Update accound, this need
s the user to lo
g in"""
self
.
setAccount
()
response
=
loadJson
(
self
.
updateAccount
(
self
.
updateUser
,
self
.
rcode
))
self
.
assertEqual
(
response
[
'code'
],
1
)
...
...
slapos/runner/utils.py
View file @
a3c09a4b
...
...
@@ -3,12 +3,10 @@
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
import
md5
import
logging
import
md5
import
multiprocessing
import
re
from
slapos.runner.process
import
Popen
,
isRunning
,
killRunningProcess
from
slapos.htpasswd
import
HtpasswdFile
import
shutil
import
os
import
time
...
...
@@ -18,6 +16,8 @@ from xml.dom import minidom
import
xml_marshaller
from
flask
import
jsonify
from
slapos.runner.process
import
Popen
,
isRunning
,
killRunningProcess
from
slapos.htpasswd
import
HtpasswdFile
import
slapos.slap
# Setup default flask (werkzeug) parser
...
...
slapos/runner/views.py
View file @
a3c09a4b
...
...
@@ -490,8 +490,7 @@ def slapgridResult():
'position'
:
0
,
'truncated'
:
False
}
if
request
.
form
[
'log'
]
==
"software"
or
\
request
.
form
[
'log'
]
==
"instance"
:
if
request
.
form
[
'log'
]
in
[
'software'
,
'instance'
]:
log_file
=
request
.
form
[
'log'
]
+
"_log"
if
os
.
path
.
exists
(
app
.
config
[
log_file
]):
log_result
=
readFileFrom
(
open
(
app
.
config
[
log_file
]),
...
...
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