#!/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# @author Laura Bieker16# @date 2011-07-221718from __future__ import absolute_import1920import os21import subprocess22import sys23sumoHome = os.path.abspath(24os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))25if "SUMO_HOME" in os.environ:26sumoHome = os.environ["SUMO_HOME"]27sys.path.append(os.path.join(sumoHome, "tools"))28import sumolib # noqa29import traci # noqa30PORT = 87653132sumoBinary = os.environ.get(33"GUISIM_BINARY", os.path.join(sumoHome, 'bin', 'sumo-gui'))34netconvertBinary = os.environ.get(35"NETCONVERT_BINARY", os.path.join(sumoHome, 'bin', 'netconvert'))3637subprocess.call([netconvertBinary, "-n", "input_nodes.nod.xml",38"-e", "input_edges.edg.xml"], stdout=sys.stdout, stderr=sys.stderr)39p = subprocess.Popen(40[sumoBinary, "-c", "sumo.sumocfg", "-v", "-S", "-Q", "--remote-port", str(PORT)],41stdout=sys.stdout, stderr=sys.stderr)42traci.init(PORT)43traci.simulationStep(200)44for i in range(10):45for j in range(10):46traci.gui.screenshot('View #0', "test_%s_%s.png" % (i, j))47traci.simulationStep()48traci.close()49p.wait()505152