68
67
create_buffer = ctypes.create_unicode_buffer
74
has_pywintypes = has_win32file = has_win32api = False
87
81
# pulling in win32com.shell is a bit of overhead, and normally we don't need
88
82
# it as ctypes is preferred and common. lazy_imports and "optional"
134
128
ctypes.byref(mem_struct),
135
129
ctypes.sizeof(mem_struct))
137
trace.note(gettext('Failed to GetProcessMemoryInfo()'))
131
trace.note('Failed to GetProcessMemoryInfo()')
139
133
info = {'PageFaultCount': mem_struct.PageFaultCount,
140
134
'PeakWorkingSetSize': mem_struct.PeakWorkingSetSize,
155
149
proc = win32process.GetCurrentProcess()
156
150
info = win32process.GetProcessMemoryInfo(proc)
158
trace.note(gettext('Cannot debug memory on win32 without ctypes'
152
trace.note('Cannot debug memory on win32 without ctypes'
162
156
# using base-2 units (see HACKING.txt).
163
trace.note(gettext('WorkingSize {0:>7}KiB'
164
'\tPeakWorking {1:>7}KiB\t{2}').format(
157
trace.note('WorkingSize %7dKiB'
158
'\tPeakWorking %7dKiB\t%s',
165
159
info['WorkingSetSize'] / 1024,
166
160
info['PeakWorkingSetSize'] / 1024,
170
164
trace.note('%s', message)
171
trace.note(gettext('WorkingSize %8d KiB'), info['WorkingSetSize'] / 1024)
172
trace.note(gettext('PeakWorking %8d KiB'), info['PeakWorkingSetSize'] / 1024)
173
trace.note(gettext('PagefileUsage %8d KiB'), info.get('PagefileUsage', 0) / 1024)
174
trace.note(gettext('PeakPagefileUsage %8d KiB'),
165
trace.note('WorkingSize %8d KiB', info['WorkingSetSize'] / 1024)
166
trace.note('PeakWorking %8d KiB', info['PeakWorkingSetSize'] / 1024)
167
trace.note('PagefileUsage %8d KiB', info.get('PagefileUsage', 0) / 1024)
168
trace.note('PeakPagefileUsage %8d KiB',
175
169
info.get('PeakPagefileUsage', 0) / 1024)
176
trace.note(gettext('PrivateUsage %8d KiB'), info.get('PrivateUsage', 0) / 1024)
177
trace.note(gettext('PageFaultCount %8d'), info.get('PageFaultCount', 0))
170
trace.note('PrivateUsage %8d KiB', info.get('PrivateUsage', 0) / 1024)
171
trace.note('PageFaultCount %8d', info.get('PageFaultCount', 0))
180
174
def get_console_size(defaultx=80, defaulty=25):
620
614
_CloseHandle(handle)
622
616
is_local_pid_dead = _ctypes_is_local_pid_dead
625
def _is_pywintypes_error(evalue):
626
"""True if exception instance is an error from pywin32"""
627
if has_pywintypes and isinstance(evalue, pywintypes.error):