Changeset View
Changeset View
Standalone View
Standalone View
lnt/testing/profile/profile.py
Show All 21 Lines | class Profile(object): | ||||
@staticmethod | @staticmethod | ||||
def fromFile(f): | def fromFile(f): | ||||
""" | """ | ||||
Load a profile from a file. | Load a profile from a file. | ||||
""" | """ | ||||
for impl in lnt.testing.profile.IMPLEMENTATIONS.values(): | for impl in lnt.testing.profile.IMPLEMENTATIONS.values(): | ||||
if impl.checkFile(f): | if impl.checkFile(f): | ||||
ret = impl.deserialize(open(f, 'rb')) | ret = None | ||||
with open(f, 'rb') as fd: | |||||
if impl is lnt.testing.profile.perf.LinuxPerfProfile: | |||||
ret = impl.deserialize(fd, | |||||
nm = os.getenv('CMAKE_NM', 'nm'), | |||||
objdump = os.getenv('CMAKE_OBJDUMP', 'objdump'), | |||||
binaryCacheRoot = os.getenv('LNT_BINARY_CACHE_ROOT', '')) | |||||
thopre: This will set the parameters to None (and thus override the default values of the parameter)… | |||||
import os def prn(x): print(x) prn(x = os.getenv('MISSING_VAR', 'abc')) Output: abc slydiman: ```
import os
def prn(x):
print(x)
prn(x = os.getenv('MISSING_VAR', 'abc'))
```
Output… | |||||
Nothing, I missed something: the second parameter of getenv. thopre: Nothing, **I** missed something: the second parameter of getenv. | |||||
Not Done ReplyInline Actionsthis patch was actually tested in production setup, so it works at least on some platforms. yakush: this patch was actually tested in production setup, so it works at least on some platforms. | |||||
else: | |||||
ret = impl.deserialize(fd) | |||||
if ret: | if ret: | ||||
return Profile(ret) | return Profile(ret) | ||||
else: | else: | ||||
return None | return None | ||||
raise RuntimeError('No profile implementations could read this file!') | raise RuntimeError('No profile implementations could read this file!') | ||||
@staticmethod | @staticmethod | ||||
def fromRendered(s): | def fromRendered(s): | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |
This will set the parameters to None (and thus override the default values of the parameter) when the environment variables are not set. I don't think this is what you meant.