2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
18 return sys
.platform
.startswith('linux')
21 def get_free_disk_space(failures
):
22 """Returns the amount of free space on the current disk, in GiB.
25 The amount of free space on the current disk, measured in GiB.
27 if os
.name
== 'posix':
28 # Stat the current path for info on the current disk.
29 stat_result
= os
.statvfs('.')
30 # Multiply block size by number of free blocks, express in GiB.
31 return stat_result
.f_frsize
* stat_result
.f_bavail
/ (
32 1024.0 / 1024.0 / 1024.0)
34 failures
.append('get_free_disk_space: OS %s not supported.' % os
.name
)
38 def get_num_cpus(failures
):
39 """Returns the number of logical CPUs on this machine.
42 The number of logical CPUs on this machine, or 'unknown' if indeterminate.
45 return multiprocessing
.cpu_count()
46 except NotImplementedError:
47 failures
.append('get_num_cpus')
51 def get_device_info(args
, failures
):
52 """Parses the device info for each attached device, and returns a summary
53 of the device info and any mismatches.
56 A dict indicating the result.
61 with common
.temporary_file() as tempfile_path
:
62 rc
= common
.run_command([
64 os
.path
.join(args
.paths
['checkout'],
68 'bb_device_status_check.py'),
69 '--json-output', tempfile_path
,
70 '--blacklist-file', os
.path
.join(
71 args
.paths
['checkout'], 'out', 'bad_devices.json')])
74 failures
.append('bb_device_status_check')
77 with
open(tempfile_path
, 'r') as src
:
78 device_info
= json
.load(src
)
81 results
['devices'] = sorted(v
['serial'] for v
in device_info
)
83 details
= [v
['build_detail'] for v
in device_info
]
85 def unique_build_details(index
):
86 return sorted(list(set([v
.split(':')[index
] for v
in details
])))
89 'device_names': unique_build_details(0),
90 'build_versions': unique_build_details(1),
91 'build_types': unique_build_details(2),
94 for k
, v
in parsed_details
.iteritems():
98 results
[k
] = 'MISMATCH'
99 results
['%s_list' % k
] = v
108 host_info
['os_system'] = platform
.system()
109 host_info
['os_release'] = platform
.release()
111 host_info
['processor'] = platform
.processor()
112 host_info
['num_cpus'] = get_num_cpus(failures
)
113 host_info
['free_disk_space'] = get_free_disk_space(failures
)
115 host_info
['python_version'] = platform
.python_version()
116 host_info
['python_path'] = sys
.executable
118 host_info
['devices'] = get_device_info(args
, failures
)
122 'failures': failures
,
123 '_host_info': host_info
,
126 return len(failures
) != 0
129 def main_compile_targets(args
):
130 json
.dump([], args
.output
)
133 if __name__
== '__main__':
136 'compile_targets': main_compile_targets
,
138 sys
.exit(common
.run_script(sys
.argv
[1:], funcs
))