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
Show 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 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# vim: set et sts=2:
from
optparse
import
OptionParser
,
Option
import
ConfigParser
import
ConfigParser
import
datetime
import
logging
import
logging
import
logging.handlers
import
logging.handlers
from
optparse
import
OptionParser
,
Option
import
os
import
os
import
sys
import
sys
import
subprocess
from
datetime
import
timedelta
class
Parser
(
OptionParser
):
class
Parser
(
OptionParser
):
"""
"""
...
@@ -124,7 +124,7 @@ def serve(config):
...
@@ -124,7 +124,7 @@ def serve(config):
instance_profile
=
'instance.cfg'
,
instance_profile
=
'instance.cfg'
,
software_profile
=
'software.cfg'
,
software_profile
=
'software.cfg'
,
SECRET_KEY
=
os
.
urandom
(
24
),
SECRET_KEY
=
os
.
urandom
(
24
),
PERMANENT_SESSION_LIFETIME
=
timedelta
(
days
=
31
),
PERMANENT_SESSION_LIFETIME
=
datetime
.
timedelta
(
days
=
31
),
)
)
if
not
os
.
path
.
exists
(
workdir
):
if
not
os
.
path
.
exists
(
workdir
):
os
.
mkdir
(
workdir
)
os
.
mkdir
(
workdir
)
...
...
slapos/runner/fileBrowser.py
View file @
13de3916
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# vim: set et sts=2:
import
os
import
urllib
from
flask
import
jsonify
from
werkzeug
import
secure_filename
import
shutil
import
datetime
import
datetime
import
hashlib
import
hashlib
from
utils
import
realpath
,
tail
,
isText
import
os
import
re
import
re
import
shutil
import
urllib
import
zipfile
import
zipfile
import
werkzeug
from
slapos.runner.utils
import
realpath
,
tail
,
isText
class
fileBrowser
(
object
):
class
fileBrowser
(
object
):
"""This class contain all bases function for file browser"""
"""This class contain all bases function for file browser"""
...
@@ -164,7 +165,7 @@ class fileBrowser(object):
...
@@ -164,7 +165,7 @@ class fileBrowser(object):
raise NameError('Could not load directory %s: Permission denied' % dir)
raise NameError('Could not load directory %s: Permission denied' % dir)
for file in files:
for file in files:
if files[file]:
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)):
if not os.path.exists(os.path.join(dir, filename)):
files[file].save(os.path.join(realdir, filename))
files[file].save(os.path.join(realdir, filename))
return '{result:
\
'
1
\
'
}'
return '{result:
\
'
1
\
'
}'
...
...
slapos/runner/gittools.py
View file @
13de3916
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# vim: set et sts=2:
import
subprocess
import
os
import
os
import
re
import
re
from
flask
import
jsonify
import
shutil
import
shutil
import
subprocess
from
git
import
Repo
from
git
import
Repo
from
flask
import
jsonify
class
Popen
(
subprocess
.
Popen
):
class
Popen
(
subprocess
.
Popen
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
slapos/runner/runnertest.py
View file @
13de3916
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# vim: set et sts=2:
import
os
import
sys
import
views
import
unittest
import
tempfile
from
optparse
import
OptionParser
,
Option
import
ConfigParser
import
ConfigParser
import
shutil
import
datetime
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
\
gitPush
,
gitPull
from
flaskext.auth
import
Auth
,
AuthUser
,
login_required
,
logout
from
utils
import
*
import
json
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
:
class
Config
:
def
setConfig
(
self
):
def
setConfig
(
self
):
...
@@ -64,7 +61,7 @@ class SlaprunnerTestCase(unittest.TestCase):
...
@@ -64,7 +61,7 @@ class SlaprunnerTestCase(unittest.TestCase):
instance_profile
=
'instance.cfg'
,
instance_profile
=
'instance.cfg'
,
software_profile
=
'software.cfg'
,
software_profile
=
'software.cfg'
,
SECRET_KEY
=
"123456"
,
SECRET_KEY
=
"123456"
,
PERMANENT_SESSION_LIFETIME
=
timedelta
(
days
=
31
),
PERMANENT_SESSION_LIFETIME
=
datetime
.
timedelta
(
days
=
31
),
)
)
self
.
app
=
views
.
app
.
test_client
()
self
.
app
=
views
.
app
.
test_client
()
self
.
app
.
config
=
views
.
app
.
config
self
.
app
.
config
=
views
.
app
.
config
...
@@ -106,16 +103,7 @@ class SlaprunnerTestCase(unittest.TestCase):
...
@@ -106,16 +103,7 @@ class SlaprunnerTestCase(unittest.TestCase):
return
json
.
loads
(
response
.
data
)
return
json
.
loads
(
response
.
data
)
def
configAccount
(
self
,
username
,
password
,
email
,
name
,
rcode
):
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
,
email
=
email
,
name
=
name
,
rcode
=
rcode
),
follow_redirects
=
True
)
def
configAccount
(
self
,
username
,
password
,
email
,
name
,
rcode
):
"""Helper for configAccoun"""
return
self
.
app
.
post
(
'/configAccount'
,
data
=
dict
(
return
self
.
app
.
post
(
'/configAccount'
,
data
=
dict
(
username
=
username
,
username
=
username
,
password
=
password
,
password
=
password
,
...
...
slapos/runner/utils.py
View file @
13de3916
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# vim: set et sts=2:
import
slapos.slap
import
hashlib
import
time
import
logging
import
subprocess
import
multiprocessing
import
os
from
xml_marshaller
import
xml_marshaller
from
xml.dom
import
minidom
import
re
import
re
import
urllib
import
signal
from
flask
import
jsonify
import
shutil
import
shutil
import
string
import
string
import
hashlib
import
os
import
signal
import
subprocess
import
multiprocessing
import
time
import
urllib
import
xml.dom
import
xml_marshaller
from
flask
import
jsonify
import
slapos.slap
# Setup default flask (werkzeug) parser
# Setup default flask (werkzeug) parser
import
logging
logger
=
logging
.
getLogger
(
'werkzeug'
)
logger
=
logging
.
getLogger
(
'werkzeug'
)
...
@@ -170,7 +173,7 @@ def updateProxy(config):
...
@@ -170,7 +173,7 @@ def updateProxy(config):
'reference'
:
partition_reference
,
'reference'
:
partition_reference
,
'tap'
:
{
'name'
:
partition_reference
},
'tap'
:
{
'name'
:
partition_reference
},
})
})
computer
.
updateConfiguration
(
xml_marshaller
.
dumps
(
slap_config
))
computer
.
updateConfiguration
(
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_config
))
return
True
return
True
def
readPid
(
file
):
def
readPid
(
file
):
...
@@ -801,7 +804,7 @@ def readParameters(path):
...
@@ -801,7 +804,7 @@ def readParameters(path):
a dictionnary of instance parameters."""
a dictionnary of instance parameters."""
if os.path.exists(path):
if os.path.exists(path):
try:
try:
xmldoc = minidom.parse(path)
xmldoc =
xml.dom.
minidom.parse(path)
object = {}
object = {}
for elt in xmldoc.childNodes:
for elt in xmldoc.childNodes:
sub_object = {}
sub_object = {}
...
...
slapos/runner/views.py
View file @
13de3916
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# 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
os
import
shutil
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
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
=
Flask
(
__name__
)
app
.
config
[
'MAX_CONTENT_LENGTH'
]
=
20
*
1024
*
1024
app
.
config
[
'MAX_CONTENT_LENGTH'
]
=
20
*
1024
*
1024
auth
=
Auth
(
app
,
login_url_name
=
'login'
)
auth
=
Auth
(
app
,
login_url_name
=
'login'
)
...
@@ -430,7 +438,7 @@ def getPath():
...
@@ -430,7 +438,7 @@ def getPath():
break
break
else
:
else
:
list
.
append
(
path
)
list
.
append
(
path
)
realfile
=
string
.
join
(
list
,
"#"
)
realfile
=
'#'
.
join
(
list
)
if
not
realfile
:
if
not
realfile
:
return
jsonify
(
code
=
0
,
result
=
"Can not access to this file: Permission Denied!"
)
return
jsonify
(
code
=
0
,
result
=
"Can not access to this file: Permission Denied!"
)
else
:
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