Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: client/common_lib/log.py

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/bin/partition.py ('k') | client/common_lib/revision_control.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys, re, traceback 1 import sys, re, traceback
2 2
3 3 # these statuses are ordered such that a status earlier in the list will
4 # override a status later in a list (e.g. ERROR during a test will override
5 # prior GOOD results, but WARN will not override a FAIL)
4 job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT", 6 job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT",
5 "RUNNING", "NOSTATUS"] 7 "RUNNING", "NOSTATUS"]
6 8
7 def is_valid_status(status): 9 def is_valid_status(status):
8 if not re.match(r'(START|INFO|(END )?('+'|'.join(job_statuses)+'))$', 10 if not re.match(r'(START|INFO|(END )?(' + '|'.join(job_statuses) + '))$',
9 status): 11 status):
10 return False 12 return False
11 else: 13 else:
12 return True 14 return True
13 15
14 16
17 def is_failure(status):
18 if not is_valid_status(status):
19 return False
20 if status in ('START', 'INFO'):
21 return False
22 if status.startswith('END '):
23 status = status[len('END '):]
24 return job_statuses.index(status) <= job_statuses.index("FAIL")
25
26
15 def record(fn): 27 def record(fn):
16 """ 28 """
17 Generic method decorator for logging calls under the 29 Generic method decorator for logging calls under the
18 assumption that return=GOOD, exception=FAIL. The method 30 assumption that return=GOOD, exception=FAIL. The method
19 determines parameters as: 31 determines parameters as:
20 subdir = self.subdir if it exists, or None 32 subdir = self.subdir if it exists, or None
21 operation = "class name"."method name" 33 operation = "class name"."method name"
22 status = None on GOOD, str(exception) on FAIL 34 status = None on GOOD, str(exception) on FAIL
23 The object using this method must have a job attribute 35 The object using this method must have a job attribute
24 for the logging to actually occur, otherwise the logging 36 for the logging to actually occur, otherwise the logging
(...skipping 29 matching lines...) Expand all
54 try-except block. """ 66 try-except block. """
55 def decorator(fn): 67 def decorator(fn):
56 def decorated_func(*args, **dargs): 68 def decorated_func(*args, **dargs):
57 try: 69 try:
58 fn(*args, **dargs) 70 fn(*args, **dargs)
59 except Exception: 71 except Exception:
60 print msg 72 print msg
61 traceback.print_exc(file=sys.stdout) 73 traceback.print_exc(file=sys.stdout)
62 return decorated_func 74 return decorated_func
63 return decorator 75 return decorator
OLDNEW
« no previous file with comments | « client/bin/partition.py ('k') | client/common_lib/revision_control.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698