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

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

Issue 2933593002: Promote 'model' from state to dimension for Macs. (Closed)
Patch Set: typo Created 3 years, 6 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
« no previous file with comments | « no previous file | appengine/swarming/swarming_bot/api/os_utilities_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 if hidpi: 931 if hidpi:
932 dimensions[u'hidpi'] = hidpi 932 dimensions[u'hidpi'] = hidpi
933 933
934 machine_type = get_machine_type() 934 machine_type = get_machine_type()
935 if machine_type: 935 if machine_type:
936 dimensions[u'machine_type'] = [machine_type] 936 dimensions[u'machine_type'] = [machine_type]
937 if platforms.is_gce(): 937 if platforms.is_gce():
938 dimensions[u'zone'] = [platforms.gce.get_zone()] 938 dimensions[u'zone'] = [platforms.gce.get_zone()]
939 939
940 if sys.platform == 'darwin': 940 if sys.platform == 'darwin':
941 model = platforms.osx.get_hardware_model_string()
942 if model:
943 dimensions[u'model'] = [model]
Ken Russell (switch to Gerrit) 2017/06/09 20:34:00 Might want to make this a more specific name like
M-A Ruel 2017/06/09 20:44:05 Changed to mac_model. wdyt?
Ken Russell (switch to Gerrit) 2017/06/09 20:45:33 SGTM.
944 xcode_versions = platforms.osx.get_xcode_versions()
945 if xcode_versions:
946 dimensions[u'xcode_version'] = xcode_versions
947
948 # iOS devices
941 udids = platforms.osx.get_ios_device_ids() 949 udids = platforms.osx.get_ios_device_ids()
942 device_types = set() 950 device_types = set()
943 for udid in udids: 951 for udid in udids:
944 version = platforms.osx.get_ios_version(udid) 952 version = platforms.osx.get_ios_version(udid)
945 if version: 953 if version:
946 dimensions[u'os'].append('iOS-%s' % version) 954 dimensions[u'os'].append('iOS-%s' % version)
947 dimensions[u'os'].sort() 955 dimensions[u'os'].sort()
948 device_type = platforms.osx.get_ios_device_type(udid) 956 device_type = platforms.osx.get_ios_device_type(udid)
949 if device_type: 957 if device_type:
950 device_types.add(device_type) 958 device_types.add(device_type)
951 if device_types: 959 if device_types:
952 dimensions[u'device'] = sorted(device_types) 960 dimensions[u'device'] = sorted(device_types)
953 dimensions[u'xcode_version'] = platforms.osx.get_xcode_versions()
954 961
955 return dimensions 962 return dimensions
956 963
957 964
958 def get_state(): 965 def get_state():
959 """Returns dict with a state of the bot reported to the server with each poll. 966 """Returns dict with a state of the bot reported to the server with each poll.
960 967
961 Supposed to be use only for dynamic state that changes while bot is running. 968 Supposed to be use only for dynamic state that changes while bot is running.
962 969
963 The server can not use this state for immediate scheduling purposes (use 970 The server can not use this state for immediate scheduling purposes (use
(...skipping 26 matching lines...) Expand all
990 u'uptime': int(round(get_uptime())), 997 u'uptime': int(round(get_uptime())),
991 u'user': getpass.getuser().decode('utf-8'), 998 u'user': getpass.getuser().decode('utf-8'),
992 } 999 }
993 if sys.platform in ('cygwin', 'win32'): 1000 if sys.platform in ('cygwin', 'win32'):
994 state[u'cygwin'] = [sys.platform == 'cygwin'] 1001 state[u'cygwin'] = [sys.platform == 'cygwin']
995 if sys.platform == 'win32': 1002 if sys.platform == 'win32':
996 integrity = platforms.win.get_integrity_level() 1003 integrity = platforms.win.get_integrity_level()
997 if integrity is not None: 1004 if integrity is not None:
998 state[u'integrity'] = [integrity] 1005 state[u'integrity'] = [integrity]
999 if sys.platform == 'darwin': 1006 if sys.platform == 'darwin':
1000 model = platforms.osx.get_hardware_model_string()
1001 if model:
1002 state[u'model'] = model
1003 state[u'xcode'] = platforms.osx.get_xcode_state() 1007 state[u'xcode'] = platforms.osx.get_xcode_state()
1004 if sys.platform == 'linux2': 1008 if sys.platform == 'linux2':
1005 temp = platforms.linux.get_temperatures() 1009 temp = platforms.linux.get_temperatures()
1006 if temp: 1010 if temp:
1007 state[u'temp'] = temp 1011 state[u'temp'] = temp
1008 1012
1009 # Put an arbitrary limit on the amount of junk that can stay in TEMP. 1013 # Put an arbitrary limit on the amount of junk that can stay in TEMP.
1010 if nb_files_in_temp == 'N/A': 1014 if nb_files_in_temp == 'N/A':
1011 state[u'quarantined'] = 'Failed to access TEMP (%s)' % tmpdir 1015 state[u'quarantined'] = 'Failed to access TEMP (%s)' % tmpdir
1012 elif nb_files_in_temp > 1024: 1016 elif nb_files_in_temp > 1024:
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 1268
1265 1269
1266 def trim_rolled_log(name): 1270 def trim_rolled_log(name):
1267 try: 1271 try:
1268 for item in glob.iglob('%s.??' % name): 1272 for item in glob.iglob('%s.??' % name):
1269 os.remove(item) 1273 os.remove(item)
1270 for item in glob.iglob('%s.???' % name): 1274 for item in glob.iglob('%s.???' % name):
1271 os.remove(item) 1275 os.remove(item)
1272 except Exception as e: 1276 except Exception as e:
1273 logging.exception('trim_rolled_log(%s) failed: %s', name, e) 1277 logging.exception('trim_rolled_log(%s) failed: %s', name, e)
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/swarming_bot/api/os_utilities_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698