Update of /cvsroot/pywin32/pywin32/win32/Demos
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15490/Demos
Modified Files:
Tag: py3k
BackupRead_BackupWrite.py BackupSeek_streamheaders.py
CopyFileEx.py CreateFileTransacted_MiniVersion.py
FileSecurityTest.py GetSaveFileName.py OpenEncryptedFileRaw.py
RegRestoreKey.py SystemParametersInfo.py cerapi.py
desktopmanager.py eventLogDemo.py getfilever.py
mmapfile_demo.py print_desktop.py rastest.py timer_demo.py
win32clipboardDemo.py win32comport_demo.py
win32console_demo.py win32cred_demo.py win32fileDemo.py
win32gui_demo.py win32gui_devicenotify.py win32gui_dialog.py
win32gui_menu.py win32gui_taskbar.py win32netdemo.py
win32rcparser_demo.py win32servicedemo.py
win32ts_logoff_disconnected.py winprocess.py
Log Message:
Changes to build for Python 3.0
Index: CreateFileTransacted_MiniVersion.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/CreateFileTransacted_MiniVersion.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** CreateFileTransacted_MiniVersion.py 8 Nov 2007 20:02:30 -0000 1.2
--- CreateFileTransacted_MiniVersion.py 29 Aug 2008 04:59:23 -0000 1.2.2.1
***************
*** 22,26 ****
tempdir=win32api.GetTempPath()
tempfile=win32api.GetTempFileName(tempdir,'cft')[0]
! print tempfile
f=open(tempfile,'w')
f.write('This is original file.\n')
--- 22,26 ----
tempdir=win32api.GetTempPath()
tempfile=win32api.GetTempFileName(tempdir,'cft')[0]
! print(tempfile)
f=open(tempfile,'w')
f.write('This is original file.\n')
***************
*** 46,50 ****
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=base_ver)
! print 'version:',base_ver,win32file.ReadFile(hfile_0, 100)
hfile_0.Close()
--- 46,50 ----
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=base_ver)
! print('version:',base_ver,win32file.ReadFile(hfile_0, 100))
hfile_0.Close()
***************
*** 52,56 ****
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_1)
! print 'version:',ver_1,win32file.ReadFile(hfile_1, 100)
hfile_1.Close()
--- 52,56 ----
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_1)
! print('version:',ver_1,win32file.ReadFile(hfile_1, 100))
hfile_1.Close()
***************
*** 58,62 ****
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_2)
! print 'version:',ver_2,win32file.ReadFile(hfile_2, 100)
hfile_2.Close()
--- 58,62 ----
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_2)
! print('version:',ver_2,win32file.ReadFile(hfile_2, 100))
hfile_2.Close()
Index: BackupSeek_streamheaders.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/BackupSeek_streamheaders.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** BackupSeek_streamheaders.py 7 Jan 2005 00:20:24 -0000 1.1
--- BackupSeek_streamheaders.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 19,23 ****
tempdir=win32api.GetTempPath()
tempfile=win32api.GetTempFileName(tempdir,'bkr')[0]
! print 'Filename:',tempfile
f=open(tempfile,'w')
--- 19,23 ----
tempdir=win32api.GetTempPath()
tempfile=win32api.GetTempFileName(tempdir,'bkr')[0]
! print('Filename:',tempfile)
f=open(tempfile,'w')
***************
*** 59,63 ****
def parse_stream_header(h,ctxt,data):
stream_type, stream_attributes, stream_size, stream_name_size=struct.unpack(win32_stream_id_format,data)
! print '\nType:',stream_type,stream_types[stream_type], 'Attributes:', stream_attributes, 'Size:', stream_size, 'Name len:',stream_name_size
if stream_name_size>0:
## ??? sdk says this size is in characters, but it appears to be number of bytes ???
--- 59,63 ----
def parse_stream_header(h,ctxt,data):
stream_type, stream_attributes, stream_size, stream_name_size=struct.unpack(win32_stream_id_format,data)
! print('\nType:',stream_type,stream_types[stream_type], 'Attributes:', stream_attributes, 'Size:', stream_size, 'Name len:',stream_name_size)
if stream_name_size>0:
## ??? sdk says this size is in characters, but it appears to be number of bytes ???
***************
*** 66,70 ****
else:
stream_name='Unnamed'
! print 'Name:'+stream_name
return ctxt, stream_type, stream_attributes, stream_size, stream_name_size, stream_name
--- 66,70 ----
else:
stream_name='Unnamed'
! print('Name:'+stream_name)
return ctxt, stream_type, stream_attributes, stream_size, stream_name_size, stream_name
***************
*** 79,83 ****
if stream_size>0:
bytes_moved=win32file.BackupSeek(h, stream_size, ctxt)
! print 'Moved: ',bytes_moved
win32file.BackupRead(h, win32_stream_id_size, win32_stream_id_buf, True, True, ctxt)
--- 79,83 ----
if stream_size>0:
bytes_moved=win32file.BackupSeek(h, stream_size, ctxt)
! print('Moved: ',bytes_moved)
win32file.BackupRead(h, win32_stream_id_size, win32_stream_id_buf, True, True, ctxt)
Index: CopyFileEx.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/CopyFileEx.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** CopyFileEx.py 8 Nov 2007 20:02:29 -0000 1.2
--- CopyFileEx.py 29 Aug 2008 04:59:23 -0000 1.2.2.1
***************
*** 5,10 ****
def ProgressRoutine(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred,
StreamNumber, CallbackReason, SourceFile, DestinationFile, Data):
! print Data
! print TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred, StreamNumber, CallbackReason, SourceFile, DestinationFile
##if TotalBytesTransferred > 100000:
## return win32file.PROGRESS_STOP
--- 5,10 ----
def ProgressRoutine(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred,
StreamNumber, CallbackReason, SourceFile, DestinationFile, Data):
! print(Data)
! print(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred, StreamNumber, CallbackReason, SourceFile, DestinationFile)
##if TotalBytesTransferred > 100000:
## return win32file.PROGRESS_STOP
***************
*** 14,18 ****
fsrc=win32api.GetTempFileName(temp_dir,'cfe')[0]
fdst=win32api.GetTempFileName(temp_dir,'cfe')[0]
! print fsrc, fdst
f=open(fsrc,'w')
--- 14,18 ----
fsrc=win32api.GetTempFileName(temp_dir,'cfe')[0]
fdst=win32api.GetTempFileName(temp_dir,'cfe')[0]
! print(fsrc, fdst)
f=open(fsrc,'w')
Index: RegRestoreKey.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/RegRestoreKey.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** RegRestoreKey.py 30 Nov 2006 07:05:24 -0000 1.1
--- RegRestoreKey.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 5,9 ****
temp_dir=win32api.GetTempPath()
fname=win32api.GetTempFileName(temp_dir,'rsk')[0]
! print fname
## file can't exist
os.remove(fname)
--- 5,9 ----
temp_dir=win32api.GetTempPath()
fname=win32api.GetTempFileName(temp_dir,'rsk')[0]
! print(fname)
## file can't exist
os.remove(fname)
Index: win32cred_demo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32cred_demo.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** win32cred_demo.py 13 Sep 2006 07:44:27 -0000 1.1
--- win32cred_demo.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 14,18 ****
attrs=[
! {'Keyword':'attr1', 'Flags':0, 'Value':u'unicode data'},
{'Keyword':'attr2', 'Flags':0, 'Value':'character data'}
]
--- 14,18 ----
attrs=[
! {'Keyword':'attr1', 'Flags':0, 'Value':'unicode data'},
{'Keyword':'attr2', 'Flags':0, 'Value':'character data'}
]
***************
*** 23,27 ****
win32cred.CredWrite(cred)
pwd=None
! print win32cred.CredRead(target, win32cred.CRED_TYPE_DOMAIN_PASSWORD)
## Marshal saved credential and use it to log on
--- 23,27 ----
win32cred.CredWrite(cred)
pwd=None
! print(win32cred.CredRead(target, win32cred.CRED_TYPE_DOMAIN_PASSWORD))
## Marshal saved credential and use it to log on
***************
*** 29,33 ****
th=win32security.LogonUser(mc,None,'',win32con.LOGON32_LOGON_INTERACTIVE, win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(th)
! print 'GetUserName:',win32api.GetUserName()
win32security.RevertToSelf()
--- 29,33 ----
th=win32security.LogonUser(mc,None,'',win32con.LOGON32_LOGON_INTERACTIVE, win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(th)
! print('GetUserName:',win32api.GetUserName())
win32security.RevertToSelf()
Index: OpenEncryptedFileRaw.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/OpenEncryptedFileRaw.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** OpenEncryptedFileRaw.py 18 Sep 2006 07:17:29 -0000 1.1
--- OpenEncryptedFileRaw.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 7,11 ****
f.write(input_buffer)
## python 2.3 throws an error if return value is a plain int
! return long(winerror.ERROR_SUCCESS)
def WriteCallback(output_buffer, data, buflen):
--- 7,11 ----
f.write(input_buffer)
## python 2.3 throws an error if return value is a plain int
! return int(winerror.ERROR_SUCCESS)
def WriteCallback(output_buffer, data, buflen):
***************
*** 22,30 ****
os.remove(dst_dir)
os.mkdir(dst_dir)
! print 'Destination dir:', dst_dir
## create an encrypted file
fname=win32api.GetTempFileName(dst_dir,'ref')[0]
! print 'orig file:',fname
f=open(fname,'w')
f.write('xxxxxxxxxxxxxxxx\n'*32768)
--- 22,30 ----
os.remove(dst_dir)
os.mkdir(dst_dir)
! print('Destination dir:', dst_dir)
## create an encrypted file
fname=win32api.GetTempFileName(dst_dir,'ref')[0]
! print('orig file:',fname)
f=open(fname,'w')
f.write('xxxxxxxxxxxxxxxx\n'*32768)
***************
*** 41,45 ****
## backup raw data of encrypted file
bkup_fname=win32api.GetTempFileName(dst_dir,'bef')[0]
! print 'backup file:', bkup_fname
f=open(bkup_fname,'wb')
ctxt=win32file.OpenEncryptedFileRaw(fname,0)
--- 41,45 ----
## backup raw data of encrypted file
bkup_fname=win32api.GetTempFileName(dst_dir,'bef')[0]
! print('backup file:', bkup_fname)
f=open(bkup_fname,'wb')
ctxt=win32file.OpenEncryptedFileRaw(fname,0)
***************
*** 53,57 ****
## restore data from backup to new encrypted file
dst_fname=win32api.GetTempFileName(dst_dir,'wef')[0]
! print 'restored file:', dst_fname
f=open(bkup_fname,'rb')
ctxtout=win32file.OpenEncryptedFileRaw(dst_fname, win32file.CREATE_FOR_IMPORT)
--- 53,57 ----
## restore data from backup to new encrypted file
dst_fname=win32api.GetTempFileName(dst_dir,'wef')[0]
! print('restored file:', dst_fname)
f=open(bkup_fname,'rb')
ctxtout=win32file.OpenEncryptedFileRaw(dst_fname, win32file.CREATE_FOR_IMPORT)
Index: win32clipboardDemo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32clipboardDemo.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** win32clipboardDemo.py 3 Feb 2003 00:30:29 -0000 1.2
--- win32clipboardDemo.py 29 Aug 2008 04:59:23 -0000 1.2.4.1
***************
*** 7,16 ****
if not __debug__:
! print "WARNING: The test code in this module uses assert"
! print "This instance of Python has asserts disabled, so many tests will be skipped"
cf_names = {}
# Build map of CF_* constants to names.
! for name, val in win32con.__dict__.items():
if name[:3]=="CF_" and name != "CF_SCREENFONTS": # CF_SCREEN_FONTS==CF_TEXT!?!?
cf_names[val] = name
--- 7,16 ----
if not __debug__:
! print("WARNING: The test code in this module uses assert")
! print("This instance of Python has asserts disabled, so many tests will be skipped")
cf_names = {}
# Build map of CF_* constants to names.
! for name, val in list(win32con.__dict__.items()):
if name[:3]=="CF_" and name != "CF_SCREENFONTS": # CF_SCREEN_FONTS==CF_TEXT!?!?
cf_names[val] = name
***************
*** 41,45 ****
got = GetClipboardData(win32con.CF_UNICODETEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! assert type(got)==types.UnicodeType, "Didnt get the correct result back - '%r'." % (got,)
got = GetClipboardData(win32con.CF_OEMTEXT)
--- 41,45 ----
got = GetClipboardData(win32con.CF_UNICODETEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! assert type(got)==str, "Didnt get the correct result back - '%r'." % (got,)
got = GetClipboardData(win32con.CF_OEMTEXT)
***************
*** 48,52 ****
# Unicode tests
EmptyClipboard()
! text = u"Hello from Python unicode"
# Now set the Unicode value
SetClipboardData(win32con.CF_UNICODETEXT, text)
--- 48,52 ----
# Unicode tests
EmptyClipboard()
! text = "Hello from Python unicode"
# Now set the Unicode value
SetClipboardData(win32con.CF_UNICODETEXT, text)
***************
*** 54,58 ****
got = GetClipboardData(win32con.CF_UNICODETEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! assert type(got)==types.UnicodeType, "Didnt get the correct result back - '%r'." % (got,)
# Close and open the clipboard to ensure auto-conversions take place.
--- 54,58 ----
got = GetClipboardData(win32con.CF_UNICODETEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! assert type(got)==str, "Didnt get the correct result back - '%r'." % (got,)
# Close and open the clipboard to ensure auto-conversions take place.
***************
*** 68,75 ****
# Make sure we get back the correct types.
got = GetClipboardData(win32con.CF_UNICODETEXT)
! assert type(got)==types.UnicodeType, "Didnt get the correct result back - '%r'." % (got,)
got = GetClipboardData(win32con.CF_OEMTEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! print "Clipboard text tests worked correctly"
finally:
CloseClipboard()
--- 68,75 ----
# Make sure we get back the correct types.
got = GetClipboardData(win32con.CF_UNICODETEXT)
! assert type(got)==str, "Didnt get the correct result back - '%r'." % (got,)
got = GetClipboardData(win32con.CF_OEMTEXT)
assert got == text, "Didnt get the correct result back - '%r'." % (got,)
! print("Clipboard text tests worked correctly")
finally:
CloseClipboard()
***************
*** 92,97 ****
n = "unknown (%s)" % (enum,)
! print "Have format", n
! print "Clipboard enumerator tests worked correctly"
finally:
CloseClipboard()
--- 92,97 ----
n = "unknown (%s)" % (enum,)
! print("Have format", n)
! print("Clipboard enumerator tests worked correctly")
finally:
CloseClipboard()
***************
*** 108,120 ****
# Just for the fun of it pickle Python objects through the clipboard
fmt = RegisterClipboardFormat("Python Pickle Format")
! import cPickle
pickled_object = Foo(a=1, b=2, Hi=3)
! SetClipboardData(fmt, cPickle.dumps( pickled_object ) )
# Now read it back.
data = GetClipboardData(fmt)
! loaded_object = cPickle.loads(data)
! assert cPickle.loads(data) == pickled_object, "Didnt get the correct data!"
! print "Clipboard custom format tests worked correctly"
finally:
CloseClipboard()
--- 108,120 ----
# Just for the fun of it pickle Python objects through the clipboard
fmt = RegisterClipboardFormat("Python Pickle Format")
! import pickle
pickled_object = Foo(a=1, b=2, Hi=3)
! SetClipboardData(fmt, pickle.dumps( pickled_object ) )
# Now read it back.
data = GetClipboardData(fmt)
! loaded_object = pickle.loads(data)
! assert pickle.loads(data) == pickled_object, "Didnt get the correct data!"
! print("Clipboard custom format tests worked correctly")
finally:
CloseClipboard()
Index: win32ts_logoff_disconnected.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32ts_logoff_disconnected.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** win32ts_logoff_disconnected.py 5 Jul 2006 15:25:57 -0000 1.1
--- win32ts_logoff_disconnected.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 10,13 ****
sessionid=session['SessionId']
username=win32ts.WTSQuerySessionInformation(win32ts.WTS_CURRENT_SERVER_HANDLE, sessionid, win32ts.WTSUserName)
! print 'Logging off disconnected user:',username
win32ts.WTSLogoffSession(win32ts.WTS_CURRENT_SERVER_HANDLE, sessionid, True)
--- 10,13 ----
sessionid=session['SessionId']
username=win32ts.WTSQuerySessionInformation(win32ts.WTS_CURRENT_SERVER_HANDLE, sessionid, win32ts.WTSUserName)
! print('Logging off disconnected user:',username)
win32ts.WTSLogoffSession(win32ts.WTS_CURRENT_SERVER_HANDLE, sessionid, True)
Index: win32fileDemo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32fileDemo.py,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -C2 -d -r1.6 -r1.6.4.1
*** win32fileDemo.py 5 May 2003 01:01:20 -0000 1.6
--- win32fileDemo.py 29 Aug 2008 04:59:23 -0000 1.6.4.1
***************
*** 29,33 ****
handle.Close()
if data == test_data:
! print "Successfully wrote and read a file"
os.unlink(testName)
--- 29,33 ----
handle.Close()
if data == test_data:
! print("Successfully wrote and read a file")
os.unlink(testName)
Index: win32gui_dialog.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_dialog.py,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** win32gui_dialog.py 4 Jan 2007 08:30:33 -0000 1.7
--- win32gui_dialog.py 29 Aug 2008 04:59:23 -0000 1.7.2.1
***************
*** 24,28 ****
import struct, array
import commctrl
! import Queue
import os
--- 24,28 ----
import struct, array
import commctrl
! import queue
import os
***************
*** 44,55 ****
else:
full_fmt += fmt
! for name, val in kw.items():
! if not self.__dict__.has_key(name):
! raise ValueError, "LVITEM structures do not have an item '%s'" % (name,)
self.__dict__[name] = val
def __setattr__(self, attr, val):
! if not attr.startswith("_") and not self.__dict__.has_key(attr):
! raise AttributeError, attr
self.__dict__[attr] = val
--- 44,55 ----
else:
full_fmt += fmt
! for name, val in list(kw.items()):
! if name not in self.__dict__:
! raise ValueError("LVITEM structures do not have an item '%s'" % (name,))
self.__dict__[name] = val
def __setattr__(self, attr, val):
! if not attr.startswith("_") and attr not in self.__dict__:
! raise AttributeError(attr)
self.__dict__[attr] = val
***************
*** 72,76 ****
vals.append(0)
else:
! str_buf = array.array("c", val+'\0')
vals.append(str_buf.buffer_info()[0])
vals.append(len(val))
--- 72,76 ----
vals.append(0)
else:
! str_buf = array.array("b", val+'\0')
vals.append(str_buf.buffer_info()[0])
vals.append(len(val))
***************
*** 81,85 ****
vals.append(val)
full_fmt += fmt
! return apply(struct.pack, (full_fmt,) + tuple(vals) )
--- 81,85 ----
vals.append(val)
full_fmt += fmt
! return struct.pack(*(full_fmt,) + tuple(vals))
***************
*** 139,144 ****
try:
classAtom = win32gui.RegisterClass(wc)
! except win32gui.error, err_info:
! if err_info[0]!=winerror.ERROR_CLASS_ALREADY_EXISTS:
raise
return className
--- 139,144 ----
try:
classAtom = win32gui.RegisterClass(wc)
! except win32gui.error as err_info:
! if err_info.args[0]!=winerror.ERROR_CLASS_ALREADY_EXISTS:
raise
return className
***************
*** 150,154 ****
# Window frame and title
! dlg = [ [title, (0, 0, 210, 250), style, None, (8, "MS Sans Serif"), None, dlgClassName], ]
# ID label and text box
--- 150,154 ----
# Window frame and title
! dlg = [ [title, (0, 0, 210, 250), style, 0, (8, "MS Sans Serif"), None, dlgClassName], ]
# ID label and text box
***************
*** 248,253 ****
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
! centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)/2, (dt_b-dt_t)/2) )
! win32gui.MoveWindow(hwnd, centre_x-(r/2), centre_y-(b/2), r-l, b-t, 0)
self._SetupList()
l,t,r,b = win32gui.GetClientRect(self.hwnd)
--- 248,253 ----
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
! centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
! win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
self._SetupList()
l,t,r,b = win32gui.GetClientRect(self.hwnd)
***************
*** 286,295 ****
while 1:
params = self.result_queue.get(0)
! apply(self.AddListItem, params)
! except Queue.Empty:
pass
def OnSearchFinished(self, hwnd, msg, wparam, lparam):
! print "OnSearchFinished"
def OnNotify(self, hwnd, msg, wparam, lparam):
--- 286,295 ----
while 1:
params = self.result_queue.get(0)
! self.AddListItem(*params)
! except queue.Empty:
pass
def OnSearchFinished(self, hwnd, msg, wparam, lparam):
! print("OnSearchFinished")
def OnNotify(self, hwnd, msg, wparam, lparam):
***************
*** 305,309 ****
code += commctrl.PY_0U
if code == commctrl.NM_DBLCLK:
! print "Double click on item", iItem+1
return 1
--- 305,309 ----
code += commctrl.PY_0U
if code == commctrl.NM_DBLCLK:
! print("Double click on item", iItem+1)
return 1
***************
*** 321,331 ****
import threading
! self.result_queue = Queue.Queue()
thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
thread.start()
elif id == IDC_BUTTON_DISPLAY:
! print "Display button selected"
sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
! print "The selected item is", sel+1
# These function differ based on how the window is used, so may be overridden
--- 321,331 ----
import threading
! self.result_queue = queue.Queue()
thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
thread.start()
elif id == IDC_BUTTON_DISPLAY:
! print("Display button selected")
sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
! print("The selected item is", sel+1)
# These function differ based on how the window is used, so may be overridden
Index: SystemParametersInfo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/SystemParametersInfo.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** SystemParametersInfo.py 16 Oct 2005 17:17:10 -0000 1.1
--- SystemParametersInfo.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 14,25 ****
"SPI_GETFONTSMOOTHINGCONTRAST", "SPI_GETFONTSMOOTHINGTYPE", "SPI_GETFOCUSBORDERHEIGHT",
"SPI_GETFOCUSBORDERWIDTH", "SPI_GETMOUSECLICKLOCKTIME"):
! print pname
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print '\toriginal setting:',orig_value
win32gui.SystemParametersInfo(cset, orig_value+1)
new_value=win32gui.SystemParametersInfo(cget)
! print '\tnew value:',new_value
assert new_value==orig_value+1
win32gui.SystemParametersInfo(cset, orig_value)
--- 14,25 ----
"SPI_GETFONTSMOOTHINGCONTRAST", "SPI_GETFONTSMOOTHINGTYPE", "SPI_GETFOCUSBORDERHEIGHT",
"SPI_GETFOCUSBORDERWIDTH", "SPI_GETMOUSECLICKLOCKTIME"):
! print(pname)
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print('\toriginal setting:',orig_value)
win32gui.SystemParametersInfo(cset, orig_value+1)
new_value=win32gui.SystemParametersInfo(cget)
! print('\tnew value:',new_value)
assert new_value==orig_value+1
win32gui.SystemParametersInfo(cset, orig_value)
***************
*** 35,46 ****
"SPI_GETTOOLTIPANIMATION", "SPI_GETTOOLTIPFADE", "SPI_GETUIEFFECTS", "SPI_GETACTIVEWINDOWTRACKING",
"SPI_GETACTIVEWNDTRKZORDER"):
! print pname
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print orig_value
win32gui.SystemParametersInfo(cset, not orig_value)
new_value=win32gui.SystemParametersInfo(cget)
! print new_value
assert orig_value!=new_value
win32gui.SystemParametersInfo(cset, orig_value)
--- 35,46 ----
"SPI_GETTOOLTIPANIMATION", "SPI_GETTOOLTIPFADE", "SPI_GETUIEFFECTS", "SPI_GETACTIVEWINDOWTRACKING",
"SPI_GETACTIVEWNDTRKZORDER"):
! print(pname)
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print(orig_value)
win32gui.SystemParametersInfo(cset, not orig_value)
new_value=win32gui.SystemParametersInfo(cget)
! print(new_value)
assert orig_value!=new_value
win32gui.SystemParametersInfo(cset, orig_value)
***************
*** 54,65 ****
"SPI_GETKEYBOARDPREF","SPI_GETSCREENSAVEACTIVE","SPI_GETMENUDROPALIGNMENT",
"SPI_GETDRAGFULLWINDOWS", "SPI_GETSHOWIMEUI"):
! print pname
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print orig_value
win32gui.SystemParametersInfo(cset, not orig_value)
new_value=win32gui.SystemParametersInfo(cget)
! print new_value
assert orig_value!=new_value
win32gui.SystemParametersInfo(cset, orig_value)
--- 54,65 ----
"SPI_GETKEYBOARDPREF","SPI_GETSCREENSAVEACTIVE","SPI_GETMENUDROPALIGNMENT",
"SPI_GETDRAGFULLWINDOWS", "SPI_GETSHOWIMEUI"):
! print(pname)
cget=getattr(win32con,pname)
cset=getattr(win32con,pname.replace('_GET','_SET'))
orig_value=win32gui.SystemParametersInfo(cget)
! print(orig_value)
win32gui.SystemParametersInfo(cset, not orig_value)
new_value=win32gui.SystemParametersInfo(cget)
! print(new_value)
assert orig_value!=new_value
win32gui.SystemParametersInfo(cset, orig_value)
***************
*** 68,81 ****
! print "SPI_GETICONTITLELOGFONT"
lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT)
orig_height=lf.lfHeight
orig_italic=lf.lfItalic
! print 'Height:', orig_height, 'Italic:',orig_italic
lf.lfHeight+=2
lf.lfItalic=not lf.lfItalic
win32gui.SystemParametersInfo(win32con.SPI_SETICONTITLELOGFONT, lf)
new_lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT)
! print 'New Height:', new_lf.lfHeight, 'New Italic:',new_lf.lfItalic
assert new_lf.lfHeight==orig_height+2
assert new_lf.lfItalic!=orig_italic
--- 68,81 ----
! print("SPI_GETICONTITLELOGFONT")
lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT)
orig_height=lf.lfHeight
orig_italic=lf.lfItalic
! print('Height:', orig_height, 'Italic:',orig_italic)
lf.lfHeight+=2
lf.lfItalic=not lf.lfItalic
win32gui.SystemParametersInfo(win32con.SPI_SETICONTITLELOGFONT, lf)
new_lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT)
! print('New Height:', new_lf.lfHeight, 'New Italic:',new_lf.lfItalic)
assert new_lf.lfHeight==orig_height+2
assert new_lf.lfItalic!=orig_italic
***************
*** 90,98 ****
! print "SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEHOVERHEIGHT, SPI_GETMOUSEHOVERTIME"
w=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERWIDTH)
h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT)
t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME)
! print 'w,h,t:', w,h,t
win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERWIDTH,w+1)
--- 90,98 ----
! print("SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEHOVERHEIGHT, SPI_GETMOUSEHOVERTIME")
w=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERWIDTH)
h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT)
t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME)
! print('w,h,t:', w,h,t)
win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERWIDTH,w+1)
***************
*** 102,106 ****
new_h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT)
new_t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME)
! print 'new w,h,t:', new_w, new_h, new_t
assert new_w==w+1
assert new_h==h+2
--- 102,106 ----
new_h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT)
new_t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME)
! print('new w,h,t:', new_w, new_h, new_t)
assert new_w==w+1
assert new_h==h+2
***************
*** 119,131 ****
! print "SPI_SETDOUBLECLKWIDTH, SPI_SETDOUBLECLKHEIGHT"
x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK)
y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK)
! print 'x,y:', x, y
win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKWIDTH, x+1)
win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKHEIGHT, y+2)
new_x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK)
new_y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK)
! print 'new x,y:', new_x, new_y
assert new_x==x+1
assert new_y==y+2
--- 119,131 ----
! print("SPI_SETDOUBLECLKWIDTH, SPI_SETDOUBLECLKHEIGHT")
x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK)
y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK)
! print('x,y:', x, y)
win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKWIDTH, x+1)
win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKHEIGHT, y+2)
new_x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK)
new_y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK)
! print('new x,y:', new_x, new_y)
assert new_x==x+1
assert new_y==y+2
***************
*** 139,151 ****
! print "SPI_SETDRAGWIDTH, SPI_SETDRAGHEIGHT"
dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG)
dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG)
! print 'dw,dh:', dw, dh
win32gui.SystemParametersInfo(win32con.SPI_SETDRAGWIDTH,dw+1)
win32gui.SystemParametersInfo(win32con.SPI_SETDRAGHEIGHT,dh+2)
new_dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG)
new_dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG)
! print 'new dw,dh:', new_dw, new_dh
assert new_dw==dw+1
assert new_dh==dh+2
--- 139,151 ----
! print("SPI_SETDRAGWIDTH, SPI_SETDRAGHEIGHT")
dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG)
dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG)
! print('dw,dh:', dw, dh)
win32gui.SystemParametersInfo(win32con.SPI_SETDRAGWIDTH,dw+1)
win32gui.SystemParametersInfo(win32con.SPI_SETDRAGHEIGHT,dh+2)
new_dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG)
new_dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG)
! print('new dw,dh:', new_dw, new_dh)
assert new_dw==dw+1
assert new_dh==dh+2
***************
*** 160,168 ****
orig_wallpaper=win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER)
! print 'Original: ',orig_wallpaper
for bmp in glob.glob(os.path.join(os.environ['windir'],'*.bmp')):
! print bmp
win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, Param=bmp)
! print win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER)
time.sleep(1)
--- 160,168 ----
orig_wallpaper=win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER)
! print('Original: ',orig_wallpaper)
for bmp in glob.glob(os.path.join(os.environ['windir'],'*.bmp')):
! print(bmp)
win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, Param=bmp)
! print(win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER))
time.sleep(1)
Index: win32gui_devicenotify.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_devicenotify.py,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** win32gui_devicenotify.py 4 May 2008 10:45:54 -0000 1.1
--- win32gui_devicenotify.py 29 Aug 2008 04:59:23 -0000 1.1.2.1
***************
*** 15,22 ****
# using the self-identifying data inside the DEV_BROADCAST_HDR.
info = win32gui_struct.UnpackDEV_BROADCAST(lp)
! print "Device change notification:", wp, info
if wp==win32con.DBT_DEVICEQUERYREMOVE and info.devicetype==win32con.DBT_DEVTYP_HANDLE:
# Our handle is stored away in the structure - just close it
! print "Device being removed - closing handle"
win32file.CloseHandle(info.handle)
# and cancel our notifications - if it gets plugged back in we get
--- 15,22 ----
# using the self-identifying data inside the DEV_BROADCAST_HDR.
info = win32gui_struct.UnpackDEV_BROADCAST(lp)
! print("Device change notification:", wp, info)
if wp==win32con.DBT_DEVICEQUERYREMOVE and info.devicetype==win32con.DBT_DEVTYP_HANDLE:
# Our handle is stored away in the structure - just close it
! print("Device being removed - closing handle")
win32file.CloseHandle(info.handle)
# and cancel our notifications - if it gets plugged back in we get
***************
*** 63,72 ****
# now start a message pump and wait for messages to be delivered.
! print "Watching", len(hdevs), "handles - press Ctrl+C to terminate, or"
! print "add and remove some USB devices..."
if not dir_names:
! print "(Note you can also pass paths to watch on the command-line - eg,"
! print "pass the root of an inserted USB stick to see events specific to"
! print "that volume)"
while 1:
win32gui.PumpWaitingMessages()
--- 63,72 ----
# now start a message pump and wait for messages to be delivered.
! print("Watching", len(hdevs), "handles - press Ctrl+C to terminate, or")
! print("add and remove some USB devices...")
if not dir_names:
! print("(Note you can also pass paths to watch on the command-line - eg,")
! print("pass the root of an inserted USB stick to see events specific to")
! print("that volume)")
while 1:
win32gui.PumpWaitingMessages()
Index: FileSecurityTest.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/FileSecurityTest.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** FileSecurityTest.py 3 Feb 2003 00:30:29 -0000 1.2
--- FileSecurityTest.py 29 Aug 2008 04:59:23 -0000 1.2.4.1
***************
*** 9,28 ****
if not os.path.exists(name):
! print name, "does not exist!"
sys.exit()
! print "On file " , name, "\n"
# get owner SID
! print "OWNER"
sd= win32security.GetFileSecurity(name, win32security.OWNER_SECURITY_INFORMATION)
sid= sd.GetSecurityDescriptorOwner()
! print " ", win32security.LookupAccountSid(None, sid)
# get group SID
! print "GROUP"
sd= win32security.GetFileSecurity(name, win32security.GROUP_SECURITY_INFORMATION)
sid= sd.GetSecurityDescriptorGroup()
! print " ", win32security.LookupAccountSid(None, sid)
# get ACEs
--- 9,28 ----
if not os.path.exists(name):
! print(name, "does not exist!")
sys.exit()
! print("On file " , name, "\n")
# get owner SID
! print("OWNER")
sd= win32security.GetFileSecurity(name, win32security.OWNER_SECURITY_INFORMATION)
sid= sd.GetSecurityDescriptorOwner()
! print(" ", win32security.LookupAccountSid(None, sid))
# get group SID
! print("GROUP")
sd= win32security.GetFileSecurity(name, win32security.GROUP_SECURITY_INFORMATION)
sid= sd.GetSecurityDescriptorGroup()
! print(" ", win32security.LookupAccountSid(None, sid))
# get ACEs
***************
*** 30,50 ****
dacl= sd.GetSecurityDescriptorDacl()
if dacl == None:
! print "No Discretionary ACL"
else:
for ace_no in range(0, dacl.GetAceCount()):
ace= dacl.GetAce(ace_no)
! print "ACE", ace_no
! print " -Type"
for i in ("ACCESS_ALLOWED_ACE_TYPE", "ACCESS_DENIED_ACE_TYPE", "SYSTEM_AUDIT_ACE_TYPE", "SYSTEM_ALARM_ACE_TYPE"):
if getattr(ntsecuritycon, i) == ace[0][0]:
! print " ", i
! print " -Flags", hex(ace[0][1])
for i in ("OBJECT_INHERIT_ACE", "CONTAINER_INHERIT_ACE", "NO_PROPAGATE_INHERIT_ACE", "INHERIT_ONLY_ACE", "SUCCESSFUL_ACCESS_ACE_FLAG", "FAILED_ACCESS_ACE_FLAG"):
if getattr(ntsecuritycon, i) & ace[0][1] == getattr(ntsecuritycon, i):
! print " ", i
! print " -mask", hex(ace[1])
# files and directories do permissions differently
--- 30,50 ----
dacl= sd.GetSecurityDescriptorDacl()
if dacl == None:
! print("No Discretionary ACL")
else:
for ace_no in range(0, dacl.GetAceCount()):
ace= dacl.GetAce(ace_no)
! print("ACE", ace_no)
! print(" -Type")
for i in ("ACCESS_ALLOWED_ACE_TYPE", "ACCESS_DENIED_ACE_TYPE", "SYSTEM_AUDIT_ACE_TYPE", "SYSTEM_ALARM_ACE_TYPE"):
if getattr(ntsecuritycon, i) == ace[0][0]:
! print(" ", i)
! print(" -Flags", hex(ace[0][1]))
for i in ("OBJECT_INHERIT_ACE", "CONTAINER_INHERIT_ACE", "NO_PROPAGATE_INHERIT_ACE", "INHERIT_ONLY_ACE", "SUCCESSFUL_ACCESS_ACE_FLAG", "FAILED_ACCESS_ACE_FLAG"):
if getattr(ntsecuritycon, i) & ace[0][1] == getattr(ntsecuritycon, i):
! print(" ", i)
! print(" -mask", hex(ace[1]))
# files and directories do permissions differently
***************
*** 64,68 ****
if getattr(ntsecuritycon, i) & ace[1] == getattr(ntsecuritycon, i):
calc_mask= calc_mask | getattr(ntsecuritycon, i)
! print " ", i
! print " ", "Calculated Check Mask=", hex(calc_mask)
! print " -SID\n ", win32security.LookupAccountSid(None, ace[2])
--- 64,68 ----
if getattr(ntsecuritycon, i) & ace[1] == getattr(ntsecuritycon, i):
calc_mask= calc_mask | getattr(ntsecuritycon, i)
! print(" ", i)
! print(" ", "Calculated Check Mask=", hex(calc_mask))
! print(" -SID\n ", win32security.LookupAccountSid(None, ace[2]))
Index: win32servicedemo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32servicedemo.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** win32servicedemo.py 3 Feb 2003 00:30:29 -0000 1.2
--- win32servicedemo.py 29 Aug 2008 04:59:23 -0000 1.2.4.1
***************
*** 18,22 ****
statuses = win32service.EnumServicesStatus(hscm, typeFilter, stateFilter)
for (short_name, desc, status) in statuses:
! print short_name, desc, status
--- 18,22 ----
statuses = win32service.EnumServicesStatus(hscm, typeFilter, stateFilter)
for (short_name, desc, status) in statuses:
! print(short_name, desc, status)
Index: getfilever.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/getfilever.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** getfilever.py 18 Oct 2003 06:15:48 -0000 1.1
--- getfilever.py 29 Aug 2008 04:59:23 -0000 1.1.4.1
***************
*** 8,13 ****
d=win32api.GetFileVersionInfo(fname, '\\')
## backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
! for n, v in d.items():
! print n, v
pairs=win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')
--- 8,13 ----
d=win32api.GetFileVersionInfo(fname, '\\')
## backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
! for n, v in list(d.items()):
! print(n, v)
pairs=win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')
***************
*** 15,23 ****
## any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle two are language/codepage pair returned from above
for lang, codepage in pairs:
! print 'lang: ', lang, 'codepage:', codepage
for ver_string in ver_strings:
! str_info=u'\\StringFileInfo\\%04X%04X\\%s' %(lang,codepage,ver_string)
## print str_info
! print ver_string, win32api.GetFileVersionInfo(fname, str_info)
--- 15,23 ----
## any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle two are language/codepage pair returned from above
for lang, codepage in pairs:
! print('lang: ', lang, 'codepage:', codepage)
for ver_string in ver_strings:
! str_info='\\StringFileInfo\\%04X%04X\\%s' %(lang,codepage,ver_string)
## print str_info
! print(ver_string, win32api.GetFileVersionInfo(fname, str_info))
Index: print_desktop.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/print_desktop.py,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -C2 -d -r1.5 -r1.5.4.1
*** print_desktop.py 19 Dec 2006 13:51:22 -0000 1.5
--- print_desktop.py 29 Aug 2008 04:59:23 -0000 1.5.4.1
***************
*** 2,8 ****
pname=win32print.GetDefaultPrinter()
! print pname
p=win32print.OpenPrinter(pname)
! print 'Printer handle: ',p
print_processor=win32print.GetPrinter(p,2)['pPrintProcessor']
## call with last parm set to 0 to get total size needed for printer's DEVMODE
--- 2,8 ----
pname=win32print.GetDefaultPrinter()
! print(pname)
p=win32print.OpenPrinter(pname)
! print('Printer handle: ',p)
print_processor=win32print.GetPrinter(p,2)['pPrintProcessor']
## call with last parm set to 0 to get total size needed for printer's DEVMODE
Index: cerapi.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/cerapi.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** cerapi.py 3 Feb 2003 00:30:29 -0000 1.2
--- cerapi.py 29 Aug 2008 04:59:23 -0000 1.2.4.1
***************
*** 10,14 ****
import sys
import getopt
! from repr import repr
--- 10,14 ----
import sys
import getopt
! from reprlib import repr
***************
*** 17,24 ****
h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\PythonPath" % sys.winver)
except win32api.error:
! print "The remote device does not appear to have Python installed"
return 0
path, typ = wincerapi.CeRegQueryValueEx(h, None)
! print "The remote PythonPath is '%s'" % (str(path), )
h.Close()
return 1
--- 17,24 ----
h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\PythonPath" % sys.winver)
except win32api.error:
! print("The remote device does not appear to have Python installed")
return 0
path, typ = wincerapi.CeRegQueryValueEx(h, None)
! print("The remote PythonPath is '%s'" % (str(path), ))
h.Close()
return 1
***************
*** 35,39 ****
except win32api.error:
break
! print "%s%s=%s" % (level_prefix, name, repr(str(data)))
index = index+1
# Now enumerate all keys.
--- 35,39 ----
except win32api.error:
break
! print("%s%s=%s" % (level_prefix, name, repr(str(data))))
index = index+1
# Now enumerate all keys.
***************
*** 44,48 ****
except win32api.error:
break
! print "%s%s\\" % (level_prefix, name)
subkey = wincerapi.CeRegOpenKeyEx(root, name)
DumpRegistry(subkey, level+1)
--- 44,48 ----
except win32api.error:
break
! print("%s%s\\" % (level_prefix, name))
subkey = wincerapi.CeRegOpenKeyEx(root, name)
DumpRegistry(subkey, level+1)
***************
*** 57,65 ****
cefile = wincerapi.CeCreateFile("TestPython", win32con.GENERIC_READ, 0, None, win32con.OPEN_EXISTING, 0, None)
if wincerapi.CeReadFile(cefile, 100) != "Hello from Python":
! print "Couldnt read the data from the device!"
cefile.Close()
# Delete the test file
wincerapi.CeDeleteFile("TestPython")
! print "Created, wrote to, read from and deleted a test file!"
def DemoCreateProcess():
--- 57,65 ----
cefile = wincerapi.CeCreateFile("TestPython", win32con.GENERIC_READ, 0, None, win32con.OPEN_EXISTING, 0, None)
if wincerapi.CeReadFile(cefile, 100) != "Hello from Python":
! print("Couldnt read the data from the device!")
cefile.Close()
# Delete the test file
wincerapi.CeDeleteFile("TestPython")
! print("Created, wrote to, read from and deleted a test file!")
def DemoCreateProcess():
***************
*** 71,77 ****
hp.Close()
ht.Close()
! print "Python is running on the remote device!"
! except win32api.error, (hr, fn, msg):
! print "Couldnt execute remote process -", msg
def DumpRemoteMachineStatus():
--- 71,78 ----
hp.Close()
ht.Close()
! print("Python is running on the remote device!")
! except win32api.error as xxx_todo_changeme:
! (hr, fn, msg) = xxx_todo_changeme.args
! print("Couldnt execute remote process -", msg)
def DumpRemoteMachineStatus():
***************
*** 86,123 ****
else:
batPerc = BatteryLifePercent
! print "The batteries are at %s%%, and is currently being powered by %s" % (batPerc, power)
memLoad, totalPhys, availPhys, totalPage, availPage, totalVirt, availVirt = \
wincerapi.CeGlobalMemoryStatus()
! print "The memory is %d%% utilized." % (memLoad)
! print "%-20s%-10s%-10s" % ("", "Total", "Avail")
! print "%-20s%-10s%-10s" % ("Physical Memory", totalPhys, availPhys)
! print "%-20s%-10s%-10s" % ("Virtual Memory", totalVirt, availVirt)
! print "%-20s%-10s%-10s" % ("Paging file", totalPage, availPage)
storeSize, freeSize = wincerapi.CeGetStoreInformation()
! print "%-20s%-10s%-10s" % ("File store", storeSize, freeSize)
! print "The CE temp path is", wincerapi.CeGetTempPath()
! print "The system info for the device is", wincerapi.CeGetSystemInfo()
def DumpRemoteFolders():
# Dump all special folders possible.
! for name, val in wincerapi.__dict__.items():
if name[:6]=="CSIDL_":
try:
loc = str(wincerapi.CeGetSpecialFolderPath(val))
! print "Folder %s is at %s" % (name, loc)
! except win32api.error, details:
pass
# Get the shortcut targets for the "Start Menu"
! print "Dumping start menu shortcuts..."
try:
startMenu = str(wincerapi.CeGetSpecialFolderPath(wincerapi.CSIDL_STARTMENU))
! except win32api.error, details:
! print "This device has no start menu!", details
startMenu = None
--- 87,124 ----
else:
batPerc = BatteryLifePercent
! print("The batteries are at %s%%, and is currently being powered by %s" % (batPerc, power))
memLoad, totalPhys, availPhys, totalPage, availPage, totalVirt, availVirt = \
wincerapi.CeGlobalMemoryStatus()
! print("The memory is %d%% utilized." % (memLoad))
! print("%-20s%-10s%-10s" % ("", "Total", "Avail"))
! print("%-20s%-10s%-10s" % ("Physical Memory", totalPhys, availPhys))
! print("%-20s%-10s%-10s" % ("Virtual Memory", totalVirt, availVirt))
! print("%-20s%-10s%-10s" % ("Paging file", totalPage, availPage))
storeSize, freeSize = wincerapi.CeGetStoreInformation()
! print("%-20s%-10s%-10s" % ("File store", storeSize, freeSize))
! print("The CE temp path is", wincerapi.CeGetTempPath())
! print("The system info for the device is", wincerapi.CeGetSystemInfo())
def DumpRemoteFolders():
# Dump all special folders possible.
! for name, val in list(wincerapi.__dict__.items()):
if name[:6]=="CSIDL_":
try:
loc = str(wincerapi.CeGetSpecialFolderPath(val))
! print("Folder %s is at %s" % (name, loc))
! except win32api.error as details:
pass
# Get the shortcut targets for the "Start Menu"
! print("Dumping start menu shortcuts...")
try:
startMenu = str(wincerapi.CeGetSpecialFolderPath(wincerapi.CSIDL_STARTMENU))
! except win32api.error as details:
! print("This device has no start menu!", details)
startMenu = None
***************
*** 128,134 ****
try:
resolved = wincerapi.CeSHGetShortcutTarget(fullPath)
! except win32api.error, (rc, fn, msg):
resolved = "#Error - %s" % msg
! print "%s->%s" % (fileName, resolved)
# print "The start menu is at",
--- 129,136 ----
try:
resolved = wincerapi.CeSHGetShortcutTarget(fullPath)
! except win32api.error as xxx_todo_changeme1:
! (rc, fn, msg) = xxx_todo_changeme1.args
resolved = "#Error - %s" % msg
! print("%s->%s" % (fileName, resolved))
# print "The start menu is at",
***************
*** 136,146 ****
def usage():
! print "Options:"
! print "-a - Execute all demos"
! print "-p - Execute Python process on remote device"
! print "-r - Dump the remote registry"
! print "-f - Dump all remote special folder locations"
! print "-s - Dont dump machine status"
! print "-y - Perform asynch init of CE connection"
def main():
--- 138,148 ----
def usage():
! print("Options:")
! print("-a - Execute all demos")
! print("-p - Execute Python process on remote device")
! print("-r - Dump the remote registry")
! print("-f - Dump all remote special folder locations")
! print("-s - Dont dump machine status")
! print("-y - Perform asynch init of CE connection")
def main():
***************
*** 149,154 ****
try:
opts, args = getopt.getopt(sys.argv[1:], "apr")
! except getopt.error, why:
! print "Invalid usage:", why
usage()
return
--- 151,156 ----
try:
opts, args = getopt.getopt(sys.argv[1:], "apr")
! except getopt.error as why:
! print("Invalid usage:", why)
usage()
return
***************
*** 166,170 ****
bDumpFolders = 1
if o=="-y":
! print "Doing asynch init of CE connection"
async_init = 1
--- 168,172 ----
bDumpFolders = 1
if o=="-y":
! print("Doing asynch init of CE connection")
async_init = 1
***************
*** 177,211 ****
break
else:
! print "Waiting for Initialize to complete (picture a Cancel button here :)"
else:
wincerapi.CeRapiInit()
! print "Connected to remote CE device."
try:
verinfo = wincerapi.CeGetVersionEx()
! print "The device is running windows CE version %d.%d - %s" % (verinfo[0], verinfo[1], verinfo[4])
if bDumpStatus:
! print "Dumping remote machine status"
DumpRemoteMachineStatus()
if bDumpRegistry:
! print "Dumping remote registry..."
DumpRegistry(win32con.HKEY_LOCAL_MACHINE)
if bDumpFolders:
! print "Dumping remote folder information"
DumpRemoteFolders()
DemoCopyFile()
if bStartPython:
! print "Starting remote Python process"
if DumpPythonRegistry():
DemoCreateProcess()
else:
! print "Not trying to start Python, as it's not installed"
finally:
wincerapi.CeRapiUninit()
! print "Disconnected"
if __name__=='__main__':
--- 179,213 ----
break
else:
! print("Waiting for Initialize to complete (picture a Cancel button here :)")
else:
wincerapi.CeRapiInit()
! print("Connected to remote CE device.")
try:
verinfo = wincerapi.CeGetVersionEx()
! print("The device is running windows CE version %d.%d - %s" % (verinfo[0], verinfo[1], verinfo[4]))
if bDumpStatus:
! print("Dumping remote machine status")
DumpRemoteMachineStatus()
if bDumpRegistry:
! print("Dumping remote registry...")
DumpRegistry(win32con.HKEY_LOCAL_MACHINE)
if bDumpFolders:
! print("Dumping remote folder information")
DumpRemoteFolders()
DemoCopyFile()
if bStartPython:
! print("Starting remote Python process")
if DumpPythonRegistry():
DemoCreateProcess()
else:
! print("Not trying to start Python, as it's not installed")
finally:
wincerapi.CeRapiUninit()
! print("Disconnected")
if __name__=='__main__':
Index: winprocess.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/winprocess.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** winprocess.py 3 Feb 2003 00:30:29 -0000 1.2
--- winprocess.py 29 Aug 2008 04:59:24 -0000 1.2.4.1
***************
*** 164,168 ****
if child.wait(mSec) != win32event.WAIT_OBJECT_0:
child.kill()
! raise WindowsError, 'process timeout exceeded'
return child.exitCode()
--- 164,168 ----
if child.wait(mSec) != win32event.WAIT_OBJECT_0:
child.kill()
! raise WindowsError('process timeout exceeded')
return child.exitCode()
***************
*** 171,175 ****
# Pipe commands to a shell and display the output in notepad
! print 'Testing winprocess.py...'
import tempfile
--- 171,175 ----
# Pipe commands to a shell and display the output in notepad
! print('Testing winprocess.py...')
import tempfile
***************
*** 184,195 ****
""" % timeoutSeconds
! cmd, out = tempfile.TemporaryFile(), tempfile.TemporaryFile()
! cmd.write(cmdString)
cmd.seek(0)
! print 'CMD.EXE exit code:', run('cmd.exe', show=0, stdin=cmd,
! stdout=out, stderr=out)
cmd.close()
! print 'NOTEPAD exit code:', run('notepad.exe %s' % out.file.name,
show=win32con.SW_MAXIMIZE,
! mSec=timeoutSeconds*1000)
out.close()
--- 184,197 ----
""" % timeoutSeconds
! cmd = tempfile.NamedTemporaryFile(delete=False)
! out = tempfile.NamedTemporaryFile(suffix='.txt', delete=False)
! cmd.write(cmdString.encode('mbcs'))
cmd.seek(0)
! print('CMD.EXE exit code:', run('cmd.exe', show=0, stdin=cmd,
! stdout=out, stderr=out))
cmd.close()
! out.close()
! print('NOTEPAD exit code:', run('notepad.exe %s' % out.name,
show=win32con.SW_MAXIMIZE,
! mSec=timeoutSeconds*1000))
out.close()
Index: win32gui_taskbar.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_taskbar.py,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** win32gui_taskbar.py 30 Oct 2007 09:27:13 -0000 1.9
--- win32gui_taskbar.py 29 Aug 2008 04:59:23 -0000 1.9.2.1
***************
*** 45,49 ****
hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags)
else:
! print "Can't find a Python icon file - using default"
hicon = LoadIcon(0, win32con.IDI_APPLICATION)
--- 45,49 ----
hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags)
else:
! print("Can't find a Python icon file - using default")
hicon = LoadIcon(0, win32con.IDI_APPLICATION)
***************
*** 55,59 ****
# This is common when windows is starting, and this code is hit
# before the taskbar has been created.
! print "Failed to add the taskbar icon - is explorer running?"
# but keep running anyway - when explorer starts, we get the
# TaskbarCreated message.
--- 55,59 ----
# This is common when windows is starting, and this code is hit
# before the taskbar has been created.
! print("Failed to add the taskbar icon - is explorer running?")
# but keep running anyway - when explorer starts, we get the
# TaskbarCreated message.
***************
*** 69,78 ****
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
if lparam==win32con.WM_LBUTTONUP:
! print "You clicked me."
elif lparam==win32con.WM_LBUTTONDBLCLK:
! print "You double-clicked me - goodbye"
DestroyWindow(self.hwnd)
elif lparam==win32con.WM_RBUTTONUP:
! print "You right clicked me."
menu = CreatePopupMenu()
AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
--- 69,78 ----
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
if lparam==win32con.WM_LBUTTONUP:
! print("You clicked me.")
elif lparam==win32con.WM_L...
[truncated message content] |