Path: blob/main/tests/complex/sumo-gui/stateReplay/runner.py
169686 views
#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file runner.py14# @author Michael Behrisch15# @date 2023-01-081617from __future__ import absolute_import18from __future__ import print_function19import os20import subprocess21import sys22import time23sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))24import sumolib # noqa25import traci # noqa262728sumoBinary = sumolib.checkBinary("sumo")29os.mkdir("src")30traci.start([sumoBinary, "--no-step-log", "--no-duration-log", "-n", "input_net.net.xml",31"-r", "input_routes.rou.xml", "--save-state.period", "1", "--output-prefix", "src/"])32replay = subprocess.Popen([sys.executable, os.path.join(os.environ["SUMO_HOME"], "tools", "stateReplay.py"),33"--src", "src/", "--iterations", "10"])34for _ in range(10):35traci.simulationStep()36time.sleep(1)37traci.close()38replay.wait()394041