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
13de3916
Commit
13de3916
authored
Oct 11, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pyflakes compliance
parent
5f2a733a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
59 deletions
+61
-59
slapos/runner/__init__.py
slapos/runner/__init__.py
+4
-4
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+8
-7
slapos/runner/gittools.py
slapos/runner/gittools.py
+4
-2
slapos/runner/runnertest.py
slapos/runner/runnertest.py
+11
-23
slapos/runner/utils.py
slapos/runner/utils.py
+17
-14
slapos/runner/views.py
slapos/runner/views.py
+17
-9
No files found.
slapos/runner/__init__.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
from
optparse
import
OptionParser
,
Option
import
ConfigParser
import
datetime
import
logging
import
logging.handlers
from
optparse
import
OptionParser
,
Option
import
os
import
sys
import
subprocess
from
datetime
import
timedelta
class
Parser
(
OptionParser
):
"""
...
...
@@ -124,7 +124,7 @@ def serve(config):
instance_profile
=
'instance.cfg'
,
software_profile
=
'software.cfg'
,
SECRET_KEY
=
os
.
urandom
(
24
),
PERMANENT_SESSION_LIFETIME
=
timedelta
(
days
=
31
),
PERMANENT_SESSION_LIFETIME
=
datetime
.
timedelta
(
days
=
31
),
)
if
not
os
.
path
.
exists
(
workdir
):
os
.
mkdir
(
workdir
)
...
...
slapos/runner/fileBrowser.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
import
os
import
urllib
from
flask
import
jsonify
from
werkzeug
import
secure_filename
import
shutil
import
datetime
import
hashlib
from
utils
import
realpath
,
tail
,
isText
import
os
import
re
import
shutil
import
urllib
import
zipfile
import
werkzeug
from
slapos.runner.utils
import
realpath
,
tail
,
isText
class
fileBrowser
(
object
):
"""This class contain all bases function for file browser"""
...
...
@@ -164,7 +165,7 @@ class fileBrowser(object):
raise NameError('Could not load directory %s: Permission denied' % dir)
for file in files:
if files[file]:
filename = secure_filename(files[file].filename)
filename =
werkzeug.
secure_filename(files[file].filename)
if not os.path.exists(os.path.join(dir, filename)):
files[file].save(os.path.join(realdir, filename))
return '{result:
\
'
1
\
'
}'
...
...
slapos/runner/gittools.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
import
subprocess
import
os
import
re
from
flask
import
jsonify
import
shutil
import
subprocess
from
git
import
Repo
from
flask
import
jsonify
class
Popen
(
subprocess
.
Popen
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
slapos/runner/runnertest.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
import
os
import
sys
import
views
import
unittest
import
tempfile
from
optparse
import
OptionParser
,
Option
import
ConfigParser
import
shutil
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
\
gitPush
,
gitPull
from
flaskext.auth
import
Auth
,
AuthUser
,
login_required
,
logout
from
utils
import
*
import
datetime
import
json
from
datetime
import
timedelta
import
os
import
shutil
import
unittest
from
slapos.runner.utils
import
(
getProfilePath
,
getSession
,
isInstanceRunning
,
isSoftwareRunning
,
readPid
,
recursifKill
,
startProxy
)
from
slapos.runner
import
views
class
Config
:
def
setConfig
(
self
):
...
...
@@ -64,7 +61,7 @@ class SlaprunnerTestCase(unittest.TestCase):
instance_profile
=
'instance.cfg'
,
software_profile
=
'software.cfg'
,
SECRET_KEY
=
"123456"
,
PERMANENT_SESSION_LIFETIME
=
timedelta
(
days
=
31
),
PERMANENT_SESSION_LIFETIME
=
datetime
.
timedelta
(
days
=
31
),
)
self
.
app
=
views
.
app
.
test_client
()
self
.
app
.
config
=
views
.
app
.
config
...
...
@@ -106,16 +103,7 @@ class SlaprunnerTestCase(unittest.TestCase):
return
json
.
loads
(
response
.
data
)
def
configAccount
(
self
,
username
,
password
,
email
,
name
,
rcode
):
"""Helper for configAccoun"""
return
self
.
app
.
post
(
'/configAccount'
,
data
=
dict
(
username
=
username
,
password
=
password
,
email
=
email
,
name
=
name
,
rcode
=
rcode
),
follow_redirects
=
True
)
def
configAccount
(
self
,
username
,
password
,
email
,
name
,
rcode
):
"""Helper for configAccoun"""
"""Helper for configAccount"""
return
self
.
app
.
post
(
'/configAccount'
,
data
=
dict
(
username
=
username
,
password
=
password
,
...
...
slapos/runner/utils.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
import
slapos.slap
import
time
import
subprocess
import
os
from
xml_marshaller
import
xml_marshaller
from
xml.dom
import
minidom
import
hashlib
import
logging
import
multiprocessing
import
re
import
urllib
from
flask
import
jsonify
import
signal
import
shutil
import
string
import
hashlib
import
signal
import
multiprocessing
import
os
import
subprocess
import
time
import
urllib
import
xml.dom
import
xml_marshaller
from
flask
import
jsonify
import
slapos.slap
# Setup default flask (werkzeug) parser
import
logging
logger
=
logging
.
getLogger
(
'werkzeug'
)
...
...
@@ -170,7 +173,7 @@ def updateProxy(config):
'reference'
:
partition_reference
,
'tap'
:
{
'name'
:
partition_reference
},
})
computer
.
updateConfiguration
(
xml_marshaller
.
dumps
(
slap_config
))
computer
.
updateConfiguration
(
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_config
))
return
True
def
readPid
(
file
):
...
...
@@ -801,7 +804,7 @@ def readParameters(path):
a dictionnary of instance parameters."""
if os.path.exists(path):
try:
xmldoc = minidom.parse(path)
xmldoc =
xml.dom.
minidom.parse(path)
object = {}
for elt in xmldoc.childNodes:
sub_object = {}
...
...
slapos/runner/views.py
View file @
13de3916
# -*- coding: utf-8 -*-
# vim: set et sts=2:
from
flask
import
Flask
,
request
,
redirect
,
url_for
,
\
render_template
,
g
,
flash
,
jsonify
,
session
,
abort
,
send_file
from
utils
import
*
import
os
import
shutil
import
md5
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
\
gitPush
,
gitPull
from
flaskext.auth
import
Auth
,
AuthUser
,
login_required
,
logout
from
fileBrowser
import
fileBrowser
import
urllib
from
flaskext.auth
import
Auth
,
AuthUser
,
login_required
,
logout
from
flask
import
(
Flask
,
request
,
redirect
,
url_for
,
render_template
,
g
,
flash
,
jsonify
,
session
,
abort
,
send_file
)
from
slapos.runner.utils
import
(
checkSoftwareFolder
,
configNewSR
,
getFolder
,
getFolderContent
,
getProfilePath
,
getProjectList
,
getProjectTitle
,
getSession
,
getSlapStatus
,
getSvcStatus
,
getSvcTailProcess
,
isInstanceRunning
,
isSoftwareRunning
,
isText
,
killRunningProcess
,
loadSoftwareRList
,
md5sum
,
newSoftware
,
readFileFrom
,
readParameters
,
realpath
,
removeInstanceRoot
,
removeProxyDb
,
removeSoftwareByName
,
runInstanceWithLock
,
runSoftwareWithLock
,
saveSession
,
svcStartStopProcess
,
svcStopAll
,
tail
,
updateInstanceParameter
)
from
slapos.runner.fileBrowser
import
fileBrowser
from
slapos.runner.gittools
import
(
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
gitPush
,
gitPull
)
app
=
Flask
(
__name__
)
app
.
config
[
'MAX_CONTENT_LENGTH'
]
=
20
*
1024
*
1024
auth
=
Auth
(
app
,
login_url_name
=
'login'
)
...
...
@@ -430,7 +438,7 @@ def getPath():
break
else
:
list
.
append
(
path
)
realfile
=
string
.
join
(
list
,
"#"
)
realfile
=
'#'
.
join
(
list
)
if
not
realfile
:
return
jsonify
(
code
=
0
,
result
=
"Can not access to this file: Permission Denied!"
)
else
:
...
...
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