mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Update vendored windows libs
This commit is contained in:
parent
f61c211655
commit
b1cefa94e5
226 changed files with 33472 additions and 11882 deletions
39
libs/win/bugs/environ-api-wierdness.py
Normal file
39
libs/win/bugs/environ-api-wierdness.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import ctypes
|
||||
from jaraco.windows import environ
|
||||
import os
|
||||
|
||||
getenv = ctypes.cdll.msvcrt.getenv
|
||||
getenv.restype = ctypes.c_char_p
|
||||
putenv = ctypes.cdll.msvcrt._putenv
|
||||
|
||||
|
||||
def do_putenv(*pair):
|
||||
return putenv("=".join(pair))
|
||||
|
||||
|
||||
def print_environment_variable(key):
|
||||
for method in (os.environ.get, os.getenv, environ.GetEnvironmentVariable, getenv):
|
||||
try:
|
||||
print(repr(method(key)))
|
||||
except Exception as e:
|
||||
print(e, end=' ')
|
||||
print
|
||||
|
||||
|
||||
def do_test():
|
||||
key = 'TEST_PYTHON_ENVIRONMENT'
|
||||
print_environment_variable(key)
|
||||
methods = (
|
||||
os.environ.__setitem__,
|
||||
os.putenv,
|
||||
environ.SetEnvironmentVariable,
|
||||
do_putenv,
|
||||
)
|
||||
for i, method in enumerate(methods):
|
||||
print('round', i)
|
||||
method(key, 'value when using method %d' % i)
|
||||
print_environment_variable(key)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
do_test()
|
Loading…
Add table
Add a link
Reference in a new issue