Only write a job keyval out if there isn't already a keyval with
"job_started" in it. This way we don't stomp all over any existing
values when doing secondary follow-up jobs like crashinfo collection.
Risk: Low
Visibility: Prevents secondary jobs from overwriting the keyvals of
the primary job.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3024 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 36a0689..106fa2c 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -161,16 +161,17 @@
if os.path.isdir(path):
path = os.path.join(path, 'keyval')
keyval = {}
- for line in open(path):
- line = re.sub('#.*', '', line).rstrip()
- if not re.search(r'^[-\.\w]+=', line):
- raise ValueError('Invalid format line: %s' % line)
- key, value = line.split('=', 1)
- if re.search('^\d+$', value):
- value = int(value)
- elif re.search('^(\d+\.)?\d+$', value):
- value = float(value)
- keyval[key] = value
+ if os.path.exists(path):
+ for line in open(path):
+ line = re.sub('#.*', '', line).rstrip()
+ if not re.search(r'^[-\.\w]+=', line):
+ raise ValueError('Invalid format line: %s' % line)
+ key, value = line.split('=', 1)
+ if re.search('^\d+$', value):
+ value = int(value)
+ elif re.search('^(\d+\.)?\d+$', value):
+ value = float(value)
+ keyval[key] = value
return keyval