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
6
Merge Requests
6
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
nexedi
slapos.toolbox
Commits
decbd4b3
Commit
decbd4b3
authored
Jun 29, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding comments
parent
5d472df2
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
205 additions
and
4 deletions
+205
-4
slapos/runner/gittools.py
slapos/runner/gittools.py
+33
-0
slapos/runner/utils.py
slapos/runner/utils.py
+161
-4
slapos/runner/views.py
slapos/runner/views.py
+11
-0
No files found.
slapos/runner/gittools.py
View file @
decbd4b3
...
...
@@ -23,6 +23,15 @@ class Popen(subprocess.Popen):
self
.
stdin
=
None
def
cloneRepo
(
data
):
"""Clonne a repository
Args:
data: a dictionnary 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['user'] is the name of the user
Returns:
a jsonify data"""
workDir
=
data
[
'path'
]
if
not
workDir
:
return
jsonify
(
code
=
0
,
...
...
@@ -47,6 +56,11 @@ def cloneRepo(data):
return
jsonify
(
code
=
code
,
result
=
json
)
def
gitStatus
(
project
):
"""Run git status and return status of specified project folder
Args:
project: path of the projet ti get status
Returns:
a parsed string that contains the result of git status"""
code
=
0
json
=
""
try
:
...
...
@@ -61,6 +75,12 @@ def gitStatus(project):
return
jsonify
(
code
=
code
,
result
=
json
,
branch
=
branch
,
dirty
=
isdirty
)
def
switchBranch
(
project
,
name
):
"""Switch a git branch
Args:
project: directory of the local git repository
name: switch from current branch to `name` branch
Returns:
a jsonify data"""
code
=
0
json
=
""
try
:
...
...
@@ -78,6 +98,13 @@ def switchBranch(project, name):
return
jsonify
(
code
=
code
,
result
=
json
)
def
addBranch
(
project
,
name
,
onlyCheckout
=
False
):
"""Add new git branch to the repository
Args:
project: directory of the local git repository
name: name of the new branch
onlyCheckout: if True then the branch `name` is created before checkout
Returns:
a jsonify data"""
code
=
0
json
=
""
try
:
...
...
@@ -93,6 +120,7 @@ def addBranch(project, name, onlyCheckout=False):
return
jsonify
(
code
=
code
,
result
=
json
)
def
getDiff
(
project
):
"""Get git diff for the specified project directory"""
result
=
""
try
:
repo
=
Repo
(
project
)
...
...
@@ -104,6 +132,10 @@ def getDiff(project):
return
result
def
gitPush
(
project
,
msg
):
"""Commit and Push changes for the specified repository
Args:
project: directory of the local repository
msg: commit message"""
code
=
0
json
=
""
undo_commit
=
False
...
...
@@ -145,5 +177,6 @@ def gitPull(project):
return
jsonify
(
code
=
code
,
result
=
result
)
def
safeResult
(
result
):
"""Parse string and remove credential of the user"""
regex
=
re
.
compile
(
"(https:
\
/
\
/)([
\
w
\
d
\
._-]+:[
\
w
\
d
\
._-]+)
\
@([
\
S]+
\
s)
"
, re.VERBOSE)
return regex.sub(r'
\
1
\
3
', result)
\ No newline at end of file
slapos/runner/utils.py
View file @
decbd4b3
This diff is collapsed.
Click to expand it.
slapos/runner/views.py
View file @
decbd4b3
...
...
@@ -77,6 +77,7 @@ def inspectSoftware():
return
render_template
(
'runResult.html'
,
softwareRoot
=
'software_root'
,
softwares
=
loadSoftwareData
(
app
.
config
[
'runner_workdir'
]))
#remove content of compiled software release
@
app
.
route
(
'/removeSoftware'
)
def
removeSoftware
():
file_config
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".softdata"
)
...
...
@@ -114,6 +115,7 @@ def editInstanceProfile():
return
render_template
(
'updateInstanceProfile.html'
,
workDir
=
'workspace'
,
profile
=
profile
,
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]))
# get status of all computer partitions and process state
@
app
.
route
(
'/inspectInstance'
,
methods
=
[
'GET'
])
def
inspectInstance
():
file_content
=
''
...
...
@@ -127,6 +129,7 @@ def inspectInstance():
file_path
=
file_content
,
supervisor
=
result
,
slap_status
=
getSlapStatus
(
app
.
config
),
supervisore
=
result
,
partition_amount
=
app
.
config
[
'partition_amount'
])
#Reload instance process ans returns new value to ajax
@
app
.
route
(
'/supervisordStatus'
,
methods
=
[
'GET'
])
def
supervisordStatus
():
result
=
getSvcStatus
(
app
.
config
)
...
...
@@ -253,6 +256,7 @@ def getProjectStatus():
else
:
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
#view for current software release files
@
app
.
route
(
"/editCurrentProject"
)
def
editCurrentProject
():
project
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
)
...
...
@@ -262,6 +266,7 @@ def editCurrentProject():
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]))
return
redirect
(
url_for
(
'configRepo'
))
#create file or directory
@
app
.
route
(
"/createFile"
,
methods
=
[
'POST'
])
def
createFile
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
],
False
)
...
...
@@ -277,6 +282,7 @@ def createFile():
except
Exception
,
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
#remove file or directory
@
app
.
route
(
"/removeFile"
,
methods
=
[
'POST'
])
def
removeFile
():
try
:
...
...
@@ -296,6 +302,7 @@ def removeSoftwareDir():
except
Exception
,
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
#read file and return content to ajax
@
app
.
route
(
"/getFileContent"
,
methods
=
[
'POST'
])
def
getFileContent
():
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
...
...
@@ -379,6 +386,7 @@ def getmd5sum():
else
:
return
jsonify
(
code
=
0
,
result
=
"Can not get md5sum for this file!"
)
#return informations about state of slapgrid process
@
app
.
route
(
"/slapgridResult"
,
methods
=
[
'POST'
])
def
slapgridResult
():
software_state
=
isSoftwareRunning
(
app
.
config
)
...
...
@@ -415,6 +423,7 @@ def getPath():
else
:
return
jsonify
(
code
=
1
,
result
=
realfile
)
#update instance parameter into a local xml file
@
app
.
route
(
"/saveParameterXml"
,
methods
=
[
'POST'
])
def
saveParameterXml
():
project
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
)
...
...
@@ -441,6 +450,7 @@ def saveParameterXml():
return
jsonify
(
code
=
0
,
result
=
"An error occurred while applying your settings!<br/>"
+
str
(
e
))
return
jsonify
(
code
=
1
,
result
=
""
)
#read instance parameters into the local xml file and return a dict
@
app
.
route
(
"/getParameterXml/<request>"
,
methods
=
[
'GET'
])
def
getParameterXml
(
request
):
param_path
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".parameter.xml"
)
...
...
@@ -457,6 +467,7 @@ def getParameterXml(request):
else
:
return
jsonify
(
code
=
1
,
result
=
parameters
)
#update user account data
@
app
.
route
(
"/updateAccount"
,
methods
=
[
'POST'
])
def
updateAccount
():
account
=
[]
...
...
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