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

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

Issue 3541002: Revert "Merge remote branch 'cros/upstream' into tempbranch2" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/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 # these statuses are ordered such that a status earlier in the list will 3
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)
6 job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT", 4 job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT",
7 "RUNNING", "NOSTATUS"] 5 "RUNNING", "NOSTATUS"]
8 6
9 def is_valid_status(status): 7 def is_valid_status(status):
10 if not re.match(r'(START|INFO|(END )?(' + '|'.join(job_statuses) + '))$', 8 if not re.match(r'(START|INFO|(END )?('+'|'.join(job_statuses)+'))$',
11 status): 9 status):
12 return False 10 return False
13 else: 11 else:
14 return True 12 return True
15 13
16 14
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
27 def record(fn): 15 def record(fn):
28 """ 16 """
29 Generic method decorator for logging calls under the 17 Generic method decorator for logging calls under the
30 assumption that return=GOOD, exception=FAIL. The method 18 assumption that return=GOOD, exception=FAIL. The method
31 determines parameters as: 19 determines parameters as:
32 subdir = self.subdir if it exists, or None 20 subdir = self.subdir if it exists, or None
33 operation = "class name"."method name" 21 operation = "class name"."method name"
34 status = None on GOOD, str(exception) on FAIL 22 status = None on GOOD, str(exception) on FAIL
35 The object using this method must have a job attribute 23 The object using this method must have a job attribute
36 for the logging to actually occur, otherwise the logging 24 for the logging to actually occur, otherwise the logging
(...skipping 29 matching lines...) Expand all
66 try-except block. """ 54 try-except block. """
67 def decorator(fn): 55 def decorator(fn):
68 def decorated_func(*args, **dargs): 56 def decorated_func(*args, **dargs):
69 try: 57 try:
70 fn(*args, **dargs) 58 fn(*args, **dargs)
71 except Exception: 59 except Exception:
72 print msg 60 print msg
73 traceback.print_exc(file=sys.stdout) 61 traceback.print_exc(file=sys.stdout)
74 return decorated_func 62 return decorated_func
75 return decorator 63 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