forked from wikimedia/pywikibot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_env.py
executable file
·44 lines (36 loc) · 1.02 KB
/
print_env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
"""Script that forms part of pwb_tests."""
#
# (C) Pywikibot team, 2015-2022
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
import os
import sys
from pywikibot.tools import first_upper
def main() -> None:
"""Print environment variables."""
_pwb_dir = os.path.abspath(os.path.join(
os.path.split(__file__)[0], '..', '..'))
_pwb_dir = first_upper(_pwb_dir)
print('os.environ:')
for k, v in sorted(os.environ.items()):
# Don't leak the password into logs
if k == 'USER_PASSWORD':
continue
# This only appears in subprocesses
if k == 'PYWIKIBOT_DIR_PWB':
continue
print(f'{k}: {v}')
print('sys.path:')
for path in sys.path:
if path == '' or path.startswith('.'):
continue
# Normalise DOS drive letter
path = first_upper(path)
if path.startswith(_pwb_dir):
continue
print(path)
if __name__ == '__main__':
main()