Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/buildTestNets.py
169656 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2025 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 buildTestNets.py
15
# @author Daniel Krajzewicz
16
# @author Michael Behrisch
17
# @date 2007-04-03
18
19
from __future__ import print_function
20
import os
21
import sys
22
import subprocess
23
24
mRoot = "."
25
if len(sys.argv) > 1:
26
mRoot = sys.argv[1]
27
binPrefix = os.path.join(
28
os.path.dirname(os.path.abspath(__file__)), '..', 'bin', 'net')
29
for root, dirs, files in os.walk(mRoot):
30
if ".svn" in dirs:
31
dirs.remove(".svn")
32
for file in files:
33
if file.endswith(".netccfg") or file.endswith(".netgcfg"):
34
exe = binPrefix + "generate"
35
if file.endswith(".netccfg"):
36
exe = binPrefix + "convert"
37
print("----------------------------------")
38
print("Rebuilding config: " + os.path.join(root, file))
39
sys.stdout.flush()
40
curDir = os.getcwd()
41
os.chdir(root)
42
subprocess.call([exe, "--save-configuration", file +
43
".tmp", "-c", file], stdout=sys.stdout, stderr=sys.stderr)
44
sys.stdout.flush()
45
os.remove(file)
46
os.rename(file + ".tmp", file)
47
os.chdir(curDir)
48
print("Running: " + file)
49
sys.stdout.flush()
50
subprocess.call(
51
[exe, "-v", "-c", os.path.join(root, file)], stdout=sys.stdout, stderr=sys.stderr)
52
sys.stdout.flush()
53
print("----------------------------------\n")
54
55