Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
138b37b3
Commit
138b37b3
authored
Feb 27, 2014
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Platform: use argument parser to allow defining host and port
parent
baf78621
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
dream/platform/__init__.py
dream/platform/__init__.py
+15
-6
No files found.
dream/platform/__init__.py
View file @
138b37b3
...
...
@@ -18,6 +18,7 @@
# ===========================================================================
import
sys
import
argparse
import
json
import
traceback
import
multiprocessing
...
...
@@ -30,6 +31,7 @@ import logging
from
flask
import
Flask
,
jsonify
,
redirect
,
url_for
from
flask
import
request
global
klass_name
app
=
Flask
(
__name__
)
# Serve static file with no cache
...
...
@@ -127,9 +129,6 @@ def _runSimulation(parameter_dict, queue):
def
getGUIInstance
():
# XXX do not instanciate each time!
klass_name
=
'dream.simulation.GUI.Default'
if
len
(
sys
.
argv
)
>
1
:
klass_name
=
'dream.simulation.GUI.%s'
%
sys
.
argv
[
1
]
klass
=
__import__
(
klass_name
,
globals
(),
{},
klass_name
)
instance
=
klass
.
Simulation
(
logger
=
app
.
logger
)
return
instance
...
...
@@ -147,15 +146,26 @@ def getInputIdList():
return
jsonify
(
getGUIInstance
().
getInputIdList
())
def
main
(
*
args
):
parser
=
argparse
.
ArgumentParser
(
description
=
'Launch the DREAM simulation platform.'
)
parser
.
add_argument
(
'gui_class'
,
metavar
=
'GUI_KLASS'
,
help
=
'The GUI klass to launch'
)
parser
.
add_argument
(
'--port'
,
dest
=
'port'
,
default
=
5000
,
type
=
int
,
help
=
'Port number to listen to'
)
parser
.
add_argument
(
'--host'
,
dest
=
'host'
,
default
=
"localhost"
,
help
=
'Host address'
)
arguments
=
parser
.
parse_args
()
global
klass_name
klass_name
=
'dream.simulation.GUI.%s'
%
arguments
.
gui_class
# start the server
file_handler
=
logging
.
FileHandler
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'log'
,
'dream.log'
))
file_handler
.
setLevel
(
logging
.
DEBUG
)
app
.
logger
.
addHandler
(
file_handler
)
app
.
run
(
debug
=
True
)
app
.
run
(
debug
=
True
,
host
=
arguments
.
host
,
port
=
arguments
.
port
)
def
run
(
*
args
):
# run with one topology input
slmdfksfdmlj
()
args
=
args
or
sys
.
argv
[
1
:]
input_data
=
json
.
load
(
open
(
args
[
0
]))
queue
=
multiprocessing
.
Queue
()
...
...
@@ -164,5 +174,4 @@ def run(*args):
print
json
.
dumps
(
output_data
,
indent
=
True
)
if
__name__
==
"__main__"
:
main
()
main
()
\ No newline at end of file
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