MCPcopy Index your code
hub / github.com/python/cpython / collect_os

Function collect_os

Lib/test/pythoninfo.py:222–366  ·  view source on GitHub ↗
(info_add)

Source from the content-addressed store, hash-verified

220
221
222def collect_os(info_add):
223 import os
224
225 def format_attr(attr, value):
226 if attr in ('supports_follow_symlinks', 'supports_fd',
227 'supports_effective_ids'):
228 return str(sorted(func.__name__ for func in value))
229 else:
230 return value
231
232 attributes = (
233 'name',
234 'supports_bytes_environ',
235 'supports_effective_ids',
236 'supports_fd',
237 'supports_follow_symlinks',
238 )
239 copy_attributes(info_add, os, 'os.%s', attributes, formatter=format_attr)
240
241 for func in (
242 'cpu_count',
243 'getcwd',
244 'getegid',
245 'geteuid',
246 'getgid',
247 'getloadavg',
248 'getresgid',
249 'getresuid',
250 'getuid',
251 'process_cpu_count',
252 'uname',
253 ):
254 call_func(info_add, 'os.%s' % func, os, func)
255
256 def format_groups(groups):
257 return ', '.join(map(str, groups))
258
259 call_func(info_add, 'os.getgroups', os, 'getgroups', formatter=format_groups)
260
261 if hasattr(os, 'getlogin'):
262 try:
263 login = os.getlogin()
264 except OSError:
265 # getlogin() fails with "OSError: [Errno 25] Inappropriate ioctl
266 # for device" on Travis CI
267 pass
268 else:
269 info_add("os.login", login)
270
271 # Environment variables used by the stdlib and tests. Don't log the full
272 # environment: filter to list to not leak sensitive information.
273 #
274 # HTTP_PROXY is not logged because it can contain a password.
275 ENV_VARS = frozenset((
276 "APPDATA",
277 "AR",
278 "ARCHFLAGS",
279 "ARFLAGS",

Callers

nothing calls this directly

Calls 6

copy_attributesFunction · 0.85
call_funcFunction · 0.85
itemsMethod · 0.45
upperMethod · 0.45
startswithMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…