Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
python-handel
Commits
982e67fd
Commit
982e67fd
authored
Nov 14, 2017
by
Vincent Michel
Browse files
Improve handel-server using argparse
parent
45679f35
Pipeline
#1342
passed with stages
in 1 minute and 22 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
982e67fd
...
...
@@ -112,12 +112,6 @@ A few scripts are provided:
*
msgpack_numpy
TODO
----
-
Improve
`handel-server`
using argparse.
Contact
-------
...
...
scripts/handel-server
View file @
982e67fd
...
...
@@ -16,7 +16,7 @@ Test on the client machine using:
# Imports
import
sys
import
argparse
import
zerorpc
import
msgpack_numpy
...
...
@@ -24,12 +24,6 @@ import msgpack_numpy
import
handel.gevent
import
handel.interface
as
hi
# Patching
handel
.
gevent
.
patch
()
msgpack_numpy
.
patch
()
# Run server
def
run
(
bind
=
'0.0.0.0'
,
port
=
8000
):
...
...
@@ -49,15 +43,28 @@ def run(bind='0.0.0.0', port=8000):
hi
.
exit
()
# Parsing
def
parse_args
(
args
=
None
):
parser
=
argparse
.
ArgumentParser
(
prog
=
'handel-server'
,
description
=
'Serve the handel interface over the network using zerorpc'
)
parser
.
add_argument
(
'--bind'
,
'-b'
,
default
=
''
,
metavar
=
'address'
,
help
=
'Specify alternate bind address [default: all interfaces]'
)
parser
.
add_argument
(
'port'
,
action
=
'store'
,
default
=
8000
,
type
=
int
,
nargs
=
'?'
,
help
=
'Specify alternate port [default: 8000]'
)
return
parser
.
parse_args
(
args
)
# Main function
def
main
(
args
=
None
):
if
args
is
None
:
args
=
sys
.
argv
if
len
(
args
)
>
1
:
run
(
port
=
int
(
args
[
1
]))
else
:
run
()
namespace
=
parse_args
(
args
)
handel
.
gevent
.
patch
()
msgpack_numpy
.
patch
()
run
(
namespace
.
bind
,
namespace
.
port
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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