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

Side by Side Diff: appengine/swarming/swarming_bot/api/os_utilities.py

Issue 2987023002: swarming: report CPU temperature on OSX as state. (Closed)
Patch Set: Created 3 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 # coding: utf-8 1 # coding: utf-8
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """OS specific utility functions. 6 """OS specific utility functions.
7 7
8 Includes code: 8 Includes code:
9 - to declare the current system this code is running under. 9 - to declare the current system this code is running under.
10 - to run a command on user login. 10 - to run a command on user login.
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 u'user': getpass.getuser().decode('utf-8'), 1022 u'user': getpass.getuser().decode('utf-8'),
1023 } 1023 }
1024 if sys.platform in ('cygwin', 'win32'): 1024 if sys.platform in ('cygwin', 'win32'):
1025 state[u'cygwin'] = [sys.platform == 'cygwin'] 1025 state[u'cygwin'] = [sys.platform == 'cygwin']
1026 if sys.platform == 'win32': 1026 if sys.platform == 'win32':
1027 integrity = platforms.win.get_integrity_level() 1027 integrity = platforms.win.get_integrity_level()
1028 if integrity is not None: 1028 if integrity is not None:
1029 state[u'integrity'] = [integrity] 1029 state[u'integrity'] = [integrity]
1030 if sys.platform == 'darwin': 1030 if sys.platform == 'darwin':
1031 state[u'xcode'] = platforms.osx.get_xcode_state() 1031 state[u'xcode'] = platforms.osx.get_xcode_state()
1032 temp = platforms.osx.get_cpu_temperature()
1033 if temp is not None:
1034 state[u'temp'] = temp
Vadim Sh. 2017/07/28 18:15:56 on linux this is a dict. Is there a way to make t
M-A Ruel 2017/07/28 20:41:57 Generalized.
1032 if sys.platform == 'linux2': 1035 if sys.platform == 'linux2':
1033 temp = platforms.linux.get_temperatures() 1036 temp = platforms.linux.get_temperatures()
1034 if temp: 1037 if temp:
1035 state[u'temp'] = temp 1038 state[u'temp'] = temp
1036 1039
1037 # Put an arbitrary limit on the amount of junk that can stay in TEMP. 1040 # Put an arbitrary limit on the amount of junk that can stay in TEMP.
1038 if nb_files_in_temp == 'N/A': 1041 if nb_files_in_temp == 'N/A':
1039 state[u'quarantined'] = 'Failed to access TEMP (%s)' % tmpdir 1042 state[u'quarantined'] = 'Failed to access TEMP (%s)' % tmpdir
1040 elif nb_files_in_temp > 1024: 1043 elif nb_files_in_temp > 1024:
1041 state[u'quarantined'] = '> 1024 files in TEMP (%s)' % tmpdir 1044 state[u'quarantined'] = '> 1024 files in TEMP (%s)' % tmpdir
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1295
1293 1296
1294 def trim_rolled_log(name): 1297 def trim_rolled_log(name):
1295 try: 1298 try:
1296 for item in glob.iglob('%s.??' % name): 1299 for item in glob.iglob('%s.??' % name):
1297 os.remove(item) 1300 os.remove(item)
1298 for item in glob.iglob('%s.???' % name): 1301 for item in glob.iglob('%s.???' % name):
1299 os.remove(item) 1302 os.remove(item)
1300 except Exception as e: 1303 except Exception as e:
1301 logging.exception('trim_rolled_log(%s) failed: %s', name, e) 1304 logging.exception('trim_rolled_log(%s) failed: %s', name, e)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698