OLD | NEW |
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Functions specific to handle goma related info. | 5 """Functions specific to handle goma related info. |
6 """ | 6 """ |
7 | 7 |
8 import base64 | 8 import base64 |
9 import datetime | 9 import datetime |
10 import getpass | 10 import getpass |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 TIMESTAMP_PATTERN = re.compile('(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})') | 35 TIMESTAMP_PATTERN = re.compile('(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})') |
36 TIMESTAMP_FORMAT = '%Y/%m/%d %H:%M:%S' | 36 TIMESTAMP_FORMAT = '%Y/%m/%d %H:%M:%S' |
37 | 37 |
38 | 38 |
39 def GetShortHostname(): | 39 def GetShortHostname(): |
40 """Get this machine's short hostname in lower case.""" | 40 """Get this machine's short hostname in lower case.""" |
41 return socket.gethostname().split('.')[0].lower() | 41 return socket.gethostname().split('.')[0].lower() |
42 | 42 |
43 | 43 |
44 def GetGomaTmpDirectory(): | 44 def GetGomaLogDirectory(): |
45 """Get goma's temp directory.""" | 45 """Get goma's log directory.""" |
46 candidates = ['GOMA_TMP_DIR', 'TEST_TMPDIR', 'TMPDIR', 'TMP'] | 46 candidates = ['TEST_TMPDIR', 'TMPDIR', 'TMP'] |
47 for candidate in candidates: | 47 for candidate in candidates: |
48 value = os.environ.get(candidate) | 48 value = os.environ.get(candidate) |
49 if value and os.path.isdir(value): | 49 if value and os.path.isdir(value): |
50 return value | 50 return value |
51 return '/tmp' | 51 return '/tmp' |
52 | 52 |
53 | 53 |
54 def GetLatestGlogInfoFile(pattern): | 54 def GetLatestGlogInfoFile(pattern): |
55 """Get a filename of the latest google glog INFO file. | 55 """Get a filename of the latest google glog INFO file. |
56 | 56 |
57 Args: | 57 Args: |
58 pattern: a string of INFO file pattern. | 58 pattern: a string of INFO file pattern. |
59 | 59 |
60 Returns: | 60 Returns: |
61 the latest glog INFO filename in fullpath. | 61 the latest glog INFO filename in fullpath. |
62 """ | 62 """ |
63 dirname = GetGomaTmpDirectory() | 63 dirname = GetGomaLogDirectory() |
64 info_pattern = os.path.join(dirname, '%s.*.INFO.*' % pattern) | 64 info_pattern = os.path.join(dirname, '%s.*.INFO.*' % pattern) |
65 candidates = glob.glob(info_pattern) | 65 candidates = glob.glob(info_pattern) |
66 if not candidates: | 66 if not candidates: |
67 return None | 67 return None |
68 return sorted(candidates, reverse=True)[0] | 68 return sorted(candidates, reverse=True)[0] |
69 | 69 |
70 | 70 |
71 def GetLatestGomaCompilerProxyInfo(): | 71 def GetLatestGomaCompilerProxyInfo(): |
72 """Get a filename of the latest goma comiler_proxy.INFO.""" | 72 """Get a filename of the latest goma comiler_proxy.INFO.""" |
73 return GetLatestGlogInfoFile('compiler_proxy') | 73 return GetLatestGlogInfoFile('compiler_proxy') |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 retcode = chromium_utils.RunCommand( | 348 retcode = chromium_utils.RunCommand( |
349 cmd, filter_obj=cmd_filter, | 349 cmd, filter_obj=cmd_filter, |
350 max_time=30) | 350 max_time=30) |
351 if retcode: | 351 if retcode: |
352 print('Execution of send_ts_mon_values failed with code %s' | 352 print('Execution of send_ts_mon_values failed with code %s' |
353 % retcode) | 353 % retcode) |
354 print '\n'.join(cmd_filter.text) | 354 print '\n'.join(cmd_filter.text) |
355 | 355 |
356 except Exception as ex: | 356 except Exception as ex: |
357 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) | 357 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) |
OLD | NEW |