Skip to content
Snippets Groups Projects
Commit 5c0f2634 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

Replace scripts dependency on win32api module with bundled ctypes.

parent 86d1b0b6
No related branches found
No related tags found
No related merge requests found
......@@ -793,8 +793,13 @@ def _getuser():
import getpass
return getpass.getuser()
except ImportError:
import win32api
return win32api.GetUserName()
import ctypes
MAX_PATH = 260 # according to a recent WinDef.h
name = ctypes.create_unicode_buffer(MAX_PATH)
namelen = ctypes.c_int(len(name)) # len in chars, NOT bytes
if not ctypes.windll.advapi32.GetUserNameW(name, ctypes.byref(namelen)):
raise ctypes.WinError()
return name.value
def _default_installable_cache():
"""In general, the installable files do not change much, so find a
......
......@@ -203,8 +203,13 @@ def getuser():
import getpass
return getpass.getuser()
except ImportError:
import win32api
return win32api.GetUserName()
import ctypes
MAX_PATH = 260 # according to a recent WinDef.h
name = ctypes.create_unicode_buffer(MAX_PATH)
namelen = ctypes.c_int(len(name)) # len in chars, NOT bytes
if not ctypes.windll.advapi32.GetUserNameW(name, ctypes.byref(namelen)):
raise ctypes.WinError()
return name.value
def local_master_cache_filename():
"""Returns the location of the master template cache (which is in the system tempdir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment