Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
a0556599
Commit
a0556599
authored
Sep 04, 2015
by
Giorgos Korfiatis
Browse files
Add debug option in script
parent
af39696b
Changes
3
Hide whitespace changes
Inline
Side-by-side
agkyra/gui.py
View file @
a0556599
...
...
@@ -96,9 +96,9 @@ class GUI(WebSocketBaseClient):
LOG
.
debug
(
'GUI finished, close GUI wrapper connection'
)
def
run
(
callback
):
def
run
(
callback
,
debug
):
"""Prepare SessionHelper and GUI and run them in the proper order"""
launch_server
(
callback
)
launch_server
(
callback
,
debug
)
LOG
.
info
(
'Client blocks until session is ready'
)
session
=
SessionHelper
().
wait_session_to_load
()
assert
session
,
'UI server failed to load...'
...
...
agkyra/protocol.py
View file @
a0556599
...
...
@@ -711,13 +711,21 @@ class WebSocketProtocol(WebSocket):
self
.
terminate
()
def
launch_server
(
callback
):
def
launch_server
(
callback
,
debug
):
"""Launch the server in a separate process"""
LOG
.
info
(
'Start SessionHelper session'
)
if
utils
.
iswin
():
subprocess
.
Popen
([
callback
,
"server"
],
command
=
[
callback
]
if
debug
:
command
.
append
(
'-d'
)
command
.
append
(
"server"
)
subprocess
.
Popen
(
command
,
close_fds
=
True
)
else
:
pid
=
os
.
fork
()
if
not
pid
:
os
.
execlp
(
callback
,
callback
,
"server"
)
command
=
[
callback
,
callback
]
if
debug
:
command
.
append
(
'-d'
)
command
.
append
(
"server"
)
os
.
execlp
(
*
command
)
agkyra/scripts/agkyra
View file @
a0556599
...
...
@@ -16,6 +16,7 @@
import
os
import
sys
import
argparse
try
:
from
agkyra
import
config
...
...
@@ -33,11 +34,16 @@ FORMATTER = logging.Formatter(
"%(name)s:%(lineno)s %(levelname)s:%(asctime)s:%(message)s"
)
HANDLER
.
setFormatter
(
FORMATTER
)
LOGGER
.
addHandler
(
HANDLER
)
LOGGER
.
setLevel
(
logging
.
INFO
)
CALLBACK
=
os
.
path
.
realpath
(
sys
.
argv
[
0
])
def
run_server
():
def
set_debug
(
debug
):
level
=
logging
.
DEBUG
if
debug
else
logging
.
INFO
LOGGER
.
setLevel
(
level
)
def
run_server
(
debug
):
set_debug
(
debug
)
from
agkyra.protocol
import
SessionHelper
LOGGER
.
debug
(
'Start the session helper'
)
helper
=
SessionHelper
()
...
...
@@ -50,21 +56,28 @@ def run_server():
LOGGER
.
debug
(
'Session Helper is now down'
)
def
run_gui
():
def
run_gui
(
debug
):
set_debug
(
debug
)
from
agkyra
import
gui
gui
.
run
(
callback
=
CALLBACK
)
gui
.
run
(
callback
=
CALLBACK
,
debug
=
debug
)
DISPATCH
=
{
'server'
:
run_server
,
'gui'
:
run_gui
,
}
parser
=
argparse
.
ArgumentParser
(
description
=
'Agkyra syncer launcher'
)
parser
.
add_argument
(
'--debug'
,
'-d'
,
action
=
'store_true'
,
help
=
"set logging level to 'debug'"
)
parser
.
add_argument
(
'component'
,
nargs
=
"?"
,
default
=
"gui"
,
help
=
"run 'server' or 'gui' (default)"
)
def
main
():
if
len
(
sys
.
argv
)
>
1
:
arg
=
sys
.
argv
[
1
]
else
:
arg
=
'gui'
DISPATCH
[
arg
](
)
args
=
parser
.
parse_args
()
debug
=
args
.
debug
set_debug
(
debug
)
component
=
args
.
component
DISPATCH
[
component
](
debug
)
if
__name__
==
"__main__"
:
main
()
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