|
1 | | -#!/usr/bin/python |
| 1 | +#!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | # A script to update gazebo models to be web-friendly. |
4 | 4 | # It converts all textures to png format and make sure they are |
|
56 | 56 |
|
57 | 57 | if texture_dir != dest_dir: |
58 | 58 | cmd = ['mv', dest_path, texture_dir] |
59 | | - print cmd |
| 59 | + print(cmd) |
60 | 60 | subprocess.check_call(cmd) |
61 | 61 |
|
62 | 62 | # update texture path in dae files |
63 | 63 | if format.lower() in ['dae']: |
64 | 64 | sed_cmd = ["sed", "-i", "-e", |
65 | 65 | 's/\(\.tga\|\.tiff\|\.tif\|\.jpg\|\.jpeg\|\.gif\)/\.png/g', file] |
66 | | - print sed_cmd |
| 66 | + print(sed_cmd) |
67 | 67 | subprocess.check_call(sed_cmd) |
68 | 68 |
|
69 | 69 | # find relatvie path to texture dir |
|
79 | 79 | # replace dae file png references to texture path |
80 | 80 | sed_cmd = ["sed", "-i","-e", |
81 | 81 | 's/\(>\)\(.*\/\)\(.*\.png\)/\\1'+ relative_path + 'materials\/textures\/\\3/g', file] |
82 | | - print sed_cmd |
| 82 | + print(sed_cmd) |
83 | 83 | subprocess.check_call(sed_cmd) |
84 | 84 |
|
85 | 85 | sed_cmd = ["sed", "-i","-e", |
86 | 86 | '/[a-zA-Z0-9_\.\/\-]\+materials\/textures/!s/\([a-zA-Z0-9_\-]\+\)\(\.png\W\)/'+ relative_path + 'materials\/textures\/\\1\\2/g', file] |
87 | 87 |
|
88 | | - print sed_cmd |
| 88 | + print(sed_cmd) |
89 | 89 | subprocess.check_call(sed_cmd) |
90 | 90 |
|
91 | 91 | if format.lower() in ['material', 'txt', 'sdf']: |
92 | 92 | sed_cmd = ["sed", "-i", "-e", |
93 | 93 | 's/\(\.tga\|\.tiff\|\.tif\|\.jpg\|\.jpeg\|\.gif\)/\.png/g', file] |
94 | | - print sed_cmd |
| 94 | + print(sed_cmd) |
95 | 95 | subprocess.check_call(sed_cmd) |
96 | 96 |
|
97 | | - except Exception, e: |
98 | | - print "error %s" % e |
| 97 | + except Exception as e: |
| 98 | + print("error %s" % e) |
99 | 99 | raise |
0 commit comments