pywin32-checkins Mailing List for Python for Windows Extensions (Page 135)
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...> - 2004-04-26 00:23:38
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1305 Modified Files: testall.py Added Files: testClipboard.py Log Message: Test the new OLE Clipboard support. Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** testall.py 25 Apr 2004 04:10:48 -0000 1.22 --- testall.py 26 Apr 2004 00:23:30 -0000 1.23 *************** *** 72,75 **** --- 72,76 ---- testAXScript testxslt testDictionary testCollections testServers errorSemantics.test testvb.TestAll testArrays + testClipboard """.split(), # Level 2 tests. --- NEW FILE: testClipboard.py --- # testClipboard.py import unittest import pythoncom import win32con import winerror import win32clipboard from win32com.server.util import NewEnum, wrap from win32com.server.exception import COMException IDataObject_Methods = """GetData GetDataHere QueryGetData GetCanonicalFormatEtc SetData EnumFormatEtc DAdvise DUnadvise EnumDAdvise""".split() # A COM object implementing IDataObject used for basic testing. num_do_objects = 0 class TestDataObject: _com_interfaces_ = [pythoncom.IID_IDataObject] _public_methods_ = IDataObject_Methods def __init__(self, strval): global num_do_objects num_do_objects += 1 self.strval = strval self.supported_fe = [] for cf in (win32con.CF_TEXT, win32con.CF_UNICODETEXT): fe = cf, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_fe.append(fe) def __del__(self): global num_do_objects num_do_objects -= 1 def _query_interface_(self, iid): if iid==pythoncom.IID_IEnumFORMATETC: return NewEnum(self.supported_fe, iid=iid) def GetData(self, fe): ret_stg = None cf, target, aspect, index, tymed = fe if aspect & pythoncom.DVASPECT_CONTENT and \ tymed==pythoncom.TYMED_HGLOBAL: if cf == win32con.CF_TEXT: ret_stg = pythoncom.STGMEDIUM() ret_stg.set(pythoncom.TYMED_HGLOBAL, self.strval) elif cf == win32con.CF_UNICODETEXT: ret_stg = pythoncom.STGMEDIUM() ret_stg.set(pythoncom.TYMED_HGLOBAL, unicode(self.strval)) if ret_stg is None: raise COMException(hresult=winerror.E_NOTIMPL) return ret_stg def GetDataHere(self, fe): raise COMException(hresult=winerror.E_NOTIMPL) def QueryGetData(self, fe): cf, target, aspect, index, tymed = fe if aspect & pythoncom.DVASPECT_CONTENT == 0: raise COMException(hresult=winerror.DV_E_DVASPECT) if tymed!=pythoncom.TYMED_HGLOBAL: raise COMException(hresult=winerror.DV_E_TYMED) return None # should check better def GetCanonicalFormatEtc(self, fe): RaiseCOMException(winerror.DATA_S_SAMEFORMATETC) # return fe def SetData(self, fe, medium): raise COMException(hresult=winerror.E_NOTIMPL) def EnumFormatEtc(self, direction): if direction != pythoncom.DATADIR_GET: raise COMException(hresult=winerror.E_NOTIMPL) return NewEnum(self.supported_fe, iid=pythoncom.IID_IEnumFORMATETC) def DAdvise(self, fe, flags, sink): raise COMException(hresult=winerror.E_NOTIMPL) def DUnadvise(self, connection): raise COMException(hresult=winerror.E_NOTIMPL) def EnumDAdvise(self): raise COMException(hresult=winerror.E_NOTIMPL) class ClipboardTester(unittest.TestCase): def setUp(self): pythoncom.OleInitialize() def tearDown(self): pythoncom.OleFlushClipboard() def testIsCurrentClipboard(self): do = TestDataObject("Hello from Python") do = wrap(do, iid=pythoncom.IID_IDataObject) pythoncom.OleSetClipboard(do) self.failUnless(pythoncom.OleIsCurrentClipboard(do)) def testComToWin32(self): # Set the data via our DataObject do = TestDataObject("Hello from Python") do = wrap(do, iid=pythoncom.IID_IDataObject) pythoncom.OleSetClipboard(do) # Then get it back via the standard win32 clipboard functions. win32clipboard.OpenClipboard() got = win32clipboard.GetClipboardData(win32con.CF_TEXT) self.assertEqual(got, "Hello from Python") # Now check unicode got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) self.assertEqual(got, u"Hello from Python") win32clipboard.CloseClipboard() def testWin32ToCom(self): # Set the data via the std win32 clipboard functions. val = "Hello again!" win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32con.CF_TEXT, val) win32clipboard.CloseClipboard() # and get it via an IDataObject provided by COM do = pythoncom.OleGetClipboard() cf = win32con.CF_TEXT, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL stg = do.GetData(cf) got = stg.data # The data we get back has the \0, as our STGMEDIUM has no way of # knowing if it meant to be a string, or a binary buffer, so # it must return it too. self.failUnlessEqual(got, val+"\0") def testDataObjectFlush(self): do = TestDataObject("Hello from Python") do = wrap(do, iid=pythoncom.IID_IDataObject) pythoncom.OleSetClipboard(do) self.assertEqual(num_do_objects, 1) do = None # clear my ref! pythoncom.OleFlushClipboard() self.assertEqual(num_do_objects, 0) def testDataObjectReset(self): do = TestDataObject("Hello from Python") do = wrap(do) pythoncom.OleSetClipboard(do) do = None # clear my ref! self.assertEqual(num_do_objects, 1) pythoncom.OleSetClipboard(None) self.assertEqual(num_do_objects, 0) if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2004-04-26 00:18:14
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32762/extensions Modified Files: PySTGMEDIUM.cpp Log Message: Bite the bullet - do the buffer/unicode thing now. If nothing else, it makes the tests seem more complete Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PySTGMEDIUM.cpp 25 Apr 2004 23:58:38 -0000 1.3 --- PySTGMEDIUM.cpp 26 Apr 2004 00:17:58 -0000 1.4 *************** *** 47,64 **** break; case TYMED_HGLOBAL: { ! // todo: support buffer (but see byte-count discussion below) ! if (!PyString_Check(ob)) ! return PyErr_Format(PyExc_TypeError, "tymed value of %d requires a string", tymed); ! // We need to include the NULL, as the Windows clipboard functions ! // will assume it is there for text related formats (eg, CF_TEXT). ! // I can't see one extra byte could cause any problems - but if ! // in the future it does, we can take the win32clipboard route, ! // and only include the extra \0 for strings, allowing buffers to ! // use the exact cb. ! int cb = PyString_Size(ob)+1; ps->medium.hGlobal = GlobalAlloc(GMEM_FIXED, cb); if (!ps->medium.hGlobal) return PyErr_NoMemory(); ! memcpy( (void *)ps->medium.hGlobal, PyString_AsString(ob), cb); break; } --- 47,67 ---- break; case TYMED_HGLOBAL: { ! const void * buf = NULL; ! int cb = 0; ! if (PyObject_AsReadBuffer(ob,&buf,&cb)==-1) ! return PyErr_Format(PyExc_TypeError, "tymed value of %d requires a string/unicode/buffer", tymed); ! // size doesnt include nulls! ! // We need to include the NULL for strings and unicode, as the ! // Windows clipboard functions will assume it is there for ! // text related formats (eg, CF_TEXT). ! if (PyString_Check(ob)) ! cb += 1; ! else if (PyUnicode_Check(ob)) ! cb += sizeof(wchar_t); ! // else assume buffer needs no terminator... ps->medium.hGlobal = GlobalAlloc(GMEM_FIXED, cb); if (!ps->medium.hGlobal) return PyErr_NoMemory(); ! memcpy( (void *)ps->medium.hGlobal, buf, cb); break; } |
From: Mark H. <mha...@us...> - 2004-04-25 23:58:46
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28720/extensions Modified Files: PySTGMEDIUM.cpp Log Message: When writing to a HGLOBAL's memory, include the strings trailing \0. This should have no effect for binary buffers, but will allow data formats treated as text (eg, CF_TEXT) to work better. Unfortunately, the medium itself has no info about the format, so we can't be smart like the win32clipboard routines. Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PySTGMEDIUM.cpp 9 Oct 2003 12:49:38 -0000 1.2 --- PySTGMEDIUM.cpp 25 Apr 2004 23:58:38 -0000 1.3 *************** *** 47,57 **** break; case TYMED_HGLOBAL: { ! // todo: support buffer if (!PyString_Check(ob)) return PyErr_Format(PyExc_TypeError, "tymed value of %d requires a string", tymed); ! ps->medium.hGlobal = GlobalAlloc(GMEM_FIXED, PyString_Size(ob)); if (!ps->medium.hGlobal) return PyErr_NoMemory(); ! memcpy( (void *)ps->medium.hGlobal, PyString_AsString(ob), PyString_Size(ob)); break; } --- 47,64 ---- break; case TYMED_HGLOBAL: { ! // todo: support buffer (but see byte-count discussion below) if (!PyString_Check(ob)) return PyErr_Format(PyExc_TypeError, "tymed value of %d requires a string", tymed); ! // We need to include the NULL, as the Windows clipboard functions ! // will assume it is there for text related formats (eg, CF_TEXT). ! // I can't see one extra byte could cause any problems - but if ! // in the future it does, we can take the win32clipboard route, ! // and only include the extra \0 for strings, allowing buffers to ! // use the exact cb. ! int cb = PyString_Size(ob)+1; ! ps->medium.hGlobal = GlobalAlloc(GMEM_FIXED, cb); if (!ps->medium.hGlobal) return PyErr_NoMemory(); ! memcpy( (void *)ps->medium.hGlobal, PyString_AsString(ob), cb); break; } |
From: Mark H. <mha...@us...> - 2004-04-25 19:46:58
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19651 Modified Files: setup_win32all.py Log Message: Bump build number to 201 Index: setup_win32all.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** setup_win32all.py 21 Apr 2004 06:37:45 -0000 1.16 --- setup_win32all.py 25 Apr 2004 10:21:10 -0000 1.17 *************** *** 1,3 **** ! build_number=200 """distutils setup-script for win32all --- 1,3 ---- ! build_number=201 """distutils setup-script for win32all |
From: Mark H. <mha...@us...> - 2004-04-25 18:02:51
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28916/win32/src Modified Files: win32gui.i Log Message: PyExc_PendingDeprecationWarning only exists in Python 2.3+ Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** win32gui.i 25 Apr 2004 07:02:49 -0000 1.37 --- win32gui.i 25 Apr 2004 11:17:43 -0000 1.38 *************** *** 1898,1903 **** static PyObject *Unicode(PyObject *self, PyObject *args) { - PyErr_Warn(PyExc_PendingDeprecationWarning, "win32gui.Unicode will die!"); char *text; if (!PyArg_ParseTuple(args, "s", &text)) return NULL; --- 1898,1905 ---- static PyObject *Unicode(PyObject *self, PyObject *args) { char *text; + #if PY_VERSION_HEX > 0x2030300 + PyErr_Warn(PyExc_PendingDeprecationWarning, "win32gui.Unicode will die!"); + #endif if (!PyArg_ParseTuple(args, "s", &text)) return NULL; |
From: Mark H. <mha...@us...> - 2004-04-25 15:46:32
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605 Modified Files: win32evtlogutil.py Log Message: File has mixed tabs/spaces - normalize. Index: win32evtlogutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32evtlogutil.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32evtlogutil.py 25 Apr 2004 07:21:34 -0000 1.9 --- win32evtlogutil.py 25 Apr 2004 10:34:10 -0000 1.10 *************** *** 9,152 **** def AddSourceToRegistry(appName, msgDLL = None, eventLogType = "Application", eventLogFlags = None): ! """Add a source of messages to the event log. ! Allows Python program to register a custom source of messages in the ! registry. You must also provide the DLL name that has the message table, so the ! full message text appears in the event log. ! Note that the win32evtlog.pyd file has a number of string entries with just "%1" ! built in, so many Python programs can simply use this DLL. Disadvantages are that ! you do not get language translation, and the full text is stored in the event log, ! blowing the size of the log up. ! """ ! ! # When an application uses the RegisterEventSource or OpenEventLog ! # function to get a handle of an event log, the event loggging service ! # searches for the specified source name in the registry. You can add a ! # new source name to the registry by opening a new registry subkey ! # under the Application key and adding registry values to the new ! # subkey. ! if msgDLL is None: ! msgDLL = win32evtlog.__file__ ! # Create a new key for our application ! hkey = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, \ ! "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) ! # Add the Event-ID message-file name to the subkey. ! win32api.RegSetValueEx(hkey, ! "EventMessageFile", # value name \ ! 0, # reserved \ ! win32con.REG_EXPAND_SZ,# value type \ ! msgDLL) ! # Set the supported types flags and add it to the subkey. ! if eventLogFlags is None: ! eventLogFlags = win32evtlog.EVENTLOG_ERROR_TYPE | win32evtlog.EVENTLOG_WARNING_TYPE | win32evtlog.EVENTLOG_INFORMATION_TYPE ! win32api.RegSetValueEx(hkey, # subkey handle \ ! "TypesSupported", # value name \ ! 0, # reserved \ ! win32con.REG_DWORD, # value type \ ! eventLogFlags) ! win32api.RegCloseKey(hkey) def RemoveSourceFromRegistry(appName, eventLogType = "Application"): ! """Removes a source of messages from the event log. ! """ ! ! # Delete our key ! try: ! win32api.RegDeleteKey(win32con.HKEY_LOCAL_MACHINE, \ ! "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) ! except win32api.error, (hr, fn, desc): ! if hr != winerror.ERROR_FILE_NOT_FOUND: ! raise def ReportEvent(appName, eventID, eventCategory = 0, eventType=win32evtlog.EVENTLOG_ERROR_TYPE, strings = None, data = None, sid=None): ! """Report an event for a previously added event source. ! """ ! # Get a handle to the Application event log ! hAppLog = win32evtlog.RegisterEventSource(None, appName) ! # Now report the event, which will add this event to the event log */ ! win32evtlog.ReportEvent(hAppLog, # event-log handle \ ! eventType, ! eventCategory, ! eventID, ! sid, ! strings, ! data) ! win32evtlog.DeregisterEventSource(hAppLog); def FormatMessage( eventLogRecord, logType="Application" ): ! """Given a tuple from ReadEventLog, and optionally where the event ! record came from, load the message, and process message inserts. ! Note that this function may raise win32api.error. See also the ! function SafeFormatMessage which will return None if the message can ! not be processed. ! """ ! ! # From the event log source name, we know the name of the registry ! # key to look under for the name of the message DLL that contains ! # the messages we need to extract with FormatMessage. So first get ! # the event log source name... ! keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName) ! # Now open this key and get the EventMessageFile value, which is ! # the name of the message DLL. ! handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName) ! try: ! dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";") ! # Win2k etc appear to allow multiple DLL names ! data = None ! for dllName in dllNames: ! try: ! # Expand environment variable strings in the message DLL path name, ! # in case any are there. ! dllName = win32api.ExpandEnvironmentStrings(dllName) ! dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.DONT_RESOLVE_DLL_REFERENCES) ! try: ! data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE, ! dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts) ! finally: ! win32api.FreeLibrary(dllHandle) ! except win32api.error: ! pass # Not in this DLL - try the next ! if data is not None: ! break ! finally: ! win32api.RegCloseKey(handle) ! return data or u'' # Don't want "None" ever being returned. def SafeFormatMessage( eventLogRecord, logType=None ): ! """As for FormatMessage, except returns an error message if ! the message can not be processed. ! """ ! if logType is None: logType = "Application" ! try: ! return FormatMessage(eventLogRecord, logType) ! except win32api.error: ! if eventLogRecord.StringInserts is None: ! desc = "" ! else: ! desc = u", ".join(eventLogRecord.StringInserts) ! return u"<The description for Event ID ( %d ) in Source ( %r ) could not be found. It contains the following insertion string(s):%r.>" % (winerror.HRESULT_CODE(eventLogRecord.EventID), eventLogRecord.SourceName, desc) def FeedEventLogRecords(feeder, machineName = None, logName = "Application", readFlags = None): ! if readFlags is None: ! readFlags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ ! h=win32evtlog.OpenEventLog(machineName, logName) ! try: ! while 1: ! objects = win32evtlog.ReadEventLog(h, readFlags, 0) ! if not objects: ! break ! map(lambda item, feeder = feeder: apply(feeder, (item,)), objects) ! finally: ! win32evtlog.CloseEventLog(h) --- 9,152 ---- def AddSourceToRegistry(appName, msgDLL = None, eventLogType = "Application", eventLogFlags = None): ! """Add a source of messages to the event log. ! Allows Python program to register a custom source of messages in the ! registry. You must also provide the DLL name that has the message table, so the ! full message text appears in the event log. ! Note that the win32evtlog.pyd file has a number of string entries with just "%1" ! built in, so many Python programs can simply use this DLL. Disadvantages are that ! you do not get language translation, and the full text is stored in the event log, ! blowing the size of the log up. ! """ ! # When an application uses the RegisterEventSource or OpenEventLog ! # function to get a handle of an event log, the event loggging service ! # searches for the specified source name in the registry. You can add a ! # new source name to the registry by opening a new registry subkey ! # under the Application key and adding registry values to the new ! # subkey. ! if msgDLL is None: ! msgDLL = win32evtlog.__file__ ! # Create a new key for our application ! hkey = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, \ ! "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) ! # Add the Event-ID message-file name to the subkey. ! win32api.RegSetValueEx(hkey, ! "EventMessageFile", # value name \ ! 0, # reserved \ ! win32con.REG_EXPAND_SZ,# value type \ ! msgDLL) ! ! # Set the supported types flags and add it to the subkey. ! if eventLogFlags is None: ! eventLogFlags = win32evtlog.EVENTLOG_ERROR_TYPE | win32evtlog.EVENTLOG_WARNING_TYPE | win32evtlog.EVENTLOG_INFORMATION_TYPE ! win32api.RegSetValueEx(hkey, # subkey handle \ ! "TypesSupported", # value name \ ! 0, # reserved \ ! win32con.REG_DWORD, # value type \ ! eventLogFlags) ! win32api.RegCloseKey(hkey) def RemoveSourceFromRegistry(appName, eventLogType = "Application"): ! """Removes a source of messages from the event log. ! """ ! ! # Delete our key ! try: ! win32api.RegDeleteKey(win32con.HKEY_LOCAL_MACHINE, \ ! "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) ! except win32api.error, (hr, fn, desc): ! if hr != winerror.ERROR_FILE_NOT_FOUND: ! raise def ReportEvent(appName, eventID, eventCategory = 0, eventType=win32evtlog.EVENTLOG_ERROR_TYPE, strings = None, data = None, sid=None): ! """Report an event for a previously added event source. ! """ ! # Get a handle to the Application event log ! hAppLog = win32evtlog.RegisterEventSource(None, appName) ! # Now report the event, which will add this event to the event log */ ! win32evtlog.ReportEvent(hAppLog, # event-log handle \ ! eventType, ! eventCategory, ! eventID, ! sid, ! strings, ! data) ! win32evtlog.DeregisterEventSource(hAppLog); def FormatMessage( eventLogRecord, logType="Application" ): ! """Given a tuple from ReadEventLog, and optionally where the event ! record came from, load the message, and process message inserts. ! Note that this function may raise win32api.error. See also the ! function SafeFormatMessage which will return None if the message can ! not be processed. ! """ ! # From the event log source name, we know the name of the registry ! # key to look under for the name of the message DLL that contains ! # the messages we need to extract with FormatMessage. So first get ! # the event log source name... ! keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName) ! # Now open this key and get the EventMessageFile value, which is ! # the name of the message DLL. ! handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName) ! try: ! dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";") ! # Win2k etc appear to allow multiple DLL names ! data = None ! for dllName in dllNames: ! try: ! # Expand environment variable strings in the message DLL path name, ! # in case any are there. ! dllName = win32api.ExpandEnvironmentStrings(dllName) ! ! dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.DONT_RESOLVE_DLL_REFERENCES) ! try: ! data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE, ! dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts) ! finally: ! win32api.FreeLibrary(dllHandle) ! except win32api.error: ! pass # Not in this DLL - try the next ! if data is not None: ! break ! finally: ! win32api.RegCloseKey(handle) ! return data or u'' # Don't want "None" ever being returned. def SafeFormatMessage( eventLogRecord, logType=None ): ! """As for FormatMessage, except returns an error message if ! the message can not be processed. ! """ ! if logType is None: logType = "Application" ! try: ! return FormatMessage(eventLogRecord, logType) ! except win32api.error: ! if eventLogRecord.StringInserts is None: ! desc = "" ! else: ! desc = u", ".join(eventLogRecord.StringInserts) ! return u"<The description for Event ID ( %d ) in Source ( %r ) could not be found. It contains the following insertion string(s):%r.>" % (winerror.HRESULT_CODE(eventLogRecord.EventID), eventLogRecord.SourceName, desc) def FeedEventLogRecords(feeder, machineName = None, logName = "Application", readFlags = None): ! if readFlags is None: ! readFlags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ ! h=win32evtlog.OpenEventLog(machineName, logName) ! try: ! while 1: ! objects = win32evtlog.ReadEventLog(h, readFlags, 0) ! if not objects: ! break ! map(lambda item, feeder = feeder: apply(feeder, (item,)), objects) ! finally: ! win32evtlog.CloseEventLog(h) |
From: Mark H. <mha...@us...> - 2004-04-25 11:19:06
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19370 Modified Files: MANIFEST.in Log Message: Everything so the 'sdist' command packages enough to build and install. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pywin32/pywin32/MANIFEST.in,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MANIFEST.in 7 Feb 2004 09:56:25 -0000 1.1 --- MANIFEST.in 25 Apr 2004 10:20:23 -0000 1.2 *************** *** 5,9 **** include MANIFEST.in ! include pythonwin/Scintilla/* include win32/src/*.h include com/win32com/src/*.h --- 5,82 ---- include MANIFEST.in ! # Core win32 stuff ! include win32/src/*.rc ! include win32/src/win32popenWin9x.cpp ! include win32/scripts/*.py ! include win32/test/*.py ! include win32/Demos/*.py include win32/src/*.h + include win32/src/PerfMon/perfmondata.def + include win32/src/dbi.def + include win32/*.dsp + include win32/License.txt + # COM + include com/pythoncom.py include com/win32com/src/*.h + include com/win32com/src/PythonCOM.def + include com/win32com/readme.htm + include com/win32com/HTML/*.html + include com/win32com/HTML/image/*.gif + include com/License.txt + include com/*.dsp + include com/win32comext/axscript/src/*.h + include com/win32comext/axscript/src/*.H + include com/win32comext/axscript/test/*.py + include com/win32comext/axscript/test/*.pys + include com/win32comext/axscript/test/*.vbs + include com/win32comext/axscript/test/*.BAT + include com/win32comext/axscript/test/*.html + include com/win32comext/axscript/demos/client/asp/*.asp + include com/win32comext/axscript/demos/client/asp/interrupt/*.asp + include com/win32comext/axscript/demos/client/asp/interrupt/*.html + include com/win32comext/axscript/demos/client/ie/*.HTM + include com/win32comext/axscript/demos/client/ie/*.htm + include com/win32comext/axscript/demos/client/ie/*.gif + include com/win32comext/axscript/demos/client/wsh/*.pys + include com/win32comext/axdebug/src/*.h + include com/win32comext/adsi/src/*.h + include com/win32comext/axcontrol/src/*.h + include com/win32comext/internet/src/*.h + include com/win32comext/mapi/src/*.h + include com/win32comext/shell/src/*.h + include com/win32comext/shell/demos/servers/*.py + include com/win32comext/taskscheduler/src/*.h + + # Pythonwin + include pythonwin/pythonwin.cpp + include pythonwin/pythonwin.rc + include pythonwin/stdafxpw.cpp + include pythonwin/*.dsp + include pythonwin/*.h + include pythonwin/res/*.ico + include pythonwin/res/*.ICO + include pythonwin/res/*.bmp + include pythonwin/res/*.BMP + include pythonwin/pywin/*.cfg + include pythonwin/License.txt + # scintilla + include pythonwin/Scintilla/README* + include pythonwin/Scintilla/License.txt + include pythonwin/Scintilla/makefile_pythonwin + include pythonwin/Scintilla/update.bat + include pythonwin/Scintilla/include/* + include pythonwin/Scintilla/src/* + include pythonwin/Scintilla/win32/*.cxx + include pythonwin/Scintilla/win32/*.h + include pythonwin/Scintilla/win32/*.rc + include pythonwin/Scintilla/win32/*.def + include pythonwin/Scintilla/win32/*.mak + include pythonwin/Scintilla/win32/*.cur + + # Other tools + include SWIG/swig.exe + include SWIG/readme.txt + include SWIG/swig_lib/*.i + include SWIG/swig_lib/*.swg + include SWIG/swig_lib/python/*.i + include SWIG/swig_lib/python/*.swg |
From: Mark H. <mha...@us...> - 2004-04-25 10:29:30
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20228 Modified Files: winout.py Log Message: Try and use msbc encoding rather than ascii when a Unicode object is obtained from the queue. Index: winout.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/winout.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** winout.py 27 Sep 2002 05:14:48 -0000 1.10 --- winout.py 25 Apr 2004 10:25:57 -0000 1.11 *************** *** 438,446 **** item = self.outputQueue.get_nowait() if is_platform_unicode: ! if type(item) != UnicodeType: item = unicode(item, default_platform_encoding) item = item.encode(default_scintilla_encoding) # What scintilla uses. else: ! item = str(item) items.append(item) except Queue.Empty: --- 438,449 ---- item = self.outputQueue.get_nowait() if is_platform_unicode: ! # Note is_platform_unicode is never true any more! ! if not isinstance(type, UnicodeType): item = unicode(item, default_platform_encoding) item = item.encode(default_scintilla_encoding) # What scintilla uses. else: ! # try and display using mbcs encoding ! if isinstance(type, UnicodeType): ! item = item.encode("mbcs") items.append(item) except Queue.Empty: |
From: Mark H. <mha...@us...> - 2004-04-25 10:29:26
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20008 Modified Files: win32rcparser.py Log Message: Fox code that generates a .py file from a .rc file. Index: win32rcparser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32rcparser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32rcparser.py 9 Apr 2004 11:13:19 -0000 1.1 --- win32rcparser.py 25 Apr 2004 10:24:13 -0000 1.2 *************** *** 10,14 **** __author__="Adam Walker" ! import sys, os, shlex import win32con import commctrl --- 10,15 ---- __author__="Adam Walker" ! import sys, os, shlex, stat ! import pprint import win32con import commctrl *************** *** 470,474 **** return rcp ! def GenerateFrozenResource(inputFilename, outputFilename): """Converts an .rc windows resource source file into a python source file with the same basic public interface as the rest of this module. --- 471,475 ---- return rcp ! def GenerateFrozenResource(rc_name, output_name, h_name = None): """Converts an .rc windows resource source file into a python source file with the same basic public interface as the rest of this module. *************** *** 476,492 **** where a frozen .py file can be used inplace of a real .rc file. """ ! rcp = rcparser.ParseDialogs(inputFilename) ! in_stat = os.stat(inputFilename) ! out = open(outputFilename, "wt") ! out.write("#%s\n" % outputFilename) ! out.write("#This is a generated file. Please edit %s instead.\n" % inputFilename) out.write("_rc_size_=%d\n_rc_mtime_=%d\n" % (in_stat[stat.ST_SIZE], in_stat[stat.ST_MTIME])) out.write("class FakeParser:\n") ! out.write("\tdialogs = "+repr(rcp.dialogs)+"\n") ! out.write("\tids = "+repr(rcp.ids)+"\n") ! out.write("\tnames = "+repr(rcp.names)+"\n") ! out.write("\tbitmaps = "+repr(rcp.bitmaps)+"\n") ! out.write("def ParseDialogs(s):\n") out.write("\treturn FakeParser()\n") out.close() --- 477,495 ---- where a frozen .py file can be used inplace of a real .rc file. """ ! rcp = Parse(rc_name, h_name) ! in_stat = os.stat(rc_name) ! out = open(output_name, "wt") ! out.write("#%s\n" % output_name) ! out.write("#This is a generated file. Please edit %s instead.\n" % rc_name) out.write("_rc_size_=%d\n_rc_mtime_=%d\n" % (in_stat[stat.ST_SIZE], in_stat[stat.ST_MTIME])) out.write("class FakeParser:\n") ! ! for name in "dialogs", "ids", "names", "bitmaps", "icons", "stringTable": ! out.write("\t%s = \\\n" % (name,)) ! pprint.pprint(getattr(rcp, name), out) ! out.write("\n") ! ! out.write("def Parse(s):\n") out.write("\treturn FakeParser()\n") out.close() |
From: Mark H. <mha...@us...> - 2004-04-25 10:27:46
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20117 Modified Files: PyWin32.kpf Log Message: Few new files in the komodo project file Index: PyWin32.kpf =================================================================== RCS file: /cvsroot/pywin32/pywin32/PyWin32.kpf,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyWin32.kpf 5 Feb 2004 23:38:49 -0000 1.4 --- PyWin32.kpf 25 Apr 2004 10:24:58 -0000 1.5 *************** *** 36,45 **** <file name="PyCOMImpl.h" url="com/TestSources/PyCOMTest/PyCOMImpl.h"> </file> - <file name="PyCOMTest.h" url="com/TestSources/PyCOMTest/PyCOMTest.h"> - </file> <file name="SimpleCounter.cpp" url="com/TestSources/PyCOMTest/SimpleCounter.cpp"> </file> <file name="SimpleCounter.h" url="com/TestSources/PyCOMTest/SimpleCounter.h"> </file> </folder> </folder> --- 36,47 ---- <file name="PyCOMImpl.h" url="com/TestSources/PyCOMTest/PyCOMImpl.h"> </file> <file name="SimpleCounter.cpp" url="com/TestSources/PyCOMTest/SimpleCounter.cpp"> </file> <file name="SimpleCounter.h" url="com/TestSources/PyCOMTest/SimpleCounter.h"> </file> + <file name="PyCOMTest.idl" url="com/TestSources/PyCOMTest/PyCOMTest.idl"> + </file> + <file name="DSCArrayTest.cpp" url="com/TestSources/PyCOMTest/DSCArrayTest.cpp"> + </file> </folder> </folder> *************** *** 287,290 **** --- 289,296 ---- <file name="PyVARDESC.cpp" url="com/win32com/src/extensions/PyVARDESC.cpp"> </file> + <file name="PyIDropTarget.cpp" url="com/win32com/src/extensions/PyIDropTarget.cpp"> + </file> + <file name="PyIDropSource.cpp" url="com/win32com/src/extensions/PyIDropSource.cpp"> + </file> </folder> <folder name="include" url="com/win32com/src/include"> *************** *** 307,312 **** <file name="PyICatRegister.h" url="com/win32com/src/include/PyICatRegister.h"> </file> - <file name="PyIConnectionPoint.h" url="com/win32com/src/include/PyIConnectionPoint.h"> - </file> <file name="PyIConnectionPointContainer.h" url="com/win32com/src/include/PyIConnectionPointContainer.h"> </file> --- 313,316 ---- *************** *** 371,374 **** --- 375,380 ---- <file name="univgw_dataconv.h" url="com/win32com/src/include/univgw_dataconv.h"> </file> + <file name="PyIConnectionPoint.h" url="com/win32com/src/include/PyIConnectionPoint.h"> + </file> </folder> </folder> *************** *** 1026,1029 **** --- 1032,1039 ---- <file name="shell_pch.h" url="com/win32comext/shell/src/shell_pch.h"> </file> + <file name="PyIColumnProvider.cpp" url="com/win32comext/shell/src/PyIColumnProvider.cpp"> + </file> + <file name="PyIColumnProvider.h" url="com/win32comext/shell/src/PyIColumnProvider.h"> + </file> </folder> <folder name="test" url="com/win32comext/shell/test"> *************** *** 1685,1688 **** --- 1695,1700 ---- </folder> <folder name="Lib" url="win32/Lib"> + <preference-set id=""> + </preference-set> <file name="afxres.py" url="win32/Lib/afxres.py"> </file> *************** *** 1723,1726 **** --- 1735,1744 ---- <file name="winperf.py" url="win32/Lib/winperf.py"> </file> + <file name="win32rcparser.py" url="win32/lib/win32rcparser.py"> + <preference-set id=""> + <preference-set id="Invocations"> + </preference-set> + </preference-set> + </file> </folder> <folder name="scripts" url="win32/scripts"> *************** *** 1759,1774 **** <file name="dbi.h" url="win32/src/dbi.h"> </file> - <file name="ddeconv.cpp" url="win32/src/ddeconv.cpp"> - </file> - <file name="ddeitem.cpp" url="win32/src/ddeitem.cpp"> - </file> - <file name="ddemodule.cpp" url="win32/src/ddemodule.cpp"> - </file> - <file name="ddemodule.h" url="win32/src/ddemodule.h"> - </file> - <file name="ddeserver.cpp" url="win32/src/ddeserver.cpp"> - </file> - <file name="ddetopic.cpp" url="win32/src/ddetopic.cpp"> - </file> <file name="mmapfilemodule.cpp" url="win32/src/mmapfilemodule.cpp"> </file> --- 1777,1780 ---- *************** *** 1811,1818 **** <file name="PyWinTypesmodule.cpp" url="win32/src/PyWinTypesmodule.cpp"> </file> - <file name="stdafxdde.h" url="win32/src/stdafxdde.h"> - </file> - <file name="stddde.cpp" url="win32/src/stddde.cpp"> - </file> <file name="stddde.h" url="win32/src/stddde.h"> </file> --- 1817,1820 ---- *************** *** 1976,1985 **** <preference-set id="Invocations"> <preference-set id="Python"> - <string id="userEnvironment"></string> <string id="postparams"></string> <string id="getparams"></string> <boolean id="use-console">0</boolean> <string id="mpostparams"></string> - <boolean id="sim-cgi">0</boolean> <string id="filename">E:\src\pythonex\setup_win32all.py</string> <string id="request-method">GET</string> --- 1978,1986 ---- <preference-set id="Invocations"> <preference-set id="Python"> <string id="postparams"></string> + <string id="userEnvironment"></string> <string id="getparams"></string> <boolean id="use-console">0</boolean> <string id="mpostparams"></string> <string id="filename">E:\src\pythonex\setup_win32all.py</string> <string id="request-method">GET</string> *************** *** 1990,1993 **** --- 1991,1995 ---- <string id="cookieparams"></string> <boolean id="show-dialog">1</boolean> + <boolean id="sim-cgi">0</boolean> <string id="cwd"></string> </preference-set> |
From: Mark H. <mha...@us...> - 2004-04-25 07:49:34
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23138 Modified Files: win32pdhquery.py win32pdhutil.py Log Message: pdh comment improvements as suggested in [ 913591 ] Possable PDH Docs update. Index: win32pdhquery.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32pdhquery.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32pdhquery.py 8 Jan 2002 05:41:13 -0000 1.2 --- win32pdhquery.py 25 Apr 2004 07:44:41 -0000 1.3 *************** *** 87,93 **** If you can access the MS Developers Network Library, you can find ! information about the PDH API as MS describes it. In general the ! Python version of the API is just a wrapper around the Query-based ! version of this API (as far as I can see), so you can learn what you need to from there. From what I understand, the MSDN Online resources are available for the price of signing up for them. I can't --- 87,100 ---- If you can access the MS Developers Network Library, you can find ! information about the PDH API as MS describes it. For a background article, ! try: ! http://msdn.microsoft.com/library/en-us/dnperfmo/html/msdn_pdhlib.asp ! ! The reference guide for the PDH API was last spotted at: ! http://msdn.microsoft.com/library/en-us/perfmon/base/using_the_pdh_interface.asp ! ! ! In general the Python version of the API is just a wrapper around the ! Query-based version of this API (as far as I can see), so you can learn what you need to from there. From what I understand, the MSDN Online resources are available for the price of signing up for them. I can't Index: win32pdhutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32pdhutil.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32pdhutil.py 6 Oct 2003 13:03:41 -0000 1.7 --- win32pdhutil.py 25 Apr 2004 07:44:41 -0000 1.8 *************** *** 42,50 **** def GetPerformanceAttributes(object, counter, instance = None, inum=-1, format = win32pdh.PDH_FMT_LONG, machine=None): ! # NOTE: If you attempt to use this function to get "% Processor Time", ! # it will not work as you expect - the problem is that by creating a ! # new query each time, we force the CPU to 100%. If you pull this ! # function apart, and only do the inner "CollectQueryData" each time ! # you need to know, it will give the correct results. path = win32pdh.MakeCounterPath( (machine,object,instance, None, inum,counter) ) hq = win32pdh.OpenQuery() --- 42,53 ---- def GetPerformanceAttributes(object, counter, instance = None, inum=-1, format = win32pdh.PDH_FMT_LONG, machine=None): ! # NOTE: Many counters require 2 samples to give accurate results, ! # including "% Processor Time" (as by definition, at any instant, a ! # thread's CPU usage is either 0 or 100). To read counters like this, ! # you should copy this function, but keep the counter open, and call ! # CollectQueryData() each time you need to know. ! # See http://msdn.microsoft.com/library/en-us/dnperfmo/html/perfmonpt2.asp ! # My older explanation for this was that the "AddCounter" process forced ! # the CPU to 100%, but the above makes more sense :) path = win32pdh.MakeCounterPath( (machine,object,instance, None, inum,counter) ) hq = win32pdh.OpenQuery() |
From: Mark H. <mha...@us...> - 2004-04-25 07:27:34
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19097 Modified Files: win32evtlogutil.py Log Message: [ 839358 ] FormatMessage in win32evtlogutil.py is incorrect We didn't handle the error when the message was not found in first listed message DLL, so we never checked the second. Index: win32evtlogutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32evtlogutil.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32evtlogutil.py 6 Oct 2003 13:04:18 -0000 1.8 --- win32evtlogutil.py 25 Apr 2004 07:21:34 -0000 1.9 *************** *** 68,72 **** """Report an event for a previously added event source. """ - # Get a handle to the Application event log hAppLog = win32evtlog.RegisterEventSource(None, appName) --- 68,71 ---- *************** *** 106,119 **** data = None for dllName in dllNames: - # Expand environment variable strings in the message DLL path name, - # in case any are there. - dllName = win32api.ExpandEnvironmentStrings(dllName) - - dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.DONT_RESOLVE_DLL_REFERENCES) try: ! data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE, ! dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts) ! finally: ! win32api.FreeLibrary(dllHandle) if data is not None: break --- 105,121 ---- data = None for dllName in dllNames: try: ! # Expand environment variable strings in the message DLL path name, ! # in case any are there. ! dllName = win32api.ExpandEnvironmentStrings(dllName) ! ! dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.DONT_RESOLVE_DLL_REFERENCES) ! try: ! data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE, ! dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts) ! finally: ! win32api.FreeLibrary(dllHandle) ! except win32api.error: ! pass # Not in this DLL - try the next if data is not None: break |
From: Mark H. <mha...@us...> - 2004-04-25 07:07:42
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16601 Modified Files: win32gui.i Log Message: Add GetWindowLong (which is in win32api, but still makes sense here) and GetClasSLong. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** win32gui.i 22 Apr 2004 10:03:20 -0000 1.36 --- win32gui.i 25 Apr 2004 07:02:49 -0000 1.37 *************** *** 992,995 **** --- 992,1005 ---- } + // @pyswig int|GetWindowLong| + // @pyparm int|hwnd|| + // @pyparm int|index|| + long GetWindowLong(HWND hwnd, int index); + + // @pyswig int|GetClassLong| + // @pyparm int|hwnd|| + // @pyparm int|index|| + long GetClassLong(HWND hwnd, int index); + // @pyswig int|SetWindowLong| %{ |
From: Mark H. <mha...@us...> - 2004-04-25 06:51:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14078 Modified Files: PyTime.cpp Log Message: Allow time.Format() to work with pre 1970 dates. As contributed by David Fraser, in [ 873846 ] Fix PyTime.Format (null pointer error) Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyTime.cpp 22 Jan 2004 04:40:22 -0000 1.10 --- PyTime.cpp 25 Apr 2004 06:46:47 -0000 1.11 *************** *** 144,148 **** --- 144,185 ---- #ifndef MS_WINCE + + /* the following code is taken from Python 2.3 Modules/datetimemodule.c + * it is used for calculating day of the year for PyTime::Format + */ + + static int _days_before_month[] = { + 0, /* unused; this vector uses 1-based indexing */ + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + }; + + /* year -> 1 if leap year, else 0. */ + static int is_leap(int year) + { + /* Cast year to unsigned. The result is the same either way, but + * C can generate faster code for unsigned mod than for signed + * mod (especially for % 4 -- a good compiler should just grab + * the last 2 bits when the LHS is unsigned). + */ + const unsigned int ayear = (unsigned int)year; + return ayear % 4 == 0 && (ayear % 100 != 0 || ayear % 400 == 0); + } + + /* year, month -> number of days in year preceeding first day of month */ + static int + days_before_month(int year, int month) + { + int days; + + assert(month >= 1); + assert(month <= 12); + days = _days_before_month[month]; + if (month > 2 && is_leap(year)) + ++days; + return days; + } + // @pymethod <o PyUnicode>|PyTime|Format|Formats the time value. + PyObject *PyTime::Format(PyObject *self, PyObject *args) { *************** *** 175,194 **** tm.tm_mon = st.wMonth - 1; tm.tm_year = st.wYear - 1900; - tm.tm_isdst = -1; /* have the library figure it out */ - /* converting to time_t and back allows us to calculate - * tm.tm_wday (day of week) and tm.tm_yday (day of year) - * though day of week is available as st.wDayOfWeek, day of year is not in st - */ - time_t time = mktime(&tm); - /* We need a better way to format, but for now we have to live inside - the limitations of localtime() - */ - struct tm *local = localtime(&time); - if (local==NULL) - return PyErr_Format(PyExc_ValueError, "The time value is too early to be formatted"); ! tm = *local; ! // tm.tm_wday = st.wDayOfWeek; ! // tm.tm_yday = st. day of year; if (!_tcsftime(szBuffer, 256/*_countof()*/, fmt, &tm)) --- 212,233 ---- tm.tm_mon = st.wMonth - 1; tm.tm_year = st.wYear - 1900; ! /* Ask windows for the current is_dst flag */ ! TIME_ZONE_INFORMATION tzinfo; ! switch (GetTimeZoneInformation(&tzinfo)) { ! case TIME_ZONE_ID_STANDARD: ! tm.tm_isdst = 0; ! break; ! case TIME_ZONE_ID_DAYLIGHT: ! tm.tm_isdst = 1; ! break; ! default: ! tm.tm_isdst = -1; ! break; ! } ! /* tm_wday: day of week (0-6) sunday=0 : weekday(y, m, d) */ ! /* tm_yday: day of year (0-365) january 1=0: days_before_month(y, m) + d */ ! tm.tm_wday = st.wDayOfWeek; ! tm.tm_yday = days_before_month(st.wYear, st.wMonth) + st.wDay - 1; if (!_tcsftime(szBuffer, 256/*_countof()*/, fmt, &tm)) |
From: Mark H. <mha...@us...> - 2004-04-25 04:32:02
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26244 Modified Files: odbc.cpp Log Message: Remove apparently unnecessary lowercase of the column names, as requested in [ 937779 ] ODBC-Metadata. Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** odbc.cpp 20 Jan 2004 22:48:17 -0000 1.9 --- odbc.cpp 25 Apr 2004 04:31:41 -0000 1.10 *************** *** 1027,1031 **** &nullok); name[nsize] = 0; - _strlwr(name); dsize = display_size(vtype, vsize, name); prec = 0; --- 1027,1030 ---- |
From: Mark H. <mha...@us...> - 2004-04-25 04:24:38
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25142 Modified Files: selecttlb.py Log Message: Address issue raised in [ 850322 ] Patch to fix error running makepy.py, and correct an unescaped backslash in a string. Index: selecttlb.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/selecttlb.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** selecttlb.py 22 Apr 2004 00:26:42 -0000 1.7 --- selecttlb.py 25 Apr 2004 04:24:27 -0000 1.8 *************** *** 58,62 **** val = win32api.RegQueryValue(root, item) except win32api.error: ! val = None ret.append((item, val)) --- 58,62 ---- val = win32api.RegQueryValue(root, item) except win32api.error: ! val = "" # code using this assumes a string. ret.append((item, val)) *************** *** 109,113 **** # Only care about "{lcid}\win32" key - jump straight there. try: ! key4 = win32api.RegOpenKey(key3, "%s\win32" % (lcid,)) except win32api.error: continue --- 109,113 ---- # Only care about "{lcid}\win32" key - jump straight there. try: ! key4 = win32api.RegOpenKey(key3, "%s\\win32" % (lcid,)) except win32api.error: continue |
From: Mark H. <mha...@us...> - 2004-04-25 04:11:04
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822/win32com/test Modified Files: testall.py testvb.py Added Files: testArrays.py Log Message: Implement arbitrary sized safe-arrays. Originally from: [ 898555 ] Patch to use arbitrarely sized Safearray, by Stefan Schukat. Includes the main change to oleargs.cpp, plus alot of new test code around it. Thanks Stefan! Index: testvb.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testvb.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** testvb.py 24 Oct 2003 05:28:32 -0000 1.16 --- testvb.py 25 Apr 2004 04:10:48 -0000 1.17 *************** *** 272,283 **** _DoTestArray(vbtest, (1, 2.0, vbtest)) ! # Pass bad data - first item wrong size arrayData = ( ((1,2,1),(3,4),(5,6)), ((7,8),(9,10),(11,12)) ) ! _DoTestArray(vbtest, arrayData, TypeError) arrayData = ( ((vbtest,vbtest),), ((vbtest,),)) ! _DoTestArray(vbtest, arrayData, TypeError) # Pass bad data - last item wrong size arrayData = ( ((1,2),(3,4),(5,6,8)), ((7,8),(9,10),(11,12)) ) ! _DoTestArray(vbtest, arrayData, TypeError) # byref safearray results with incorrect size. --- 272,285 ---- _DoTestArray(vbtest, (1, 2.0, vbtest)) ! # Pass arbitrarily sized arrays - these used to fail, but thanks to ! # Stefan Schukat, they now work! ! expected_exception = None arrayData = ( ((1,2,1),(3,4),(5,6)), ((7,8),(9,10),(11,12)) ) ! _DoTestArray(vbtest, arrayData, expected_exception) arrayData = ( ((vbtest,vbtest),), ((vbtest,),)) ! _DoTestArray(vbtest, arrayData, expected_exception) # Pass bad data - last item wrong size arrayData = ( ((1,2),(3,4),(5,6,8)), ((7,8),(9,10),(11,12)) ) ! _DoTestArray(vbtest, arrayData, expected_exception) # byref safearray results with incorrect size. --- NEW FILE: testArrays.py --- # Originally contributed by Stefan Schukat as part of this arbitrary-sized # arrays patch. from win32com.client import gencache import win32com.test.util import unittest ZeroD = 0 OneDEmpty = [] OneD = [1,2,3] TwoD = [ [1,2,3], [1,2,3], [1,2,3] ] TwoD1 = [ [ [1,2,3,5], [1,2,3], [1,2,3] ], [ [1,2,3], [1,2,3], [1,2,3] ] ] OneD1 = [ [ [1,2,3], [1,2,3], [1,2,3] ], [ [1,2,3], [1,2,3] ] ] OneD2 = [ [1,2,3], [1,2,3,4,5], [ [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ] ] ThreeD = [ [ [1,2,3], [1,2,3], [1,2,3] ], [ [1,2,3], [1,2,3], [1,2,3] ] ] FourD = [ [ [[1,2,3],[1,2,3],[1,2,3]], [[1,2,3],[1,2,3],[1,2,3]], [[1,2,3],[1,2,3],[1,2,3]] ], [ [[1,2,3],[1,2,3],[1,2,3]], [[1,2,3],[1,2,3],[1,2,3]], [[1,2,3],[1,2,3],[1,2,3]] ] ] def _normalize_array(a): if type(a) != type(()): return a ret = [] for i in a: ret.append(_normalize_array(i)) return ret class ArrayTest(win32com.test.util.TestCase): def setUp(self): self.arr = gencache.EnsureDispatch("PyCOMTest.ArrayTest") def tearDown(self): self.arr = None def _doTest(self, array): self.arr.Array = array self.failUnlessEqual(_normalize_array(self.arr.Array), array) def testZeroD(self): self._doTest(ZeroD) def testOneDEmpty(self): self._doTest(OneDEmpty) def testOneD(self): self._doTest(OneD) def testTwoD(self): self._doTest(TwoD) def testThreeD(self): self._doTest(ThreeD) def testFourD(self): self._doTest(FourD) def testTwoD1(self): self._doTest(TwoD1) def testOneD1(self): self._doTest(OneD1) def testOneD2(self): self._doTest(OneD2) if __name__ == "__main__": unittest.main() Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** testall.py 22 Apr 2004 08:24:00 -0000 1.21 --- testall.py 25 Apr 2004 04:10:48 -0000 1.22 *************** *** 33,37 **** win32com.client.gencache.__init__() # Reset ! def ExecuteSilentlyIfOK(cmd): f = os.popen(cmd) data = f.read() --- 33,37 ---- win32com.client.gencache.__init__() # Reset ! def ExecuteSilentlyIfOK(cmd, testcase): f = os.popen(cmd) data = f.read() *************** *** 39,43 **** if rc: print data ! self.fail("Executing '%s' failed (%d)" % (cmd, rc)) return data.strip() --- 39,43 ---- if rc: print data ! testcase.fail("Executing '%s' failed (%d)" % (cmd, rc)) return data.strip() *************** *** 48,52 **** fname = os.path.join(os.path.dirname(this_file), "testPyComTest.py") cmd = '%s "%s" -q 2>&1' % (sys.executable, fname) ! data = ExecuteSilentlyIfOK(cmd) if data: print "** testPyCOMTest generated unexpected output" --- 48,52 ---- fname = os.path.join(os.path.dirname(this_file), "testPyComTest.py") cmd = '%s "%s" -q 2>&1' % (sys.executable, fname) ! data = ExecuteSilentlyIfOK(cmd, self) if data: print "** testPyCOMTest generated unexpected output" *************** *** 64,68 **** fname = os.path.join(os.path.dirname(this_file), "testPippo.py") cmd = '%s "%s" 2>&1' % (python, fname) ! ExecuteSilentlyIfOK(cmd) unittest_modules = [ --- 64,68 ---- fname = os.path.join(os.path.dirname(this_file), "testPippo.py") cmd = '%s "%s" 2>&1' % (python, fname) ! ExecuteSilentlyIfOK(cmd, self) unittest_modules = [ *************** *** 71,75 **** testStreams testWMI policySemantics testShell testROT testAXScript testxslt testDictionary testCollections ! testServers errorSemantics.test testvb.TestAll """.split(), # Level 2 tests. --- 71,75 ---- testStreams testWMI policySemantics testShell testROT testAXScript testxslt testDictionary testCollections ! testServers errorSemantics.test testvb.TestAll testArrays """.split(), # Level 2 tests. |
From: Mark H. <mha...@us...> - 2004-04-25 04:11:04
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822/win32com/src Modified Files: oleargs.cpp Log Message: Implement arbitrary sized safe-arrays. Originally from: [ 898555 ] Patch to use arbitrarely sized Safearray, by Stefan Schukat. Includes the main change to oleargs.cpp, plus alot of new test code around it. Thanks Stefan! Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** oleargs.cpp 8 Nov 2003 00:34:32 -0000 1.25 --- oleargs.cpp 25 Apr 2004 04:10:48 -0000 1.26 *************** *** 454,457 **** --- 454,554 ---- + // Arbitrary-sized array dimensions contributed by Stefan Schukat Feb-2004 + static long PyCom_CalculatePyObjectDimension(PyObject *obItemCheck, long lDimension, PyObject* ppyobDimensionDictionary) + { + long lReturnDimension = lDimension; + // Allow arbitrary sequences, but not strings or Unicode objects. + if(obItemCheck && + PySequence_Check(obItemCheck) && + !PyString_Check(obItemCheck) && + !PyUnicode_Check(obItemCheck)) + { + PyObject* ppyobDimension; + PyObject* ppyobSize; + PyObject* ppyobDimensionSize; + PyObject* ppyobItem; + long lIndex; + long lMinimalDimension = -1; + long lActualDimension = -1; + long lObjectSize; + + if (PyBuffer_Check(obItemCheck)) + // buffers are a special case - they define 1 new dimension. + return lReturnDimension+1; + + // Retrieve the size of the object + lObjectSize = PySequence_Length(obItemCheck); + if (lObjectSize == -1) { + /* has a __len__, but it failed. Treat as not a sequence */ + assert(PyErr_Occurred()); // can't *really* have -1 elems! */ + PyErr_Clear(); + } + if (lObjectSize != -1) { // A real sequence of size zero should be OK though. + ppyobSize = PyInt_FromLong(lObjectSize); + + // Retrieve the stored size in this dimension + ppyobDimension = PyInt_FromLong(lDimension); + ppyobDimensionSize = PyDict_GetItem(ppyobDimensionDictionary, ppyobDimension); + if (NULL == ppyobDimensionSize) { + // Not found so first element defines the size in this dimension + PyErr_Clear(); + PyDict_SetItem(ppyobDimensionDictionary, ppyobDimension, ppyobSize); + } else { + // Check if stored size in this dimension equals the size of the element to check + long lStoredSize = PyInt_AsLong(ppyobDimensionSize); + if (lStoredSize != lObjectSize) + { + // if not the same size => no new dimension + Py_XDECREF(ppyobDimensionSize); + Py_XDECREF(ppyobSize); + Py_XDECREF(ppyobDimension); + return lReturnDimension; + } + } + Py_XDECREF(ppyobDimensionSize); + Py_XDECREF(ppyobSize); + Py_XDECREF(ppyobDimension); + + // A special case for a zero-length sequence - we accept this as + // a new dimension, but no children to check. + // ie an empty list has 1 dimension. + if (lObjectSize==0) + return lReturnDimension+1; + + // Now check for all elements in this list for their dimensionality + // Their size is compared to the size stored in the dimension dictionary + for(lIndex = 0; lIndex < lObjectSize; lIndex++) { + ppyobItem = PySequence_GetItem(obItemCheck, lIndex); + if (ppyobItem == NULL) { + // Says it is a sequence, but getting the item failed. + // (eg, may be a COM instance that has __getitem__, but fails when attempting) + // Ignore the error, and pretend it is not a sequence. + PyErr_Clear(); + break; + } + // Call method recursively + lActualDimension = PyCom_CalculatePyObjectDimension(ppyobItem, lDimension + 1, ppyobDimensionDictionary); + if (-1 == lMinimalDimension) { + // First call so store it + lMinimalDimension = lActualDimension; + lReturnDimension = lActualDimension; + } else { + // Get the smallest dimension + if (lActualDimension < lMinimalDimension) { + lMinimalDimension = lActualDimension; + } + // Check if all dimensions of the sublist are equal + if (lReturnDimension != lActualDimension) { + // if not set the minimal dimension + lReturnDimension = lMinimalDimension; + } + } + Py_XDECREF(ppyobItem); + } + } + } + return lReturnDimension; + } + static BOOL PyCom_SAFEARRAYFromPyObjectEx(PyObject *obj, SAFEARRAY **ppSA, bool bAllocNewArray, VARENUM vt) { *************** *** 469,511 **** } LONG cDims = 0; ! PyObject *obItemCheck = obj; ! Py_INCREF(obItemCheck); ! // Allow arbitary sequences, but not strings or Unicode objects. ! while (obItemCheck && PySequence_Check(obItemCheck) && !PyString_Check(obItemCheck) && !PyUnicode_Check(obItemCheck)) { ! if (!PyBuffer_Check(obItemCheck) ) { ! // We *think* it is a sequence, but may not be. (eg, maybe ! // a COM instance with __len__/__getitem__, but they will fail. ! // In these cases, ignore the error and pretend it is not a sequence. ! int sub_len = PySequence_Length(obItemCheck); ! if (sub_len<0) { // __len__ failed. ! PyErr_Clear(); ! break; ! } ! if (sub_len) { ! // The reckon we have at least one item - fetch it. ! // XXX - is this really necessary? Isn't __len__ failure ! // good enough? ! PyObject *obSave = obItemCheck; ! obItemCheck = PySequence_GetItem(obItemCheck,0); ! ! Py_DECREF(obSave); ! if (obItemCheck==NULL) { ! // getting the item failed. ! PyErr_Clear(); ! break; ! } ! } else { ! // it is a sequence, but has zero items - can't search ! // any deeper for another dimension ! Py_XDECREF(obItemCheck); ! obItemCheck = NULL; ! } ! } else { ! Py_XDECREF(obItemCheck); ! obItemCheck = NULL; ! } ! cDims = cDims + 1; ! } ! Py_XDECREF(obItemCheck); if (cDims==0) { --- 566,575 ---- } LONG cDims = 0; ! // Arbitrary-sized array dimensions contributed by Stefan Schukat Feb-2004 ! // Allow arbitrary sized sequences to be transported to a COM server ! PyObject* ppyobDimensionDictionary = PyDict_New(); ! // Calculate the unique dimension of the sequence ! cDims = PyCom_CalculatePyObjectDimension(obj, 0, ppyobDimensionDictionary); ! Py_DECREF(ppyobDimensionDictionary); if (cDims==0) { *************** *** 523,527 **** // Now run down again, setting up the bounds ! obItemCheck = obj; Py_INCREF(obItemCheck); for (LONG dimLook = 1;dimLook <= cDims;dimLook++) { --- 587,591 ---- // Now run down again, setting up the bounds ! PyObject *obItemCheck = obj; Py_INCREF(obItemCheck); for (LONG dimLook = 1;dimLook <= cDims;dimLook++) { |
From: Mark H. <mha...@us...> - 2004-04-25 04:11:04
|
Update of /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822/TestSources/PyCOMTest Modified Files: .cvsignore Connect.cpp Connect.rc PyCOMTest.dsp PyCOMTest.idl SimpleCounter.h connres.h Added Files: ArrayTest.rgs DSCArrayTest.cpp DSCArrayTest.h Log Message: Implement arbitrary sized safe-arrays. Originally from: [ 898555 ] Patch to use arbitrarely sized Safearray, by Stefan Schukat. Includes the main change to oleargs.cpp, plus alot of new test code around it. Thanks Stefan! --- NEW FILE: DSCArrayTest.cpp --- // DSCArrayTest.cpp : Implementation of DSCArrayTest #include "preconn.h" #include "connres.h" #include "initguid.h" #include "PyCOMTest.h" #include "PyCOMImpl.h" #include "DSCArrayTest.h" ///////////////////////////////////////////////////////////////////////////// // DSCArrayTest DSCArrayTest::DSCArrayTest() { } void DSCArrayTest::FinalRelease() { m_spvarcArray.Clear(); } STDMETHODIMP DSCArrayTest::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_IArrayTest }; for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++) { if (::InlineIsEqualGUID(*arr[i],riid)) return S_OK; } return S_FALSE; } HRESULT CreateVector(long lArraySize, VARIANT& rVarout) { SAFEARRAY* pSafeArray; long lIndex; VARIANT varElement; pSafeArray = SafeArrayCreateVector(VT_VARIANT, 0, lArraySize); for(lIndex = 0; lIndex < lArraySize; lIndex++) { VariantInit(&varElement); varElement.vt = VT_R8; varElement.dblVal = double(lIndex); SafeArrayPutElement(pSafeArray, &lIndex, (void*)&varElement); VariantClear(&varElement); } VariantInit(&rVarout); rVarout.vt = VT_ARRAY | VT_VARIANT; rVarout.parray = pSafeArray; return S_OK; } HRESULT CreateMatrix(long lXSize,long lYSize, VARIANT& rVarout) { SAFEARRAY* pSafeArray; SAFEARRAYBOUND ArrayBounds[2]; long lXIndex; long lYIndex; long lDimensions; long lIndexArray[2]; VARIANT varElement; // Number of dimensions lDimensions = 2; // Set the elements in each dimension ArrayBounds[0].cElements = lXSize; ArrayBounds[0].lLbound = 0; ArrayBounds[1].cElements = lYSize; ArrayBounds[1].lLbound = 0; // Create the two dimensional array pSafeArray = SafeArrayCreate(VT_VARIANT, lDimensions, ArrayBounds); for(lYIndex = 0; lYIndex < lYSize; lYIndex++) { for(lXIndex = 0; lXIndex < lXSize; lXIndex++) { VariantInit(&varElement); lIndexArray[0] = lXIndex; lIndexArray[1] = lYIndex; varElement.vt = VT_R8; varElement.dblVal = double(lXIndex * 100 + lYIndex); SafeArrayPutElement(pSafeArray, lIndexArray, (void*)&varElement); VariantClear(&varElement); } } VariantInit(&rVarout); rVarout.vt = VT_ARRAY | VT_VARIANT; rVarout.parray = pSafeArray; return S_OK; } STDMETHODIMP DSCArrayTest::get_Array(VARIANT *pVal) { HRESULT hr = E_POINTER; if (NULL != pVal) { hr = ::VariantCopy(pVal, &m_spvarcArray); } return hr; } STDMETHODIMP DSCArrayTest::put_Array(VARIANT newVal) { m_spvarcArray.Clear(); m_spvarcArray = newVal; return S_OK; } STDMETHODIMP DSCArrayTest::ReturnSampleArray(VARIANT *pVal) { SAFEARRAY* pSafeArray; long lIndex; VARIANT varXAxis; VARIANT varYAxis; VARIANT varZValue; pSafeArray = SafeArrayCreateVector(VT_VARIANT, 0, 3); VariantInit(&varXAxis); VariantInit(&varYAxis); VariantInit(&varZValue); // Retrieve the axis variant which is a vector CreateVector(3, varXAxis); CreateVector(5, varYAxis); CreateMatrix(3, 5, varZValue); lIndex = 0; SafeArrayPutElement(pSafeArray, &lIndex, (void*)&varXAxis); lIndex = 1; SafeArrayPutElement(pSafeArray, &lIndex, (void*)&varYAxis); lIndex = 2; SafeArrayPutElement(pSafeArray, &lIndex, (void*)&varZValue); VariantClear(&varXAxis); VariantClear(&varYAxis); VariantClear(&varZValue); VariantInit(pVal); pVal->vt = VT_ARRAY | VT_VARIANT; pVal->parray = pSafeArray; return S_OK; } Index: .cvsignore =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/.cvsignore,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** .cvsignore 18 Dec 2002 11:57:36 -0000 1.3 --- .cvsignore 25 Apr 2004 04:10:47 -0000 1.4 *************** *** 5,6 **** --- 5,7 ---- *.opt PyCOMTest.h + Connect.aps Index: PyCOMTest.dsp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyCOMTest.dsp 3 Sep 1999 07:42:08 -0000 1.1 --- PyCOMTest.dsp 25 Apr 2004 04:10:48 -0000 1.2 *************** *** 191,194 **** --- 191,198 ---- # Begin Source File + SOURCE=.\ArrayTest.rgs + # End Source File + # Begin Source File + SOURCE=.\Connect.cpp # End Source File *************** *** 203,206 **** --- 207,214 ---- # Begin Source File + SOURCE=.\DSCArrayTest.cpp + # End Source File + # Begin Source File + SOURCE=.\preconn.cpp # ADD CPP /Yc"preconn.h" *************** *** 307,310 **** --- 315,322 ---- # Begin Source File + SOURCE=.\DSCArrayTest.h + # End Source File + # Begin Source File + SOURCE=.\preconn.h # End Source File Index: SimpleCounter.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/SimpleCounter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleCounter.h 8 Mar 2000 09:32:49 -0000 1.2 --- SimpleCounter.h 25 Apr 2004 04:10:48 -0000 1.3 *************** *** 35,39 **** STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) { ! return (InlineIsEqualGUID(IID_ISimpleCounter,riid)) ? S_OK : S_FALSE; --- 35,39 ---- STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) { ! return (::InlineIsEqualGUID(IID_ISimpleCounter,riid)) ? S_OK : S_FALSE; --- NEW FILE: DSCArrayTest.h --- // DSCArrayTest.h : Declaration of the DSCArrayTest #ifndef __ARRAYTEST_H_ #define __ARRAYTEST_H_ //#include "resource.h" // main symbols ///////////////////////////////////////////////////////////////////////////// // DSCArrayTest class ATL_NO_VTABLE DSCArrayTest : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<DSCArrayTest, &CLSID_ArrayTest>, public ISupportErrorInfo, public IDispatchImpl<IArrayTest, &IID_IArrayTest, &LIBID_PyCOMTestLib> { public: DECLARE_REGISTRY_RESOURCEID(IDR_ARRAYTEST) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(DSCArrayTest) COM_INTERFACE_ENTRY(IArrayTest) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) END_COM_MAP() DSCArrayTest(); void FinalRelease(); // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); // IArrayTest public: STDMETHOD(ReturnSampleArray)(/*[out, retval]*/ VARIANT *pVal); STDMETHOD(get_Array)(/*[out, retval]*/ VARIANT *pVal); STDMETHOD(put_Array)(/*[in]*/ VARIANT newVal); private: CComVariant m_spvarcArray; }; #endif //__ARRAYTEST_H_ Index: Connect.rc =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/Connect.rc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Connect.rc 3 Sep 1999 07:42:08 -0000 1.1 --- Connect.rc 25 Apr 2004 04:10:48 -0000 1.2 *************** *** 96,99 **** --- 96,100 ---- IDR_PYCOMTEST REGISTRY MOVEABLE PURE "PyCOMTest.rgs" + IDR_ARRAYTEST REGISTRY MOVEABLE PURE "ArrayTest.rgs" ///////////////////////////////////////////////////////////////////////////// Index: Connect.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/Connect.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Connect.cpp 3 Sep 1999 07:42:08 -0000 1.1 --- Connect.cpp 25 Apr 2004 04:10:48 -0000 1.2 *************** *** 12,15 **** --- 12,16 ---- #include "PyCOMImpl.h" #include "SimpleCounter.h" + #include "DSCArrayTest.h" #define IID_DEFINED *************** *** 23,26 **** --- 24,28 ---- OBJECT_ENTRY(CLSID_CoPyCOMTest2, CPyCOMTest2) OBJECT_ENTRY(CLSID_CoSimpleCounter, CSimpleCounter) + OBJECT_ENTRY(CLSID_ArrayTest, DSCArrayTest) END_OBJECT_MAP() Index: PyCOMTest.idl =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.idl,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyCOMTest.idl 19 Nov 2002 05:03:24 -0000 1.8 --- PyCOMTest.idl 25 Apr 2004 04:10:48 -0000 1.9 *************** *** 304,307 **** --- 304,330 ---- [default, source] dispinterface IPyCOMTestNoDispatchEvent; // use same events for now. }; + // Some array tests, from Stefan Schukat + [ + object, + uuid(974f29b3-4e58-4654-9f85-4491d7a2418c), + dual, + helpstring("PyCOMTest IArrayTest Interface"), + pointer_default(unique) + ] + interface IArrayTest : IDispatch + { + [propget, id(1), helpstring("property Array")] HRESULT Array([out, retval] VARIANT *pVal); + [propput, id(1), helpstring("property Array")] HRESULT Array([in] VARIANT newVal); + [id(2), helpstring("method ReturnSampleArray")] HRESULT ReturnSampleArray([out, retval] VARIANT *pVal); + }; + [ + uuid(f1a51873-24e9-47ed-ae71-925462c5fe3b), + helpstring("PyCOMTest ArrayTest Class") + ] + coclass ArrayTest + { + [default] interface IArrayTest; + }; + }; Index: connres.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/connres.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** connres.h 3 Sep 1999 07:42:08 -0000 1.1 --- connres.h 25 Apr 2004 04:10:48 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- #define IDR_PYCOMTEST 1 + #define IDR_ARRAYTEST 2 --- NEW FILE: ArrayTest.rgs --- HKCR { PyCOMTest.ArrayTest.1 = s 'PythonCOM ArrayTest Class' { CLSID = s '{f1a51873-24e9-47ed-ae71-925462c5fe3b}' } PyCOMTest.ArrayTest = s 'PythonCOM ArrayTest Class' { CLSID = s '{f1a51873-24e9-47ed-ae71-925462c5fe3b}' CurVer = s 'PyCOMTest.ArrayTest.1' } NoRemove CLSID { ForceRemove {f1a51873-24e9-47ed-ae71-925462c5fe3b} = s 'ArrayTest Class' { ProgID = s 'PyCOMTest.ArrayTest.1' VersionIndependentProgID = s 'PyCOMTest.ArrayTest' ForceRemove 'Programmable' InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } 'TypeLib' = s '{6bcdcb60-5605-11d0-ae5f-cadd4c000000}' } } } |
From: Mark H. <mha...@us...> - 2004-04-25 04:11:03
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822/win32com/src/include Modified Files: PyComTypeObjects.h Log Message: Implement arbitrary sized safe-arrays. Originally from: [ 898555 ] Patch to use arbitrarely sized Safearray, by Stefan Schukat. Includes the main change to oleargs.cpp, plus alot of new test code around it. Thanks Stefan! Index: PyComTypeObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PyComTypeObjects.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyComTypeObjects.h 8 Oct 2003 04:28:42 -0000 1.2 --- PyComTypeObjects.h 25 Apr 2004 04:10:48 -0000 1.3 *************** *** 124,128 **** public: PySTGMEDIUM(STGMEDIUM *pS = NULL); ! virtual ~PySTGMEDIUM(void); void DropOwnership(void); --- 124,128 ---- public: PySTGMEDIUM(STGMEDIUM *pS = NULL); ! ~PySTGMEDIUM(void); void DropOwnership(void); |
From: Mark H. <mha...@us...> - 2004-04-25 04:11:03
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822/win32com/src/extensions Modified Files: PyIDataObject.cpp Log Message: Implement arbitrary sized safe-arrays. Originally from: [ 898555 ] Patch to use arbitrarely sized Safearray, by Stefan Schukat. Includes the main change to oleargs.cpp, plus alot of new test code around it. Thanks Stefan! Index: PyIDataObject.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIDataObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIDataObject.cpp 19 Mar 2004 04:29:24 -0000 1.3 --- PyIDataObject.cpp 25 Apr 2004 04:10:48 -0000 1.4 *************** *** 196,203 **** hr = pIDO->SetData( &formatetc, &pymedium->medium, fRelease ); PY_INTERFACE_POSTCALL; - if ( FAILED(hr) ) - return PyCom_BuildPyException(hr, pIDO, IID_IDataObject ); if (fRelease) pymedium->DropOwnership(); Py_INCREF(Py_None); return Py_None; --- 196,203 ---- hr = pIDO->SetData( &formatetc, &pymedium->medium, fRelease ); PY_INTERFACE_POSTCALL; if (fRelease) pymedium->DropOwnership(); + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIDO, IID_IDataObject ); Py_INCREF(Py_None); return Py_None; *************** *** 400,404 **** PySTGMEDIUM *obmedium = PyObject_FromSTGMEDIUM(pmedium); if (obmedium==NULL) return PyCom_HandlePythonFailureToCOM(); ! HRESULT hr=InvokeViaPolicy("SetData", NULL, "OOi", obpformatetc, obmedium, fRelease); if (!fRelease) obmedium->DropOwnership(); --- 400,406 ---- PySTGMEDIUM *obmedium = PyObject_FromSTGMEDIUM(pmedium); if (obmedium==NULL) return PyCom_HandlePythonFailureToCOM(); ! // PySTGMEDIUM should be the exact same pointer as PyObject ! assert((void *)(PyObject *)obmedium==(void *)obmedium); ! HRESULT hr=InvokeViaPolicy("SetData", NULL, "OOi", obpformatetc, (PyObject *)obmedium, fRelease); if (!fRelease) obmedium->DropOwnership(); |
From: Mark H. <mha...@us...> - 2004-04-25 04:07:56
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22551 Modified Files: PythonCOM.cpp Log Message: autoduck correction. Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** PythonCOM.cpp 7 Apr 2004 05:17:37 -0000 1.29 --- PythonCOM.cpp 25 Apr 2004 04:07:47 -0000 1.30 *************** *** 1366,1370 **** // @pymethod |pythoncom|RegisterDragDrop|Registers the specified window as // one that can be the target of an OLE drag-and-drop operation and ! // specifies the <om PyIDropTarget> instance to use for drop operations. static PyObject *pythoncom_RegisterDragDrop(PyObject *, PyObject *args) { --- 1366,1370 ---- // @pymethod |pythoncom|RegisterDragDrop|Registers the specified window as // one that can be the target of an OLE drag-and-drop operation and ! // specifies the <o PyIDropTarget> instance to use for drop operations. static PyObject *pythoncom_RegisterDragDrop(PyObject *, PyObject *args) { |
From: Mark H. <mha...@us...> - 2004-04-25 04:03:11
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21815 Modified Files: shell.cpp Log Message: autoduck correction. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** shell.cpp 15 Apr 2004 07:52:32 -0000 1.21 --- shell.cpp 25 Apr 2004 04:02:53 -0000 1.22 *************** *** 704,708 **** &p->hwnd, // @tupleitem 0|int|hwnd| &p->wFunc, // @tupleitem 1|int|wFunc| ! &obFrom, // @tupleitem 2|string/list of stringsfrom| &obTo, // @tupleitem 3|string/list of strings|to| &p->fFlags, // @tupleitem 4|int|flags|Default=0 --- 704,708 ---- &p->hwnd, // @tupleitem 0|int|hwnd| &p->wFunc, // @tupleitem 1|int|wFunc| ! &obFrom, // @tupleitem 2|string/list of stringsfrom|obFrom| &obTo, // @tupleitem 3|string/list of strings|to| &p->fFlags, // @tupleitem 4|int|flags|Default=0 |
From: Mark H. <mha...@us...> - 2004-04-25 03:59:49
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21248 Modified Files: shellcon.py Log Message: New shell-related clipboard format names. Index: shellcon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/shellcon.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** shellcon.py 9 Apr 2004 11:24:53 -0000 1.10 --- shellcon.py 25 Apr 2004 03:59:41 -0000 1.11 *************** *** 409,415 **** --- 409,424 ---- CFSTR_FILENAMEMAPW = "FileNameMapW" CFSTR_SHELLURL = "UniformResourceLocator" + CFSTR_INETURLA = CFSTR_SHELLURL + CFSTR_INETURLW = "UniformResourceLocatorW" + CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect" CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect" CFSTR_PASTESUCCEEDED = "Paste Succeeded" CFSTR_INDRAGLOOP = "InShellDragLoop" + CFSTR_DRAGCONTEXT = "DragContext" + CFSTR_MOUNTEDVOLUME = "MountedVolume" + CFSTR_PERSISTEDDATAOBJECT = "PersistedDataObject" + CFSTR_TARGETCLSID = "TargetCLSID" + CFSTR_LOGICALPERFORMEDDROPEFFECT = "Logical Performed DropEffect" + CFSTR_AUTOPLAY_SHELLIDLISTS = "Autoplay Enumerated IDList Array" CFSTR_FILEDESCRIPTOR = CFSTR_FILEDESCRIPTORW CFSTR_FILENAME = CFSTR_FILENAMEW |
From: Mark H. <mha...@us...> - 2004-04-25 03:58:58
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21146 Modified Files: testPyComTest.py Log Message: Pass some non-sequence objects to our array decoder, and watch it fail. Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** testPyComTest.py 2 Nov 2003 10:03:24 -0000 1.17 --- testPyComTest.py 25 Apr 2004 03:58:50 -0000 1.18 *************** *** 163,166 **** --- 163,178 ---- raise error, "GetSetDispatch failed" + # Pass some non-sequence objects to our array decoder, and watch it fail. + try: + o.SetVariantSafeArray("foo") + raise error, "Expected a type error" + except TypeError: + pass + try: + o.SetVariantSafeArray(666) + raise error, "Expected a type error" + except TypeError: + pass + o.GetSimpleSafeArray(None) TestApplyResult(o.GetSimpleSafeArray, (None,), tuple(range(10))) |