Path: blob/main/tests/complex/tutorial/output_parsing/runner.py
169685 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 2012-12-091617from __future__ import absolute_import18from __future__ import print_function192021import os22import subprocess23import sys24import shutil25sys.path.append(26os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', "tools"))27sys.path.append(os.path.join(os.environ.get("SUMO_HOME", os.path.join(28os.path.dirname(__file__), "..", "..", "..")), "tools"))29from sumolib import checkBinary # noqa303132netconvertBinary = checkBinary('netconvert')33sumoBinary = checkBinary('sumo')34# build/check network35retcode = subprocess.call(36[netconvertBinary, "-c", "data/circular.netccfg"], stdout=sys.stdout, stderr=sys.stderr)37try:38shutil.copy("data/circular.net.xml", "net.net.xml")39except IOError:40print("Missing 'circular.net.xml'")41print(">> Netbuilding closed with status %s" % retcode)42sys.stdout.flush()43# run simulation44retcode = subprocess.call(45[sumoBinary, "-c", "data/output_file.sumocfg", "--no-step-log"], stdout=sys.stdout, stderr=sys.stderr)46print(">> Simulation closed with status %s" % retcode)47sys.stdout.flush()484950