Skip to content

Commit 9069a0a

Browse files
committed
improve version matching; support stderr and stdout as output for version info
1 parent 8fa5b48 commit 9069a0a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/cdo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ def operator_doc(tool, path2cdo):
6969

7070
# some helper functions without side effects {{{
7171
def getCdoVersion(path2cdo, verbose=False):
72-
proc = subprocess.Popen([path2cdo, '-V'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
72+
proc = subprocess.Popen([path2cdo, '-V', '2>&1'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
7373
ret = proc.communicate()
74-
cdo_help = ret[1].decode("utf-8")
74+
cdo_help = ret[0].decode("utf-8")
7575
if verbose:
7676
return cdo_help
77-
match = re.search("Climate Data Operators version (\d.*) .*", cdo_help)
77+
match = re.search("Climate Data Operators version (\d+\.\d+(\.\d+)*) .*", cdo_help)
7878
return match.group(1)
7979

8080
def setupLogging(logFile):
@@ -208,6 +208,7 @@ def __get__(self, instance, owner):
208208
if name in self.AliasOperators.keys() and \
209209
( parse_version(getCdoVersion(self.CDO)) < parse_version('1.9.7') ):
210210
name = self.AliasOperators[name]
211+
211212
return self.__class__(
212213
instance.CDO,
213214
instance.returnNoneOnError,

0 commit comments

Comments
 (0)