Changeset 25100
- Timestamp:
- 06/22/20 11:39:17 (5 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/coordsystems/epsg2proj.py
r25050 r25100 15 15 16 16 TODO: 17 - Implement try/catch for proc.communicate()17 - Implement try/catch for subproc.communicate() 18 18 - In case of Python 2, except socket.timeout: https://docs.python.org/3/library/socket.html?highlight=socket%20timeout#socket.timeout 19 19 - In case of Python 3, except TimeoutExpired: https://docs.python.org/3/library/subprocess.html#subprocess.SubprocessError … … 21 21 22 22 #First, get GDAL version 23 args = "gdalsrsinfo --version | awk '{print $2}' | cut -d '.' -f1"24 proc = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)25 outs, errs = proc.communicate()23 subproc_args = "gdalsrsinfo --version | awk '{print $2}' | cut -d '.' -f1" 24 subproc = subprocess.Popen(subproc_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 25 outs, errs = subproc.communicate() 26 26 if errs != '': 27 27 raise RuntimeError("epsg2proj: call to gdalsrsinfo failed: {}".format(errs)) … … 29 29 version_major=int(outs) 30 30 31 args = "gdalsrsinfo epsg:{} | grep PROJ.4 | tr -d '\n' | sed 's/PROJ.4 : //'".format(epsg)32 proc = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)33 outs, errs =proc.communicate()34 if errs != '':35 raise RuntimeError("epsg2proj: call to gdalsrsinfo failed: {}".format(errs))31 subproc_args = "gdalsrsinfo epsg:{} | grep PROJ.4 | tr -d '\n' | sed 's/PROJ.4 : //'".format(epsg) 32 subproc = subprocess.Popen(subproc_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 33 outs, errs = subproc.communicate() 34 if errs != '': 35 raise RuntimeError("epsg2proj: call to gdalsrsinfo failed: {}".format(errs)) 36 36 37 37 if version_major == 1: -
issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py
r25099 r25100 26 26 27 27 # Get Gmsh version 28 args = "gmsh -info | grep 'Version' | sed -e 's/Version[[:blank:]]*:[[:blank:]]//' | cut -d '.' -f1"29 proc = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)30 outs, errs = proc.communicate()28 subproc_args = "gmsh -info | grep 'Version' | sed -e 's/Version[[:blank:]]*:[[:blank:]]//' | cut -d '.' -f1" 29 subproc = subprocess.Popen(subproc_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 30 outs, errs = subproc.communicate() 31 31 if errs != '': 32 32 raise Exception("gmshplanet: call to gmsh failed: {}".format(errs)) 33 33 gmshmajorversion = int(outs) 34 34 if gmshmajorversion not in [3, 4]: 35 raise RuntimeError("gmshplanet: Gmsh major version {} not supported!".format( 35 raise RuntimeError("gmshplanet: Gmsh major version {} not supported!".format(gmshmajorversion)) 36 36 37 37 #process options
Note:
See TracChangeset
for help on using the changeset viewer.