__init__.py (12563:8d59ed22ae79) __init__.py (13663:9b64aeabf9a5)
1# Copyright (c) 2016 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 114 unchanged lines hidden (view full) ---

123 returns -1, 0, 1 if v1 is <, ==, > v2
124 """
125 def make_version_list(v):
126 if isinstance(v, (list,tuple)):
127 return v
128 elif isinstance(v, str):
129 return map(lambda x: int(re.match('\d+', x).group()), v.split('.'))
130 else:
1# Copyright (c) 2016 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 114 unchanged lines hidden (view full) ---

123 returns -1, 0, 1 if v1 is <, ==, > v2
124 """
125 def make_version_list(v):
126 if isinstance(v, (list,tuple)):
127 return v
128 elif isinstance(v, str):
129 return map(lambda x: int(re.match('\d+', x).group()), v.split('.'))
130 else:
131 raise TypeError
131 raise TypeError()
132
133 v1 = make_version_list(v1)
134 v2 = make_version_list(v2)
135 # Compare corresponding elements of lists
136 for n1,n2 in zip(v1, v2):
137 if n1 < n2: return -1
138 if n1 > n2: return 1
139 # all corresponding values are equal... see if one has extra values

--- 49 unchanged lines hidden (view full) ---

189 exception = kwargs.pop('exception', None)
190
191 kwargs.setdefault('shell', False)
192 kwargs.setdefault('stdout', PIPE)
193 kwargs.setdefault('stderr', STDOUT)
194 kwargs.setdefault('close_fds', True)
195 try:
196 subp = Popen(cmd, **kwargs)
132
133 v1 = make_version_list(v1)
134 v2 = make_version_list(v2)
135 # Compare corresponding elements of lists
136 for n1,n2 in zip(v1, v2):
137 if n1 < n2: return -1
138 if n1 > n2: return 1
139 # all corresponding values are equal... see if one has extra values

--- 49 unchanged lines hidden (view full) ---

189 exception = kwargs.pop('exception', None)
190
191 kwargs.setdefault('shell', False)
192 kwargs.setdefault('stdout', PIPE)
193 kwargs.setdefault('stderr', STDOUT)
194 kwargs.setdefault('close_fds', True)
195 try:
196 subp = Popen(cmd, **kwargs)
197 except Exception, e:
197 except Exception as e:
198 if no_exception:
199 return exception
200 raise
201
202 return subp.communicate()[0]
203
204def makeDir(path):
205 """Make a directory if it doesn't exist. If the path does exist,
206 ensure that it is a directory"""
207 if os.path.exists(path):
208 if not os.path.isdir(path):
198 if no_exception:
199 return exception
200 raise
201
202 return subp.communicate()[0]
203
204def makeDir(path):
205 """Make a directory if it doesn't exist. If the path does exist,
206 ensure that it is a directory"""
207 if os.path.exists(path):
208 if not os.path.isdir(path):
209 raise AttributeError, "%s exists but is not directory" % path
209 raise AttributeError("%s exists but is not directory" % path)
210 else:
211 os.mkdir(path)
212
213def isInteractive():
214 """Check if the simulator is run interactively or in a batch environment"""
215
216 return sys.__stdin__.isatty()
210 else:
211 os.mkdir(path)
212
213def isInteractive():
214 """Check if the simulator is run interactively or in a batch environment"""
215
216 return sys.__stdin__.isatty()