Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
57855547
Commit
57855547
authored
Nov 10, 2014
by
ThorbenQuast
Browse files
editor: autopep8 run over .py code, add syntax highlighting for .cc files
parent
9c058618
Changes
2
Hide whitespace changes
Inline
Side-by-side
vispa/extensions/codeeditor/static/js/editor.js
View file @
57855547
...
...
@@ -461,6 +461,7 @@ var CodeEditor = Emitter.extend({
var
mode
=
"
ace/mode/
"
;
switch
(
fileExtension
)
{
case
"
c
"
:
case
"
cc
"
:
case
"
cpp
"
:
case
"
h
"
:
mode
+=
"
c_cpp
"
;
...
...
vispa/extensions/codeeditor/workspace/__init__.py
View file @
57855547
...
...
@@ -23,19 +23,19 @@ class CodeEditorRpc:
SIGTEM_SIGKILL_DELAY
=
0.1
def
__init__
(
self
,
window_id
,
view_id
):
self
.
_view_id
=
view_id
self
.
_window_id
=
window_id
self
.
_topic
=
"extension.%s.socket"
%
self
.
_view_id
self
.
_thread
=
None
self
.
_abort
=
False
self
.
_pty_master
,
self
.
_pty_slave
=
pty
.
openpty
()
self
.
_pty_fd
=
os
.
fdopen
(
self
.
_pty_master
,
'r'
)
self
.
_pty_fno
=
self
.
_pty_fd
.
fileno
()
self
.
_popen
=
None
logger
.
debug
(
"CodeEditorRpc created"
)
def
close
(
self
):
...
...
@@ -44,11 +44,12 @@ class CodeEditorRpc:
self
.
_abort
=
True
def
_send
(
self
,
topic
,
data
=
None
):
vispa
.
remote
.
send_topic
(
self
.
_topic
+
"."
+
topic
,
window_id
=
self
.
_window_id
,
data
=
data
)
vispa
.
remote
.
send_topic
(
self
.
_topic
+
"."
+
topic
,
window_id
=
self
.
_window_id
,
data
=
data
)
def
runningjob
(
self
):
return
bool
(
self
.
_thread
and
self
.
_thread
.
is_alive
())
def
start
(
self
,
cmd
,
base
):
if
self
.
runningjob
():
return
"There is already a job running"
...
...
@@ -56,43 +57,43 @@ class CodeEditorRpc:
self
.
_cmd
=
expand
(
cmd
)
self
.
_base
=
expand
(
base
)
self
.
_starttime
=
time
.
time
()
try
:
self
.
_popen
=
Popen
(
self
.
_cmd
,
cwd
=
self
.
_base
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
self
.
_pty_slave
,
stderr
=
self
.
_pty_slave
,
close_fds
=
True
,
preexec_fn
=
os
.
setsid
)
stdin
=
PIPE
,
stdout
=
self
.
_pty_slave
,
stderr
=
self
.
_pty_slave
,
close_fds
=
True
,
preexec_fn
=
os
.
setsid
)
except
Exception
as
e
:
return
str
(
e
)
# send result via socket to ensure in order processing
self
.
_send
(
'start'
,
{
"command"
:
self
.
_cmd
,
"base"
:
self
.
_base
,
"base"
:
self
.
_base
,
})
logger
.
debug
(
"CodeEditorRpc starting _stream"
)
self
.
_thread
=
threading
.
Thread
(
target
=
self
.
_stream
)
self
.
_thread
.
daemon
=
True
self
.
_thread
.
start
()
return
""
def
_stream
(
self
):
# maxiumum stdout/err transmission burst (via bus)
max_burst
=
1
<<
12
max_burst
=
1
<<
12
returncode
=
None
self
.
_abort
=
False
while
not
self
.
_abort
:
r
,
_
,
_
=
select
.
select
([
self
.
_pty_fno
],
[],
[],
0.1
)
if
self
.
_pty_fno
in
r
:
self
.
_send
(
'data'
,
os
.
read
(
self
.
_pty_fno
,
max_burst
))
returncode
=
self
.
_popen
.
poll
()
if
returncode
is
not
None
:
break
# soft kill
if
self
.
_abort
:
pgid
=
os
.
getpgid
(
self
.
_popen
.
pid
)
...
...
@@ -102,28 +103,27 @@ class CodeEditorRpc:
try
:
os
.
killpg
(
pgid
,
signal
.
SIGKILL
)
except
OSError
as
e
:
if
e
.
errno
!=
3
:
# No such process
if
e
.
errno
!=
3
:
# No such process
raise
e
else
:
returncode
=
-
signal
.
SIGKILL
# check remaing data
r
=
True
while
r
:
r
,
_
,
_
=
select
.
select
([
self
.
_pty_fno
],
[],
[],
0
)
if
self
.
_pty_fno
in
r
:
self
.
_send
(
'data'
,
os
.
read
(
self
.
_pty_fno
,
max_burst
))
runtime
=
round
(
time
.
time
()
-
self
.
_starttime
,
2
)
self
.
_send
(
'done'
,
{
"success"
:
True
,
"runtime"
:
runtime
,
"returncode"
:
returncode
,
"aborted"
:
self
.
_abort
})
self
.
_send
(
'done'
,
{
"success"
:
True
,
"runtime"
:
runtime
,
"returncode"
:
returncode
,
"aborted"
:
self
.
_abort
})
logger
.
debug
(
"CodeEditorExecuteRpc _stream finished"
)
def
abort
(
self
):
if
not
self
.
runningjob
():
return
False
self
.
_abort
=
True
return
True
\ No newline at end of file
return
True
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