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
Łukasz Nowak
slapos.toolbox
Commits
05913751
Commit
05913751
authored
Nov 06, 2013
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authentification is now made throught htpasswd
Conflicts: slapos/runner/views.py
parent
ca6a670a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
76 deletions
+9
-76
slapos/runner/static/js/scripts/common.js
slapos/runner/static/js/scripts/common.js
+0
-9
slapos/runner/templates/layout.html
slapos/runner/templates/layout.html
+1
-1
slapos/runner/templates/login.html
slapos/runner/templates/login.html
+1
-0
slapos/runner/templates/shell.html
slapos/runner/templates/shell.html
+3
-0
slapos/runner/views.py
slapos/runner/views.py
+4
-66
No files found.
slapos/runner/static/js/scripts/common.js
View file @
05913751
...
@@ -90,13 +90,4 @@ function bindRemove() {
...
@@ -90,13 +90,4 @@ function bindRemove() {
}
}
});
});
}(
jQuery
,
document
,
this
));
}(
jQuery
,
document
,
this
));
/********************************/
$
(
document
).
ready
(
function
()
{
$
(
"
#linkshell
"
).
click
(
function
()
{
"
use strict
"
;
$
(
"
#main
"
).
empty
();
//XXX It is not finished
$
(
"
#main
"
).
append
(
"
<iframe id=
\"
shellinabox
\"
src=
\"
https://login:password@[2001:67c:1254:3b:fc93:4aff:feca:66ac]:50005/shellinabox
\"
></iframe>
"
);
});
});
slapos/runner/templates/layout.html
View file @
05913751
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
<div
class=
"line"
></div>
<div
class=
"line"
></div>
<a
href=
"{{ url_for('manageProject') }}"
style=
"float:left"
title=
"Manage Your repositories"
><img
alt=
""
src=
"{{ url_for('static', filename='images/manage_repo-little.png') }}"
/></a>
<a
href=
"{{ url_for('manageProject') }}"
style=
"float:left"
title=
"Manage Your repositories"
><img
alt=
""
src=
"{{ url_for('static', filename='images/manage_repo-little.png') }}"
/></a>
<div
class=
"line"
></div>
<div
class=
"line"
></div>
<
span
id=
"linkshell"
style=
"float:left"
title=
"Use the shell"
><img
alt=
""
src=
"{{ url_for('static', filename='images/terminal.png') }}"
/></span
>
<
a
href=
"{{ url_for('shell') }}"
style=
"float:left"
title=
"Use the shell"
><img
alt=
""
src=
"{{ url_for('static', filename='images/terminal.png') }}"
/></a
>
<div
class=
"line"
></div>
<div
class=
"line"
></div>
<a
href=
"{{ url_for('dologout') }}"
style=
"float:left"
title=
"Close your session"
><img
alt=
""
src=
"{{ url_for('static', filename='images/logout.png') }}"
/></a>
<a
href=
"{{ url_for('dologout') }}"
style=
"float:left"
title=
"Close your session"
><img
alt=
""
src=
"{{ url_for('static', filename='images/logout.png') }}"
/></a>
<h2
class=
"info"
>
{% block title %}{% endblock %} - {{session.title}}
</h2>
<h2
class=
"info"
>
{% block title %}{% endblock %} - {{session.title}}
</h2>
...
...
slapos/runner/templates/login.html
View file @
05913751
...
@@ -18,5 +18,6 @@
...
@@ -18,5 +18,6 @@
<input
type=
"reset"
class=
"button"
value=
"reset"
/>
<input
type=
"reset"
class=
"button"
value=
"reset"
/>
<input
type=
"submit"
class=
"button"
id=
"login"
value=
"login"
/>
<input
type=
"submit"
class=
"button"
id=
"login"
value=
"login"
/>
</div>
</div>
<p><a
href=
"https://nwavrant:nicolas@[2001:67c:1254:3b:fc93:4aff:feca:66ac]:50005/"
>
Next
</a></p>
</form>
</form>
{% endblock %}
{% endblock %}
slapos/runner/templates/shell.html
View file @
05913751
{% extends "layout.html" %}
{% block body %}
<iframe
id=
"shellinabox"
src=
"/shellinabox"
></iframe>
<iframe
id=
"shellinabox"
src=
"/shellinabox"
></iframe>
{% endblock %}
slapos/runner/views.py
View file @
05913751
...
@@ -33,8 +33,6 @@ from slapos.runner.gittools import (cloneRepo, gitStatus, switchBranch,
...
@@ -33,8 +33,6 @@ from slapos.runner.gittools import (cloneRepo, gitStatus, switchBranch,
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
.
user_timeout
=
0
file_request
=
FileBrowser
(
app
.
config
)
file_request
=
FileBrowser
(
app
.
config
)
# Setup default flask (werkzeug) parser
# Setup default flask (werkzeug) parser
...
@@ -45,8 +43,6 @@ logger = logging.getLogger('werkzeug')
...
@@ -45,8 +43,6 @@ logger = logging.getLogger('werkzeug')
def
login_redirect
(
*
args
,
**
kwargs
):
def
login_redirect
(
*
args
,
**
kwargs
):
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'login'
))
#Access Control: Only static files and login pages are allowed to guest
@
app
.
before_request
@
app
.
before_request
def
before_request
():
def
before_request
():
if
request
.
path
.
startswith
(
'/static'
):
if
request
.
path
.
startswith
(
'/static'
):
...
@@ -54,24 +50,18 @@ def before_request():
...
@@ -54,24 +50,18 @@ def before_request():
account
=
getSession
(
app
.
config
)
account
=
getSession
(
app
.
config
)
if
account
:
if
account
:
user
=
AuthUser
(
username
=
account
[
0
])
user
.
set_and_encrypt_password
(
account
[
1
],
"123400ZYX"
)
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
g
.
users
=
{
account
[
0
]:
user
}
else
:
else
:
session
[
'title'
]
=
"No account is defined"
session
[
'title'
]
=
"No account is defined"
if
request
.
path
!=
"/setAccount"
and
request
.
path
!=
"/configAccount"
:
if
request
.
path
!=
"/setAccount"
and
request
.
path
!=
"/configAccount"
:
return
redirect
(
url_for
(
'setAccount'
))
return
redirect
(
url_for
(
'setAccount'
))
# general views
# general views
@
login_required
()
def
home
():
def
home
():
return
render_template
(
'index.html'
)
return
render_template
(
'index.html'
)
# general views
# general views
@
login_required
()
def
browseWorkspace
():
def
browseWorkspace
():
return
render_template
(
'workspace.html'
)
return
render_template
(
'workspace.html'
)
...
@@ -89,7 +79,6 @@ def setAccount():
...
@@ -89,7 +79,6 @@ def setAccount():
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'login'
))
@
login_required
()
def
myAccount
():
def
myAccount
():
account
=
getSession
(
app
.
config
)
account
=
getSession
(
app
.
config
)
return
render_template
(
'account.html'
,
username
=
account
[
0
],
return
render_template
(
'account.html'
,
username
=
account
[
0
],
...
@@ -102,7 +91,6 @@ def dologout():
...
@@ -102,7 +91,6 @@ def dologout():
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'login'
))
@
login_required
()
def
configRepo
():
def
configRepo
():
public_key
=
open
(
app
.
config
[
'public_key'
]).
read
()
public_key
=
open
(
app
.
config
[
'public_key'
]).
read
()
account
=
getSession
(
app
.
config
)
account
=
getSession
(
app
.
config
)
...
@@ -113,16 +101,12 @@ def configRepo():
...
@@ -113,16 +101,12 @@ def configRepo():
@
app
.
route
(
"/doLogin"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/doLogin"
,
methods
=
[
'POST'
])
def
doLogin
():
def
doLogin
():
username
=
request
.
form
[
'clogin'
]
#XXX Now has to check the .htpasswd if we want to warn
if
username
in
g
.
users
:
#the user that he misspelled his name/password
# Authenticate and log in!
if
g
.
users
[
username
].
authenticate
(
request
.
form
[
'cpwd'
]):
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
0
,
result
=
"Login or password is incorrect, please check it!"
),
401
# software views
# software views
@
login_required
()
def
editSoftwareProfile
():
def
editSoftwareProfile
():
profile
=
getProfilePath
(
app
.
config
[
'etc_dir'
],
app
.
config
[
'software_profile'
])
profile
=
getProfilePath
(
app
.
config
[
'etc_dir'
],
app
.
config
[
'software_profile'
])
if
profile
==
""
:
if
profile
==
""
:
...
@@ -131,14 +115,12 @@ def editSoftwareProfile():
...
@@ -131,14 +115,12 @@ def editSoftwareProfile():
profile
=
profile
,
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]))
profile
=
profile
,
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]))
@
login_required
()
def
inspectSoftware
():
def
inspectSoftware
():
return
render_template
(
'runResult.html'
,
softwareRoot
=
'software_link/'
,
return
render_template
(
'runResult.html'
,
softwareRoot
=
'software_link/'
,
softwares
=
loadSoftwareRList
(
app
.
config
))
softwares
=
loadSoftwareRList
(
app
.
config
))
#remove content of compiled software release
#remove content of compiled software release
@
login_required
()
def
removeSoftware
():
def
removeSoftware
():
if
isSoftwareRunning
(
app
.
config
)
or
isInstanceRunning
(
app
.
config
):
if
isSoftwareRunning
(
app
.
config
)
or
isInstanceRunning
(
app
.
config
):
flash
(
'Software installation or instantiation in progress, cannot remove'
)
flash
(
'Software installation or instantiation in progress, cannot remove'
)
...
@@ -151,7 +133,6 @@ def removeSoftware():
...
@@ -151,7 +133,6 @@ def removeSoftware():
return
redirect
(
url_for
(
'inspectSoftware'
))
return
redirect
(
url_for
(
'inspectSoftware'
))
@
login_required
()
def
runSoftwareProfile
():
def
runSoftwareProfile
():
if
runSoftwareWithLock
(
app
.
config
):
if
runSoftwareWithLock
(
app
.
config
):
return
jsonify
(
result
=
True
)
return
jsonify
(
result
=
True
)
...
@@ -159,7 +140,6 @@ def runSoftwareProfile():
...
@@ -159,7 +140,6 @@ def runSoftwareProfile():
return
jsonify
(
result
=
False
)
return
jsonify
(
result
=
False
)
@
login_required
()
def
viewSoftwareLog
():
def
viewSoftwareLog
():
if
os
.
path
.
exists
(
app
.
config
[
'software_log'
]):
if
os
.
path
.
exists
(
app
.
config
[
'software_log'
]):
result
=
tail
(
open
(
app
.
config
[
'software_log'
]),
lines
=
1500
)
result
=
tail
(
open
(
app
.
config
[
'software_log'
]),
lines
=
1500
)
...
@@ -170,7 +150,6 @@ def viewSoftwareLog():
...
@@ -170,7 +150,6 @@ def viewSoftwareLog():
# instance views
# instance views
@
login_required
()
def
editInstanceProfile
():
def
editInstanceProfile
():
profile
=
getProfilePath
(
app
.
config
[
'etc_dir'
],
app
.
config
[
'instance_profile'
])
profile
=
getProfilePath
(
app
.
config
[
'etc_dir'
],
app
.
config
[
'instance_profile'
])
if
profile
==
""
:
if
profile
==
""
:
...
@@ -180,7 +159,6 @@ def editInstanceProfile():
...
@@ -180,7 +159,6 @@ def editInstanceProfile():
# get status of all computer partitions and process state
# get status of all computer partitions and process state
@
login_required
()
def
inspectInstance
():
def
inspectInstance
():
if
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
if
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
file_path
=
'instance_root'
file_path
=
'instance_root'
...
@@ -196,7 +174,6 @@ def inspectInstance():
...
@@ -196,7 +174,6 @@ def inspectInstance():
#Reload instance process ans returns new value to ajax
#Reload instance process ans returns new value to ajax
@
login_required
()
def
supervisordStatus
():
def
supervisordStatus
():
result
=
getSvcStatus
(
app
.
config
)
result
=
getSvcStatus
(
app
.
config
)
if
not
result
:
if
not
result
:
...
@@ -213,7 +190,6 @@ def supervisordStatus():
...
@@ -213,7 +190,6 @@ def supervisordStatus():
return
jsonify
(
code
=
1
,
result
=
html
)
return
jsonify
(
code
=
1
,
result
=
html
)
@
login_required
()
def
removeInstance
():
def
removeInstance
():
if
isInstanceRunning
(
app
.
config
):
if
isInstanceRunning
(
app
.
config
):
flash
(
'Instantiation in progress, cannot remove'
)
flash
(
'Instantiation in progress, cannot remove'
)
...
@@ -228,7 +204,6 @@ def removeInstance():
...
@@ -228,7 +204,6 @@ def removeInstance():
return
redirect
(
url_for
(
'inspectInstance'
))
return
redirect
(
url_for
(
'inspectInstance'
))
@
login_required
()
def
runInstanceProfile
():
def
runInstanceProfile
():
if
not
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
if
not
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
os
.
mkdir
(
app
.
config
[
'instance_root'
])
os
.
mkdir
(
app
.
config
[
'instance_root'
])
...
@@ -238,7 +213,6 @@ def runInstanceProfile():
...
@@ -238,7 +213,6 @@ def runInstanceProfile():
return
jsonify
(
result
=
False
)
return
jsonify
(
result
=
False
)
@
login_required
()
def
viewInstanceLog
():
def
viewInstanceLog
():
if
os
.
path
.
exists
(
app
.
config
[
'instance_log'
]):
if
os
.
path
.
exists
(
app
.
config
[
'instance_log'
]):
result
=
open
(
app
.
config
[
'instance_log'
]).
read
()
result
=
open
(
app
.
config
[
'instance_log'
]).
read
()
...
@@ -248,31 +222,26 @@ def viewInstanceLog():
...
@@ -248,31 +222,26 @@ def viewInstanceLog():
result
=
result
.
encode
(
"utf-8"
))
result
=
result
.
encode
(
"utf-8"
))
@
login_required
()
def
stopAllPartition
():
def
stopAllPartition
():
svcStopAll
(
app
.
config
)
svcStopAll
(
app
.
config
)
return
redirect
(
url_for
(
'inspectInstance'
))
return
redirect
(
url_for
(
'inspectInstance'
))
@
login_required
(
login_redirect
)
def
tailProcess
(
process
):
def
tailProcess
(
process
):
return
render_template
(
'processTail.html'
,
return
render_template
(
'processTail.html'
,
process_log
=
getSvcTailProcess
(
app
.
config
,
process
),
process
=
process
)
process_log
=
getSvcTailProcess
(
app
.
config
,
process
),
process
=
process
)
@
login_required
(
login_redirect
)
def
startStopProccess
(
process
,
action
):
def
startStopProccess
(
process
,
action
):
svcStartStopProcess
(
app
.
config
,
process
,
action
)
svcStartStopProcess
(
app
.
config
,
process
,
action
)
return
redirect
(
url_for
(
'inspectInstance'
))
return
redirect
(
url_for
(
'inspectInstance'
))
@
login_required
(
login_redirect
)
def
openProject
(
method
):
def
openProject
(
method
):
return
render_template
(
'projectFolder.html'
,
method
=
method
,
return
render_template
(
'projectFolder.html'
,
method
=
method
,
workDir
=
'workspace'
)
workDir
=
'workspace'
)
@
login_required
()
def
cloneRepository
():
def
cloneRepository
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'name'
],
False
)
path
=
realpath
(
app
.
config
,
request
.
form
[
'name'
],
False
)
data
=
{
data
=
{
...
@@ -284,27 +253,22 @@ def cloneRepository():
...
@@ -284,27 +253,22 @@ def cloneRepository():
return
cloneRepo
(
data
)
return
cloneRepo
(
data
)
@
login_required
()
def
readFolder
():
def
readFolder
():
return
getFolderContent
(
app
.
config
,
request
.
form
[
'dir'
])
return
getFolderContent
(
app
.
config
,
request
.
form
[
'dir'
])
@
login_required
()
def
openFolder
():
def
openFolder
():
return
getFolder
(
app
.
config
,
request
.
form
[
'dir'
])
return
getFolder
(
app
.
config
,
request
.
form
[
'dir'
])
@
login_required
()
def
createSoftware
():
def
createSoftware
():
return
newSoftware
(
request
.
form
[
'folder'
],
app
.
config
,
session
)
return
newSoftware
(
request
.
form
[
'folder'
],
app
.
config
,
session
)
@
login_required
()
def
checkFolder
():
def
checkFolder
():
return
checkSoftwareFolder
(
request
.
form
[
'path'
],
app
.
config
)
return
checkSoftwareFolder
(
request
.
form
[
'path'
],
app
.
config
)
@
login_required
()
def
setCurrentProject
():
def
setCurrentProject
():
if
configNewSR
(
app
.
config
,
request
.
form
[
'path'
]):
if
configNewSR
(
app
.
config
,
request
.
form
[
'path'
]):
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
...
@@ -313,13 +277,11 @@ def setCurrentProject():
...
@@ -313,13 +277,11 @@ def setCurrentProject():
return
jsonify
(
code
=
0
,
result
=
(
"Can not setup this Software Release"
))
return
jsonify
(
code
=
0
,
result
=
(
"Can not setup this Software Release"
))
@
login_required
()
def
manageProject
():
def
manageProject
():
return
render_template
(
'manageProject.html'
,
workDir
=
'workspace'
,
return
render_template
(
'manageProject.html'
,
workDir
=
'workspace'
,
project
=
getProjectList
(
app
.
config
[
'workspace'
]))
project
=
getProjectList
(
app
.
config
[
'workspace'
]))
@
login_required
()
def
getProjectStatus
():
def
getProjectStatus
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -329,7 +291,6 @@ def getProjectStatus():
...
@@ -329,7 +291,6 @@ def getProjectStatus():
#view for current software release files
#view for current software release files
@
login_required
()
def
editCurrentProject
():
def
editCurrentProject
():
project
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".project"
)
project
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".project"
)
if
os
.
path
.
exists
(
project
):
if
os
.
path
.
exists
(
project
):
...
@@ -340,7 +301,6 @@ def editCurrentProject():
...
@@ -340,7 +301,6 @@ def editCurrentProject():
#create file or directory
#create file or directory
@
login_required
()
def
createFile
():
def
createFile
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
],
False
)
path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
],
False
)
if
not
path
:
if
not
path
:
...
@@ -356,7 +316,6 @@ def createFile():
...
@@ -356,7 +316,6 @@ def createFile():
#remove file or directory
#remove file or directory
@
login_required
()
def
removeFile
():
def
removeFile
():
try
:
try
:
if
request
.
form
[
'type'
]
==
"folder"
:
if
request
.
form
[
'type'
]
==
"folder"
:
...
@@ -368,7 +327,6 @@ def removeFile():
...
@@ -368,7 +327,6 @@ def removeFile():
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
@
login_required
()
def
removeSoftwareDir
():
def
removeSoftwareDir
():
try
:
try
:
data
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
data
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
...
@@ -379,7 +337,6 @@ def removeSoftwareDir():
...
@@ -379,7 +337,6 @@ def removeSoftwareDir():
#read file and return content to ajax
#read file and return content to ajax
@
login_required
()
def
getFileContent
():
def
getFileContent
():
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
if
file_path
:
if
file_path
:
...
@@ -395,7 +352,6 @@ def getFileContent():
...
@@ -395,7 +352,6 @@ def getFileContent():
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
@
login_required
()
def
saveFileContent
():
def
saveFileContent
():
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
if
file_path
:
if
file_path
:
...
@@ -405,7 +361,6 @@ def saveFileContent():
...
@@ -405,7 +361,6 @@ def saveFileContent():
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
@
login_required
()
def
changeBranch
():
def
changeBranch
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -414,7 +369,6 @@ def changeBranch():
...
@@ -414,7 +369,6 @@ def changeBranch():
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
()
def
newBranch
():
def
newBranch
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -426,12 +380,10 @@ def newBranch():
...
@@ -426,12 +380,10 @@ def newBranch():
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
(
login_redirect
)
def
getProjectDiff
(
project
):
def
getProjectDiff
(
project
):
path
=
os
.
path
.
join
(
app
.
config
[
'workspace'
],
project
)
path
=
os
.
path
.
join
(
app
.
config
[
'workspace'
],
project
)
return
render_template
(
'projectDiff.html'
,
project
=
project
,
return
render_template
(
'projectDiff.html'
,
project
=
project
,
diff
=
getDiff
(
path
))
diff
=
getDiff
(
path
))
@
login_required
()
def
commitProjectFiles
():
def
commitProjectFiles
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -440,7 +392,6 @@ def commitProjectFiles():
...
@@ -440,7 +392,6 @@ def commitProjectFiles():
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
()
def
pushProjectFiles
():
def
pushProjectFiles
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -449,7 +400,6 @@ def pushProjectFiles():
...
@@ -449,7 +400,6 @@ def pushProjectFiles():
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
()
def
pullProjectFiles
():
def
pullProjectFiles
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
if
path
:
...
@@ -458,7 +408,6 @@ def pullProjectFiles():
...
@@ -458,7 +408,6 @@ def pullProjectFiles():
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
()
def
checkFileType
():
def
checkFileType
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'path'
])
path
=
realpath
(
app
.
config
,
request
.
form
[
'path'
])
if
not
path
:
if
not
path
:
...
@@ -470,7 +419,6 @@ def checkFileType():
...
@@ -470,7 +419,6 @@ def checkFileType():
result
=
"Can not open a binary file, please select a text file!"
)
result
=
"Can not open a binary file, please select a text file!"
)
@
login_required
()
def
getmd5sum
():
def
getmd5sum
():
realfile
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
realfile
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
if
not
realfile
:
if
not
realfile
:
...
@@ -483,7 +431,6 @@ def getmd5sum():
...
@@ -483,7 +431,6 @@ def getmd5sum():
#return information about state of slapgrid process
#return information about state of slapgrid process
@
login_required
()
def
slapgridResult
():
def
slapgridResult
():
software_state
=
isSoftwareRunning
(
app
.
config
)
software_state
=
isSoftwareRunning
(
app
.
config
)
instance_state
=
isInstanceRunning
(
app
.
config
)
instance_state
=
isInstanceRunning
(
app
.
config
)
...
@@ -501,13 +448,11 @@ def slapgridResult():
...
@@ -501,13 +448,11 @@ def slapgridResult():
result
=
(
instance_state
or
software_state
),
content
=
log_result
)
result
=
(
instance_state
or
software_state
),
content
=
log_result
)
@
login_required
()
def
stopSlapgrid
():
def
stopSlapgrid
():
result
=
killRunningProcess
(
request
.
form
[
'type'
])
result
=
killRunningProcess
(
request
.
form
[
'type'
])
return
jsonify
(
result
=
result
)
return
jsonify
(
result
=
result
)
@
login_required
()
def
getPath
():
def
getPath
():
files
=
request
.
form
[
'file'
].
split
(
'#'
)
files
=
request
.
form
[
'file'
].
split
(
'#'
)
list
=
[]
list
=
[]
...
@@ -526,7 +471,6 @@ def getPath():
...
@@ -526,7 +471,6 @@ def getPath():
return
jsonify
(
code
=
1
,
result
=
realfile
)
return
jsonify
(
code
=
1
,
result
=
realfile
)
@
login_required
()
def
saveParameterXml
():
def
saveParameterXml
():
"""
"""
Update instance parameter into a local xml file.
Update instance parameter into a local xml file.
...
@@ -557,7 +501,6 @@ def saveParameterXml():
...
@@ -557,7 +501,6 @@ def saveParameterXml():
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
@
login_required
()
def
getSoftwareType
():
def
getSoftwareType
():
software_type_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".software_type.xml"
)
software_type_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".software_type.xml"
)
if
os
.
path
.
exists
(
software_type_path
):
if
os
.
path
.
exists
(
software_type_path
):
...
@@ -566,7 +509,6 @@ def getSoftwareType():
...
@@ -566,7 +509,6 @@ def getSoftwareType():
#read instance parameters into the local xml file and return a dict
#read instance parameters into the local xml file and return a dict
@
login_required
()
def
getParameterXml
(
request
):
def
getParameterXml
(
request
):
param_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".parameter.xml"
)
param_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".parameter.xml"
)
if
not
os
.
path
.
exists
(
param_path
):
if
not
os
.
path
.
exists
(
param_path
):
...
@@ -583,7 +525,6 @@ def getParameterXml(request):
...
@@ -583,7 +525,6 @@ def getParameterXml(request):
#update user account data
#update user account data
@
login_required
()
def
updateAccount
():
def
updateAccount
():
code
=
request
.
form
[
'rcode'
].
strip
()
code
=
request
.
form
[
'rcode'
].
strip
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
()
...
@@ -629,7 +570,6 @@ def configAccount():
...
@@ -629,7 +570,6 @@ def configAccount():
#Global File Manager
#Global File Manager
@
login_required
()
def
fileBrowser
():
def
fileBrowser
():
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
filename
=
request
.
form
.
get
(
'filename'
,
''
).
encode
(
'utf-8'
)
filename
=
request
.
form
.
get
(
'filename'
,
''
).
encode
(
'utf-8'
)
...
@@ -694,16 +634,14 @@ def fileBrowser():
...
@@ -694,16 +634,14 @@ def fileBrowser():
return
result
return
result
@
login_required
()
def
editFile
():
def
editFile
():
return
render_template
(
'editFile.html'
,
workDir
=
'workspace'
,
return
render_template
(
'editFile.html'
,
workDir
=
'workspace'
,
profile
=
urllib
.
unquote
(
request
.
args
.
get
(
'profile'
,
''
)),
profile
=
urllib
.
unquote
(
request
.
args
.
get
(
'profile'
,
''
)),
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]),
projectList
=
getProjectList
(
app
.
config
[
'workspace'
]),
filename
=
urllib
.
unquote
(
request
.
args
.
get
(
'filename'
,
''
)))
filename
=
urllib
.
unquote
(
request
.
args
.
get
(
'filename'
,
''
)))
@
login_required
()
def
shell
():
def
shell
():
return
"<iframe id=
\
"
shellinabox
\
"
src=
\
"
/shellinabox
\
"
></iframe>"
return
render_template
(
'shell.html'
)
#Setup List of URLs
#Setup List of URLs
app
.
add_url_rule
(
'/'
,
'home'
,
home
)
app
.
add_url_rule
(
'/'
,
'home'
,
home
)
...
...
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