pywin32-checkins Mailing List for Python for Windows Extensions (Page 26)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2009-01-14 13:04:35
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3275/win32/Demos Modified Files: winprocess.py Log Message: bash demo back into shape and working with py2k and py3k Index: winprocess.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/winprocess.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** winprocess.py 1 Oct 2008 14:44:53 -0000 1.3 --- winprocess.py 14 Jan 2009 12:12:26 -0000 1.4 *************** *** 17,20 **** --- 17,21 ---- import win32api, win32process, win32security import win32event, win32con, msvcrt, win32gui + import os *************** *** 178,182 **** cmdString = """\ REM Test of winprocess.py piping commands to a shell.\r ! REM This window will close in %d seconds.\r vol\r net user\r --- 179,183 ---- cmdString = """\ REM Test of winprocess.py piping commands to a shell.\r ! REM This 'notepad' process will terminate in %d seconds.\r vol\r net user\r *************** *** 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() --- 185,206 ---- """ % timeoutSeconds ! cmd_name = tempfile.mktemp() ! out_name = cmd_name + '.txt' ! try: ! cmd = open(cmd_name, "w+b") ! out = open(out_name, "w+b") ! 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() ! print 'NOTEPAD exit code:', run('notepad.exe %s' % out.name, ! show=win32con.SW_MAXIMIZE, ! mSec=timeoutSeconds*1000) ! out.close() ! finally: ! for n in (cmd_name, out_name): ! try: ! os.unlink(cmd_name) ! except os.error: ! pass |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:46
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460 Modified Files: Tag: py3k setup.py Log Message: merge lots of changes from the trunk Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.81.2.13 retrieving revision 1.81.2.14 diff -C2 -d -r1.81.2.13 -r1.81.2.14 *** setup.py 5 Jan 2009 12:51:26 -0000 1.81.2.13 --- setup.py 14 Jan 2009 12:42:02 -0000 1.81.2.14 *************** *** 29,35 **** The 'exchange' extensions require headers that are no longer in any current SDKs, so these fail to build, but the 'mapi' extension should still build. ! Also, 'axdebug' once worked with recent Platform SDKs, with no ! additional software was needed - but currently this extension is known to not ! build. Building: --- 29,45 ---- The 'exchange' extensions require headers that are no longer in any current SDKs, so these fail to build, but the 'mapi' extension should still build. ! ! To build the axdebug extension for 32bit Python, follow these instructions: ! ! * Download the "Internet Explorer 4.01 Refresh of the Internet Client SDK" ! from http://support.microsoft.com/kb/q177877/. ! * The download is a self-extracting archive - execute it and unzip the ! contents to a 'temp' directory. ! * From that directory, copy 'include/axdebug.h' and 'lib/msdbg.lib' to ! somewhere the build process will find them - the 'include' and 'lib' ! directories of your SDK installation works. ! ! Note that no equivalent SDK for 64bit operating systems appears available, ! so this extension does not build on 64bit versions. Building: *************** *** 879,883 **** # Copy cpp lib files needed to create Python COM extensions clib_files = (['win32', 'pywintypes%s.lib'], ! ['win32com', 'pythoncom%s.lib']) for clib_file in clib_files: target_dir = os.path.join(self.build_lib, clib_file[0], "libs") --- 889,894 ---- # Copy cpp lib files needed to create Python COM extensions clib_files = (['win32', 'pywintypes%s.lib'], ! ['win32com', 'pythoncom%s.lib'], ! ['axscript', 'axscript%s.lib']) for clib_file in clib_files: target_dir = os.path.join(self.build_lib, clib_file[0], "libs") *************** *** 1544,1547 **** --- 1555,1559 ---- 'shell' : 'com/win32comext/shell/src', 'axcontrol' : 'com/win32comext/axcontrol/src', + 'axdebug' : 'com/win32comext/axdebug/src', 'mapi' : 'com/win32comext/mapi/src', 'authorization' : 'com/win32comext/authorization/src', *************** *** 1593,1596 **** --- 1605,1609 ---- dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], + implib_name="axscript.lib", pch_header = "stdafx.h" ), *************** *** 1598,1605 **** # module for details on getting it built. WinExt_win32com('axdebug', ! dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript", ! pch_header = "stdafx.h", ! optional_headers = ["activdbg.h"], ), WinExt_win32com('internet'), --- 1611,1664 ---- # module for details on getting it built. WinExt_win32com('axdebug', ! libraries="axscript msdbg", ! pch_header="stdafx.h", ! optional_headers=["activdbg.h"], ! platforms=['win32'], ! sources=(""" ! %(axdebug)s/AXDebug.cpp ! %(axdebug)s/PyIActiveScriptDebug.cpp ! %(axdebug)s/PyIActiveScriptErrorDebug.cpp ! %(axdebug)s/PyIActiveScriptSiteDebug.cpp ! %(axdebug)s/PyIApplicationDebugger.cpp ! %(axdebug)s/PyIDebugApplication.cpp ! %(axdebug)s/PyIDebugApplicationNode.cpp ! %(axdebug)s/PyIDebugApplicationNodeEvents.cpp ! %(axdebug)s/PyIDebugApplicationThread.cpp ! %(axdebug)s/PyIDebugCodeContext.cpp ! %(axdebug)s/PyIDebugDocument.cpp ! %(axdebug)s/PyIDebugDocumentContext.cpp ! %(axdebug)s/PyIDebugDocumentHelper.cpp ! %(axdebug)s/PyIDebugDocumentHost.cpp ! %(axdebug)s/PyIDebugDocumentInfo.cpp ! %(axdebug)s/PyIDebugDocumentProvider.cpp ! %(axdebug)s/PyIDebugDocumentText.cpp ! %(axdebug)s/PyIDebugDocumentTextAuthor.cpp ! %(axdebug)s/PyIDebugDocumentTextEvents.cpp ! %(axdebug)s/PyIDebugDocumentTextExternalAuthor.cpp ! %(axdebug)s/PyIDebugExpression.cpp ! %(axdebug)s/PyIDebugExpressionCallBack.cpp ! %(axdebug)s/PyIDebugExpressionContext.cpp ! %(axdebug)s/PyIDebugProperties.cpp ! %(axdebug)s/PyIDebugSessionProvider.cpp ! %(axdebug)s/PyIDebugStackFrame.cpp ! %(axdebug)s/PyIDebugStackFrameSniffer.cpp ! %(axdebug)s/PyIDebugStackFrameSnifferEx.cpp ! %(axdebug)s/PyIDebugSyncOperation.cpp ! %(axdebug)s/PyIEnumDebugApplicationNodes.cpp ! %(axdebug)s/PyIEnumDebugCodeContexts.cpp ! %(axdebug)s/PyIEnumDebugExpressionContexts.cpp ! %(axdebug)s/PyIEnumDebugPropertyInfo.cpp ! %(axdebug)s/PyIEnumDebugStackFrames.cpp ! %(axdebug)s/PyIEnumRemoteDebugApplications.cpp ! %(axdebug)s/PyIEnumRemoteDebugApplicationThreads.cpp ! %(axdebug)s/PyIMachineDebugManager.cpp ! %(axdebug)s/PyIMachineDebugManagerEvents.cpp ! %(axdebug)s/PyIProcessDebugManager.cpp ! %(axdebug)s/PyIProvideExpressionContexts.cpp ! %(axdebug)s/PyIRemoteDebugApplication.cpp ! %(axdebug)s/PyIRemoteDebugApplicationEvents.cpp ! %(axdebug)s/PyIRemoteDebugApplicationThread.cpp ! %(axdebug)s/stdafx.cpp ! """ % dirs).split(), ), WinExt_win32com('internet'), *************** *** 1907,1910 **** --- 1966,1970 ---- 'win32comext.taskscheduler', 'win32comext.directsound', + 'win32comext.directsound.test', 'win32comext.authorization', 'win32comext.bits', |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:41
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/Pythonwin Modified Files: Tag: py3k pythonpsheet.cpp win32control.h win32uimodule.cpp win32view.cpp Log Message: merge lots of changes from the trunk Index: win32view.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32view.cpp,v retrieving revision 1.4.2.3 retrieving revision 1.4.2.4 diff -C2 -d -r1.4.2.3 -r1.4.2.4 *** win32view.cpp 28 Dec 2008 10:55:49 -0000 1.4.2.3 --- win32view.cpp 14 Jan 2009 12:42:02 -0000 1.4.2.4 *************** *** 690,709 **** GET_PY_CTOR(PyCCtrlView)); - /* Inheritance from PyCView and control type is now done via tp_bases */ - /* - PyObject * - PyCCtrlView::getattr(char *name) - { - // implement inheritance. - PyObject *retMethod = PyCView::getattr(name); - if (!retMethod) { - PyErr_Clear(); - PyCCtrlView_Type *thisType = (PyCCtrlView_Type *)ob_type; - if (thisType) - retMethod = Py_FindMethod(thisType->control->methods, (PyObject *)this, name); - } - return retMethod; - } - */ ///////////////////////////////////////////////////////////////////// --- 690,693 ---- Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.39.2.13 retrieving revision 1.39.2.14 diff -C2 -d -r1.39.2.13 -r1.39.2.14 *** win32uimodule.cpp 8 Jan 2009 02:14:14 -0000 1.39.2.13 --- win32uimodule.cpp 14 Jan 2009 12:42:02 -0000 1.39.2.14 *************** *** 380,384 **** struct PyMethodDef ui_base_class_methods[] = { - // {"GetMethodByType", ui_base_class_GetMethodByType, 1}, {NULL, NULL} }; --- 380,383 ---- *************** *** 2025,2028 **** --- 2024,2034 ---- #endif ADD_CONSTANT(debug); // @const win32ui|debug|1 if we are current using a _DEBUG build of win32ui, else 0. + if (PyModule_AddIntConstant(module, "UNICODE", + #ifdef UNICODE + 1 + #else + 0 + #endif + ) == -1) return -1; ADD_CONSTANT(AFX_IDW_PANE_FIRST); // @const win32ui|AFX_IDW_PANE_FIRST|Id of the first splitter pane ADD_CONSTANT(AFX_IDW_PANE_LAST); // @const win32ui|AFX_IDW_PANE_LAST|Id of the last splitter pane Index: win32control.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32control.h,v retrieving revision 1.1.4.2 retrieving revision 1.1.4.3 diff -C2 -d -r1.1.4.2 -r1.1.4.3 *** win32control.h 28 Dec 2008 10:55:49 -0000 1.1.4.2 --- win32control.h 14 Jan 2009 12:42:02 -0000 1.1.4.3 *************** *** 31,35 **** MAKE_PY_CTOR(PyCCtrlView) static PyCCtrlView_Type type; - // PyObject * getattr(char *name); static PyObject *create(PyObject *self, PyObject *args); protected: --- 31,34 ---- Index: pythonpsheet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pythonpsheet.cpp,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -C2 -d -r1.4.2.2 -r1.4.2.3 *** pythonpsheet.cpp 3 Jan 2009 04:45:16 -0000 1.4.2.2 --- pythonpsheet.cpp 14 Jan 2009 12:42:02 -0000 1.4.2.3 *************** *** 211,215 **** if (!py_bob->is_uiobject(&ui_assoc_object::type)) { TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n"); ! Py_DECREF(py_bob); return; } --- 211,215 ---- if (!py_bob->is_uiobject(&ui_assoc_object::type)) { TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n"); ! Py_DECREF(py_bob); return; } *************** *** 225,229 **** PyErr_Restore(t,v,tb); } ! Py_DECREF(py_bob); if (!m_customizeFont) { --- 225,229 ---- PyErr_Restore(t,v,tb); } ! Py_DECREF(py_bob); if (!m_customizeFont) { |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:32
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/Pythonwin/pywin/debugger Modified Files: Tag: py3k debugger.py Log Message: merge lots of changes from the trunk Index: debugger.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger/debugger.py,v retrieving revision 1.17.2.6 retrieving revision 1.17.2.7 diff -C2 -d -r1.17.2.6 -r1.17.2.7 *** debugger.py 4 Jan 2009 01:54:09 -0000 1.17.2.6 --- debugger.py 14 Jan 2009 12:42:02 -0000 1.17.2.7 *************** *** 28,31 **** --- 28,35 ---- #import win32traceutil + if win32ui.UNICODE: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW + else: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA from .dbgcon import * *************** *** 238,242 **** itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0) list.InsertColumn(col, itemDetails) ! parent.HookNotify( self.OnListEndLabelEdit, commctrl.LVN_ENDLABELEDITW) parent.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK) parent.HookNotify(self.OnItemDoubleClick, commctrl.NM_DBLCLK) --- 242,246 ---- itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0) list.InsertColumn(col, itemDetails) ! parent.HookNotify(self.OnListEndLabelEdit, LVN_ENDLABELEDIT) parent.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK) parent.HookNotify(self.OnItemDoubleClick, commctrl.NM_DBLCLK) *************** *** 249,254 **** def EditSelected(self): ! sel = self.GetNextItem(-1, commctrl.LVNI_SELECTED) ! if sel == -1: return self.EditLabel(sel) --- 253,259 ---- def EditSelected(self): ! try: ! sel = self.GetNextItem(-1, commctrl.LVNI_SELECTED) ! except win32ui.error: return self.EditLabel(sel) |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:30
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/Pythonwin/pywin/framework Modified Files: Tag: py3k scriptutils.py toolmenu.py Log Message: merge lots of changes from the trunk Index: toolmenu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/toolmenu.py,v retrieving revision 1.3.4.2 retrieving revision 1.3.4.3 diff -C2 -d -r1.3.4.2 -r1.3.4.3 *** toolmenu.py 5 Jan 2009 12:51:26 -0000 1.3.4.2 --- toolmenu.py 14 Jan 2009 12:42:02 -0000 1.3.4.3 *************** *** 123,126 **** --- 123,131 ---- from pywin.mfc import dialog + if win32ui.UNICODE: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW + else: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA + class ToolMenuPropPage(dialog.PropertyPage): def __init__(self): *************** *** 137,141 **** self.HookNotify(self.OnNotifyListControl, commctrl.LVN_ITEMCHANGED) ! self.HookNotify(self.OnNotifyListControlEndLabelEdit, commctrl.LVN_ENDLABELEDITW) # Hook the button clicks. --- 142,146 ---- self.HookNotify(self.OnNotifyListControl, commctrl.LVN_ITEMCHANGED) ! self.HookNotify(self.OnNotifyListControlEndLabelEdit, commctrl.LVN_ENDLABELEDIT) # Hook the button clicks. Index: scriptutils.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/scriptutils.py,v retrieving revision 1.18.2.5 retrieving revision 1.18.2.6 diff -C2 -d -r1.18.2.5 -r1.18.2.6 *** scriptutils.py 5 Jan 2009 12:51:26 -0000 1.18.2.5 --- scriptutils.py 14 Jan 2009 12:42:02 -0000 1.18.2.6 *************** *** 413,421 **** exec(codeObj, __main__.__dict__) if bNeedReload: ! ! import imp ! imp.reload(sys.modules[modName]) ! # codeObj = compile('reload('+modName+')','<auto import>','eval') ! # exec codeObj in __main__.__dict__ win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"'") except: --- 413,421 ---- exec(codeObj, __main__.__dict__) if bNeedReload: ! try: ! from imp import reload # py3k ! except ImportError: ! pass # reload a builtin in py2k ! reload(sys.modules[modName]) win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"'") except: |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:20
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/Pythonwin/pywin/tools Modified Files: Tag: py3k browser.py hierlist.py Log Message: merge lots of changes from the trunk Index: hierlist.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/hierlist.py,v retrieving revision 1.7.2.4 retrieving revision 1.7.2.5 diff -C2 -d -r1.7.2.4 -r1.7.2.5 *** hierlist.py 5 Jan 2009 12:51:26 -0000 1.7.2.4 --- hierlist.py 14 Jan 2009 12:42:02 -0000 1.7.2.5 *************** *** 314,323 **** return None # same as other # for py3k/rich-comp sorting compatibility. ! def __cmp__(self): # this is always overridden, but to be sure... return cmp(id(self), id(other)) def __lt__(self, other): try: ! return self.__cmp__(self, other) < 0 except TypeError: # we want unrelated items to be sortable... --- 314,323 ---- return None # same as other # for py3k/rich-comp sorting compatibility. ! def __cmp__(self, other): # this is always overridden, but to be sure... return cmp(id(self), id(other)) def __lt__(self, other): try: ! return self.__cmp__(other) < 0 except TypeError: # we want unrelated items to be sortable... *************** *** 326,330 **** def __eq__(self, other): try: ! return __cmp__(self, other) == 0 except TypeError: # unrelated items compare false --- 326,330 ---- def __eq__(self, other): try: ! return self.__cmp__(other) == 0 except TypeError: # unrelated items compare false Index: browser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/browser.py,v retrieving revision 1.10.2.6 retrieving revision 1.10.2.7 diff -C2 -d -r1.10.2.6 -r1.10.2.7 *** browser.py 5 Jan 2009 12:51:26 -0000 1.10.2.6 --- browser.py 14 Jan 2009 12:42:02 -0000 1.10.2.7 *************** *** 206,211 **** except AttributeError: pass ! ret.append( MakeHLI( self.myobject.__code__, "Code" )) ! ret.append( MakeHLI( self.myobject.__globals__, "Globals" )) self.InsertDocString(ret) return ret --- 206,218 ---- except AttributeError: pass ! try: ! code = self.myobject.__code__ ! globs = self.myobject.__globals__ ! except AttributeError: ! # must be py2.5 or earlier... ! code = self.myobject.func_code ! globs = self.myobject.func_globals ! ret.append(MakeHLI(code, "Code" )) ! ret.append(MakeHLI(globs, "Globals" )) self.InsertDocString(ret) return ret |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:16
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32com/client Modified Files: Tag: py3k build.py genpy.py Log Message: merge lots of changes from the trunk Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.55.2.8 retrieving revision 1.55.2.9 diff -C2 -d -r1.55.2.8 -r1.55.2.9 *** genpy.py 5 Jan 2009 12:51:26 -0000 1.55.2.8 --- genpy.py 14 Jan 2009 12:42:02 -0000 1.55.2.9 *************** *** 205,211 **** val = vdesc[1] if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, int)): ! if val==0x80000000-1+1: # special case for py2.3 (and avoid 'L' syntax for py3k) use = "0x80000000L" # 'L' for future warning ! elif val > 0x80000000-1+1 or val < 0: # avoid a FutureWarning use = int(val) else: --- 205,212 ---- val = vdesc[1] if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, int)): ! # in python 2.3, 0x80000000L == 2147483648 ! if val==2147483648: # == 0x80000000L - special case for 2.3... use = "0x80000000L" # 'L' for future warning ! elif val > 2147483648 or val < 0: # avoid a FutureWarning use = int(val) else: *************** *** 827,831 **** print('python_version = 0x%x' % (sys.hexversion,), file=self.file) print(file=self.file) ! print('import win32com.client.CLSIDToClass, pythoncom', file=self.file) print('import win32com.client.util', file=self.file) print('from pywintypes import IID', file=self.file) --- 828,832 ---- print('python_version = 0x%x' % (sys.hexversion,), file=self.file) print(file=self.file) ! print('import win32com.client.CLSIDToClass, pythoncom, pywintypes', file=self.file) print('import win32com.client.util', file=self.file) print('from pywintypes import IID', file=self.file) Index: build.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v retrieving revision 1.31.2.7 retrieving revision 1.31.2.8 diff -C2 -d -r1.31.2.7 -r1.31.2.8 *** build.py 5 Jan 2009 12:51:26 -0000 1.31.2.7 --- build.py 14 Jan 2009 12:42:02 -0000 1.31.2.8 *************** *** 19,23 **** import sys import string - from keyword import iskeyword --- 19,22 ---- *************** *** 560,564 **** if type(val) is TimeType: year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec ! return "pythoncom.MakeTime((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals() else: return repr(val) --- 559,563 ---- if type(val) is TimeType: year=val.year; month=val.month; day=val.day; hour=val.hour; minute=val.minute; second=val.second; msec=val.msec ! return "pywintypes.Time((%(year)d, %(month)d, %(day)d, %(hour)d, %(minute)d, %(second)d,0,0,0,%(msec)d))" % locals() else: return repr(val) |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:12
|
Update of /cvsroot/pywin32/pywin32/com/win32com/demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32com/demos Modified Files: Tag: py3k connect.py Log Message: merge lots of changes from the trunk Index: connect.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/connect.py,v retrieving revision 1.2.4.3 retrieving revision 1.2.4.4 diff -C2 -d -r1.2.4.3 -r1.2.4.4 *** connect.py 27 Nov 2008 04:58:41 -0000 1.2.4.3 --- connect.py 14 Jan 2009 12:42:02 -0000 1.2.4.4 *************** *** 10,13 **** --- 10,14 ---- import win32com.server.connect from win32com.server.exception import Exception + from pywin32_testutil import str2bytes # This is the IID of the Events interface both Client and Server support. *************** *** 71,75 **** connection.Connect(server, client, IID_IConnectDemoEvents) CheckEvent(server, client, "Hello", verbose) ! CheckEvent(server, client, b"Here is a null>\x00<", verbose) CheckEvent(server, client, "Here is a null>\x00<", verbose) val = "test-\xe0\xf2" # 2 extended characters. --- 72,76 ---- connection.Connect(server, client, IID_IConnectDemoEvents) CheckEvent(server, client, "Hello", verbose) ! CheckEvent(server, client, str2bytes("Here is a null>\x00<"), verbose) CheckEvent(server, client, "Here is a null>\x00<", verbose) val = "test-\xe0\xf2" # 2 extended characters. |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:10
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32com/src Modified Files: Tag: py3k PythonCOM.cpp oleargs.cpp Log Message: merge lots of changes from the trunk Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.52.2.5 retrieving revision 1.52.2.6 diff -C2 -d -r1.52.2.5 -r1.52.2.6 *** PythonCOM.cpp 8 Jan 2009 03:45:49 -0000 1.52.2.5 --- PythonCOM.cpp 14 Jan 2009 12:42:02 -0000 1.52.2.6 *************** *** 18,21 **** --- 18,23 ---- #include "PyComTypeObjects.h" #include "OleAcc.h" // for ObjectFromLresult proto... + #include "pyerrors.h" // for PyErr_Warn in 2.5 and earlier... + extern int PyCom_RegisterCoreIIDs(PyObject *dict); *************** *** 744,748 **** static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeIID is deprecated - please use pywintypes.IID() instead.", 1); return PyWinMethod_NewIID(self, args); } --- 746,750 ---- static PyObject *pythoncom_MakeIID(PyObject *self, PyObject *args) { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "MakeIID is deprecated - please use pywintypes.IID() instead."); return PyWinMethod_NewIID(self, args); } *************** *** 751,755 **** static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! PyErr_WarnEx(PyExc_PendingDeprecationWarning, "MakeTime is deprecated - please use pywintypes.Time() instead.", 1); return PyWinMethod_NewTime(self, args); } --- 753,757 ---- static PyObject *pythoncom_MakeTime(PyObject *self, PyObject *args) { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "MakeTime is deprecated - please use pywintypes.Time() instead."); return PyWinMethod_NewTime(self, args); } Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.41.2.6 retrieving revision 1.41.2.7 diff -C2 -d -r1.41.2.6 -r1.41.2.7 *** oleargs.cpp 8 Jan 2009 03:45:49 -0000 1.41.2.6 --- oleargs.cpp 14 Jan 2009 12:42:02 -0000 1.41.2.7 *************** *** 108,113 **** V_I4(var) = PyInt_AsLong(obj); } - // PyInstance_Check had disappeared in py3k - // else if (PyInstance_Check(obj) && PyObject_HasAttrString(obj, "_oleobj_")) else if (PyObject_HasAttrString(obj, "_oleobj_")) { --- 108,111 ---- *************** *** 625,629 **** Py_DECREF(obSave); if (obItemCheck==NULL) { - // Py_XDECREF(obItemCheck); delete [] pBounds; return FALSE; --- 623,626 ---- |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:06
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32com/test Modified Files: Tag: py3k testShell.py testall.py util.py Log Message: merge lots of changes from the trunk Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.27.2.4 retrieving revision 1.27.2.5 diff -C2 -d -r1.27.2.4 -r1.27.2.5 *** testall.py 27 Nov 2008 11:31:05 -0000 1.27.2.4 --- testall.py 14 Jan 2009 12:42:03 -0000 1.27.2.5 *************** *** 82,85 **** --- 82,87 ---- ExecuteSilentlyIfOK(cmd, self) + # This is a list of "win32com.test.???" module names, optionally with a + # function in that module if the module isn't unitest based... unittest_modules = [ # Level 1 tests. *************** *** 99,102 **** --- 101,117 ---- ] + # A list of other unittest modules we use - these are fully qualified module + # names and the module is assumed to be unittest based. + unittest_other_modules = [ + # Level 1 tests. + """win32com.directsound.test.ds_test + """.split(), + # Level 2 tests. + [], + # Level 3 tests. + [] + ] + + output_checked_programs = [ # Level 1 tests. *************** *** 171,174 **** --- 186,206 ---- for test_class in custom_test_cases[i]: suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(test_class)) + # other "normal" unittest modules. + for i in range(testLevel): + for mod_name in unittest_other_modules[i]: + try: + __import__(mod_name) + except: + import_failures.append((mod_name, sys.exc_info()[:2])) + continue + + mod = sys.modules[mod_name] + if hasattr(mod, "suite"): + test = mod.suite() + else: + test = loader.loadTestsFromModule(mod) + assert test.countTestCases() > 0, "No tests loaded from %r" % mod + suite.addTest(test) + return suite, import_failures Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/util.py,v retrieving revision 1.9.2.8 retrieving revision 1.9.2.9 diff -C2 -d -r1.9.2.8 -r1.9.2.9 *** util.py 7 Jan 2009 06:25:15 -0000 1.9.2.8 --- util.py 14 Jan 2009 12:42:03 -0000 1.9.2.9 *************** *** 223,226 **** def testmain(*args, **kw): ! pywin32_testutil.testmain(*args, **new_kw) CheckClean() --- 223,226 ---- def testmain(*args, **kw): ! pywin32_testutil.testmain(*args, **kw) CheckClean() Index: testShell.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testShell.py,v retrieving revision 1.10.4.5 retrieving revision 1.10.4.6 diff -C2 -d -r1.10.4.5 -r1.10.4.6 *** testShell.py 7 Jan 2009 06:25:15 -0000 1.10.4.5 --- testShell.py 14 Jan 2009 12:42:02 -0000 1.10.4.6 *************** *** 99,104 **** class FILEGROUPDESCRIPTORTester(win32com.test.util.TestCase): def _testRT(self, fd): ! fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd], 1) ! fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string, 1)[0] fd = fd.copy() --- 99,104 ---- class FILEGROUPDESCRIPTORTester(win32com.test.util.TestCase): def _testRT(self, fd): ! fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd]) ! fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0] fd = fd.copy() *************** *** 114,128 **** self.assertEqual(fd, fd2) ! def testSimple(self): ! fgd = shell.FILEGROUPDESCRIPTORAsString([]) header = struct.pack("i", 0) self.assertEqual(header, fgd[:len(header)]) self._testRT(dict()) d = dict() ! fgd = shell.FILEGROUPDESCRIPTORAsString([d]) header = struct.pack("i", 1) self.assertEqual(header, fgd[:len(header)]) self._testRT(d) ! def testComplex(self): if sys.hexversion < 0x2030000: --- 114,134 ---- self.assertEqual(fd, fd2) ! def _testSimple(self, make_unicode): ! fgd = shell.FILEGROUPDESCRIPTORAsString([], make_unicode) header = struct.pack("i", 0) self.assertEqual(header, fgd[:len(header)]) self._testRT(dict()) d = dict() ! fgd = shell.FILEGROUPDESCRIPTORAsString([d], make_unicode) header = struct.pack("i", 1) self.assertEqual(header, fgd[:len(header)]) self._testRT(d) ! ! def testSimpleBytes(self): ! self._testSimple(False) ! ! def testSimpleUnicode(self): ! self._testSimple(True) ! def testComplex(self): if sys.hexversion < 0x2030000: |
From: Mark H. <mha...@us...> - 2009-01-14 13:03:02
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32comext/directsound/test Modified Files: Tag: py3k ds_test.py Log Message: merge lots of changes from the trunk Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.3 diff -C2 -d -r1.4.4.2 -r1.4.4.3 *** ds_test.py 13 Sep 2008 16:14:24 -0000 1.4.4.2 --- ds_test.py 14 Jan 2009 12:42:03 -0000 1.4.4.3 *************** *** 6,9 **** --- 6,10 ---- import win32event, win32api import os + from pywin32_testutil import str2bytes, TestSkipped import win32com.directsound.directsound as ds # next two lines are for for debugging: *************** *** 19,26 **** = struct.unpack('<4sl4s4slhhllhh4sl', data) ! if riff != b'RIFF': raise ValueError('invalid wav header') ! if fmtsize != 16 or fmt != b'fmt ' or data != b'data': # fmt chuck is not first chunk, directly followed by data chuck # It is nowhere required that they are, it is just very common --- 20,27 ---- = struct.unpack('<4sl4s4slhhllhh4sl', data) ! if riff != str2bytes('RIFF'): raise ValueError('invalid wav header') ! if fmtsize != 16 or fmt != str2bytes('fmt ') or str2bytes(data) != 'data': # fmt chuck is not first chunk, directly followed by data chuck # It is nowhere required that they are, it is just very common *************** *** 262,266 **** def testPlay(self): '''Mesdames et Messieurs, la cour de Devin Dazzle''' ! fname=os.path.join(os.path.dirname(sys.argv[0]), "01-Intro.wav") f = open(fname, 'rb') hdr = f.read(WAV_HEADER_SIZE) --- 263,282 ---- def testPlay(self): '''Mesdames et Messieurs, la cour de Devin Dazzle''' ! # look for the test file in various places ! candidates = [ ! os.path.dirname(__file__), ! os.path.dirname(sys.argv[0]), ! # relative to 'testall.py' in the win32com test suite. ! os.path.join(os.path.dirname(sys.argv[0]), ! '../../win32comext/directsound/test'), ! '.', ! ] ! for candidate in candidates: ! fname=os.path.join(candidate, "01-Intro.wav") ! if os.path.isfile(fname): ! break ! else: ! raise TestSkipped("Can't find test .wav file to play") ! f = open(fname, 'rb') hdr = f.read(WAV_HEADER_SIZE) |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:58
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/com/win32comext/shell/src Modified Files: Tag: py3k shell.cpp Log Message: merge lots of changes from the trunk Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.68.2.6 retrieving revision 1.68.2.7 diff -C2 -d -r1.68.2.6 -r1.68.2.7 *** shell.cpp 9 Dec 2008 12:38:52 -0000 1.68.2.6 --- shell.cpp 14 Jan 2009 12:42:03 -0000 1.68.2.7 *************** *** 1946,1950 **** // <nl>In general, you can omit dwFlags - it will be set correctly based // on what other attributes exist. ! // @pyparm bool|make_unicode|False|If true, a FILEDESCRIPTORW object is created #ifdef UNICODE int make_unicode = TRUE; --- 1946,1950 ---- // <nl>In general, you can omit dwFlags - it will be set correctly based // on what other attributes exist. ! // @pyparm bool|make_unicode|False on py2k, True on py3k|If true, a FILEDESCRIPTORW object is created #ifdef UNICODE int make_unicode = TRUE; |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:49
|
Update of /cvsroot/pywin32/pywin32/isapi/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/isapi/test Modified Files: Tag: py3k extension_simple.py Log Message: merge lots of changes from the trunk Index: extension_simple.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/test/extension_simple.py,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.3 diff -C2 -d -r1.2.4.2 -r1.2.4.3 *** extension_simple.py 5 Jan 2009 12:49:52 -0000 1.2.4.2 --- extension_simple.py 14 Jan 2009 12:42:03 -0000 1.2.4.3 *************** *** 84,88 **** if not isinstance(us, str): raise RuntimeError, "unexpected type!" ! if us != unicode(ecb.GetServerVariable("SERVER_NAME")): raise RuntimeError, "Unicode and non-unicode values were not the same" return "worked!" --- 84,88 ---- if not isinstance(us, str): raise RuntimeError, "unexpected type!" ! if us != str(ecb.GetServerVariable("SERVER_NAME")): raise RuntimeError, "Unicode and non-unicode values were not the same" return "worked!" |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:46
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/win32/Demos Modified Files: Tag: py3k win32gui_dialog.py winprocess.py Log Message: merge lots of changes from the trunk Index: winprocess.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/winprocess.py,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -C2 -d -r1.2.4.1 -r1.2.4.2 *** winprocess.py 29 Aug 2008 04:59:24 -0000 1.2.4.1 --- winprocess.py 14 Jan 2009 12:42:03 -0000 1.2.4.2 *************** *** 17,20 **** --- 17,21 ---- import win32api, win32process, win32security import win32event, win32con, msvcrt, win32gui + import os *************** *** 178,182 **** cmdString = """\ REM Test of winprocess.py piping commands to a shell.\r ! REM This window will close in %d seconds.\r vol\r net user\r --- 179,183 ---- cmdString = """\ REM Test of winprocess.py piping commands to a shell.\r ! REM This 'notepad' process will terminate in %d seconds.\r vol\r net user\r *************** *** 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() --- 185,206 ---- """ % timeoutSeconds ! cmd_name = tempfile.mktemp() ! out_name = cmd_name + '.txt' ! try: ! cmd = open(cmd_name, "w+b") ! out = open(out_name, "w+b") ! 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() ! print('NOTEPAD exit code:', run('notepad.exe %s' % out.name, ! show=win32con.SW_MAXIMIZE, ! mSec=timeoutSeconds*1000)) ! out.close() ! finally: ! for n in (cmd_name, out_name): ! try: ! os.unlink(cmd_name) ! except os.error: ! pass Index: win32gui_dialog.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_dialog.py,v retrieving revision 1.7.2.4 retrieving revision 1.7.2.5 diff -C2 -d -r1.7.2.4 -r1.7.2.5 *** win32gui_dialog.py 4 Dec 2008 01:07:20 -0000 1.7.2.4 --- win32gui_dialog.py 14 Jan 2009 12:42:03 -0000 1.7.2.5 *************** *** 72,88 **** vals.append(0) else: ! # Unicode object no longer supports buffer interface. According to pep 3137 ! # (http://www.python.org/dev/peps/pep-3137/) ! # this is because the internal represention is platform dependent. This seems ! # spurious to me since whatever code receives the data alreeady needs to know ! # the encoding anyway, whether it's python's internal encoding or not. And since ! # there is no way to specify the encoding in the data itself, what difference does ! # it make ? if isinstance(val, str): ! val=(val+'\0').encode('utf-16-le') ! else: ! # Should this continue to accept a byte string, or would it be better to ! # throw an error here ? ! val=val+b'\0' str_buf = array.array("b", val) vals.append(str_buf.buffer_info()[0]) --- 72,82 ---- vals.append(0) else: ! # Note this demo still works with byte strings. An ! # alternate strategy would be to use unicode natively ! # and use the 'W' version of the messages - eg, ! # LVM_SETITEMW etc. ! val = val + "\0" if isinstance(val, str): ! val = val.encode("mbcs") str_buf = array.array("b", val) vals.append(str_buf.buffer_info()[0]) *************** *** 232,240 **** lvc.text = "Title" lvc.cx = 200 ! win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMNW, 0, lvc.toparam()) lvc.iSubItem = 0 lvc.text = "Order" lvc.cx = 50 ! win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMNW, 0, lvc.toparam()) win32gui.UpdateWindow(self.hwnd) --- 226,234 ---- lvc.text = "Title" lvc.cx = 200 ! win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam()) lvc.iSubItem = 0 lvc.text = "Order" lvc.cx = 50 ! win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam()) win32gui.UpdateWindow(self.hwnd) *************** *** 247,255 **** num_items = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETITEMCOUNT) item = LVITEM(text=columns[0], iItem = num_items) ! new_index = win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTITEMW, 0, item.toparam()) col_no = 1 for col in columns[1:]: item = LVITEM(text=col, iItem = new_index, iSubItem = col_no) ! win32gui.SendMessage(self.hwndList, commctrl.LVM_SETITEMW, 0, item.toparam()) col_no += 1 self.list_data[new_index] = data --- 241,249 ---- num_items = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETITEMCOUNT) item = LVITEM(text=columns[0], iItem = num_items) ! new_index = win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam()) col_no = 1 for col in columns[1:]: item = LVITEM(text=col, iItem = new_index, iSubItem = col_no) ! win32gui.SendMessage(self.hwndList, commctrl.LVM_SETITEM, 0, item.toparam()) col_no += 1 self.list_data[new_index] = data *************** *** 307,320 **** def OnNotify(self, hwnd, msg, wparam, lparam): ! format = "iiiiiiiiiii" ## ??? needs adjustment for 64-bit ??? buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, idFrom, code, iItem, iSubItem, uNewState, uOldState, uChanged, actionx, actiony, lParam \ = struct.unpack(format, buf) - # *sigh* - work around a problem with old commctrl modules, which had a - # bad value for PY_OU, which therefore cause most "control notification" - # messages to be wrong. - # Code that needs to work with both pre and post pywin32-204 must do - # this too. - code += commctrl.PY_0U if code == commctrl.NM_DBLCLK: print("Double click on item", iItem+1) --- 301,308 ---- def OnNotify(self, hwnd, msg, wparam, lparam): ! format = "PPiiiiiiiiP" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, idFrom, code, iItem, iSubItem, uNewState, uOldState, uChanged, actionx, actiony, lParam \ = struct.unpack(format, buf) if code == commctrl.NM_DBLCLK: print("Double click on item", iItem+1) |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:37
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/win32/Lib Modified Files: Tag: py3k win32gui_struct.py Log Message: merge lots of changes from the trunk Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.11.2.2 retrieving revision 1.11.2.3 diff -C2 -d -r1.11.2.2 -r1.11.2.3 *** win32gui_struct.py 3 Jan 2009 04:51:00 -0000 1.11.2.2 --- win32gui_struct.py 14 Jan 2009 12:42:03 -0000 1.11.2.3 *************** *** 35,38 **** --- 35,61 ---- import pywintypes + # Encode a string suitable for passing in a win32gui related structure + # If win32gui is built with UNICODE defined (ie, py3k), then functions + # like InsertMenuItem are actually calling InsertMenuItemW etc, so all + # strings will need to be unicode. + if win32gui.UNICODE: + def _make_text_buffer(text): + # XXX - at this stage win32gui.UNICODE is only True in py3k, + # and in py3k is makes sense to reject bytes. + if not isinstance(text, str): + raise TypeError('MENUITEMINFO text must be unicode') + data = (text+'\0').encode("unicode-internal") + return array.array("b", data) + + else: + def _make_text_buffer(text): + if isinstance(text, str): + text = text.encode("mbcs") + return array.array("b", text+'\0') + + # make an 'empty' buffer, ready for filling with cch characters. + def _make_empty_text_buffer(cch): + return _make_text_buffer("\0" * cch) + # Generic WM_NOTIFY unpacking def UnpackWMNOTIFY(lparam): *************** *** 48,52 **** # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '5i5PiP' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, --- 71,75 ---- # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! _menuiteminfo_fmt = '5i5PiP' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, *************** *** 89,96 **** if text is not None: fMask |= win32con.MIIM_STRING ! if not isinstance(text, str): ! raise TypeError('MENUITEMINFO text must be unicode') ! encoded_text = (text+'\0').encode("utf-16-le") ! str_buf = array.array("b", encoded_text) cch = len(text) # We are taking address of strbuf - it must not die until windows --- 112,116 ---- if text is not None: fMask |= win32con.MIIM_STRING ! str_buf = _make_text_buffer(text) cch = len(text) # We are taking address of strbuf - it must not die until windows *************** *** 104,109 **** # 'P' format does not accept PyHANDLE's ! item = struct.pack( ! menuitem_fmt, ! struct.calcsize(menuitem_fmt), # cbSize fMask, fType, --- 124,129 ---- # 'P' format does not accept PyHANDLE's ! item = struct.pack( ! _menuiteminfo_fmt, ! struct.calcsize(_menuiteminfo_fmt), # cbSize fMask, fType, *************** *** 134,138 **** lptext, cch, ! hbmpItem) = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None --- 154,158 ---- lptext, cch, ! hbmpItem) = struct.unpack(_menuiteminfo_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None *************** *** 151,154 **** --- 171,175 ---- def EmptyMENUITEMINFO(mask = None, text_buf_size=512): + # text_buf_size is number of *characters* - not necessarily no of bytes. extra = [] if mask is None: *************** *** 160,172 **** if mask & win32con.MIIM_STRING: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 buf = struct.pack( ! menuitem_fmt, ! struct.calcsize(menuitem_fmt), # cbSize mask, 0, #fType, --- 181,195 ---- if mask & win32con.MIIM_STRING: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 + # Now copy the string to a writable buffer, so that the result + # could be passed to a 'Get' function buf = struct.pack( ! _menuiteminfo_fmt, ! struct.calcsize(_menuiteminfo_fmt), # cbSize mask, 0, #fType, *************** *** 178,188 **** 0, #dwItemData, text_addr, ! text_len, 0, #hbmpItem ) ! return array.array("c", buf), extra # MENUINFO struct ! menuinfo_fmt = '7i' def PackMENUINFO(dwStyle = None, cyMax = None, --- 201,211 ---- 0, #dwItemData, text_addr, ! text_buf_size, 0, #hbmpItem ) ! return array.array("b", buf), extra # MENUINFO struct ! _menuinfo_fmt = 'iiiiPiP' def PackMENUINFO(dwStyle = None, cyMax = None, *************** *** 201,206 **** # Create the struct. item = struct.pack( ! menuinfo_fmt, ! struct.calcsize(menuinfo_fmt), # cbSize fMask, dwStyle, --- 224,229 ---- # Create the struct. item = struct.pack( ! _menuinfo_fmt, ! struct.calcsize(_menuinfo_fmt), # cbSize fMask, dwStyle, *************** *** 209,213 **** dwContextHelpID, dwMenuData) ! return array.array("c", item) def UnpackMENUINFO(s): --- 232,236 ---- dwContextHelpID, dwMenuData) ! return array.array("b", item) def UnpackMENUINFO(s): *************** *** 218,222 **** hbrBack, dwContextHelpID, ! dwMenuData) = struct.unpack(menuinfo_fmt, s) assert cb==len(s) if fMask & win32con.MIM_STYLE==0: dwStyle = None --- 241,245 ---- hbrBack, dwContextHelpID, ! dwMenuData) = struct.unpack(_menuinfo_fmt, s) assert cb==len(s) if fMask & win32con.MIM_STYLE==0: dwStyle = None *************** *** 234,239 **** buf = struct.pack( ! menuinfo_fmt, ! struct.calcsize(menuinfo_fmt), # cbSize mask, 0, #dwStyle --- 257,262 ---- buf = struct.pack( ! _menuinfo_fmt, ! struct.calcsize(_menuinfo_fmt), # cbSize mask, 0, #dwStyle *************** *** 243,247 **** 0, #dwMenuData, ) ! return array.array("c", buf) ########################################################################## --- 266,270 ---- 0, #dwMenuData, ) ! return array.array("b", buf) ########################################################################## *************** *** 289,297 **** text_addr = text_len = 0 else: ! if isinstance(text, str): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, --- 312,319 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) ! text_len = len(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, *************** *** 301,305 **** image, selimage, citems, param) ! return array.array("c", buf), extra # Make a new buffer suitable for querying hitem's attributes. --- 323,327 ---- image, selimage, citems, param) ! return array.array("b", buf), extra # Make a new buffer suitable for querying hitem's attributes. *************** *** 311,327 **** commctrl.TVIF_CHILDREN | commctrl.TVIF_PARAM if mask & commctrl.TVIF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, hitem, 0, 0, ! text_addr, text_len, # text 0, 0, 0, 0) ! return array.array("c", buf), extra def UnpackTVITEM(buffer): --- 333,349 ---- commctrl.TVIF_CHILDREN | commctrl.TVIF_PARAM if mask & commctrl.TVIF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, hitem, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0, 0) ! return array.array("b", buf), extra def UnpackTVITEM(buffer): *************** *** 390,398 **** else: mask |= commctrl.LVIF_TEXT ! if isinstance(text, str): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, --- 412,419 ---- else: mask |= commctrl.LVIF_TEXT ! text_buffer = _make_text_buffer(text) ! text_len = len(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() format = "iiiiiiiiii" buf = struct.pack(format, *************** *** 401,405 **** text_addr, text_len, # text image, param, indent) ! return array.array("c", buf), extra def UnpackLVITEM(buffer): --- 422,426 ---- text_addr, text_len, # text image, param, indent) ! return array.array("b", buf), extra def UnpackLVITEM(buffer): *************** *** 446,461 **** commctrl.LVIF_PARAM | commctrl.LVIF_STATE if mask & commctrl.LVIF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, item, subitem, 0, 0, ! text_addr, text_len, # text 0, 0, 0) ! return array.array("c", buf), extra --- 467,482 ---- commctrl.LVIF_PARAM | commctrl.LVIF_STATE if mask & commctrl.LVIF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiiiii" buf = struct.pack(format, mask, item, subitem, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0) ! return array.array("b", buf), extra *************** *** 473,481 **** text_addr = text_len = 0 else: ! if isinstance(text, str): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiii" buf = struct.pack(format, --- 494,501 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() ! text_len = len(text) format = "iiiiiiii" buf = struct.pack(format, *************** *** 483,487 **** text_addr, text_len, # text subItem, image, order) ! return array.array("c", buf), extra def UnpackLVCOLUMN(lparam): --- 503,507 ---- text_addr, text_len, # text subItem, image, order) ! return array.array("b", buf), extra def UnpackLVCOLUMN(lparam): *************** *** 510,524 **** commctrl.LVCF_SUBITEM | commctrl.LVCF_IMAGE | commctrl.LVCF_ORDER if mask & commctrl.LVCF_TEXT: ! text_buffer = array.array("c", "\0" * text_buf_size) extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() else: ! text_addr = text_len = 0 format = "iiiiiiii" buf = struct.pack(format, mask, 0, 0, ! text_addr, text_len, # text 0, 0, 0) ! return array.array("c", buf), extra # List view hit-test. --- 530,544 ---- commctrl.LVCF_SUBITEM | commctrl.LVCF_IMAGE | commctrl.LVCF_ORDER if mask & commctrl.LVCF_TEXT: ! text_buffer = _make_empty_text_buffer(text_buf_size) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() else: ! text_addr = text_buf_size = 0 format = "iiiiiiii" buf = struct.pack(format, mask, 0, 0, ! text_addr, text_buf_size, # text 0, 0, 0) ! return array.array("b", buf), extra # List view hit-test. *************** *** 528,532 **** pt[0], pt[1], 0, 0, 0) ! return array.array("c", buf), None def UnpackLVHITTEST(buf): --- 548,552 ---- pt[0], pt[1], 0, 0, 0) ! return array.array("b", buf), None def UnpackLVHITTEST(buf): *************** *** 550,558 **** text_addr = text_len = 0 else: ! if isinstance(text, str): ! text = text.encode("mbcs") ! text_buffer = array.array("c", text+"\0") extra.append(text_buffer) ! text_addr, text_len = text_buffer.buffer_info() format = "iiiiiiiiiii" --- 570,577 ---- text_addr = text_len = 0 else: ! text_buffer = _make_text_buffer(text) extra.append(text_buffer) ! text_addr, _ = text_buffer.buffer_info() ! text_len = len(text) format = "iiiiiiiiiii" *************** *** 560,564 **** mask, cxy, text_addr, hbm, text_len, fmt, param, image, order, 0, 0) ! return array.array("c", buf), extra # Device notification stuff --- 579,583 ---- mask, cxy, text_addr, hbm, text_len, fmt, param, image, order, 0, 0) ! return array.array("b", buf), extra # Device notification stuff |
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/win32/src Modified Files: Tag: py3k PyLARGE_INTEGER.cpp PyWAVEFORMATEX.cpp win32evtlog.i win32gui.i win32trace.cpp Log Message: merge lots of changes from the trunk Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -C2 -d -r1.12.2.2 -r1.12.2.3 *** PyLARGE_INTEGER.cpp 11 Dec 2008 04:13:35 -0000 1.12.2.2 --- PyLARGE_INTEGER.cpp 14 Jan 2009 12:42:03 -0000 1.12.2.3 *************** *** 48,51 **** --- 48,53 ---- BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { + #if (PY_VERSION_HEX < 0x03000000) + // py2k - ints and longs are different, and we assume 'int' is 32bits. if (PyInt_Check(ob)) { // 32 bit integer value. *************** *** 57,74 **** ULISet32(*pResult, x); return TRUE; ! } else if (PyLong_Check(ob)) { pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); - } else { - PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); - long hiVal, loVal; - if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { - PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); - return FALSE; - } - pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; - return TRUE; } ! assert(0); // not reached. } --- 59,76 ---- ULISet32(*pResult, x); return TRUE; ! } ! #endif // py2k ! if (PyLong_Check(ob)) { pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); } ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; } Index: PyWAVEFORMATEX.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWAVEFORMATEX.cpp,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -C2 -d -r1.2.4.1 -r1.2.4.2 *** PyWAVEFORMATEX.cpp 29 Aug 2008 04:59:25 -0000 1.2.4.1 --- PyWAVEFORMATEX.cpp 14 Jan 2009 12:42:03 -0000 1.2.4.2 *************** *** 2,6 **** // @doc - #include "Python.h" #include "PyWinTypes.h" #include "PyWinObjects.h" --- 2,5 ---- Index: win32trace.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v retrieving revision 1.14.2.4 retrieving revision 1.14.2.5 diff -C2 -d -r1.14.2.4 -r1.14.2.5 *** win32trace.cpp 3 Jan 2009 23:46:35 -0000 1.14.2.4 --- win32trace.cpp 14 Jan 2009 12:42:03 -0000 1.14.2.5 *************** *** 651,655 **** 0, BUFFER_SIZE, FixupObjectName(MAP_OBJECT_NAME)); ! use_global_namespace = h2 != NULL && GetLastError() == ERROR_ACCESS_DENIED; if (h2) CloseHandle(h2); --- 651,655 ---- 0, BUFFER_SIZE, FixupObjectName(MAP_OBJECT_NAME)); ! use_global_namespace = h2 != NULL; if (h2) CloseHandle(h2); Index: win32evtlog.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32evtlog.i,v retrieving revision 1.6.2.2 retrieving revision 1.6.2.3 diff -C2 -d -r1.6.2.2 -r1.6.2.3 *** win32evtlog.i 1 Oct 2008 03:55:51 -0000 1.6.2.2 --- win32evtlog.i 14 Jan 2009 12:42:03 -0000 1.6.2.3 *************** *** 141,146 **** } ! TimeGenerated = PyWinTimeObject_FromLong(pEvt->TimeGenerated); ! TimeWritten = PyWinTimeObject_FromLong(pEvt->TimeWritten); if (pEvt->UserSidLength==0) { --- 141,146 ---- } ! TimeGenerated = PyWinTimeObject_Fromtime_t((time_t)pEvt->TimeGenerated); ! TimeWritten = PyWinTimeObject_Fromtime_t((time_t)pEvt->TimeWritten); if (pEvt->UserSidLength==0) { Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.118.2.4 retrieving revision 1.118.2.5 diff -C2 -d -r1.118.2.4 -r1.118.2.5 *** win32gui.i 11 Dec 2008 04:13:35 -0000 1.118.2.4 --- win32gui.i 14 Jan 2009 12:42:03 -0000 1.118.2.5 *************** *** 273,276 **** --- 273,284 ---- #endif + PyDict_SetItemString(d, "UNICODE", + #ifdef UNICODE + Py_True + #else + Py_False + #endif + ); + // hack borrowed from win32security since version of SWIG we use doesn't do keyword arguments #ifdef WINXPGUI *************** *** 1584,1591 **** %{ ! // @pyswig bytes|PyGetString|Returns bytes from an address. static PyObject *PyGetString(PyObject *self, PyObject *args) { ! char *addr = 0; size_t len = -1; #ifdef _WIN64 --- 1592,1600 ---- %{ ! // @pyswig string|PyGetString|Returns a string from an address. ! // @rdesc If win32gui.UNICODE is True, this will return a unicode object. static PyObject *PyGetString(PyObject *self, PyObject *args) { ! TCHAR *addr = 0; size_t len = -1; #ifdef _WIN64 *************** *** 1608,1619 **** return NULL; } ! return PyString_FromStringAndSize(addr, len); } // This should probably be in a __try just in case. ! if (IsBadStringPtrA(addr, (DWORD_PTR)-1)) { PyErr_SetString(PyExc_ValueError, "The value is not a valid null-terminated string"); return NULL; } ! return PyString_FromString(addr); } %} --- 1617,1628 ---- return NULL; } ! return PyWinObject_FromTCHAR(addr, len); } // This should probably be in a __try just in case. ! if (IsBadStringPtr(addr, (DWORD_PTR)-1)) { PyErr_SetString(PyExc_ValueError, "The value is not a valid null-terminated string"); return NULL; } ! return PyWinObject_FromTCHAR(addr); } %} |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:23
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/win32/src/win32wnet Modified Files: Tag: py3k win32wnet.cpp Log Message: merge lots of changes from the trunk Index: win32wnet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/win32wnet.cpp,v retrieving revision 1.13.2.3 retrieving revision 1.13.2.4 diff -C2 -d -r1.13.2.3 -r1.13.2.4 *** win32wnet.cpp 10 Dec 2008 11:01:22 -0000 1.13.2.3 --- win32wnet.cpp 14 Jan 2009 12:42:03 -0000 1.13.2.4 *************** *** 196,199 **** --- 196,246 ---- }; + // @pymethod |win32wnet|WNetAddConnection3|Creates a connection to a network resource. + // @comm Accepts keyword arguments. + // @pyseeapi WNetAddConnection3 + static PyObject *PyWNetAddConnection3 (PyObject *self, PyObject *args, PyObject *kwargs) + { + LPTSTR Username = NULL; + LPTSTR Password = NULL; + DWORD ErrorNo; // holds the returned error number, if any + DWORD flags = 0; + NETRESOURCE *pNetResource; + PyObject *obPassword=Py_None, *obUsername=Py_None, *ret=NULL; + PyObject *obhwnd, *obnr; + + static char *keywords[] = {"HwndOwner", "NetResource","Password","UserName","Flags", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOk", keywords, + &obhwnd, // @pyparm int|hwnd||Handle to a parent window. + &obnr, // @pyparm <o PyNETRESOURCE>|NetResource||Describes the network resource for the connection. + &obPassword, // @pyparm str|Password|None|The password to use. Use None for default credentials. + &obUsername, // @pyparm str|UserName|None|The user name to connect as. Use None for default credentials. + &flags)) // @pyparm int|Flags|0|Combination win32netcon.CONNECT_* flags + return NULL; + + HWND hwnd; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) + return NULL; + if (!PyWinObject_AsNETRESOURCE(obnr, &pNetResource, FALSE)) + return NULL; + + if (!PyWinObject_AsTCHAR(obPassword, &Password, TRUE) + || !PyWinObject_AsTCHAR(obUsername, &Username, TRUE)) + goto done; + + Py_BEGIN_ALLOW_THREADS + ErrorNo = WNetAddConnection3(hwnd, pNetResource, Password, Username, flags); + Py_END_ALLOW_THREADS + if (ErrorNo != NO_ERROR) + ReturnNetError("WNetAddConnection3", ErrorNo); + else{ + Py_INCREF(Py_None); + ret = Py_None; + } + done: + PyWinObject_FreeTCHAR(Password); + PyWinObject_FreeTCHAR(Username); + return ret; + }; + // @pymethod |win32wnet|WNetCancelConnection2|Closes network connections made by WNetAddConnection2 or 3 static *************** *** 634,637 **** --- 681,686 ---- // @pymeth WNetAddConnection2|Creates a connection to a network resource. {"WNetAddConnection2", (PyCFunction)PyWNetAddConnection2, METH_KEYWORDS|METH_VARARGS, "WNetAddConnection2(NetResource, Password, UserName, Flags)"}, + // @pymeth WNetAddConnection3|Creates a connection to a network resource. + {"WNetAddConnection3", (PyCFunction)PyWNetAddConnection3, METH_KEYWORDS|METH_VARARGS, "WNetAddConnection3(HwndParent, NetResource, Password, UserName, Flags)"}, // @pymeth WNetCancelConnection2|Closes network connections made by WNetAddConnection2 or 3 {"WNetCancelConnection2", PyWNetCancelConnection2, 1, "localname,dwflags,bforce"}, |
From: Mark H. <mha...@us...> - 2009-01-14 13:02:23
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4460/win32/test Modified Files: Tag: py3k test_win32file.py Added Files: Tag: py3k test_win32guistruct.py Log Message: merge lots of changes from the trunk Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.13.2.6 retrieving revision 1.13.2.7 diff -C2 -d -r1.13.2.6 -r1.13.2.7 *** test_win32file.py 8 Jan 2009 03:45:50 -0000 1.13.2.6 --- test_win32file.py 14 Jan 2009 12:42:03 -0000 1.13.2.7 *************** *** 68,73 **** win32file.SetFilePointer(h, newSize, win32file.FILE_BEGIN) win32file.SetEndOfFile(h) ! self.failUnless(win32file.GetFileSize(h) == newSize, ! "Truncated file does not have the expected size! (%s)" %newSize) # GetFileAttributesEx/GetFileAttributesExW tests. --- 68,72 ---- win32file.SetFilePointer(h, newSize, win32file.FILE_BEGIN) win32file.SetEndOfFile(h) ! self.failUnlessEqual(win32file.GetFileSize(h), newSize) # GetFileAttributesEx/GetFileAttributesExW tests. *************** *** 79,83 **** self.failUnless(attr==win32file.GetFileAttributes(testName), "Expected GetFileAttributesEx to return the same attributes as GetFileAttributes") ! h = None # Close the file by removing the last reference to the handle! --- 78,82 ---- self.failUnless(attr==win32file.GetFileAttributes(testName), "Expected GetFileAttributesEx to return the same attributes as GetFileAttributes") ! h = None # Close the file by removing the last reference to the handle! *************** *** 126,136 **** from win32timezone import GetLocalTimeZone now = datetime.datetime.now(tz=GetLocalTimeZone()) ! ok_delta = datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) else: tick = int(time.time()) ! now = pywintypes.Time(tick) ! ok_delta = 1 ! later = pywintypes.Time(tick+120) filename = tempfile.mktemp("-testFileTimes") --- 125,140 ---- from win32timezone import GetLocalTimeZone now = datetime.datetime.now(tz=GetLocalTimeZone()) ! nowish = now + datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) else: + rc, tzi = win32api.GetTimeZoneInformation() + bias = tzi[0] + if rc==2: # daylight-savings is in effect. + bias += tzi[-1] + bias *= 60 # minutes to seconds... tick = int(time.time()) ! now = pywintypes.Time(tick+bias) ! nowish = pywintypes.Time(tick+bias+1) ! later = pywintypes.Time(tick+bias+120) filename = tempfile.mktemp("-testFileTimes") *************** *** 141,155 **** 0, None, win32con.OPEN_EXISTING, 0, None) - # *sob* - before we had tz aware datetime objects, we are faced - # with FILETIME objects being +GST out from now(). So just skip - # this... - if not issubclass(pywintypes.TimeType, datetime.datetime): - return try: ct, at, wt = win32file.GetFileTime(f) self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) ! self.failUnless( now <= ct <= now + ok_delta, (now, ct)) self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) ! self.failUnless( now <= wt <= now + ok_delta, (now, wt)) # Now set the times. --- 145,154 ---- 0, None, win32con.OPEN_EXISTING, 0, None) try: ct, at, wt = win32file.GetFileTime(f) self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) ! self.failUnless( now <= ct <= nowish, (now, ct)) self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) ! self.failUnless( now <= wt <= nowish, (now, wt)) # Now set the times. *************** *** 157,163 **** # Get them back. ct, at, wt = win32file.GetFileTime(f) ! self.failUnlessEqual(ct, later) ! self.failUnlessEqual(at, later) ! self.failUnlessEqual(wt, later) finally: --- 156,165 ---- # Get them back. ct, at, wt = win32file.GetFileTime(f) ! # XXX - the builtin PyTime type appears to be out by a dst offset. ! # just ignore that type here... ! if issubclass(pywintypes.TimeType, datetime.datetime): ! self.failUnlessEqual(ct, later) ! self.failUnlessEqual(at, later) ! self.failUnlessEqual(wt, later) finally: --- NEW FILE: test_win32guistruct.py --- import unittest import win32gui import win32gui_struct import win32con class TestBase(unittest.TestCase): def assertDictEquals(self, d, **kw): checked = dict() for n, v in kw.items(): self.failUnlessEqual(v, d[n], "'%s' doesn't match: %r != %r" % (n, v, d[n])) checked[n] = True checked_keys = list(checked.keys()) passed_keys = list(kw.keys()) checked_keys.sort() passed_keys.sort() self.failUnlessEqual(checked_keys, passed_keys) class TestMenuItemInfo(TestBase): def _testPackUnpack(self, text): vals = dict(fType=win32con.MFT_MENUBARBREAK, fState=win32con.MFS_CHECKED, wID=123, hSubMenu=1234, hbmpChecked=12345, hbmpUnchecked=123456, dwItemData=1234567, text=text, hbmpItem=321) mii, extras = win32gui_struct.PackMENUITEMINFO(**vals) fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ dwItemData, text, hbmpItem = win32gui_struct.UnpackMENUITEMINFO(mii) self.assertDictEquals(vals, fType=fType, fState=fState, wID=wID, hSubMenu=hSubMenu, hbmpChecked=hbmpChecked, hbmpUnchecked=hbmpUnchecked, dwItemData=dwItemData, text=text, hbmpItem=hbmpItem) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmptyMenuItemInfo(self): mii, extra = win32gui_struct.EmptyMENUITEMINFO() fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ dwItemData, text, hbmpItem = win32gui_struct.UnpackMENUITEMINFO(mii) self.failUnlessEqual(fType, 0) self.failUnlessEqual(fState, 0) self.failUnlessEqual(wID, 0) self.failUnlessEqual(hSubMenu, 0) self.failUnlessEqual(hbmpChecked, 0) self.failUnlessEqual(hbmpUnchecked, 0) self.failUnlessEqual(dwItemData, 0) self.failUnlessEqual(hbmpItem, 0) # it's not clear if UnpackMENUITEMINFO() should ignore cch, instead # assuming it is a buffer size rather than 'current length' - but it # never has (and this gives us every \0 in the string), and actually # helps us test the unicode/str semantics. self.failUnlessEqual(text, '\0' * len(text)) class TestMenuInfo(TestBase): def testPackUnpack(self): vals = dict(dwStyle=1, cyMax=2, hbrBack=3, dwContextHelpID=4, dwMenuData=5) mi = win32gui_struct.PackMENUINFO(**vals) dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData = \ win32gui_struct.UnpackMENUINFO(mi) self.assertDictEquals(vals, dwStyle=dwStyle, cyMax=cyMax, hbrBack=hbrBack, dwContextHelpID=dwContextHelpID, dwMenuData=dwMenuData) def testEmptyMenuItemInfo(self): mi = win32gui_struct.EmptyMENUINFO() dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData = \ win32gui_struct.UnpackMENUINFO(mi) self.failUnlessEqual(dwStyle, 0) self.failUnlessEqual(cyMax, 0) self.failUnlessEqual(hbrBack, 0) self.failUnlessEqual(dwContextHelpID, 0) self.failUnlessEqual(dwMenuData, 0) class TestTreeViewItem(TestBase): def _testPackUnpack(self, text): vals = dict(hitem=1, state=2, stateMask=3, text=text, image=4, selimage=5, citems=6, param=7) ti, extra = win32gui_struct.PackTVITEM(**vals) hitem, state, stateMask, text, image, selimage, citems, param = \ win32gui_struct.UnpackTVITEM(ti) self.assertDictEquals(vals, hitem=hitem, state=state, stateMask=stateMask, text=text, image=image, selimage=selimage, citems=citems, param=param) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyTVITEM(0) hitem, state, stateMask, text, image, selimage, citems, param = \ win32gui_struct.UnpackTVITEM(ti) self.failUnlessEqual(hitem, 0) self.failUnlessEqual(state, 0) self.failUnlessEqual(stateMask, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(image, 0) self.failUnlessEqual(selimage, 0) self.failUnlessEqual(citems, 0) self.failUnlessEqual(param, 0) class TestListViewItem(TestBase): def _testPackUnpack(self, text): vals = dict(item=None, subItem=None, state=1, stateMask=2, text=text, image=3, param=4, indent=5) ti, extra = win32gui_struct.PackLVITEM(**vals) item, subItem, state, stateMask, text, image, param, indent = \ win32gui_struct.UnpackLVITEM(ti) # patch expected values. vals['item'] = 0 vals['subItem'] = 0 self.assertDictEquals(vals, item=item, subItem=subItem, state=state, stateMask=stateMask, text=text, image=image, param=param, indent=indent) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyLVITEM(1, 2) item, subItem, state, stateMask, text, image, param, indent = \ win32gui_struct.UnpackLVITEM(ti) self.failUnlessEqual(item, 1) self.failUnlessEqual(subItem, 2) self.failUnlessEqual(state, 0) self.failUnlessEqual(stateMask, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(image, 0) self.failUnlessEqual(param, 0) self.failUnlessEqual(indent, 0) class TestLVColumn(TestBase): def _testPackUnpack(self, text): vals = dict(fmt=1, cx=2, text=text, subItem=3, image=4, order=5) ti, extra = win32gui_struct.PackLVCOLUMN(**vals) fmt, cx, text, subItem, image, order = \ win32gui_struct.UnpackLVCOLUMN(ti) self.assertDictEquals(vals, fmt=fmt, cx=cx, text=text, subItem=subItem, image=image, order=order) def testPackUnpack(self): self._testPackUnpack("Hello") def testPackUnpackNone(self): self._testPackUnpack(None) def testEmpty(self): ti, extras = win32gui_struct.EmptyLVCOLUMN() fmt, cx, text, subItem, image, order = \ win32gui_struct.UnpackLVCOLUMN(ti) self.failUnlessEqual(fmt, 0) self.failUnlessEqual(cx, 0) self.failUnlessEqual(text, '') self.failUnlessEqual(subItem, 0) self.failUnlessEqual(image, 0) self.failUnlessEqual(order, 0) if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2009-01-14 04:55:47
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9592/com/win32com/client Modified Files: genpy.py Log Message: move our '0x80000000L' special handling for 2.3 into a py3k compt. syntax Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** genpy.py 9 Jan 2009 01:29:29 -0000 1.64 --- genpy.py 14 Jan 2009 04:55:42 -0000 1.65 *************** *** 205,211 **** val = vdesc[1] if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, long)): ! if val==0x80000000L: # special case use = "0x80000000L" # 'L' for future warning ! elif val > 0x80000000L or val < 0: # avoid a FutureWarning use = long(val) else: --- 205,212 ---- val = vdesc[1] if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, long)): ! # in python 2.3, 0x80000000L == 2147483648 ! if val==2147483648: # == 0x80000000L - special case for 2.3... use = "0x80000000L" # 'L' for future warning ! elif val > 2147483648 or val < 0: # avoid a FutureWarning use = long(val) else: |
From: Mark H. <mha...@us...> - 2009-01-14 04:44:07
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9233/com/win32com/test Modified Files: testShell.py Log Message: explicitly test FILEGROUPDESCRIPTOR and FILEGROUPDESCRIPTORW Index: testShell.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testShell.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** testShell.py 7 Jan 2009 06:03:29 -0000 1.13 --- testShell.py 14 Jan 2009 04:43:56 -0000 1.14 *************** *** 114,128 **** self.assertEqual(fd, fd2) ! def testSimple(self): ! fgd = shell.FILEGROUPDESCRIPTORAsString([]) header = struct.pack("i", 0) self.assertEqual(header, fgd[:len(header)]) self._testRT(dict()) d = dict() ! fgd = shell.FILEGROUPDESCRIPTORAsString([d]) header = struct.pack("i", 1) self.assertEqual(header, fgd[:len(header)]) self._testRT(d) ! def testComplex(self): if sys.hexversion < 0x2030000: --- 114,134 ---- self.assertEqual(fd, fd2) ! def _testSimple(self, make_unicode): ! fgd = shell.FILEGROUPDESCRIPTORAsString([], make_unicode) header = struct.pack("i", 0) self.assertEqual(header, fgd[:len(header)]) self._testRT(dict()) d = dict() ! fgd = shell.FILEGROUPDESCRIPTORAsString([d], make_unicode) header = struct.pack("i", 1) self.assertEqual(header, fgd[:len(header)]) self._testRT(d) ! ! def testSimpleBytes(self): ! self._testSimple(False) ! ! def testSimpleUnicode(self): ! self._testSimple(True) ! def testComplex(self): if sys.hexversion < 0x2030000: |
From: Mark H. <mha...@us...> - 2009-01-14 04:29:08
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8363/com/win32comext/shell/src Modified Files: shell.cpp Log Message: autoduck corrections Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** shell.cpp 8 Dec 2008 13:16:37 -0000 1.73 --- shell.cpp 14 Jan 2009 04:29:01 -0000 1.74 *************** *** 1946,1950 **** // <nl>In general, you can omit dwFlags - it will be set correctly based // on what other attributes exist. ! // @pyparm bool|make_unicode|False|If true, a FILEDESCRIPTORW object is created #ifdef UNICODE int make_unicode = TRUE; --- 1946,1950 ---- // <nl>In general, you can omit dwFlags - it will be set correctly based // on what other attributes exist. ! // @pyparm bool|make_unicode|False on py2k, True on py3k|If true, a FILEDESCRIPTORW object is created #ifdef UNICODE int make_unicode = TRUE; |
From: Mark H. <mha...@us...> - 2009-01-14 04:27:49
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8306 Modified Files: setup.py Log Message: don't attempt to build axdebug on 64bit platforms Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** setup.py 12 Jan 2009 08:51:03 -0000 1.91 --- setup.py 14 Jan 2009 04:27:41 -0000 1.92 *************** *** 1529,1532 **** --- 1529,1533 ---- pch_header="stdafx.h", optional_headers=["activdbg.h"], + platforms=['win32'], sources=(""" %(axdebug)s/AXDebug.cpp |
From: Jason R. C. <ja...@us...> - 2009-01-14 04:06:19
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7086 Modified Files: win32timezone.py Log Message: Added a local implementation of GetTimeZoneInformation using ctypes in order to get a raw SYSTEMTIME object. Used the raw TIME_ZONE_INFORMATION and SYSTEMTIME structures to initialize a TimeZoneInformation purely from a TIME_ZONE_INFORMATION. All tests pass except for the pickle test. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32timezone.py 14 Jan 2009 03:01:13 -0000 1.17 --- win32timezone.py 14 Jan 2009 04:06:02 -0000 1.18 *************** *** 13,17 **** Written by Jason R. Coombs (ja...@ja...). ! Copyright © 2003-2008. All Rights Reserved. --- 13,17 ---- Written by Jason R. Coombs (ja...@ja...). ! Copyright © 2003-2009. All Rights Reserved. *************** *** 133,136 **** --- 133,137 ---- import datetime import win32api + import ctypes import re import sys *************** *** 148,182 **** def __init__(self, param): isinstance(param, basestring) and self.__load_bytes(param) ! isinstance(param, tuple) and self.__load_tuple(param) def __load_bytes(self, bytes): components = struct.unpack(self.format, bytes) ! bias, std_bias, dlt_bias = components[:3] ! daylight_times = components[3:11], components[11:19] ! std_start, dlt_start = map(pywintypes.Time, daylight_times) ! std_name = dlt_name = None ! tz_tuple = (bias, std_name, std_start, std_bias, dlt_name, dlt_start, dlt_bias) ! self.__load_values(tz_tuple) ! tuple_fields = ('bias', 'std_name', 'std_start', 'std_bias', 'dlt_name', 'dlt_start', 'dlt_bias') ! ! def __load_values(self, tz_tuple): ! "tz_tuple is a tuple such as the one returned from win32api.GetTimeZoneInformation" ! tz_dict = dict(zip(self.tuple_fields, tz_tuple)) make_minute_time_delta = lambda m: datetime.timedelta(minutes = m) ! bias_vars = [var for var in tz_dict.keys() if 'bias' in var] ! for name in bias_vars: ! bias = make_minute_time_delta(tz_dict[name]) ! setattr(self, name, bias) ! time_vars = [var for var in tz_dict.keys() if 'start' in var] ! for name in time_vars: ! value = pywintypes.Time(tz_dict[name]) setattr(self, name, value) def LocateStartDay(self, year): ! return self._locate_day(year, self.dlt_start) def LocateEndDay(self, year): ! return self._locate_day(year, self.std_start) @staticmethod --- 149,182 ---- def __init__(self, param): isinstance(param, basestring) and self.__load_bytes(param) ! isinstance(param, TIME_ZONE_INFORMATION) and self.__load_time_zone_information(param) def __load_bytes(self, bytes): components = struct.unpack(self.format, bytes) ! bias, standard_bias, daylight_bias = components[:3] ! standard_start = SYSTEMTIME(*components[3:11]) ! daylight_start = SYSTEMTIME(*components[11:19]) ! standard_name = daylight_name = "" ! tzi = TIME_ZONE_INFORMATION(bias, ! standard_name, standard_start, standard_bias, ! daylight_name, daylight_start, daylight_bias,) ! self.__load_time_zone_information(tzi) ! def __load_time_zone_information(self, tzi): ! """Copy all the attributes from a TIME_ZONE_INFORMATION structure, ! converting bias values to timedelta objects along the way.""" ! # TODO: consider merging this class with TIME_ZONE_INFORMATION make_minute_time_delta = lambda m: datetime.timedelta(minutes = m) ! bias_fields = [field for field in tzi.fields() if 'bias' in field] ! for name in tzi.fields(): ! value = getattr(tzi, name) ! if 'bias' in name: ! value = make_minute_time_delta(value) setattr(self, name, value) def LocateStartDay(self, year): ! return self._locate_day(year, self.daylight_start) def LocateEndDay(self, year): ! return self._locate_day(year, self.standard_start) @staticmethod *************** *** 192,200 **** >>> SATURDAY = 6 >>> MARCH = 3 ! >>> SYSTEMTIME_tuple = (2000, MARCH, SATURDAY, 4, 0, 0, 0, 0) # according to my calendar, the 4th Saturday in March in 2009 was the 28th >>> expected_date = datetime.datetime(2009, 3, 28) ! >>> WinTZI._locate_day(2009, pywintypes.Time(SYSTEMTIME_tuple)) == expected_date True --- 192,200 ---- >>> SATURDAY = 6 >>> MARCH = 3 ! >>> st = SYSTEMTIME(2000, MARCH, SATURDAY, 4, 0, 0, 0, 0) # according to my calendar, the 4th Saturday in March in 2009 was the 28th >>> expected_date = datetime.datetime(2009, 3, 28) ! >>> WinTZI._locate_day(2009, st) == expected_date True *************** *** 204,208 **** """ # MS stores Sunday as 0, Python datetime stores Monday as zero ! target_weekday = (cutoff.weekday + 6) % 7 # For SYSTEMTIMEs relating to time zone inforamtion, cutoff.day # is the week of the month --- 204,208 ---- """ # MS stores Sunday as 0, Python datetime stores Monday as zero ! target_weekday = (cutoff.day_of_week + 6) % 7 # For SYSTEMTIMEs relating to time zone inforamtion, cutoff.day # is the week of the month *************** *** 211,217 **** day = (week_of_month - 1) * 7 + 1 result = datetime.datetime(year, cutoff.month, day, ! cutoff.hour, cutoff.minute, cutoff.second, cutoff.msec) # now the result is the correct week, but not necessarily the correct day of the week ! days_to_go = target_weekday - result.weekday() result += datetime.timedelta(days_to_go) # if we selected a day in the month following the target month, --- 211,217 ---- day = (week_of_month - 1) * 7 + 1 result = datetime.datetime(year, cutoff.month, day, ! cutoff.hour, cutoff.minute, cutoff.second, cutoff.millisecond) # now the result is the correct week, but not necessarily the correct day of the week ! days_to_go = (target_weekday - result.weekday()) % 7 result += datetime.timedelta(days_to_go) # if we selected a day in the month following the target month, *************** *** 220,224 **** # to be the last week in a month and adding the time delta might have # pushed the result into the next month. ! while result.month == month + 1: result -= datetime.timedelta(weeks = 1) return result --- 220,224 ---- # to be the last week in a month and adding the time delta might have # pushed the result into the next month. ! while result.month == cutoff.month + 1: result -= datetime.timedelta(weeks = 1) return result *************** *** 276,283 **** def _LoadFromTZI(self, tzi): ! self.timeZoneName = tzi.std_name self.displayName = 'Unknown' ! self.standardName = tzi.std_name ! self.daylightName = tzi.dlt_name self.staticInfo = tzi --- 276,283 ---- def _LoadFromTZI(self, tzi): ! self.timeZoneName = tzi.standard_name self.displayName = 'Unknown' ! self.standardName = tzi.standard_name ! self.daylightName = tzi.daylight_name self.staticInfo = tzi *************** *** 307,313 **** def tzname(self, dt): winInfo = self.getWinInfo(dt) ! if self.dst(dt) == winInfo.dlt_bias: result = self.daylightName ! elif self.dst(dt) == winInfo.std_bias: result = self.standardName return result --- 307,313 ---- def tzname(self, dt): winInfo = self.getWinInfo(dt) ! if self.dst(dt) == winInfo.daylight_bias: result = self.daylightName ! elif self.dst(dt) == winInfo.standard_bias: result = self.standardName return result *************** *** 323,331 **** def _getStandardBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.std_bias def _getDaylightBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.dlt_bias def utcoffset(self, dt): --- 323,331 ---- def _getStandardBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.standard_bias def _getDaylightBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.daylight_bias def utcoffset(self, dt): *************** *** 342,348 **** winInfo = self.getWinInfo(dt.year) if not self.fixedStandardTime and self._inDaylightSavings(dt): ! result = winInfo.dlt_bias else: ! result = winInfo.std_bias return result --- 342,348 ---- winInfo = self.getWinInfo(dt.year) if not self.fixedStandardTime and self._inDaylightSavings(dt): ! result = winInfo.daylight_bias else: ! result = winInfo.standard_bias return result *************** *** 524,530 **** si = other.staticInfo same_bias = si.bias==self.ZERO ! same_standard_bias = si.std_bias==self.ZERO no_dst = other.fixedStandardTime == True ! same_daylight_bias = no_dst or si.dlt_bias==self.ZERO return same_bias and same_standard_bias and same_daylight_bias --- 524,530 ---- si = other.staticInfo same_bias = si.bias==self.ZERO ! same_standard_bias = si.standard_bias==self.ZERO no_dst = other.fixedStandardTime == True ! same_daylight_bias = no_dst or si.daylight_bias==self.ZERO return same_bias and same_standard_bias and same_daylight_bias *************** *** 567,571 **** True """ ! code, result = win32api.GetTimeZoneInformation() info = WinTZI(result) # code is 0 if daylight savings is disabled or not defined --- 567,571 ---- True """ ! code, result = GetTimeZoneInformation() info = WinTZI(result) # code is 0 if daylight savings is disabled or not defined *************** *** 703,704 **** --- 703,736 ---- def __new__(cls): return RangeItem.__new__(cls, -1) + + # some win32api stuff to get raw SYSTEMTIME structures + class SYSTEMTIME(ctypes.Structure): + _fields_ = [ + ('year', ctypes.c_ushort), + ('month', ctypes.c_ushort), + ('day_of_week', ctypes.c_ushort), + ('day', ctypes.c_ushort), + ('hour', ctypes.c_ushort), + ('minute', ctypes.c_ushort), + ('second', ctypes.c_ushort), + ('millisecond', ctypes.c_ushort), + ] + + class TIME_ZONE_INFORMATION(ctypes.Structure): + _fields_ = [ + ('bias', ctypes.c_long), + ('standard_name', ctypes.c_wchar*32), + ('standard_start', SYSTEMTIME), + ('standard_bias', ctypes.c_long), + ('daylight_name', ctypes.c_wchar*32), + ('daylight_start', SYSTEMTIME), + ('daylight_bias', ctypes.c_long), + ] + + def fields(self): + return map(operator.itemgetter(0), self._fields_) + + def GetTimeZoneInformation(): + tzi = TIME_ZONE_INFORMATION() + code = ctypes.windll.kernel32.GetTimeZoneInformation(ctypes.byref(tzi)) + return code, tzi |
From: Jason R. C. <ja...@us...> - 2009-01-14 03:01:25
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1315 Modified Files: win32timezone.py Log Message: Refactored to support initializing a TimeZoneInfo object with a WinTZI object. This allows GetLocalTimeZone() to use the time zone information from GetTimeZoneInformation() Unfortunately, many tests fail. I believe this is due to the fact that pywintypes.Time loses information from the SYSTEMTIME structure. The implementation will have to be improved with a more strict SYSTEMTIME implentation. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32timezone.py 13 Jan 2009 04:02:31 -0000 1.16 --- win32timezone.py 14 Jan 2009 03:01:13 -0000 1.17 *************** *** 24,29 **** >>> import win32timezone, datetime >>> assert 'Mountain Standard Time' in win32timezone.TimeZoneInfo.get_sorted_time_zone_names() ! >>> tzi = win32timezone.TimeZoneInfo('Mountain Standard Time') ! >>> now = datetime.datetime.now(tzi) The now object is now a time-zone aware object, and daylight savings- --- 24,29 ---- >>> import win32timezone, datetime >>> assert 'Mountain Standard Time' in win32timezone.TimeZoneInfo.get_sorted_time_zone_names() ! >>> MST = win32timezone.TimeZoneInfo('Mountain Standard Time') ! >>> now = datetime.datetime.now(MST) The now object is now a time-zone aware object, and daylight savings- *************** *** 40,47 **** datetime.timedelta(-1, 61200) ! >>> aug2 = datetime.datetime(2003, 8, 2, tzinfo = tzi) >>> tuple(aug2.utctimetuple()) (2003, 8, 2, 6, 0, 0, 5, 214, 0) ! >>> nov2 = datetime.datetime(2003, 11, 25, tzinfo = tzi) >>> tuple(nov2.utctimetuple()) (2003, 11, 25, 7, 0, 0, 1, 329, 0) --- 40,47 ---- datetime.timedelta(-1, 61200) ! >>> aug2 = datetime.datetime(2003, 8, 2, tzinfo = MST) >>> tuple(aug2.utctimetuple()) (2003, 8, 2, 6, 0, 0, 5, 214, 0) ! >>> nov2 = datetime.datetime(2003, 11, 25, tzinfo = MST) >>> tuple(nov2.utctimetuple()) (2003, 11, 25, 7, 0, 0, 1, 329, 0) *************** *** 137,140 **** --- 137,141 ---- import operator import warnings + import pywintypes from itertools import count *************** *** 145,187 **** format = '3l8h8h' ! def __init__(self, bytes): ! self.__init_from_bytes__(bytes) ! ! def __init_from_bytes__(self, bytes): components = struct.unpack(self.format, bytes) ! makeMinuteTimeDelta = lambda x: datetime.timedelta(minutes = x) ! self.bias, self.standardBiasOffset, self.daylightBiasOffset = \ ! map(makeMinuteTimeDelta, components[:3]) ! # daylightEnd and daylightStart are 8-tuples representing a Win32 SYSTEMTIME structure ! self.daylightEnd, self.daylightStart = components[3:11], components[11:19] def LocateStartDay(self, year): ! return self._LocateDay(year, self.daylightStart) def LocateEndDay(self, year): ! return self._LocateDay(year, self.daylightEnd) ! def _LocateDay(self, year, win32SystemTime): """ ! Takes a SYSTEMTIME structure as retrieved from a TIME_ZONE_INFORMATION ! structure and interprets it based on the given year to identify the actual day. This method is necessary because the SYSTEMTIME structure refers to a day by its ! day of the week or week of the month (e.g. 4th saturday in April). Refer to the Windows Platform SDK for more information on the SYSTEMTIME and TIME_ZONE_INFORMATION structures. """ - month = win32SystemTime[1] # MS stores Sunday as 0, Python datetime stores Monday as zero ! targetWeekday = (win32SystemTime[2] + 6) % 7 ! # win32SystemTime[3] is the week of the month, so the following ! # is the first day of that week ! day = (win32SystemTime[3] - 1) * 7 + 1 ! hour, min, sec, msec = win32SystemTime[4:] ! result = datetime.datetime(year, month, day, hour, min, sec, msec) # now the result is the correct week, but not necessarily the correct day of the week ! daysToGo = targetWeekday - result.weekday() ! result += datetime.timedelta(daysToGo) # if we selected a day in the month following the target month, # move back a week or two. --- 146,218 ---- format = '3l8h8h' ! def __init__(self, param): ! isinstance(param, basestring) and self.__load_bytes(param) ! isinstance(param, tuple) and self.__load_tuple(param) ! ! def __load_bytes(self, bytes): components = struct.unpack(self.format, bytes) ! bias, std_bias, dlt_bias = components[:3] ! daylight_times = components[3:11], components[11:19] ! std_start, dlt_start = map(pywintypes.Time, daylight_times) ! std_name = dlt_name = None ! tz_tuple = (bias, std_name, std_start, std_bias, dlt_name, dlt_start, dlt_bias) ! self.__load_values(tz_tuple) ! ! tuple_fields = ('bias', 'std_name', 'std_start', 'std_bias', 'dlt_name', 'dlt_start', 'dlt_bias') ! ! def __load_values(self, tz_tuple): ! "tz_tuple is a tuple such as the one returned from win32api.GetTimeZoneInformation" ! tz_dict = dict(zip(self.tuple_fields, tz_tuple)) ! make_minute_time_delta = lambda m: datetime.timedelta(minutes = m) ! bias_vars = [var for var in tz_dict.keys() if 'bias' in var] ! for name in bias_vars: ! bias = make_minute_time_delta(tz_dict[name]) ! setattr(self, name, bias) ! time_vars = [var for var in tz_dict.keys() if 'start' in var] ! for name in time_vars: ! value = pywintypes.Time(tz_dict[name]) ! setattr(self, name, value) def LocateStartDay(self, year): ! return self._locate_day(year, self.dlt_start) def LocateEndDay(self, year): ! return self._locate_day(year, self.std_start) ! @staticmethod ! def _locate_day(year, cutoff): """ ! Takes a pywintypes.Time object, such as retrieved from a TIME_ZONE_INFORMATION ! structure or call to GetTimeZoneInformation and interprets it based on the given ! year to identify the actual day. This method is necessary because the SYSTEMTIME structure refers to a day by its ! day of the week and week of the month (e.g. 4th saturday in March). ! ! >>> SATURDAY = 6 ! >>> MARCH = 3 ! >>> SYSTEMTIME_tuple = (2000, MARCH, SATURDAY, 4, 0, 0, 0, 0) + # according to my calendar, the 4th Saturday in March in 2009 was the 28th + >>> expected_date = datetime.datetime(2009, 3, 28) + >>> WinTZI._locate_day(2009, pywintypes.Time(SYSTEMTIME_tuple)) == expected_date + True + Refer to the Windows Platform SDK for more information on the SYSTEMTIME and TIME_ZONE_INFORMATION structures. + """ # MS stores Sunday as 0, Python datetime stores Monday as zero ! target_weekday = (cutoff.weekday + 6) % 7 ! # For SYSTEMTIMEs relating to time zone inforamtion, cutoff.day ! # is the week of the month ! week_of_month = cutoff.day ! # so the following is the first day of that week ! day = (week_of_month - 1) * 7 + 1 ! result = datetime.datetime(year, cutoff.month, day, ! cutoff.hour, cutoff.minute, cutoff.second, cutoff.msec) # now the result is the correct week, but not necessarily the correct day of the week ! days_to_go = target_weekday - result.weekday() ! result += datetime.timedelta(days_to_go) # if we selected a day in the month following the target month, # move back a week or two. *************** *** 208,215 **** tzRegKey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' ! def __init__(self, timeZoneName, fixedStandardTime=False): ! self.timeZoneName = timeZoneName ! self._LoadInfoFromKey() ! self.fixedStandardTime = fixedStandardTime def _FindTimeZoneKey(self): --- 239,249 ---- tzRegKey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' ! def __init__(self, param, fix_standard_time=False): ! if isinstance(param, WinTZI): ! self._LoadFromTZI(param) ! if isinstance(param, basestring): ! self.timeZoneName = param ! self._LoadInfoFromKey() ! self.fixedStandardTime = fix_standard_time def _FindTimeZoneKey(self): *************** *** 241,244 **** --- 275,285 ---- self._LoadDynamicInfoFromKey(key) + def _LoadFromTZI(self, tzi): + self.timeZoneName = tzi.std_name + self.displayName = 'Unknown' + self.standardName = tzi.std_name + self.daylightName = tzi.dlt_name + self.staticInfo = tzi + def _LoadDynamicInfoFromKey(self, key): try: *************** *** 266,272 **** def tzname(self, dt): winInfo = self.getWinInfo(dt) ! if self.dst(dt) == winInfo.daylightBiasOffset: result = self.daylightName ! elif self.dst(dt) == winInfo.standardBiasOffset: result = self.standardName return result --- 307,313 ---- def tzname(self, dt): winInfo = self.getWinInfo(dt) ! if self.dst(dt) == winInfo.dlt_bias: result = self.daylightName ! elif self.dst(dt) == winInfo.std_bias: result = self.standardName return result *************** *** 282,290 **** def _getStandardBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.standardBiasOffset def _getDaylightBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.daylightBiasOffset def utcoffset(self, dt): --- 323,331 ---- def _getStandardBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.std_bias def _getDaylightBias(self, dt): winInfo = self.getWinInfo(dt.year) ! return winInfo.bias + winInfo.dlt_bias def utcoffset(self, dt): *************** *** 301,307 **** winInfo = self.getWinInfo(dt.year) if not self.fixedStandardTime and self._inDaylightSavings(dt): ! result = winInfo.daylightBiasOffset else: ! result = winInfo.standardBiasOffset return result --- 342,348 ---- winInfo = self.getWinInfo(dt.year) if not self.fixedStandardTime and self._inDaylightSavings(dt): ! result = winInfo.dlt_bias else: ! result = winInfo.std_bias return result *************** *** 483,489 **** si = other.staticInfo same_bias = si.bias==self.ZERO ! same_standard_bias = si.standardBiasOffset==self.ZERO no_dst = other.fixedStandardTime == True ! same_daylight_bias = no_dst or si.daylightBiasOffset==self.ZERO return same_bias and same_standard_bias and same_daylight_bias --- 524,530 ---- si = other.staticInfo same_bias = si.bias==self.ZERO ! same_standard_bias = si.std_bias==self.ZERO no_dst = other.fixedStandardTime == True ! same_daylight_bias = no_dst or si.dlt_bias==self.ZERO return same_bias and same_standard_bias and same_daylight_bias *************** *** 527,538 **** """ code, result = win32api.GetTimeZoneInformation() ! bias, standardName, standardTimeBegin, standardBias, daylightName, daylightBegin, daylightBias = result # code is 0 if daylight savings is disabled or not defined # code is 1 or 2 if daylight savings is enabled, 2 if currently active ! fixStandardTime = not code # note that although the given information is sufficient to construct a WinTZI object, it's # not sufficient to represent the time zone in which the current user is operating due # to dynamic time zones. ! return TimeZoneInfo(standardName, fixStandardTime) def GetTZCapabilities(): --- 568,579 ---- """ code, result = win32api.GetTimeZoneInformation() ! info = WinTZI(result) # code is 0 if daylight savings is disabled or not defined # code is 1 or 2 if daylight savings is enabled, 2 if currently active ! fix_standard_time = not code # note that although the given information is sufficient to construct a WinTZI object, it's # not sufficient to represent the time zone in which the current user is operating due # to dynamic time zones. ! return TimeZoneInfo(info, fix_standard_time) def GetTZCapabilities(): |
From: Mark H. <mha...@us...> - 2009-01-14 01:21:11
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28658 Modified Files: test_win32file.py Log Message: fix FILETIME tests (mostly) for py2k Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_win32file.py 8 Jan 2009 03:35:41 -0000 1.24 --- test_win32file.py 14 Jan 2009 01:20:58 -0000 1.25 *************** *** 125,135 **** from win32timezone import GetLocalTimeZone now = datetime.datetime.now(tz=GetLocalTimeZone()) ! ok_delta = datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) else: tick = int(time.time()) ! now = pywintypes.Time(tick) ! ok_delta = 1 ! later = pywintypes.Time(tick+120) filename = tempfile.mktemp("-testFileTimes") --- 125,140 ---- from win32timezone import GetLocalTimeZone now = datetime.datetime.now(tz=GetLocalTimeZone()) ! nowish = now + datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) else: + rc, tzi = win32api.GetTimeZoneInformation() + bias = tzi[0] + if rc==2: # daylight-savings is in effect. + bias += tzi[-1] + bias *= 60 # minutes to seconds... tick = int(time.time()) ! now = pywintypes.Time(tick+bias) ! nowish = pywintypes.Time(tick+bias+1) ! later = pywintypes.Time(tick+bias+120) filename = tempfile.mktemp("-testFileTimes") *************** *** 140,154 **** 0, None, win32con.OPEN_EXISTING, 0, None) - # *sob* - before we had tz aware datetime objects, we are faced - # with FILETIME objects being +GST out from now(). So just skip - # this... - if not issubclass(pywintypes.TimeType, datetime.datetime): - return try: ct, at, wt = win32file.GetFileTime(f) self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) ! self.failUnless( now <= ct <= now + ok_delta, (now, ct)) self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) ! self.failUnless( now <= wt <= now + ok_delta, (now, wt)) # Now set the times. --- 145,154 ---- 0, None, win32con.OPEN_EXISTING, 0, None) try: ct, at, wt = win32file.GetFileTime(f) self.failUnless(ct >= now, "File was created in the past - now=%s, created=%s" % (now, ct)) ! self.failUnless( now <= ct <= nowish, (now, ct)) self.failUnless(wt >= now, "File was written-to in the past now=%s, written=%s" % (now,wt)) ! self.failUnless( now <= wt <= nowish, (now, wt)) # Now set the times. *************** *** 156,162 **** # Get them back. ct, at, wt = win32file.GetFileTime(f) ! self.failUnlessEqual(ct, later) ! self.failUnlessEqual(at, later) ! self.failUnlessEqual(wt, later) finally: --- 156,165 ---- # Get them back. ct, at, wt = win32file.GetFileTime(f) ! # XXX - the builtin PyTime type appears to be out by a dst offset. ! # just ignore that type here... ! if issubclass(pywintypes.TimeType, datetime.datetime): ! self.failUnlessEqual(ct, later) ! self.failUnlessEqual(at, later) ! self.failUnlessEqual(wt, later) finally: |