#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2008-2026 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 toolrunner.py14# @author Michael Behrisch15# @author Jakob Erdmann16# @date 2008-03-291718import os19import subprocess20import sys2122if len(sys.argv) < 2:23sys.exit('required argument <tool> missing')24idx = len(sys.argv) - 125while idx > 0 and sys.argv[idx][0] == "-":26idx -= 127for i, a in enumerate(sys.argv[1:]):28if a.endswith(".py") or a.endswith(".jar"):29idx = i + 130break31tool = [os.path.join(os.path.dirname(sys.argv[0]), "..", sys.argv[idx])]32del sys.argv[idx]33if tool[0].endswith(".jar"):34tool = ["java", "-jar"] + tool3536if tool[0].endswith(".py"):37python = sys.executable38tool = ([python] + tool) if python.endswith("2") else ([python, "-Wd"] + tool)39subprocess.call(tool + sys.argv[1:], env=os.environ, stdout=sys.stdout, stderr=sys.stderr)404142