Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/toolrunner.py
428236 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2026 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file toolrunner.py
15
# @author Michael Behrisch
16
# @author Jakob Erdmann
17
# @date 2008-03-29
18
19
import os
20
import subprocess
21
import sys
22
23
if len(sys.argv) < 2:
24
sys.exit('required argument <tool> missing')
25
idx = len(sys.argv) - 1
26
while idx > 0 and sys.argv[idx][0] == "-":
27
idx -= 1
28
for i, a in enumerate(sys.argv[1:]):
29
if a.endswith(".py") or a.endswith(".jar"):
30
idx = i + 1
31
break
32
tool = [os.path.join(os.path.dirname(sys.argv[0]), "..", sys.argv[idx])]
33
del sys.argv[idx]
34
if tool[0].endswith(".jar"):
35
tool = ["java", "-jar"] + tool
36
37
if tool[0].endswith(".py"):
38
python = sys.executable
39
tool = ([python] + tool) if python.endswith("2") else ([python, "-Wd"] + tool)
40
subprocess.call(tool + sys.argv[1:], env=os.environ, stdout=sys.stdout, stderr=sys.stderr)
41
42