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

Side by Side Diff: scripts/slave/goma_utils.py

Issue 2245553002: Inherit appropiate environment variables in goma module for goma_utils.py (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: use GLOG_log_dir for the location of INFO files Created 4 years, 4 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
OLDNEW
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
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
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))
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/goma/api.py » ('j') | scripts/slave/recipe_modules/goma/api.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698