MCPcopy Index your code
hub / github.com/RustPython/RustPython / collect_os

Function collect_os

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected