From 00646d0135aad2aa7d766decd057527999f69267 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Fri, 7 Dec 2018 16:20:31 +0100 Subject: [PATCH] Fix paths in 'configurator' module --- configurator/__init__.py | 1 + .../configurator.py | 17 ++++++++++------- .../static/simul.netcfg | 0 .../static/simul.polycfg | 0 .../static/simul.raw.osm | 0 .../static/simul.sumocfg | 0 .../typemap/osmBidiRailNetconvert.typ.xml | 0 .../static/typemap/osmNetconvert.typ.xml | 0 .../static/typemap/osmNetconvertBicycle.typ.xml | 0 .../typemap/osmNetconvertPedestrians.typ.xml | 0 .../static/typemap/osmNetconvertShips.typ.xml | 0 .../static/typemap/osmNetconvertUrbanDe.typ.xml | 0 .../typemap/osmPolyconvert.boundaries.typ.xml | 0 .../static/typemap/osmPolyconvert.typ.xml | 0 sumo-configurator/__init__.py | 0 15 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 configurator/__init__.py rename {sumo-configurator => configurator}/configurator.py (68%) rename {sumo-configurator => configurator}/static/simul.netcfg (100%) rename {sumo-configurator => configurator}/static/simul.polycfg (100%) rename {sumo-configurator => configurator}/static/simul.raw.osm (100%) rename {sumo-configurator => configurator}/static/simul.sumocfg (100%) rename {sumo-configurator => configurator}/static/typemap/osmBidiRailNetconvert.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmNetconvert.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmNetconvertBicycle.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmNetconvertPedestrians.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmNetconvertShips.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmNetconvertUrbanDe.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmPolyconvert.boundaries.typ.xml (100%) rename {sumo-configurator => configurator}/static/typemap/osmPolyconvert.typ.xml (100%) delete mode 100644 sumo-configurator/__init__.py diff --git a/configurator/__init__.py b/configurator/__init__.py new file mode 100644 index 0000000..7aff21c --- /dev/null +++ b/configurator/__init__.py @@ -0,0 +1 @@ +from .configurator import * \ No newline at end of file diff --git a/sumo-configurator/configurator.py b/configurator/configurator.py similarity index 68% rename from sumo-configurator/configurator.py rename to configurator/configurator.py index 6493945..be54271 100644 --- a/sumo-configurator/configurator.py +++ b/configurator/configurator.py @@ -5,9 +5,12 @@ import subprocess import randomTrips +# Absolute path of the directory the script is in +SCRIPTDIR = os.path.dirname(__file__) +STATICDIR = os.path.join(SCRIPTDIR, 'static') SIMNAME = 'simul' -NETCONVERTCMD = ['netconvert', '-c', f'static/{SIMNAME}.netcfg'] -POLYCONVERTCMD = ['polyconvert', '-c', f'static/{SIMNAME}.polycfg'] +NETCONVERTCMD = ['netconvert', '-c', os.path.join(STATICDIR, f'{SIMNAME}.netcfg')] +POLYCONVERTCMD = ['polyconvert', '-c', os.path.join(STATICDIR, f'{SIMNAME}.polycfg')] def clean(): @@ -22,15 +25,15 @@ def generate_scenario(out_path, name): print('Extracting polygons…') subprocess.run(POLYCONVERTCMD) print('Moving files') - shutil.move('static/simul.net.xml', os.path.join(out_path, f'{name}.net.xml')) - shutil.move('static/simul.poly.xml', os.path.join(out_path, f'{name}.poly.xml')) - shutil.copyfile('static/simul.sumocfg', os.path.join(out_path, f'{name}.sumocfg')) + shutil.move(os.path.join(STATICDIR, 'simul.net.xml'), os.path.join(out_path, f'{name}.net.xml')) + shutil.move(os.path.join(STATICDIR, 'simul.poly.xml'), os.path.join(out_path, f'{name}.poly.xml')) + shutil.copyfile(os.path.join(STATICDIR, 'simul.sumocfg'), os.path.join(out_path, f'{name}.sumocfg')) # Move log files logdir = os.path.join(out_path, 'log') os.mkdir(logdir) - for f in os.listdir('static'): + for f in os.listdir(STATICDIR): if f.endswith('.log'): - shutil.move(os.path.join('static', f), os.path.join(logdir, f)) + shutil.move(os.path.join(STATICDIR, f), os.path.join(logdir, f)) def generate_mobility(path, name): diff --git a/sumo-configurator/static/simul.netcfg b/configurator/static/simul.netcfg similarity index 100% rename from sumo-configurator/static/simul.netcfg rename to configurator/static/simul.netcfg diff --git a/sumo-configurator/static/simul.polycfg b/configurator/static/simul.polycfg similarity index 100% rename from sumo-configurator/static/simul.polycfg rename to configurator/static/simul.polycfg diff --git a/sumo-configurator/static/simul.raw.osm b/configurator/static/simul.raw.osm similarity index 100% rename from sumo-configurator/static/simul.raw.osm rename to configurator/static/simul.raw.osm diff --git a/sumo-configurator/static/simul.sumocfg b/configurator/static/simul.sumocfg similarity index 100% rename from sumo-configurator/static/simul.sumocfg rename to configurator/static/simul.sumocfg diff --git a/sumo-configurator/static/typemap/osmBidiRailNetconvert.typ.xml b/configurator/static/typemap/osmBidiRailNetconvert.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmBidiRailNetconvert.typ.xml rename to configurator/static/typemap/osmBidiRailNetconvert.typ.xml diff --git a/sumo-configurator/static/typemap/osmNetconvert.typ.xml b/configurator/static/typemap/osmNetconvert.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmNetconvert.typ.xml rename to configurator/static/typemap/osmNetconvert.typ.xml diff --git a/sumo-configurator/static/typemap/osmNetconvertBicycle.typ.xml b/configurator/static/typemap/osmNetconvertBicycle.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmNetconvertBicycle.typ.xml rename to configurator/static/typemap/osmNetconvertBicycle.typ.xml diff --git a/sumo-configurator/static/typemap/osmNetconvertPedestrians.typ.xml b/configurator/static/typemap/osmNetconvertPedestrians.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmNetconvertPedestrians.typ.xml rename to configurator/static/typemap/osmNetconvertPedestrians.typ.xml diff --git a/sumo-configurator/static/typemap/osmNetconvertShips.typ.xml b/configurator/static/typemap/osmNetconvertShips.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmNetconvertShips.typ.xml rename to configurator/static/typemap/osmNetconvertShips.typ.xml diff --git a/sumo-configurator/static/typemap/osmNetconvertUrbanDe.typ.xml b/configurator/static/typemap/osmNetconvertUrbanDe.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmNetconvertUrbanDe.typ.xml rename to configurator/static/typemap/osmNetconvertUrbanDe.typ.xml diff --git a/sumo-configurator/static/typemap/osmPolyconvert.boundaries.typ.xml b/configurator/static/typemap/osmPolyconvert.boundaries.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmPolyconvert.boundaries.typ.xml rename to configurator/static/typemap/osmPolyconvert.boundaries.typ.xml diff --git a/sumo-configurator/static/typemap/osmPolyconvert.typ.xml b/configurator/static/typemap/osmPolyconvert.typ.xml similarity index 100% rename from sumo-configurator/static/typemap/osmPolyconvert.typ.xml rename to configurator/static/typemap/osmPolyconvert.typ.xml diff --git a/sumo-configurator/__init__.py b/sumo-configurator/__init__.py deleted file mode 100644 index e69de29..0000000