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
Iliya Manolov
slapos.toolbox
Commits
b0c0d799
Commit
b0c0d799
authored
Aug 04, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: first commit for the mini-shell integration
parent
af15ba13
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
1 deletion
+93
-1
slapos/runner/static/css/editor.css
slapos/runner/static/css/editor.css
+27
-1
slapos/runner/static/css/images/terminal.png
slapos/runner/static/css/images/terminal.png
+0
-0
slapos/runner/static/js/scripts/shell.js
slapos/runner/static/js/scripts/shell.js
+28
-0
slapos/runner/templates/softwareFolder.html
slapos/runner/templates/softwareFolder.html
+8
-0
slapos/runner/views.py
slapos/runner/views.py
+30
-0
No files found.
slapos/runner/static/css/editor.css
View file @
b0c0d799
...
...
@@ -28,6 +28,7 @@
.swith_btn
{
background
:
url(../images/gnome-session-switch.png)
center
right
no-repeat
;
width
:
105px
;}
.flist_btn
{
background
:
url(../images/list2_down.png)
center
right
no-repeat
;
width
:
26px
;}
.fmenu_btn
{
background
:
url(../images/ui_menu_blue.png)
center
right
no-repeat
;
width
:
58px
;}
.shell_btn
{
background
:
url(../images/terminal.png)
center
right
no-repeat
;
width
:
62px
;}
#tabControl
{
overflow
:
hidden
;}
#tabControl
.item
{
float
:
left
;
min-width
:
60px
;
background
:
#D5D5D5
;
height
:
22px
;
padding-top
:
8px
;
font-size
:
1em
;
...
...
@@ -43,4 +44,29 @@ border-left:1px #E4E4E4 solid; cursor:pointer; color: #5C7077; text-shadow: 0px
#tabContent
pre
.active
{
display
:
block
;}
.item-hide
{
display
:
none
;}
#shell-window
{
width
:
978px
;
height
:
350px
;
z-index
:
10
;
border
:
2px
solid
#6A93A0
;
border-top
:
none
;
border-left
:
none
;
background
:
#7FAED3
;
position
:
absolute
;
display
:
none
;
}
#shell-result
{
width
:
98%
;
height
:
300px
;
margin-left
:
1%
;
margin-right
:
1%
;
box-sizing
:
border-box
;
padding
:
3px
;
}
#shell-input
{
width
:
97%
;
margin-left
:
1%
;
margin-right
:
1%
;
position
:
absolute
;
bottom
:
10px
;
}
slapos/runner/static/css/images/terminal.png
0 → 100644
View file @
b0c0d799
1.07 KB
slapos/runner/static/js/scripts/shell.js
0 → 100644
View file @
b0c0d799
/*jslint undef: true */
/*global $, document, $SCRIPT_ROOT, window */
/*global path: true */
/* vim: set et sts=4: */
$
(
document
).
ready
(
function
()
{
"
use strict
"
;
$
(
"
#shell
"
).
click
(
function
()
{
$
(
"
#shell-window
"
).
slideToggle
(
"
fast
"
);
if
(
$
(
"
#shell-window
"
).
is
(
'
:visible
'
)
)
{
$
(
"
#shell-input
"
).
focus
();
}
});
$
(
"
#shell-input
"
).
keypress
(
function
(
event
)
{
if
(
event
.
which
===
13
)
{
var
command
=
$
(
"
#shell-input
"
).
val
();
event
.
preventDefault
();
var
data
=
{
command
:
command
};
$
.
post
(
"
/runCommand
"
,
data
,
function
(
data
)
{
data
=
"
>>>
"
+
command
+
"
\n\n
"
+
data
;
$
(
"
#shell-result
"
).
val
(
data
);
$
(
"
#shell-input
"
).
val
(
""
);
});
}
});
});
slapos/runner/templates/softwareFolder.html
View file @
b0c0d799
...
...
@@ -10,6 +10,7 @@
<link
href=
"{{ url_for('static', filename='css/colorbox.css', _external=False) }}"
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
/>
<script
src=
"{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}"
type=
"application/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='js/scripts/softwareFolder.js') }}"
type=
"application/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='js/scripts/shell.js') }}"
type=
"application/javascript"
charset=
"utf-8"
></script>
{% endblock %}
{% block body %}
<style>
...
...
@@ -50,11 +51,18 @@
<li
id=
"fullscreen"
><span
class=
"expand_editor"
title=
"Show Editor in Full window. Hint: Use Ctrl+E"
>
</span></li>
<li
id=
"save"
><span
class=
"save_btn"
title=
"Save current file. Hint: Use Ctrl+S"
>
</span></li>
<li
id=
"option"
><span
class=
"fmenu_btn"
title=
'Show more options'
rel=
'tooltip'
>
Menu
</span></li>
<li
id=
"shell"
><span
class=
"shell_btn"
title=
"Run a command in a shell"
>
Shell
</span></li>
</ul>
<div
id=
"tabControl"
></div>
<div
class=
"clear"
></div>
</div>
<div
class=
"clear"
></div>
<div
id=
"shell-window"
>
<textarea
id=
"shell-result"
cols=
"80"
readonly
>
</textarea>
<input
type=
"text"
name=
"command"
id=
"shell-input"
/>
</div>
<div
class=
"clear"
></div>
<div
class=
"software_details"
>
<div
id=
"details_box"
>
<div
id=
"fileTree"
class=
"file_tree_short"
></div>
...
...
slapos/runner/views.py
View file @
b0c0d799
...
...
@@ -6,6 +6,7 @@
import
json
import
os
import
shutil
import
subprocess
import
thread
import
urllib
...
...
@@ -706,6 +707,34 @@ def isSRReady():
return
isSoftwareReleaseReady
(
app
.
config
)
def
runCommand
():
cwd
=
open
(
app
.
config
[
'minishell_cwd_file'
],
'r'
).
read
().
strip
()
command
=
request
.
form
.
get
(
"command"
,
''
).
strip
()
parsed_commands
=
command
.
split
(
';'
);
# does the user want to change current directory ?
for
cmd
in
parsed_commands
:
if
'cd'
==
cmd
[:
2
]:
cmd
=
cmd
.
split
(
' '
);
if
len
(
cmd
)
==
1
:
cmd
.
append
(
os
.
environ
.
get
(
'HOME'
))
# shorten directory's name, to avoid things like : /a/../b
cd_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
cwd
,
cmd
[
1
]))
if
os
.
path
.
exists
(
cd_dir
):
cwd
=
cd_dir
# save new cwd in the config file
open
(
app
.
config
[
'minishell_cwd_file'
],
'w'
).
write
(
cwd
)
# if the command was just cd, execute it. Otherwise, execute the rest
command
=
command
.
replace
(
' '
.
join
(
cmd
),
''
).
strip
(
';'
)
if
not
command
:
return
"Changed directory, now in : "
+
cwd
try
:
return
subprocess
.
check_output
(
command
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
cwd
=
cwd
)
except
subprocess
.
CalledProcessError
as
e
:
error
=
"Error : process exited with exit code "
+
str
(
e
.
returncode
)
+
\
"
\
n
Process says :
\
n
"
+
e
.
output
return
error
#Setup List of URLs
app
.
add_url_rule
(
'/'
,
'home'
,
home
)
app
.
add_url_rule
(
'/browseWorkspace'
,
'browseWorkspace'
,
browseWorkspace
)
...
...
@@ -789,3 +818,4 @@ app.add_url_rule('/shell', 'shell', shell)
app
.
add_url_rule
(
'/isSRReady'
,
'isSRReady'
,
isSRReady
)
app
.
add_url_rule
(
'/addUser'
,
'addUser'
,
addUser
,
methods
=
[
'POST'
])
app
.
add_url_rule
(
'/getSlapgridParameters'
,
'getSlapgridParameters'
,
getSlapgridParameters
,
methods
=
[
'GET'
])
app
.
add_url_rule
(
'/runCommand'
,
'runCommand'
,
runCommand
,
methods
=
[
'POST'
])
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