Commit e11276c1 authored by carlos's avatar carlos

python 3 migration

parent 0e0b70b8
......@@ -291,7 +291,7 @@ To write additional tests, create a directory under *Utest/*.
- run the script `makeini.py` with the obligatory option `-f`: Using the
aforementioned example the call is:
```bash
python makeini.py -f test_case1/inifile.xml
python3 makeini.py -f test_case1/inifile.xml
```
The Script is going to create two directories:
......@@ -305,7 +305,7 @@ The Script is going to create two directories:
Your script has to start with the following lines:
```python
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
from sys import *
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
- 100 peds distributed in a room with 2 exits:
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
- 100 peds distributed in a room with 2 exits:
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
- 6 peds distributed in a room with 2 exits:
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
# help: python makeini.py -h
# help: python3 makeini.py -h
import os, sys, glob
from shutil import copy2, rmtree, move
import logging, types, argparse
import errno, time
from numpy import *
from itertools import product, izip
from itertools import product
try:
import xml.etree.cElementTree as ET
except ImportError:
......@@ -112,7 +112,7 @@ def get_attribute(node):
text = ''
values = []
for node_attrib in node.attrib.keys():
for node_attrib in list(node.attrib.keys()):
if node_attrib in attributes:
text = node.attrib[node_attrib]
if text:
......@@ -146,7 +146,7 @@ def get_product(root):
d = get_tag(node)
if isinstance(d, list) or isinstance(d, ndarray):
# in case some tags have multiple values
if not input_tags.has_key(tag) and len(d) > 1:
if tag not in input_tags and len(d) > 1:
# ignore lists with one element (equiv to scalars)
# if tag in tags:
input_tags[tag] = d
......@@ -160,7 +160,7 @@ def get_product(root):
else:
continue
result_prod = [dict(izip(input_tags, x)) for x in product(*input_tags.itervalues())]
result_prod = [dict(zip(input_tags, x)) for x in product(*iter(input_tags.values()))]
# print "result", result_prod
# raw_input()
return result_prod
......@@ -168,7 +168,7 @@ def get_product(root):
def make_filename(directory, d):
name = "%s/inifiles/ini"%directory
traj = "../trajectories/traj" #%directory
for key, value in d.iteritems():
for key, value in d.items():
if key == "geometry":
value = os.path.basename(value)
# if key == "num_threads":
......@@ -193,7 +193,7 @@ def update_attrib_value(root, attr_tag, value):
# raw_input()
if attr_tag == "location": # e.g. location
for r in root.iter():
if r.attrib.has_key(attr_tag):
if attr_tag in r.attrib:
r.attrib[attr_tag] = str(value)
return
......@@ -201,7 +201,7 @@ def update_attrib_value(root, attr_tag, value):
cor_tag = attr_tag.split("-")[0]
for r in root.iter(cor_tag):
if r.attrib.has_key(attr):
if attr in r.attrib:
r.attrib[attr] = str(value)
# =======================================================
def make_file(masterfile, tree, result):
......@@ -219,7 +219,7 @@ def make_file(masterfile, tree, result):
if not os.path.isfile(newfile):
logging.error("make_file: could not create file %s"%newfile)
sys.exit(FAILURE)
for tag, value in item.iteritems():
for tag, value in item.items():
# print "tag: ", tag, "value:", value
# raw_input()
if tag in attributes_tags:
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test Description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test Description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Test description
================
......
......@@ -166,7 +166,7 @@ ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
IF(NOT PYTHON_EXECUTABLE)
MESSAGE(FATAL_ERROR "Python not found! Aborting...")
MESSAGE(FATAL_ERROR "Python 3 not found! Aborting...")
ENDIF() # NOT PYTHON_EXECUTABLE
IF(NOT GCOVR_PATH)
......
#!/usr/bin/python
#!/usr/bin/env python3
import re
UP = 103
......
#!/usr/bin/python
#!/usr/bin/env python3
# make some new ini-files based on the file <ini-Bottleneck.xml>
# so first make changes in <ini-Bottleneck.xml> and then spread them with this script to the world
......
#!/usr/bin/python
#!/usr/bin/env python3
import numpy as np
from xml.dom import minidom
import os, argparse, logging, time
......@@ -100,7 +100,7 @@ if __name__ == "__main__":
widths = [0.8, 0.9, 1.0, 1.1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.3, 2.5]
flows = []
if MAKE_INI:
sh("python makeBottleneckInifile.py")
sh("python3 makeBottleneckInifile.py")
for w in widths:
#------------------------------------------------------------------------------
......
......@@ -8,11 +8,11 @@ import os, time
from pylab import Rectangle
if len(argv)<=2:
print "usage: %s, filename geometryfile"%argv[0]
print("usage: %s, filename geometryfile"%argv[0])
exit()
from itertools import product, izip
from itertools import product
try:
import xml.etree.cElementTree as ET
except ImportError:
......@@ -138,7 +138,7 @@ def plotFrame(i, t, data, geometry):
plt.title("t=%.3f"%t)
fig.savefig("figs_bot/%.4d.png"%i)
plt.clf()
print "---> figs_bot/%.4d.png"%i
print("---> figs_bot/%.4d.png"%i)
if __name__ == "__main__":
......@@ -157,7 +157,7 @@ if __name__ == "__main__":
i += 1
if Movie:
cmd = "\"mf://figs_bot/*.png\" -mf w=800:h=600:fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o output.avi"
print "Mencoder ---- "
print("Mencoder ---- ")
os.system("mencoder %s" %cmd)
MPlayer= "mplayer output.avi"
os.system("%s" %MPlayer)
......
from itertools import product, izip
from itertools import product
try:
import xml.etree.cElementTree as ET
except ImportError:
......@@ -16,10 +16,10 @@ logging.basicConfig(filename=logfile, level=logging.INFO, format='%(asctime)s -
g = open("geometry.txt", "w")
def usage():
print "usage: python %s geometry_file trajectory_file"%sys.argv[0]
print "This will create two files:\
\n \t- Trajectories ---> b090_combined.txt \n \t- and geometry ---> geometry.txt"
print "mv geometry.txt b090_combined.txt to the location where SumoVizUnity leaves"
print("usage: python3 %s geometry_file trajectory_file"%sys.argv[0])
print("This will create two files:\
\n \t- Trajectories ---> b090_combined.txt \n \t- and geometry ---> geometry.txt")
print("mv geometry.txt b090_combined.txt to the location where SumoVizUnity leaves")
def parse_trajectories(filename):
......@@ -70,11 +70,11 @@ def get_polygon(poly):
return X, Y
def write_polygon(X, Y, Type, name, height):
print >>g, "Polygon",
print("Polygon", end=' ', file=g)
for (x, y) in zip(X, Y):
print >>g, "%.1f %.1f"%(float(x), float(y)),
print("%.1f %.1f"%(float(x), float(y)), end=' ', file=g)
print >>g, "%s %s %.2f"%(name, Type, height)
print("%s %s %.2f"%(name, Type, height), file=g)
def setMinMax(X, Y, minX, maxX, minY, maxY):
......@@ -123,8 +123,8 @@ def parse_geometry(filename):
# some trees
dx = 5
dy = 5
print >>g, "Polygon %.1f %.1f t1 tree 1.0"%(minX-dx, minY-dy)
print >>g, "Polygon %.1f %.1f t3 tree 1.0"%(maxX+dx, maxY+dy)
print("Polygon %.1f %.1f t1 tree 1.0"%(minX-dx, minY-dy), file=g)
print("Polygon %.1f %.1f t3 tree 1.0"%(maxX+dx, maxY+dy), file=g)
if __name__ == "__main__":
if len(sys.argv) <= 2:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment