From f741e76454c24ac93523686385bb60f4c5d216d1 Mon Sep 17 00:00:00 2001 From: Ahp06 Date: Wed, 6 Feb 2019 16:29:43 +0100 Subject: [PATCH] Changed files structure --- sumo_project/config.py | 3 ++- sumo_project/data.py | 2 +- sumo_project/runner.py | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sumo_project/config.py b/sumo_project/config.py index de879fa..aa11e9e 100644 --- a/sumo_project/config.py +++ b/sumo_project/config.py @@ -85,7 +85,8 @@ class Config: :param simulation_dir: The path to the simulation directory :return: """ - simdir = f'files/simulations/{simulation_dir}/' + simdir = os.path.join(os.path.dirname(__file__),f'{simulation_dir}') + for f in os.listdir(simdir): if f.endswith('.sumocfg'): self._SUMOCFG = os.path.join(simdir, f) diff --git a/sumo_project/data.py b/sumo_project/data.py index 6563403..f165bac 100644 --- a/sumo_project/data.py +++ b/sumo_project/data.py @@ -112,7 +112,7 @@ class Data: :param dump_name: The name of your data dump :return: """ - dump_dir = 'files/dump' + dump_dir = f'{self.dir}/dump' if not os.path.exists(dump_dir): os.mkdir(dump_dir) diff --git a/sumo_project/runner.py b/sumo_project/runner.py index 0c1cb19..df6e9e2 100644 --- a/sumo_project/runner.py +++ b/sumo_project/runner.py @@ -61,12 +61,14 @@ class RunProcess(multiprocessing.Process): """ now = datetime.datetime.now() current_date = now.strftime("%Y_%m_%d_%H_%M_%S") - - if not os.path.exists('files/logs'): - os.makedirs('logs') + + logdir = os.path.join(os.path.dirname(__file__), f'{self.data.dir}') + + if not os.path.exists(logdir): + os.makedirs(f'logs') conf_name = self.config.config_filename.replace('.json', '') - log_filename = f'files/logs/{self.data.dump_name}_{conf_name}_{current_date}.log' + log_filename = f'{self.data.dir}/logs/{current_date}.log' self.logger = logging.getLogger(f'{self.data.dir}_{conf_name}') self.logger.setLevel(logging.INFO) @@ -188,7 +190,7 @@ def create_dump(dump_name, simulation_dir, areas_number): traci.start(sumo_cmd) - if not os.path.isfile(f'files/dump/{dump_name}.json'): + if not os.path.isfile(f'{simulation_dir}/dump/{dump_name}.json'): start = time.perf_counter() data = Data(dump_name, traci.simulation.getNetBoundary(), areas_number, simulation_dir) data.init_grid()