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

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

Issue 2307743002: Reland "Avoid to use environment." (Closed)
Patch Set: rebase Created 4 years, 3 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 263
264 def GetCompilerProxyStartTime(): 264 def GetCompilerProxyStartTime():
265 """Returns datetime instance of the latest compiler_proxy start time.""" 265 """Returns datetime instance of the latest compiler_proxy start time."""
266 with open(GetLatestGomaCompilerProxyInfo()) as f: 266 with open(GetLatestGomaCompilerProxyInfo()) as f:
267 matched = TIMESTAMP_PATTERN.search(f.readline()) 267 matched = TIMESTAMP_PATTERN.search(f.readline())
268 if matched: 268 if matched:
269 return datetime.datetime.strptime(matched.group(1), TIMESTAMP_FORMAT) 269 return datetime.datetime.strptime(matched.group(1), TIMESTAMP_FORMAT)
270 270
271 271
272 def SendGomaTsMon(json_file, exit_status): 272 def SendGomaTsMon(json_file, exit_status,
273 builder='unknown', master='unknown', slave='unknown',
274 clobber=''):
273 """Send latest Goma status to ts_mon. 275 """Send latest Goma status to ts_mon.
274 276
275 Args: 277 Args:
276 json_file: json filename string that has goma_ctl.py jsonstatus. 278 json_file: json filename string that has goma_ctl.py jsonstatus.
277 exit_status: integer exit status of the build. 279 exit_status: integer exit status of the build.
278 """ 280 """
279 json_statuses = {} 281 json_statuses = {}
280 try: 282 try:
281 with open(json_file) as f: 283 with open(json_file) as f:
282 json_statuses = json.load(f) 284 json_statuses = json.load(f)
(...skipping 21 matching lines...) Expand all
304 infra_status['ping_status_code'] != 200 or 306 infra_status['ping_status_code'] != 200 or
305 infra_status.get('num_user_error', 0) > 0): 307 infra_status.get('num_user_error', 0) > 0):
306 result = 'exception' 308 result = 'exception'
307 309
308 num_failure = 0 310 num_failure = 0
309 ping_status_code = 0 311 ping_status_code = 0
310 if infra_status: 312 if infra_status:
311 num_failure = infra_status['num_exec_compiler_proxy_failure'] 313 num_failure = infra_status['num_exec_compiler_proxy_failure']
312 ping_status_code = infra_status['ping_status_code'] 314 ping_status_code = infra_status['ping_status_code']
313 315
314 clobber = 0
315 if os.environ.get('BUILDBOT_CLOBBER'):
316 clobber = 1
317
318 counter = { 316 counter = {
319 'name': 'goma/failure', 317 'name': 'goma/failure',
320 'value': num_failure, 318 'value': num_failure,
321 'builder': os.environ.get('BUILDBOT_BUILDERNAME', 'unknown'), 319 'builder': builder,
322 'master': os.environ.get('BUILDBOT_MASTERNAME', 'unknown'), 320 'master': master,
323 'slave': os.environ.get('BUILDBOT_SLAVENAME', 'unknown'), 321 'slave': slave,
324 'clobber': clobber, 322 'clobber': 1 if clobber else 0,
325 'os': chromium_utils.PlatformName(), 323 'os': chromium_utils.PlatformName(),
326 'ping_status_code': ping_status_code, 324 'ping_status_code': ping_status_code,
327 'result': result} 325 'result': result}
328 start_time = GetCompilerProxyStartTime() 326 start_time = GetCompilerProxyStartTime()
329 if start_time: 327 if start_time:
330 counter['start_time'] = int(time.mktime(start_time.timetuple())) 328 counter['start_time'] = int(time.mktime(start_time.timetuple()))
331 run_cmd = PLATFORM_RUN_CMD.get(os.name) 329 run_cmd = PLATFORM_RUN_CMD.get(os.name)
332 if not run_cmd: 330 if not run_cmd:
333 print 'Unknown os.name: %s' % os.name 331 print 'Unknown os.name: %s' % os.name
334 return 332 return
(...skipping 13 matching lines...) Expand all
348 retcode = chromium_utils.RunCommand( 346 retcode = chromium_utils.RunCommand(
349 cmd, filter_obj=cmd_filter, 347 cmd, filter_obj=cmd_filter,
350 max_time=30) 348 max_time=30)
351 if retcode: 349 if retcode:
352 print('Execution of send_ts_mon_values failed with code %s' 350 print('Execution of send_ts_mon_values failed with code %s'
353 % retcode) 351 % retcode)
354 print '\n'.join(cmd_filter.text) 352 print '\n'.join(cmd_filter.text)
355 353
356 except Exception as ex: 354 except Exception as ex:
357 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) 355 print('error while sending ts mon json_file=%s: %s' % (json_file, ex))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698