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 25 matching lines...) Expand all Loading... | |
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 GetGomaTmpDirectory(): |
45 """Get goma's temp directory.""" | 45 """Get goma's temp directory.""" |
46 candidates = ['GOMA_TMP_DIR', 'TEST_TMPDIR', 'TMPDIR', 'TMP'] | 46 candidates = ['GOMA_TMP_DIR', 'TEST_TMPDIR', 'TMPDIR', 'TMP'] |
ukai
2016/08/15 06:40:45
GOMA_TMP_DIR, GLOG_log_dir, ..
if it matches with
tikuta
2016/08/15 08:35:28
Removed GOMA_TMP_DIR that is not used for *.INFO f
| |
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 for dirname in [os.environ.get('GLOG_log_dir'), |
64 info_pattern = os.path.join(dirname, '%s.*.INFO.*' % pattern) | 64 GetGomaTmpDirectory()]: |
65 candidates = glob.glob(info_pattern) | 65 if not dirname: |
66 if not candidates: | 66 continue |
67 return None | 67 info_pattern = os.path.join(dirname, '%s.*.INFO.*' % pattern) |
68 return sorted(candidates, reverse=True)[0] | 68 candidates = glob.glob(info_pattern) |
69 if not candidates: | |
70 continue | |
71 return sorted(candidates, reverse=True)[0] | |
72 | |
73 return None | |
69 | 74 |
70 | 75 |
71 def GetLatestGomaCompilerProxyInfo(): | 76 def GetLatestGomaCompilerProxyInfo(): |
72 """Get a filename of the latest goma comiler_proxy.INFO.""" | 77 """Get a filename of the latest goma comiler_proxy.INFO.""" |
73 return GetLatestGlogInfoFile('compiler_proxy') | 78 return GetLatestGlogInfoFile('compiler_proxy') |
74 | 79 |
75 | 80 |
76 def GetLatestGomaCompilerProxySubprocInfo(): | 81 def GetLatestGomaCompilerProxySubprocInfo(): |
77 """Get a filename of the latest goma comiler_proxy-subproc.INFO.""" | 82 """Get a filename of the latest goma comiler_proxy-subproc.INFO.""" |
78 return GetLatestGlogInfoFile('compiler_proxy-subproc') | 83 return GetLatestGlogInfoFile('compiler_proxy-subproc') |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 retcode = chromium_utils.RunCommand( | 353 retcode = chromium_utils.RunCommand( |
349 cmd, filter_obj=cmd_filter, | 354 cmd, filter_obj=cmd_filter, |
350 max_time=30) | 355 max_time=30) |
351 if retcode: | 356 if retcode: |
352 print('Execution of send_ts_mon_values failed with code %s' | 357 print('Execution of send_ts_mon_values failed with code %s' |
353 % retcode) | 358 % retcode) |
354 print '\n'.join(cmd_filter.text) | 359 print '\n'.join(cmd_filter.text) |
355 | 360 |
356 except Exception as ex: | 361 except Exception as ex: |
357 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) | 362 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) |
OLD | NEW |