pywin32-checkins Mailing List for Python for Windows Extensions (Page 92)
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...> - 2007-05-20 11:08:22
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5351 Modified Files: test_odbc.py Log Message: Add date tests (which I believe fail, but can't test atm) Index: test_odbc.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_odbc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_odbc.py 24 May 2006 08:39:40 -0000 1.5 --- test_odbc.py 20 May 2007 11:08:22 -0000 1.6 *************** *** 56,60 **** userid varchar(5), username varchar(25), bitfield bit, intfield integer, ! floatfield float )"""),-1) --- 56,61 ---- userid varchar(5), username varchar(25), bitfield bit, intfield integer, ! floatfield float, ! datefield date, )"""),-1) *************** *** 131,134 **** --- 132,143 ---- self._test_val('username', 'foo') + def testDates(self): + import datetime + for v in ( + (1800, 12, 25, 23, 59,), + ): + d = datetime.datetime(*v) + self._test_val('datefield', 'd') + def test_set_nonzero_length(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " |
From: Mark H. <mha...@us...> - 2007-05-20 10:46:47
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29715/win32/src Modified Files: PyUnicode.cpp Log Message: PyWinObject_FromBstr no longer crashes if passed NULL. Index: PyUnicode.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyUnicode.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PyUnicode.cpp 14 Mar 2007 23:25:58 -0000 1.23 --- PyUnicode.cpp 20 May 2007 10:46:46 -0000 1.24 *************** *** 266,269 **** --- 266,273 ---- PyObject *PyWinObject_FromBstr(const BSTR bstr, BOOL takeOwnership /*=FALSE*/) { + if (bstr==NULL) { + Py_INCREF(Py_None); + return Py_None; + } PyObject *ret = PyUnicode_FromWideChar(bstr, SysStringLen(bstr)); if (takeOwnership) SysFreeString(bstr); |
From: Mark H. <mha...@us...> - 2007-05-18 11:22:18
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15549 Modified Files: win32trace.cpp Log Message: Work better on Vista, by dealing with the 'access denied' errors that are likely when working in the 'Global\\' namespace. Index: win32trace.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** win32trace.cpp 28 Jan 2005 00:02:23 -0000 1.13 --- win32trace.cpp 18 May 2007 11:22:17 -0000 1.14 *************** *** 46,58 **** const char *EVENT_EMPTY_OBJECT_NAME = "Global\\PythonTraceOutputEmptyEvent"; ! // Function to remove the "Global\\" prefix on NT4/9x static const char *FixupObjectName(const char *global_name) { ! OSVERSIONINFO info; ! info.dwOSVersionInfoSize = sizeof(info); ! GetVersionEx(&info); ! if (info.dwMajorVersion <= 4) // NT, 9x return strchr(global_name, '\\')+1; ! // 2000 or later - "Global\\" prefix OK. return global_name; } --- 46,80 ---- const char *EVENT_EMPTY_OBJECT_NAME = "Global\\PythonTraceOutputEmptyEvent"; ! // Global\\ etc goodness: ! // On NT4/9x, 'Global\\' is not understood and will fail. ! // On 2k/XP, anyone can create 'global' objects. ! // On Vista, you need elavated perms to create global objects - however, once ! // it has been created and permissions adjusted, a user with normal ! // permissions can open these global objects. ! // As a service generally will be able to create global objects, we want a ! // non-elevated Python to be capable of automatically using the global space ! // if it exists, but coping when it can't create such an object (a local ! // one is probably fine in such cases). ! // [Why bother?: without the Global namespace, a 'win32traceutil' running in ! // a 'Remote Desktop' session would not be able to see output from a ! // service - they have different local namespaces] ! ! // This means: ! // * We first check to see if the mutex exists in the local namespace. If it ! // does, it we use that namespace for all objects. ! // * We then try and create a mutex in the global namespace - if this works, we also ! // use the global namespace. ! // * We then create the mutex in our local namespace and use that for everything. ! // (Ack - the above is only true for CreateFileMapping - creating mutexes etc ! // works fine) ! ! // This behavior is controlled by a global variable set at mutex creation time. ! BOOL use_global_namespace = FALSE; ! static const char *FixupObjectName(const char *global_name) { ! if (!use_global_namespace) return strchr(global_name, '\\')+1; ! // global prefix is ok. return global_name; } *************** *** 435,439 **** if (!ok) return NULL; - // put the new object into sys Py_INCREF(Py_None); return Py_None; --- 457,460 ---- *************** *** 448,452 **** if (!ok) return NULL; - // put the new object into sys Py_INCREF(Py_None); return Py_None; --- 469,472 ---- *************** *** 614,617 **** --- 634,670 ---- assert(hMutex == NULL); + + // See comments re global namespace above - the problem child is + // CreateFileMapping - so we temporarily use that just to work out what + // namespace to use for our objects. + + // is the "Global\" namespace even possible? + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + BOOL global_ok = info.dwMajorVersion > 4; + if (global_ok) { + // see comments at top of file - if it exists locally, stick with + // local - use_global_namespace is still FALSE now, so that is the + // name we get. + HANDLE h = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, 0, + BUFFER_SIZE, + FixupObjectName(MAP_OBJECT_NAME)); + if (GetLastError() != ERROR_ALREADY_EXISTS) { + // no local one exists - see if we can create it globally - if + // we can, we go global, else we stick with local. + HANDLE h2 = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, + 0, BUFFER_SIZE, + FixupObjectName(MAP_OBJECT_NAME)); + use_global_namespace = h2 != NULL && GetLastError() == ERROR_ACCESS_DENIED; + if (h2) + CloseHandle(h2); + } + if (h) + CloseHandle(h); + } + // use_global_namespace is now set and will not change - all objects + // we use are in the same namespace. + hMutex = CreateMutex(&sa, FALSE, FixupObjectName(MUTEX_OBJECT_NAME)); if (hMutex==NULL) { |
From: Roger U. <ru...@us...> - 2007-05-14 17:10:12
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31992/win32/src Modified Files: win32file.i Log Message: Combine CreateHardLink, CreateSymbolicLink, GetFullPathName, and GetLongPathName with corresponding Transacted functions Fix a couple more 64-bit issues Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** win32file.i 23 Apr 2007 00:13:55 -0000 1.78 --- win32file.i 14 May 2007 17:10:11 -0000 1.79 *************** *** 200,204 **** // @flag FILE_SHARE_WRITE|Subsequent open operations on the object will succeed only if write access is requested. SECURITY_ATTRIBUTES *lpSecurityAttributes, // @pyparm <o PySECURITY_ATTRIBUTES>|attributes||The security attributes, or None ! DWORD dwCreationDistribution, // @pyparm int|creationDisposition||Specifies which action to take on files that exist, and which action to take when files do not exist. For more information about this parameter, see the Remarks section. This parameter must be one of the following values: // @flagh Value|Meaning // @flag CREATE_NEW|Creates a new file. The function fails if the specified file already exists. --- 200,204 ---- // @flag FILE_SHARE_WRITE|Subsequent open operations on the object will succeed only if write access is requested. SECURITY_ATTRIBUTES *lpSecurityAttributes, // @pyparm <o PySECURITY_ATTRIBUTES>|attributes||The security attributes, or None ! DWORD dwCreationDisposition, // @pyparm int|CreationDisposition||Specifies which action to take on files that exist, and which action to take when files do not exist. For more information about this parameter, see the Remarks section. This parameter must be one of the following values: // @flagh Value|Meaning // @flag CREATE_NEW|Creates a new file. The function fails if the specified file already exists. *************** *** 233,245 **** PyObject *MyCreateIoCompletionPort(PyObject *self, PyObject *args) { ! PyObject *obFileHandle, *obExistingHandle; ! int key, nt; PyObject *obRet = NULL; ! if (!PyArg_ParseTuple(args, "OOii:CreateIoCompletionPort", &obFileHandle, // @pyparm <o PyHANDLE>|handle||file handle to associate with the I/O completion port &obExistingHandle, // @pyparm <o PyHANDLE>|existing||handle to the I/O completion port ! &key, // @pyparm int|completionKey||per-file completion key for I/O completion packets &nt)) // @pyparm int|numThreads||number of threads allowed to execute concurrently return NULL; HANDLE hFile, hExisting; if (!PyWinObject_AsHANDLE(obFileHandle, &hFile, FALSE)) --- 233,248 ---- PyObject *MyCreateIoCompletionPort(PyObject *self, PyObject *args) { ! PyObject *obFileHandle, *obExistingHandle, *obkey; ! DWORD nt; ! ULONG_PTR key; PyObject *obRet = NULL; ! if (!PyArg_ParseTuple(args, "OOOi:CreateIoCompletionPort", &obFileHandle, // @pyparm <o PyHANDLE>|handle||file handle to associate with the I/O completion port &obExistingHandle, // @pyparm <o PyHANDLE>|existing||handle to the I/O completion port ! &obkey, // @pyparm int|completionKey||per-file completion key for I/O completion packets &nt)) // @pyparm int|numThreads||number of threads allowed to execute concurrently return NULL; + if (!PyWinLong_AsVoidPtr(obkey, (void **)&key)) + return NULL; HANDLE hFile, hExisting; if (!PyWinObject_AsHANDLE(obFileHandle, &hFile, FALSE)) *************** *** 1173,1177 **** if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE)) return NULL; ! DWORD bytes = 0, key = 0; OVERLAPPED *pOverlapped = NULL; UINT errCode; --- 1176,1181 ---- if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE)) return NULL; ! DWORD bytes = 0; ! ULONG_PTR key = 0; OVERLAPPED *pOverlapped = NULL; UINT errCode; *************** *** 1180,1186 **** errCode = ok ? 0 : GetLastError(); Py_END_ALLOW_THREADS ! PyObject *obOverlapped = PyWinObject_FromQueuedOVERLAPPED(pOverlapped); ! PyObject *rc = Py_BuildValue("illO", errCode, bytes, key, obOverlapped); ! Py_XDECREF(obOverlapped); return rc; } --- 1184,1190 ---- errCode = ok ? 0 : GetLastError(); Py_END_ALLOW_THREADS ! PyObject *rc = Py_BuildValue("ilNN", errCode, bytes, ! PyWinLong_FromVoidPtr((void *)key), ! PyWinObject_FromQueuedOVERLAPPED(pOverlapped)); return rc; } *************** *** 1189,1200 **** PyObject *myPostQueuedCompletionStatus(PyObject *self, PyObject *args) { ! PyObject *obHandle, *obOverlapped = NULL; ! DWORD bytesTransfered = 0, key = 0; // @pyparm <o PyHANDLE>|handle||handle to an I/O completion port // @pyparm int|numberOfbytes|0|value to return via GetQueuedCompletionStatus' first result // @pyparm int|completionKey|0|value to return via GetQueuedCompletionStatus' second result // @pyparm <o PyOVERLAPPED>|overlapped|None|value to return via GetQueuedCompletionStatus' third result ! if (!PyArg_ParseTuple(args, "O|iiO", &obHandle, &bytesTransfered, &key, &obOverlapped)) return NULL; HANDLE handle; if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE)) --- 1193,1208 ---- PyObject *myPostQueuedCompletionStatus(PyObject *self, PyObject *args) { ! PyObject *obHandle, *obOverlapped = NULL, *obkey=Py_None; ! DWORD bytesTransfered = 0; ! ULONG_PTR key = 0; // @pyparm <o PyHANDLE>|handle||handle to an I/O completion port // @pyparm int|numberOfbytes|0|value to return via GetQueuedCompletionStatus' first result // @pyparm int|completionKey|0|value to return via GetQueuedCompletionStatus' second result // @pyparm <o PyOVERLAPPED>|overlapped|None|value to return via GetQueuedCompletionStatus' third result ! if (!PyArg_ParseTuple(args, "O|iOO", &obHandle, &bytesTransfered, &obkey, &obOverlapped)) return NULL; + if (obkey!=Py_None) + if (!PyWinLong_AsVoidPtr(obkey, (void **)&key)) + return NULL; HANDLE handle; if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE)) *************** *** 1236,1329 **** #define FILE_TYPE_CHAR FILE_TYPE_CHAR // The specified file is a character file, typically an LPT device or a console. #define FILE_TYPE_PIPE FILE_TYPE_PIPE // The specified file is either a named or anonymous pipe. - - #endif // MS_WINCE - - // GetFullPathName - // @pyswig str/unicode|GetFullPathName|Returns full path for path passed in - // @comm This function takes either a plain string or a unicode string, and returns the same type - // If unicode is passed in, GetFullPathNameW is called, which supports filenames longer than MAX_PATH - %native(GetFullPathName) MyGetFullPathName; - %{ - static PyObject *MyGetFullPathName(PyObject *self, PyObject *args) - { - PyObject *ret=NULL, *obpathin; - int pathlen, retlen; - - // @pyparm str/unicode|FileName||Path on which to operate - if (!PyArg_ParseTuple(args, "O", &obpathin)) - return NULL; - WCHAR *wpathin; - if (wpathin=PyUnicode_AsUnicode(obpathin)){ - WCHAR *wpathret, *wfilepart; - pathlen=wcslen(wpathin)+1; - wpathret=(WCHAR *)malloc(pathlen*sizeof(WCHAR)); - if (wpathret==NULL){ - PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - retlen=GetFullPathNameW(wpathin, pathlen, wpathret, &wfilepart); - Py_END_ALLOW_THREADS - if (retlen>pathlen){ - pathlen=retlen; - wpathret=(WCHAR *)realloc(wpathret,pathlen*sizeof(WCHAR)); - if (wpathret==NULL){ - PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - retlen=GetFullPathNameW(wpathin, retlen, wpathret, &wfilepart); - Py_END_ALLOW_THREADS - } - if (retlen>pathlen) - PyErr_SetString(PyExc_SystemError,"GetFullPathNameW: Unexpected second increase in required buffer size"); - else - if (retlen==0) - PyWin_SetAPIError("GetFullPathNameW", GetLastError()); - else - ret=PyUnicode_FromWideChar(wpathret,retlen); - free(wpathret); - return ret; - } - - PyErr_Clear(); - char *cpathin; - if (PyString_AsStringAndSize(obpathin, &cpathin, &pathlen)!=-1){ - char *cpathret, *cfilepart; - pathlen+=1; - cpathret=(char *)malloc(pathlen); - if (cpathret==NULL){ - PyErr_SetString(PyExc_MemoryError,"GetFullPathName: unable to allocate character return buffer"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - retlen=GetFullPathName(cpathin, pathlen, cpathret, &cfilepart); - Py_END_ALLOW_THREADS - if (retlen>pathlen){ - pathlen=retlen; - cpathret=(char *)realloc(cpathret,pathlen); - if (cpathret==NULL){ - PyErr_SetString(PyExc_MemoryError,"GetFullPathName: unable to allocate character return buffer"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - retlen=GetFullPathName(cpathin, retlen, cpathret, &cfilepart); - Py_END_ALLOW_THREADS - } - if (retlen>pathlen) - PyErr_SetString(PyExc_SystemError,"GetFullPathName: Unexpected second increase in required buffer size"); - else - if (retlen==0) - PyWin_SetAPIError("GetFullPathName", GetLastError()); - else - ret=PyString_FromStringAndSize(cpathret,retlen); - free(cpathret); - } - return ret; - } - %} - - #ifndef MS_WINCE // @pyswig int|GetLogicalDrives|Returns a bitmaks of the logical drives installed. unsigned long GetLogicalDrives( // DWORD --- 1244,1248 ---- *************** *** 1702,1723 **** PyObject *myget_osfhandle (int filehandle) { ! long result = _get_osfhandle (filehandle); ! if (result == -1) return PyErr_SetFromErrno(PyExc_IOError); ! return Py_BuildValue ("l",result); } PyObject *myopen_osfhandle (PyHANDLE osfhandle, int flags) { ! int result = _open_osfhandle ((long) osfhandle, flags); if (result == -1) return PyErr_SetFromErrno(PyExc_IOError); ! return Py_BuildValue ("i",result); } %} // Overlapped Socket stuff %{ --- 1621,1643 ---- PyObject *myget_osfhandle (int filehandle) { ! HANDLE result = (HANDLE)_get_osfhandle (filehandle); ! if (result == (HANDLE)-1) return PyErr_SetFromErrno(PyExc_IOError); ! return PyWinLong_FromHANDLE(result); } PyObject *myopen_osfhandle (PyHANDLE osfhandle, int flags) { ! int result = _open_osfhandle ((ULONG_PTR)osfhandle, flags); if (result == -1) return PyErr_SetFromErrno(PyExc_IOError); ! return PyInt_FromLong(result); } %} + // Overlapped Socket stuff %{ *************** *** 2755,2764 **** typedef DWORD (WINAPI *GetFinalPathNameByHandlefunc)(HANDLE,LPWSTR,DWORD,DWORD); static GetFinalPathNameByHandlefunc pfnGetFinalPathNameByHandle = NULL; ! ! // These aren't used yet ! typedef DWORD (WINAPI *GetFullPathNameTransactedfunc)(LPCTSTR,DWORD,LPTSTR,LPTSTR*,HANDLE); ! static GetFullPathNameTransactedfunc pfnGetFullPathNameTransacted = NULL; ! typedef DWORD (WINAPI *GetLongPathNameTransactedfunc)(LPCTSTR,LPTSTR,DWORD,HANDLE); static GetLongPathNameTransactedfunc pfnGetLongPathNameTransacted = NULL; /* FILE_INFO_BY_HANDLE_CLASS and various structs used by this function are in fileextd.h, can be downloaded here: http://www.microsoft.com/downloads/details.aspx?familyid=1decc547-ab00-4963-a360-e4130ec079b8&displaylang=en --- 2675,2687 ---- typedef DWORD (WINAPI *GetFinalPathNameByHandlefunc)(HANDLE,LPWSTR,DWORD,DWORD); static GetFinalPathNameByHandlefunc pfnGetFinalPathNameByHandle = NULL; ! typedef DWORD (WINAPI *GetLongPathNamefunc)(LPCWSTR,LPWSTR,DWORD); ! static GetLongPathNamefunc pfnGetLongPathName = NULL; ! typedef DWORD (WINAPI *GetLongPathNameTransactedfunc)(LPCWSTR,LPWSTR,DWORD,HANDLE); static GetLongPathNameTransactedfunc pfnGetLongPathNameTransacted = NULL; + typedef DWORD (WINAPI *GetFullPathNameTransactedWfunc)(LPCWSTR,DWORD,LPWSTR,LPWSTR*,HANDLE); + static GetFullPathNameTransactedWfunc pfnGetFullPathNameTransactedW = NULL; + typedef DWORD (WINAPI *GetFullPathNameTransactedAfunc)(LPCSTR,DWORD,LPSTR,LPSTR*,HANDLE); + static GetFullPathNameTransactedAfunc pfnGetFullPathNameTransactedA = NULL; + /* FILE_INFO_BY_HANDLE_CLASS and various structs used by this function are in fileextd.h, can be downloaded here: http://www.microsoft.com/downloads/details.aspx?familyid=1decc547-ab00-4963-a360-e4130ec079b8&displaylang=en *************** *** 2966,3031 **** // @comm This method exists on Windows 2000 and later. Otherwise NotImplementedError will be raised. // @comm Accepts keyword args. ! CHECK_PFN(CreateHardLink); PyObject *ret=NULL; PyObject *new_file_obj; PyObject *existing_file_obj; ! PyObject *sa_obj = Py_None; ! WCHAR *new_file = NULL; ! WCHAR *existing_file = NULL; ! SECURITY_ATTRIBUTES *sa; ! static char *keywords[]={"FileName","ExistingFileName","SecurityAttributes", NULL}; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O:CreateHardLink", keywords, ! &new_file_obj, // @pyparm <o PyUnicode>|FileName||The name of the new directory entry to be created. ! &existing_file_obj, // @pyparm <o PyUnicode>|ExistingFileName||The name of the existing file to which the new link will point. ! &sa_obj)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None, ! return NULL; ! if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, TRUE)) ! return NULL; ! if (PyWinObject_AsWCHAR(new_file_obj, &new_file, FALSE) ! &&PyWinObject_AsWCHAR(existing_file_obj, &existing_file, FALSE)){ ! if (!(*pfnCreateHardLink)(new_file, existing_file, sa)) ! PyWin_SetAPIError("CreateHardLink"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(new_file); ! PyWinObject_FreeWCHAR(existing_file); ! return ret; ! } ! PyCFunction pfnpy_CreateHardLink=(PyCFunction)py_CreateHardLink; ! ! // @pyswig |CreateHardLinkTransacted|Creates an NTFS hard link as part of a transaction ! static PyObject *py_CreateHardLinkTransacted(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! // @comm This method only exists on Vista and later. ! // @comm Accepts keyword args. ! CHECK_PFN(CreateHardLinkTransacted); ! PyObject *obtrans, *ret=NULL; ! PyObject *new_file_obj; ! PyObject *existing_file_obj; ! PyObject *sa_obj = Py_None; WCHAR *new_file = NULL; WCHAR *existing_file = NULL; SECURITY_ATTRIBUTES *sa; HANDLE htrans; ! static char *keywords[]={"FileName","ExistingFileName","Transaction","SecurityAttributes", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|O:CreateHardLinkTransacted", keywords, &new_file_obj, // @pyparm <o PyUnicode>|FileName||The name of the new directory entry to be created. &existing_file_obj, // @pyparm <o PyUnicode>|ExistingFileName||The name of the existing file to which the new link will point. ! &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction ! &sa_obj)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None, return NULL; ! if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, TRUE)) return NULL; if (PyWinObject_AsWCHAR(new_file_obj, &new_file, FALSE) &&PyWinObject_AsWCHAR(existing_file_obj, &existing_file, FALSE)){ ! if (!(*pfnCreateHardLinkTransacted)(new_file, existing_file, sa, htrans)) ! PyWin_SetAPIError("CreateHardLinkTransacted"); else{ Py_INCREF(Py_None); --- 2889,2928 ---- // @comm This method exists on Windows 2000 and later. Otherwise NotImplementedError will be raised. // @comm Accepts keyword args. ! // @comm If the Transaction parameter is specified, CreateHardLinkTransacted will be called (requires Vista or later) PyObject *ret=NULL; PyObject *new_file_obj; PyObject *existing_file_obj; ! PyObject *trans_obj=Py_None, *sa_obj = Py_None; WCHAR *new_file = NULL; WCHAR *existing_file = NULL; SECURITY_ATTRIBUTES *sa; HANDLE htrans; ! static char *keywords[]={"FileName","ExistingFileName","SecurityAttributes","Transaction", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OO:CreateHardLink", keywords, &new_file_obj, // @pyparm <o PyUnicode>|FileName||The name of the new directory entry to be created. &existing_file_obj, // @pyparm <o PyUnicode>|ExistingFileName||The name of the existing file to which the new link will point. ! &sa_obj, // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None ! &trans_obj)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction, as returned by <om win32transaction.CreateTransaction> return NULL; ! if (!PyWinObject_AsHANDLE(trans_obj, &htrans, TRUE)) return NULL; if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, TRUE)) return NULL; + if (htrans){ + CHECK_PFN(CreateHardLinkTransacted); + } + else{ + CHECK_PFN(CreateHardLink); + } if (PyWinObject_AsWCHAR(new_file_obj, &new_file, FALSE) &&PyWinObject_AsWCHAR(existing_file_obj, &existing_file, FALSE)){ ! BOOL bsuccess; ! if (htrans) ! bsuccess=(*pfnCreateHardLinkTransacted)(new_file, existing_file, sa, htrans); ! else ! bsuccess=(*pfnCreateHardLink)(new_file, existing_file, sa); ! if (!bsuccess) ! PyWin_SetAPIError("CreateHardLink"); else{ Py_INCREF(Py_None); *************** *** 3037,3041 **** return ret; } ! PyCFunction pfnpy_CreateHardLinkTransacted=(PyCFunction)py_CreateHardLinkTransacted; // @pyswig |CreateSymbolicLink|Creates a symbolic link (reparse point) --- 2934,2938 ---- return ret; } ! PyCFunction pfnpy_CreateHardLink=(PyCFunction)py_CreateHardLink; // @pyswig |CreateSymbolicLink|Creates a symbolic link (reparse point) *************** *** 3044,3097 **** // @comm This method only exists on Vista and later. // @comm Accepts keyword args. ! // @comm Requires SeCreateSymbolicLink priv ! CHECK_PFN(CreateSymbolicLink); ! WCHAR *linkname=NULL, *targetname=NULL; ! PyObject *oblinkname, *obtargetname, *ret=NULL; ! DWORD flags=0; ! static char *keywords[]={"SymlinkFileName","TargetFileName","Flags", NULL}; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|k:CreateSymbolicLink", keywords, ! &oblinkname, // @pyparm <o PyUnicode>|SymlinkFileName||Path of the symbolic link to be created ! &obtargetname, // @pyparm <o PyUnicode>|TargetFileName||The name of file to which link will point ! &flags)) // @pyparm int|Flags|0|SYMLINK_FLAG_DIRECTORY is only defined flag ! return NULL; ! if (PyWinObject_AsWCHAR(oblinkname, &linkname, FALSE) && PyWinObject_AsWCHAR(obtargetname, &targetname, FALSE)){ ! if (!(*pfnCreateSymbolicLink)(linkname, targetname, flags)) ! PyWin_SetAPIError("CreateSymbolicLink"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(linkname); ! PyWinObject_FreeWCHAR(targetname); ! return ret; ! } ! PyCFunction pfnpy_CreateSymbolicLink=(PyCFunction)py_CreateSymbolicLink; ! ! // @pyswig |CreateSymbolicLinkTransacted|Creates a symbolic link as part of a transaction ! static PyObject *py_CreateSymbolicLinkTransacted(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! // @comm This method only exists on Vista and later. ! // @comm Accepts keyword args. ! // @comm Requires SeCreateSymbolicLink priv ! CHECK_PFN(CreateSymbolicLinkTransacted); WCHAR *linkname=NULL, *targetname=NULL; ! PyObject *oblinkname, *obtargetname, *obtrans, *ret=NULL; DWORD flags=0; HANDLE htrans; static char *keywords[]={"SymlinkFileName","TargetFileName","Flags","Transaction", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|k:CreateSymbolicLinkTransacted", keywords, &oblinkname, // @pyparm <o PyUnicode>|SymlinkFileName||Path of the symbolic link to be created &obtargetname, // @pyparm <o PyUnicode>|TargetFileName||The name of file to which link will point ! &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction ! &flags)) // @pyparm int|Flags|0|SYMLINK_FLAG_DIRECTORY is only defined flag ! return NULL; ! if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; if (PyWinObject_AsWCHAR(oblinkname, &linkname, FALSE) && PyWinObject_AsWCHAR(obtargetname, &targetname, FALSE)){ ! if (!(*pfnCreateSymbolicLinkTransacted)(linkname, targetname, flags, htrans)) ! PyWin_SetAPIError("CreateSymbolicLinkTransacted"); else{ Py_INCREF(Py_None); --- 2941,2975 ---- // @comm This method only exists on Vista and later. // @comm Accepts keyword args. ! // @comm Requires SeCreateSymbolicLink priv. ! // @comm If the Transaction parameter is passed in, CreateSymbolicLinkTransacted will be called WCHAR *linkname=NULL, *targetname=NULL; ! PyObject *oblinkname, *obtargetname, *obtrans=Py_None, *ret=NULL; DWORD flags=0; HANDLE htrans; static char *keywords[]={"SymlinkFileName","TargetFileName","Flags","Transaction", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|kO:CreateSymbolicLink", keywords, &oblinkname, // @pyparm <o PyUnicode>|SymlinkFileName||Path of the symbolic link to be created &obtargetname, // @pyparm <o PyUnicode>|TargetFileName||The name of file to which link will point ! &flags, // @pyparm int|Flags|0|SYMLINK_FLAG_DIRECTORY is only defined flag ! &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction, as returned by <om win32transaction.CreateTransaction> return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans){ + CHECK_PFN(CreateSymbolicLinkTransacted); + } + else{ + CHECK_PFN(CreateSymbolicLink); + } + if (PyWinObject_AsWCHAR(oblinkname, &linkname, FALSE) && PyWinObject_AsWCHAR(obtargetname, &targetname, FALSE)){ ! BOOL bsuccess; ! if (htrans) ! bsuccess=(*pfnCreateSymbolicLinkTransacted)(linkname, targetname, flags, htrans); ! else ! bsuccess=(*pfnCreateSymbolicLink)(linkname, targetname, flags); ! if (!bsuccess) ! PyWin_SetAPIError("CreateSymbolicLink"); else{ Py_INCREF(Py_None); *************** *** 3103,3107 **** return ret; } ! PyCFunction pfnpy_CreateSymbolicLinkTransacted=(PyCFunction)py_CreateSymbolicLinkTransacted; // @pyswig |EncryptFile|Encrypts specified file (requires Win2k or higher and NTFS) --- 2981,2985 ---- return ret; } ! PyCFunction pfnpy_CreateSymbolicLink=(PyCFunction)py_CreateSymbolicLink; // @pyswig |EncryptFile|Encrypts specified file (requires Win2k or higher and NTFS) *************** *** 4949,4952 **** --- 4827,4996 ---- return PyBool_FromLong(ret); } + + // @pyswig <o PyUnicode>|GetLongPathName|Retrieves the long path for a short path (8.3 filename) + // @comm Accepts keyword args + static PyObject *py_GetLongPathName(PyObject *self, PyObject *args, PyObject *kwargs) + { + PyObject *ret=NULL; + DWORD pathlen=MAX_PATH+1, retlen; + WCHAR *short_path=NULL, *long_path=NULL, *long_path_save=NULL; + PyObject *obfname, *obtrans=Py_None; + HANDLE htrans; + static char *keywords[]={"ShortPath","Transaction", NULL}; + #ifdef Py_DEBUG + pathlen=3; // test reallocation logic + #endif + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GetLongPathName", keywords, + &obfname, // @pyparm <o PyUnicode>|ShortPath||8.3 path to be expanded + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction. If specified, GetLongPathNameTransacted will be called. + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans){ + CHECK_PFN(GetLongPathNameTransacted); + } + else{ + CHECK_PFN(GetLongPathName); + } + if (!PyWinObject_AsWCHAR(obfname, &short_path, FALSE)) + return NULL; + + while (1){ + if (long_path){ + long_path_save=long_path; + long_path=(WCHAR *)realloc(long_path, pathlen*sizeof(WCHAR)); + } + else + long_path=(WCHAR *)malloc(pathlen*sizeof(WCHAR)); + if (long_path==NULL){ + if (long_path_save) + free(long_path_save); + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", pathlen*sizeof(WCHAR)); + break; + } + Py_BEGIN_ALLOW_THREADS + if (htrans) + retlen=(*pfnGetLongPathNameTransacted)(short_path, long_path, pathlen, htrans); + else + retlen=(*pfnGetLongPathName)(short_path, long_path, pathlen); + Py_END_ALLOW_THREADS + if (retlen==0){ + PyWin_SetAPIError("GetLongPathName"); + break; + } + if (retlen<=pathlen){ + ret=PyUnicode_FromWideChar(long_path,retlen); + break; + } + pathlen=retlen+1; + } + + PyWinObject_FreeWCHAR(short_path); + if (long_path) + free(long_path); + return ret; + } + PyCFunction pfnpy_GetLongPathName=(PyCFunction)py_GetLongPathName; + + // @pyswig str/unicode|GetFullPathName|Returns full path for path passed in + // @comm This function takes either a plain string or a unicode string, and returns the same type + // If unicode is passed in, GetFullPathNameW is called, which supports filenames longer than MAX_PATH + // @comm If Transaction parameter is specified, GetFullPathNameTransacted is called (requires Vista or later) + static PyObject *py_GetFullPathName(PyObject *self, PyObject *args, PyObject *kwargs) + { + HANDLE htrans; + PyObject *obtrans=Py_None, *ret=NULL, *obpathin; + DWORD pathlen=MAX_PATH+1, retlen; + static char *keywords[]={"FileName","Transaction", NULL}; + #ifdef Py_DEBUG + pathlen=3; // test reallocation logic + #endif + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GetFullPathName", keywords, + &obpathin, // @pyparm str/unicode|FileName||Path on which to operate + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction as returned by <om win32transaction.CreateTransaction> + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + + WCHAR *wpathin; + if (wpathin=PyUnicode_AsUnicode(obpathin)){ + if (htrans) + CHECK_PFN(GetFullPathNameTransactedW); + WCHAR *wpathret=NULL, *wfilepart, *wpathsave=NULL; + while (1){ + if (wpathret){ + wpathsave=wpathret; + wpathret=(WCHAR *)realloc(wpathret,pathlen*sizeof(WCHAR)); + } + else + wpathret=(WCHAR *)malloc(pathlen*sizeof(WCHAR)); + if (wpathret==NULL){ + if (wpathsave) + free(wpathsave); + PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + if (htrans) + retlen=(*pfnGetFullPathNameTransactedW)(wpathin, pathlen, wpathret, &wfilepart, htrans); + else + retlen=GetFullPathNameW(wpathin, pathlen, wpathret, &wfilepart); + Py_END_ALLOW_THREADS + if (retlen==0){ + PyWin_SetAPIError("GetFullPathNameW"); + break; + } + if (retlen<=pathlen){ + ret=PyUnicode_FromWideChar(wpathret,retlen); + break; + } + pathlen=retlen; + } + free(wpathret); + return ret; + } + + PyErr_Clear(); + char *cpathin; + if (cpathin=PyString_AsString(obpathin)){ + if (htrans) + CHECK_PFN(GetFullPathNameTransactedA); + char *cpathret=NULL, *cfilepart, *cpathsave=NULL; + while (1){ + if (cpathret){ + cpathsave=cpathret; + cpathret=(char *)realloc(cpathret,pathlen); + } + else + cpathret=(char *)malloc(pathlen); + if (cpathret==NULL){ + if (cpathsave) + free(cpathsave); + PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + if (htrans) + retlen=(*pfnGetFullPathNameTransactedA)(cpathin, pathlen, cpathret, &cfilepart, htrans); + else + retlen=GetFullPathNameA(cpathin, pathlen, cpathret, &cfilepart); + Py_END_ALLOW_THREADS + if (retlen==0){ + PyWin_SetAPIError("GetFullPathNameA"); + break; + } + if (retlen<=pathlen){ + ret=PyString_FromStringAndSize(cpathret,retlen); + break; + } + pathlen=retlen; + } + free(cpathret); + } + return ret; + } + PyCFunction pfnpy_GetFullPathName=(PyCFunction)py_GetFullPathName; %} *************** *** 4958,4964 **** %native (CreateHardLink) pfnpy_CreateHardLink; - %native (CreateHardLinkTransacted) pfnpy_CreateHardLinkTransacted; %native (CreateSymbolicLink) pfnpy_CreateSymbolicLink; - %native (CreateSymbolicLinkTransacted) pfnpy_CreateSymbolicLinkTransacted; // end of win2k volume mount functions. --- 5002,5006 ---- *************** *** 4997,5000 **** --- 5039,5044 ---- %native (FindFileNames) pfnpy_FindFileNames; %native (GetFinalPathNameByHandle) pfnpy_GetFinalPathNameByHandle; + %native (GetLongPathName) pfnpy_GetLongPathName; + %native (GetFullPathName) pfnpy_GetFullPathName; %native (SfcGetNextProtectedFile) py_SfcGetNextProtectedFile; *************** *** 5015,5021 **** ||(strcmp(pmd->ml_name, "SetFileAttributesTransacted")==0) ||(strcmp(pmd->ml_name, "CreateHardLink")==0) - ||(strcmp(pmd->ml_name, "CreateHardLinkTransacted")==0) ||(strcmp(pmd->ml_name, "CreateSymbolicLink")==0) - ||(strcmp(pmd->ml_name, "CreateSymbolicLinkTransacted")==0) ||(strcmp(pmd->ml_name, "CreateDirectoryTransacted")==0) ||(strcmp(pmd->ml_name, "RemoveDirectoryTransacted")==0) --- 5059,5063 ---- *************** *** 5031,5036 **** ||(strcmp(pmd->ml_name, "GetVolumePathNamesForVolumeName")==0) ||(strcmp(pmd->ml_name, "DuplicateEncryptionInfoFile")==0) ! ||(strcmp(pmd->ml_name, "GetFullPathNameTransacted")==0) // not impl yet ! ||(strcmp(pmd->ml_name, "GetLongPathNameTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet ) --- 5073,5078 ---- ||(strcmp(pmd->ml_name, "GetVolumePathNamesForVolumeName")==0) ||(strcmp(pmd->ml_name, "DuplicateEncryptionInfoFile")==0) ! ||(strcmp(pmd->ml_name, "GetLongPathName")==0) ! ||(strcmp(pmd->ml_name, "GetFullPathName")==0) ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet ) *************** *** 5096,5103 **** pfnFindNextFileName=(FindNextFileNamefunc)GetProcAddress(hmodule, "FindNextFileNameW"); pfnGetFinalPathNameByHandle=(GetFinalPathNameByHandlefunc)GetProcAddress(hmodule, "GetFinalPathNameByHandleW"); ! ! // these aren't wrapped yet ! pfnGetFullPathNameTransacted=(GetFullPathNameTransactedfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); // pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); } --- 5138,5145 ---- pfnFindNextFileName=(FindNextFileNamefunc)GetProcAddress(hmodule, "FindNextFileNameW"); pfnGetFinalPathNameByHandle=(GetFinalPathNameByHandlefunc)GetProcAddress(hmodule, "GetFinalPathNameByHandleW"); ! pfnGetLongPathName=(GetLongPathNamefunc)GetProcAddress(hmodule, "GetLongPathNameW"); pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); + pfnGetFullPathNameTransactedW=(GetFullPathNameTransactedWfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); + pfnGetFullPathNameTransactedA=(GetFullPathNameTransactedAfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedA"); // pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); } |
From: Roger U. <ru...@us...> - 2007-05-08 20:42:40
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10363/win32/Demos Added Files: CreateFileTransacted_MiniVersion.py Log Message: Demonstrate using CreateFileTransacted and FSCTL_TXFS_CREATE_MINIVERSION control code --- NEW FILE: CreateFileTransacted_MiniVersion.py --- """ This demonstrates the creation of miniversions of a file during a transaction. The FSCTL_TXFS_CREATE_MINIVERSION control code saves any changes to a new miniversion (effectively a savepoint within a transaction). """ import win32file, win32api, win32transaction import win32con, winioctlcon import struct """ Definition of buffer used with FSCTL_TXFS_CREATE_MINIVERSION: typedef struct _TXFS_CREATE_MINIVERSION_INFO{ USHORT StructureVersion; USHORT StructureLength; ULONG BaseVersion; USHORT MiniVersion;} """ buf_fmt='HHLH0L' ## buffer size must include struct padding buf_size=struct.calcsize(buf_fmt) tempdir=win32api.GetTempPath() tempfile=win32api.GetTempFileName(tempdir,'cft')[0] print tempfile f=open(tempfile,'w') f.write('This is original file.\n') f.close() trans=win32transaction.CreateTransaction(Description='Test creating miniversions of a file') hfile=win32file.CreateFileTransacted(tempfile, win32con.GENERIC_READ|win32con.GENERIC_WRITE, win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans) win32file.WriteFile(hfile, 'This is first miniversion.\n') buf=win32file.DeviceIoControl(hfile, winioctlcon.FSCTL_TXFS_CREATE_MINIVERSION,'',buf_size,None) struct_ver, struct_len, base_ver, ver_1=struct.unpack(buf_fmt, buf) win32file.SetFilePointer(hfile, 0, win32con.FILE_BEGIN) win32file.WriteFile(hfile, 'This is second miniversion!\n') buf=win32file.DeviceIoControl(hfile, winioctlcon.FSCTL_TXFS_CREATE_MINIVERSION,'',buf_size,None) struct_ver, struct_len, base_ver, ver_2=struct.unpack(buf_fmt, buf) hfile.Close() ## miniversions can't be opened with write access hfile_0=win32file.CreateFileTransacted(tempfile, win32con.GENERIC_READ, win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=base_ver) print 'version:',base_ver,win32file.ReadFile(hfile_0, 100) hfile_0.Close() hfile_1=win32file.CreateFileTransacted(tempfile, win32con.GENERIC_READ, win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_1) print 'version:',ver_1,win32file.ReadFile(hfile_1, 100) hfile_1.Close() hfile_2=win32file.CreateFileTransacted(tempfile, win32con.GENERIC_READ, win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, 0 , None, Transaction=trans, MiniVersion=ver_2) print 'version:',ver_2,win32file.ReadFile(hfile_2, 100) hfile_2.Close() ## MiniVersions are destroyed when transaction is committed or rolled back win32transaction.CommitTransaction(trans) |
From: Roger U. <ru...@us...> - 2007-05-07 06:00:31
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1498/win32/src Modified Files: win32gui.i Log Message: Add EnumPropsEx Allow window class to be None in FindWindow and FindWindowEx Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** win32gui.i 1 Apr 2007 13:24:04 -0000 1.105 --- win32gui.i 7 May 2007 06:00:30 -0000 1.106 *************** *** 1611,1623 **** - %typedef TCHAR *STRING_OR_ATOM %typedef TCHAR *STRING_OR_ATOM_CW ! %typemap(python,arginit) STRING_OR_ATOM, STRING_OR_ATOM_CW, RESOURCE_ID{ $target=NULL; } ! %typemap(python,in) STRING_OR_ATOM, STRING_OR_ATOM_CW { ! if (!PyWinObject_AsResourceId($source, &$target)) return NULL; } --- 1611,1629 ---- %typedef TCHAR *STRING_OR_ATOM_CW + %typedef TCHAR *RESOURCE_ID + %typedef TCHAR *RESOURCE_ID_NULLOK ! %typemap(python,arginit) STRING_OR_ATOM_CW, RESOURCE_ID, RESOURCE_ID_NULLOK{ $target=NULL; } ! %typemap(python,in) RESOURCE_ID { ! if (!PyWinObject_AsResourceId($source, &$target, FALSE)) ! return NULL; ! } ! ! %typemap(python,in) STRING_OR_ATOM_CW, RESOURCE_ID_NULLOK { ! if (!PyWinObject_AsResourceId($source, &$target, TRUE)) return NULL; } *************** *** 1643,1654 **** } ! %typedef TCHAR *RESOURCE_ID ! ! %typemap(python,in) RESOURCE_ID { ! if (!PyWinObject_AsResourceId($source, &$target)) ! return NULL; ! } ! ! %typemap(python,freearg) RESOURCE_ID { PyWinObject_FreeResourceId($source); } --- 1649,1653 ---- } ! %typemap(python,freearg) RESOURCE_ID,RESOURCE_ID_NULLOK { PyWinObject_FreeResourceId($source); } *************** *** 2824,2839 **** BOOL bEnable); // @pyparm boolean|bEnable||True to enable input to the window, False to disable input ! // @pyswig int|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindow( ! STRING_OR_ATOM className, // @pyparm int/string|className|| ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName|| #ifndef MS_WINCE ! // @pyswig int|FindWindowEx|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindowEx( ! HWND parent, // @pyparm int|hwnd|| ! HWND childAfter, // @pyparm int|childAfter|| ! STRING_OR_ATOM className, // @pyparm int/string|className|| ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName|| // @pyswig |DragAcceptFiles|Registers whether a window accepts dropped files. --- 2823,2838 ---- BOOL bEnable); // @pyparm boolean|bEnable||True to enable input to the window, False to disable input ! // @pyswig <o PyHANDLE>|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindow( ! RESOURCE_ID_NULLOK className, // @pyparm <o PyResourceId>|ClassName||Name or atom of window class to find, can be None ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName||Title of window to find, can be None #ifndef MS_WINCE ! // @pyswig <o PyHANDLE>|FindWindowEx|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindowEx( ! HWND parent, // @pyparm <o PyHANDLE>|Parent||Window whose child windows will be searched. If 0, desktop window is assumed. ! HWND childAfter, // @pyparm <o PyHANDLE>|ChildAfter||Child window after which to search in Z-order, can be 0 to search all ! RESOURCE_ID_NULLOK className, // @pyparm <o PyResourceId>|ClassName||Name or atom of window class to find, can be None ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName||Title of window to find, can be None // @pyswig |DragAcceptFiles|Registers whether a window accepts dropped files. *************** *** 6203,6207 **** PyWinObject_AsWCHAR(obTitle, (WCHAR **)&pofn->lpstrTitle, TRUE) && PyWinObject_AsWCHAR(obDefExt, (WCHAR **)&pofn->lpstrDefExt, TRUE) && ! ((obTemplateName==Py_None)||PyWinObject_AsResourceIdW(obTemplateName, (WCHAR **)&pofn->lpTemplateName)); done: --- 6202,6206 ---- PyWinObject_AsWCHAR(obTitle, (WCHAR **)&pofn->lpstrTitle, TRUE) && PyWinObject_AsWCHAR(obDefExt, (WCHAR **)&pofn->lpstrDefExt, TRUE) && ! PyWinObject_AsResourceIdW(obTemplateName, (WCHAR **)&pofn->lpTemplateName, TRUE); done: *************** *** 7227,7228 **** --- 7226,7287 ---- %} %native (DrawTextW) pfnPyDrawTextW; + + %{ + BOOL CALLBACK PyEnumPropsExCallback(HWND hwnd, LPWSTR propname, HANDLE propdata, ULONG_PTR callback_data) + { + PyObject *args=NULL, *obret=NULL; + BOOL ret; + CEnterLeavePython _celp; + PyObject **callback_objects=(PyObject **)callback_data; + args=Py_BuildValue("NNNO", + PyWinLong_FromHANDLE(hwnd), + IS_INTRESOURCE(propname) ? PyWinLong_FromVoidPtr(propname):PyWinObject_FromWCHAR(propname), + PyWinLong_FromHANDLE(propdata), + callback_objects[1]); + if (args==NULL) + return FALSE; + obret=PyObject_Call(callback_objects[0], args, NULL); + if (obret==NULL) + ret=FALSE; + else + ret=TRUE; + + Py_XDECREF(args); + Py_XDECREF(obret); + return ret; + } + + // @pyswig |EnumPropsEx|Enumerates properties attached to a window. + // Each property is passed to a callback function, which receives 4 arguments:<nl> + // Handle to the window, name of the property, handle to the property data, and Param object passed to this function + // + PyObject *PyEnumPropsEx(PyObject *self, PyObject *args) + { + HWND hwnd; + PyObject *obhwnd, *callback, *callback_data; + PyObject *callback_objects[2]; + + if (!PyArg_ParseTuple(args, "OOO:EnumPropsEx", + &obhwnd, // @pyparm <o PyHANDLE>|hWnd||Handle to a window + &callback, // @pyparm function|EnumFunc||Callback function + &callback_data)) // @pyparm object|Param||Arbitrary object to be passed to callback function + return NULL; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) + return NULL; + if (!PyCallable_Check(callback)){ + PyErr_SetString(PyExc_TypeError,"EnumFunc must be callable"); + return NULL; + } + callback_objects[0]=callback; + callback_objects[1]=callback_data; + + if (!EnumPropsExW(hwnd, PyEnumPropsExCallback, (LPARAM)callback_objects)){ + if (!PyErr_Occurred()) + PyWin_SetAPIError("EnumPropsEx"); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + %} + %native(EnumPropsEx) PyEnumPropsEx; |
From: Roger U. <ru...@us...> - 2007-05-07 03:41:22
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12905/win32/src Modified Files: PyWinTypes.h PyWinTypesmodule.cpp Log Message: Add a parm to PyWinObject_AsResourceId to allow None Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** PyWinTypesmodule.cpp 1 Apr 2007 13:07:41 -0000 1.27 --- PyWinTypesmodule.cpp 7 May 2007 03:41:21 -0000 1.28 *************** *** 574,581 **** // When passing resource names and types as strings, they are usually formatted // as a pound sign followed by decimal form of the id. ('#42' for example) ! BOOL PyWinObject_AsResourceIdA(PyObject *ob, char **presource_id) { // Plain character conversion ! if (PyWinObject_AsString(ob, presource_id)) return TRUE; PyErr_Clear(); --- 574,581 ---- // When passing resource names and types as strings, they are usually formatted // as a pound sign followed by decimal form of the id. ('#42' for example) ! BOOL PyWinObject_AsResourceIdA(PyObject *ob, char **presource_id, BOOL bNoneOK) { // Plain character conversion ! if (PyWinObject_AsString(ob, presource_id, bNoneOK)) return TRUE; PyErr_Clear(); *************** *** 587,594 **** } ! BOOL PyWinObject_AsResourceIdW(PyObject *ob, WCHAR **presource_id) { // Unicode version of above ! if (PyWinObject_AsWCHAR(ob, presource_id)) return TRUE; PyErr_Clear(); --- 587,594 ---- } ! BOOL PyWinObject_AsResourceIdW(PyObject *ob, WCHAR **presource_id, BOOL bNoneOK) { // Unicode version of above ! if (PyWinObject_AsWCHAR(ob, presource_id, bNoneOK)) return TRUE; PyErr_Clear(); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PyWinTypes.h 1 Apr 2007 13:07:41 -0000 1.37 --- PyWinTypes.h 7 May 2007 03:41:21 -0000 1.38 *************** *** 343,348 **** // Conversion for resource id/name and class atom ! PYWINTYPES_EXPORT BOOL PyWinObject_AsResourceIdA(PyObject *ob, char **presource_id); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsResourceIdW(PyObject *ob, WCHAR **presource_id); PYWINTYPES_EXPORT void PyWinObject_FreeResourceId(char *resource_id); PYWINTYPES_EXPORT void PyWinObject_FreeResourceId(WCHAR *resource_id); --- 343,348 ---- // Conversion for resource id/name and class atom ! PYWINTYPES_EXPORT BOOL PyWinObject_AsResourceIdA(PyObject *ob, char **presource_id, BOOL bNoneOK = FALSE); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsResourceIdW(PyObject *ob, WCHAR **presource_id, BOOL bNoneOK = FALSE); PYWINTYPES_EXPORT void PyWinObject_FreeResourceId(char *resource_id); PYWINTYPES_EXPORT void PyWinObject_FreeResourceId(WCHAR *resource_id); |
From: Mark H. <mha...@us...> - 2007-05-07 02:40:40
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22243 Modified Files: testall.py Log Message: Ensure tests work even if '.vbs' is not locally registered for VBScript. Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** testall.py 31 May 2005 09:28:16 -0000 1.26 --- testall.py 7 May 2007 02:40:37 -0000 1.27 *************** *** 91,96 **** # Level 1 tests. [ ! ("cscript.exe /nologo testInterp.vbs", "VBScript test worked OK"), ! ("cscript.exe /nologo testDictionary.vbs", "VBScript has successfully tested Python.Dictionary"), ], --- 91,96 ---- # Level 1 tests. [ ! ("cscript.exe /nologo //E:vbscript testInterp.vbs", "VBScript test worked OK"), ! ("cscript.exe /nologo //E:vbscript testDictionary.vbs", "VBScript has successfully tested Python.Dictionary"), ], |
From: Mark H. <mha...@us...> - 2007-05-07 02:33:01
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290 Modified Files: ErrorUtils.cpp PyComHelpers.cpp Log Message: [oops - this is the log for the previous checkin] * MakeOLECHARToObj and MakeBstrToObj now return Unicode objects instead of forcing the initial Unicode back to 8 bites * COM Exception objects now use Unicode - this is mainly related to AXScript errors. |
From: Mark H. <mha...@us...> - 2007-05-07 02:30:34
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17768 Modified Files: ErrorUtils.cpp PyComHelpers.cpp Log Message: Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ErrorUtils.cpp 11 Nov 2005 02:35:29 -0000 1.27 --- ErrorUtils.cpp 7 May 2007 02:30:33 -0000 1.28 *************** *** 770,776 **** // ### should these by PyUnicode values? Still strings for compatibility. ! PyObject *obSource = PyString_FromUnicode(pexcepInfo->bstrSource); ! PyObject *obDescription = PyString_FromUnicode(pexcepInfo->bstrDescription); ! PyObject *obHelpFile = PyString_FromUnicode(pexcepInfo->bstrHelpFile); PyObject *rc = Py_BuildValue("iOOOii", (int)pexcepInfo->wCode, --- 770,776 ---- // ### should these by PyUnicode values? Still strings for compatibility. ! PyObject *obSource = PyWinObject_FromBstr(pexcepInfo->bstrSource); ! PyObject *obDescription = PyWinObject_FromBstr(pexcepInfo->bstrDescription); ! PyObject *obHelpFile = PyWinObject_FromBstr(pexcepInfo->bstrHelpFile); PyObject *rc = Py_BuildValue("iOOOii", (int)pexcepInfo->wCode, Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyComHelpers.cpp 7 Feb 2007 03:45:05 -0000 1.11 --- PyComHelpers.cpp 7 May 2007 02:30:33 -0000 1.12 *************** *** 27,43 **** PyObject *MakeBstrToObj(const BSTR bstr) { ! if (bstr==NULL) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! ! int numChars = SysStringLen(bstr); ! int numBytes = numChars * 2; ! LPSTR str = (LPSTR)malloc(numBytes); ! numChars = WideCharToMultiByte(CP_ACP, 0, bstr, numChars, str, numBytes, NULL, NULL); ! ! PyObject *ret = PyString_FromStringAndSize(str, numChars); ! free(str); ! return ret; } --- 27,31 ---- PyObject *MakeBstrToObj(const BSTR bstr) { ! return PyWinObject_FromBstr(bstr, FALSE); } *************** *** 45,58 **** PyObject *MakeOLECHARToObj(const OLECHAR * str, int numChars) { ! if (str==NULL) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! int numBytes = numChars * 2; ! LPSTR ascstr = (LPSTR)malloc(numBytes); ! numChars = WideCharToMultiByte(CP_ACP, 0, str, numChars, ascstr, numBytes, NULL, NULL); ! PyObject *rc = PyString_FromStringAndSize(ascstr, numChars); ! free(ascstr); ! return rc; } --- 33,37 ---- PyObject *MakeOLECHARToObj(const OLECHAR * str, int numChars) { ! return PyWinObject_FromOLECHAR(str, numChars); } *************** *** 60,68 **** PyObject *MakeOLECHARToObj(const OLECHAR * str) { ! if (str==NULL) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! return PyString_FromUnicode(str); } --- 39,43 ---- PyObject *MakeOLECHARToObj(const OLECHAR * str) { ! return PyWinObject_FromOLECHAR(str); } |
From: Mark H. <mha...@us...> - 2007-05-07 02:27:51
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17342/client Modified Files: error.py framework.py Log Message: Correct a number of issues with unicode, particularly errors. Index: error.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/error.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** error.py 6 May 2007 12:03:51 -0000 1.8 --- error.py 7 May 2007 02:27:44 -0000 1.9 *************** *** 89,93 **** traceback.print_exc() # re-raise. ! raise sys.exc_info() def _BuildFromSyntaxError(self, site, value, tb): --- 89,93 ---- traceback.print_exc() # re-raise. ! raise def _BuildFromSyntaxError(self, site, value, tb): *************** *** 114,124 **** self.linetext = ExpandTabs(line.rstrip()) ! def _BuildFromOther(self, site, type, value, tb): self.colno = -1 self.lineno = 0 if debugging: # Full traceback if debugging. ! list=traceback.format_exception(type, value, tb) self.description = ExpandTabs(''.join(list)) - print "Script Traceback is", self.description return # Run down the traceback list, looking for the first "<Script..>" --- 114,123 ---- self.linetext = ExpandTabs(line.rstrip()) ! def _BuildFromOther(self, site, exc_type, value, tb): self.colno = -1 self.lineno = 0 if debugging: # Full traceback if debugging. ! list=traceback.format_exception(exc_type, value, tb) self.description = ExpandTabs(''.join(list)) return # Run down the traceback list, looking for the first "<Script..>" *************** *** 157,161 **** list = ['Traceback (most recent call last):\n'] list = list + traceback.format_list(format_items) ! if type==pythoncom.com_error: desc = "%s (0x%x)" % (value[1], value[0]) if value[0]==winerror.DISP_E_EXCEPTION and value[2] and value[2][2]: --- 156,160 ---- list = ['Traceback (most recent call last):\n'] list = list + traceback.format_list(format_items) ! if exc_type==pythoncom.com_error: desc = "%s (0x%x)" % (value[1], value[0]) if value[0]==winerror.DISP_E_EXCEPTION and value[2] and value[2][2]: *************** *** 163,172 **** list.append("COM Error: "+desc) else: ! list = list + traceback.format_exception_only(type, value) ! # list=traceback.format_exception(type, value, tb_top, depth) ! self.description = ExpandTabs(''.join(list)) # Clear tracebacks etc. tb = tb_top = tb_look = None - # sys.exc_type = sys.exc_value = sys.exc_traceback = None def ExtractTracebackInfo(self, tb, site): --- 162,175 ---- list.append("COM Error: "+desc) else: ! list = list + traceback.format_exception_only(exc_type, value) ! # all items in the list are utf8 courtesy of Python magically ! # converting unicode to utf8 before compilation. ! for i in range(len(list)): ! if type(list[i]) is str: ! #assert type(list[i]) is str, type(list[i]) ! list[i] = list[i].decode('utf8') ! self.description = ExpandTabs(u''.join(list)) # Clear tracebacks etc. tb = tb_top = tb_look = None def ExtractTracebackInfo(self, tb, site): *************** *** 184,187 **** --- 187,191 ---- codeBlock = None if codeBlock: + # Note: 'line' will now be unicode. line = codeBlock.GetLineNo(lineno) if line: Index: framework.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/framework.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** framework.py 6 May 2007 12:03:51 -0000 1.24 --- framework.py 7 May 2007 02:27:44 -0000 1.25 *************** *** 62,66 **** self.redir.write(message) except: ! win32api.OutputDebugString(message) def flush(self): pass --- 62,66 ---- self.redir.write(message) except: ! win32api.OutputDebugString(message.encode('mbcs')) def flush(self): pass |
From: Mark H. <mha...@us...> - 2007-05-07 02:27:51
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17342/test Modified Files: testHost.py Log Message: Correct a number of issues with unicode, particularly errors. Index: testHost.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/test/testHost.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testHost.py 18 Jun 2006 13:09:35 -0000 1.4 --- testHost.py 7 May 2007 02:27:44 -0000 1.5 *************** *** 6,9 **** --- 6,11 ---- from win32com.server import util, connect import win32com.server.policy + from win32com.client.dynamic import Dispatch + from win32com.server.exception import COMException import unittest *************** *** 14,24 **** class MySite(axsite.AXSite): def __init__(self, *args): ! self.seen_exception = 0 axsite.AXSite.__init__(self, *args) def OnScriptError(self, error): ! exc = error.GetExceptionInfo() context, line, char = error.GetSourcePosition() - self.seen_exception = 1 if not verbose: return --- 16,25 ---- class MySite(axsite.AXSite): def __init__(self, *args): ! self.exception_seen = None axsite.AXSite.__init__(self, *args) def OnScriptError(self, error): ! self.exception_seen = exc = error.GetExceptionInfo() context, line, char = error.GetSourcePosition() if not verbose: return *************** *** 34,39 **** class MyCollection(util.Collection): ! def _NewEnum(self): ! return util.Collection._NewEnum(self) class Test: --- 35,40 ---- class MyCollection(util.Collection): ! def _NewEnum(self): ! return util.Collection._NewEnum(self) class Test: *************** *** 124,127 **** --- 125,133 ---- """ + PyScript_Exc = u"""\ + def hello(arg1): + raise RuntimeError, "exc with extended \xa9har" + """ + ErrScript = """\ bad code for everyone! *************** *** 145,171 **** class EngineTester(win32com.test.util.TestCase): ! def _TestEngine(self, engineName, code, bShouldWork = 1): echoer = Test() model = { 'test' : util.wrap(echoer), } try: ! try: ! site = MySite(model) ! engine = site._AddEngine(engineName) ! _CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED) ! engine.AddCode(code) ! engine.Start() ! _CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED) ! finally: ! if bShouldWork: ! self.failUnless(not site.seen_exception, "Script site should not have seen an exception") ! else: ! self.failUnless(site.seen_exception, "Script site should have seen an exception") self.failUnless(not echoer.fail_called, "Fail should not have been called") # Now call into the scripts IDispatch - from win32com.client.dynamic import Dispatch ob = Dispatch(engine.GetScriptDispatch()) ! ob.hello("Goober") self.assertEqual(echoer.last, "Goober") --- 151,179 ---- class EngineTester(win32com.test.util.TestCase): ! def _TestEngine(self, engineName, code, expected_exc = None): echoer = Test() model = { 'test' : util.wrap(echoer), } + site = MySite(model) + engine = site._AddEngine(engineName) try: ! _CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED) ! engine.AddCode(code) ! engine.Start() ! _CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED) self.failUnless(not echoer.fail_called, "Fail should not have been called") # Now call into the scripts IDispatch ob = Dispatch(engine.GetScriptDispatch()) ! try: ! ob.hello("Goober") ! self.failUnless(expected_exc is None, ! "Expected %r, but no exception seen" % (expected_exc,)) ! except pythoncom.com_error: ! if expected_exc is None: ! self.fail("Unexpected failure from script code: %s" % (site.exception_seen,)) ! if expected_exc not in site.exception_seen[2]: ! self.fail("Could not find %r in %r" % (expected_exc, site.exception_seen[2])) ! return self.assertEqual(echoer.last, "Goober") *************** *** 204,213 **** def testPython(self): self._TestEngine("Python", PyScript) def testVBExceptions(self): self.assertRaises(pythoncom.com_error, ! self._TestEngine, "VBScript", ErrScript, 0) def testPythonExceptions(self): ! self.assertRaises(pythoncom.com_error, ! self._TestEngine, "Python", ErrScript, 0) if __name__ == '__main__': --- 212,223 ---- def testPython(self): self._TestEngine("Python", PyScript) + def testPythonUnicodeError(self): + self._TestEngine("Python", PyScript) def testVBExceptions(self): self.assertRaises(pythoncom.com_error, ! self._TestEngine, "VBScript", ErrScript) def testPythonExceptions(self): ! expected = u"RuntimeError: exc with extended \xa9har" ! self._TestEngine("Python", PyScript_Exc, expected) if __name__ == '__main__': |
From: Mark H. <mha...@us...> - 2007-05-06 12:03:51
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7246 Modified Files: error.py framework.py pyscript.py Log Message: die, string module, die Index: pyscript.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/pyscript.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pyscript.py 30 Jan 2007 22:35:57 -0000 1.10 --- pyscript.py 6 May 2007 12:03:51 -0000 1.11 *************** *** 16,20 **** import win32com.server.register import sys - import string import traceback import scriptdispatch --- 16,19 ---- *************** *** 37,41 **** def AddCR(text): return re.sub('\n','\r\n',text) - # return string.join(string.split(text,'\n'),'\r\n') class AXScriptCodeBlock(framework.AXScriptCodeBlock): --- 36,39 ---- *************** *** 103,107 **** def _DoFindAttribute_(self, obj, attr): try: ! return obj.subItems[string.lower(attr)].attributeObject except KeyError: pass --- 101,105 ---- def _DoFindAttribute_(self, obj, attr): try: ! return obj.subItems[attr.lower()].attributeObject except KeyError: pass *************** *** 138,142 **** # If a known subitem, return it. try: ! return self._scriptItem_.subItems[string.lower(attr)].attributeObject except KeyError: # Otherwise see if the dispatch can give it to us --- 136,140 ---- # If a known subitem, return it. try: ! return self._scriptItem_.subItems[attr.lower()].attributeObject except KeyError: # Otherwise see if the dispatch can give it to us *************** *** 147,151 **** # XXX - todo - if a known item, then should call its default # dispatch method. ! attr=string.lower(attr) if self._scriptItem_.dispatchContainer: try: --- 145,149 ---- # XXX - todo - if a known item, then should call its default # dispatch method. ! attr=attr.lower() if self._scriptItem_.dispatchContainer: try: *************** *** 309,313 **** def MakeEventMethodName(self, subItemName, eventName): ! return string.upper(subItemName[0])+subItemName[1:] + "_" + string.upper(eventName[0])+eventName[1:] def DoAddScriptlet(self, defaultName, code, itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber): --- 307,311 ---- def MakeEventMethodName(self, subItemName, eventName): ! return subItemName[0].upper()+subItemName[1:] + "_" + eventName[0].upper()+eventName[1:] def DoAddScriptlet(self, defaultName, code, itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber): *************** *** 337,341 **** if codeBlock is not None: realCode = "def %s():\n" % funcName ! for line in string.split(framework.RemoveCR(codeBlock.codeText),"\n"): realCode = realCode + '\t' + line + '\n' realCode = realCode + '\n' --- 335,339 ---- if codeBlock is not None: realCode = "def %s():\n" % funcName ! for line in framework.RemoveCR(codeBlock.codeText).split("\n"): realCode = realCode + '\t' + line + '\n' realCode = realCode + '\n' *************** *** 353,359 **** except KeyError: # Not there _exactly_ - do case ins search. ! funcNameLook = string.lower(funcName) for attr in self.globalNameSpaceModule.__dict__.keys(): ! if funcNameLook==string.lower(attr): function = self.globalNameSpaceModule.__dict__[attr] # cache back in scriptlets, to avoid this overhead next time --- 351,357 ---- except KeyError: # Not there _exactly_ - do case ins search. ! funcNameLook = funcName.lower() for attr in self.globalNameSpaceModule.__dict__.keys(): ! if funcNameLook==attr.lower(): function = self.globalNameSpaceModule.__dict__[attr] # cache back in scriptlets, to avoid this overhead next time Index: error.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/error.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** error.py 17 Oct 2006 03:09:07 -0000 1.7 --- error.py 6 May 2007 12:03:51 -0000 1.8 *************** *** 6,10 **** """ ! import sys, string, traceback from win32com.axscript import axscript import winerror --- 6,10 ---- """ ! import sys, traceback from win32com.axscript import axscript import winerror *************** *** 27,31 **** def AddCR(text): return re.sub('\n','\r\n',text) - # return string.join(string.split(text,'\n'),'\r\n') class IActiveScriptError: --- 27,30 ---- *************** *** 113,117 **** self.lineno = lineno self.colno = offset - 1 ! self.linetext = ExpandTabs(string.rstrip(line)) def _BuildFromOther(self, site, type, value, tb): --- 112,116 ---- self.lineno = lineno self.colno = offset - 1 ! self.linetext = ExpandTabs(line.rstrip()) def _BuildFromOther(self, site, type, value, tb): *************** *** 120,124 **** if debugging: # Full traceback if debugging. list=traceback.format_exception(type, value, tb) ! self.description = ExpandTabs(string.join(list,"")) print "Script Traceback is", self.description return --- 119,123 ---- if debugging: # Full traceback if debugging. list=traceback.format_exception(type, value, tb) ! self.description = ExpandTabs(''.join(list)) print "Script Traceback is", self.description return *************** *** 166,170 **** list = list + traceback.format_exception_only(type, value) # list=traceback.format_exception(type, value, tb_top, depth) ! self.description = ExpandTabs(string.join(list,"")) # Clear tracebacks etc. tb = tb_top = tb_look = None --- 165,169 ---- list = list + traceback.format_exception_only(type, value) # list=traceback.format_exception(type, value, tb_top, depth) ! self.description = ExpandTabs(''.join(list)) # Clear tracebacks etc. tb = tb_top = tb_look = None *************** *** 187,191 **** line = codeBlock.GetLineNo(lineno) if line: ! line = string.strip(line) else: line = None --- 186,190 ---- line = codeBlock.GetLineNo(lineno) if line: ! line = line.strip() else: line = None Index: framework.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/framework.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** framework.py 6 May 2007 11:39:24 -0000 1.23 --- framework.py 6 May 2007 12:03:51 -0000 1.24 *************** *** 7,11 **** There are classes defined for the engine itself, and for ScriptItems """ ! import sys, string from win32com.axscript import axscript import win32com.server.util --- 7,11 ---- There are classes defined for the engine itself, and for ScriptItems """ ! import sys from win32com.axscript import axscript import win32com.server.util *************** *** 122,131 **** pos = -1 for i in range(no-1): ! pos = string.find(self.codeText, '\n', pos+1) if pos==-1: pos=len(self.codeText) ! epos = string.find(self.codeText, '\n', pos+1) if epos==-1: epos=len(self.codeText) ! return string.strip(self.codeText[pos+1:epos]) class Event: --- 122,131 ---- pos = -1 for i in range(no-1): ! pos = self.codeText.find('\n', pos+1) if pos==-1: pos=len(self.codeText) ! epos = self.codeText.find('\n', pos+1) if epos==-1: epos=len(self.codeText) ! return self.codeText[pos+1:epos].strip() class Event: *************** *** 338,345 **** def GetSubItem(self, name): ! return self.subItems[string.lower(name)] def GetCreateSubItem(self, parentItem, name, dispatch, flags): ! keyName = string.lower(name) try: rc = self.subItems[keyName] --- 338,345 ---- def GetSubItem(self, name): ! return self.subItems[name.lower()] def GetCreateSubItem(self, parentItem, name, dispatch, flags): ! keyName = name.lower() try: rc = self.subItems[keyName] |
From: Mark H. <mha...@us...> - 2007-05-06 11:39:25
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30423 Modified Files: framework.py Log Message: Update info for InterruptScriptThread Index: framework.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/framework.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** framework.py 18 Jun 2006 13:09:33 -0000 1.22 --- framework.py 6 May 2007 11:39:24 -0000 1.23 *************** *** 688,693 **** gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) ! def InterruptScriptThread(self, state, flags): ! raise Exception("Not Implemented", scode=winerror.E_NOTIMPL) def Clone(self): --- 688,695 ---- gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) ! # This is never called by the C++ framework - it does magic. ! # See PyGActiveScript.cpp ! #def InterruptScriptThread(self, stidThread, exc_info, flags): ! # raise Exception("Not Implemented", scode=winerror.E_NOTIMPL) def Clone(self): |
From: Roger U. <ru...@us...> - 2007-05-03 08:28:39
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10121/com/win32comext/adsi/src Modified Files: PyIDsObjectPicker.i Log Message: Swig typemap for HWND moved into pywintypes.i Index: PyIDsObjectPicker.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/src/PyIDsObjectPicker.i,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIDsObjectPicker.i 26 May 2005 11:39:30 -0000 1.1 --- PyIDsObjectPicker.i 3 May 2007 08:28:39 -0000 1.2 *************** *** 6,12 **** %include "adsilib.i" - %apply HWND {long}; - typedef long HWND - %{ --- 6,9 ---- |
From: Roger U. <ru...@us...> - 2007-04-27 05:45:43
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8151/com/win32com/src Modified Files: PyStorage.cpp PythonCOM.cpp Log Message: Add CreateStreamOnHGlobal, ReadClassStm and WriteClassStm Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** PythonCOM.cpp 26 Apr 2007 19:30:43 -0000 1.44 --- PythonCOM.cpp 27 Apr 2007 05:45:42 -0000 1.45 *************** *** 48,51 **** --- 48,54 ---- extern PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args); extern PyObject *pythoncom_ReadClassStg(PyObject *self, PyObject *args); + extern PyObject *pythoncom_WriteClassStm(PyObject *self, PyObject *args); + extern PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args); + extern PyObject *pythoncom_CreateStreamOnHGlobal(PyObject *self, PyObject *args); extern PyObject *pythoncom_GetRecordFromGuids(PyObject *self, PyObject *args); extern PyObject *pythoncom_GetRecordFromTypeInfo(PyObject *self, PyObject *args); *************** *** 1791,1794 **** --- 1794,1798 ---- { "CreateTypeLib2", pythoncom_CreateTypeLib2, 1}, // @pymeth CreateTypeLib2|Provides access to a new object instance that supports the ICreateTypeLib2 interface. #endif // MS_WINCE + { "CreateStreamOnHGlobal", pythoncom_CreateStreamOnHGlobal, 1 }, // @pymeth CreateStreamOnHGlobal|Creates an in-memory stream storage object { "EnableQuitMessage", pythoncom_EnableQuitMessage, 1 }, // @pymeth EnableQuitMessage|Indicates the thread PythonCOM should post a WM_QUIT message to. { "FUNCDESC", Py_NewFUNCDESC, 1}, // @pymeth FUNCDESC|Returns a new <o FUNCDESC> object. *************** *** 1834,1837 **** --- 1838,1842 ---- #endif // MS_WINCE { "ReadClassStg", pythoncom_ReadClassStg, 1}, // @pymeth ReadClassStg|Reads a CLSID from a storage object + { "ReadClassStm", pythoncom_ReadClassStm, 1}, // @pymeth ReadClassStm|Reads a CLSID from a <o PyIStream> object { "RegisterTypeLib", pythoncom_registertypelib, 1}, // @pymeth RegisterTypeLib|Adds information about a type library to the system registry. { "UnRegisterTypeLib", pythoncom_unregistertypelib, 1}, // @pymeth UnRegisterTypeLib|Removes a type library from the system registry. *************** *** 1855,1858 **** --- 1860,1864 ---- { "WrapObject", pythoncom_WrapObject, 1 }, // @pymeth WrapObject|Wraps an object in a gateway. { "WriteClassStg", pythoncom_WriteClassStg, 1}, // @pymeth WriteClassStg|Stores a CLSID from a storage object + { "WriteClassStm", pythoncom_WriteClassStm, 1}, // @pymeth WriteClassStm|Sets the CLSID of a stream { "UnwrapObject", pythoncom_UnwrapObject, 1 }, // @pymeth UnwrapObject|Unwraps a Python instance in a gateway object. { "Unicode", pythoncom_Unicode, 1 }, // @pymeth Unicode|Converts a string into a <o PyUnicode> object. Index: PyStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyStorage.cpp 2 Dec 2005 07:53:53 -0000 1.9 --- PyStorage.cpp 27 Apr 2007 05:45:42 -0000 1.10 *************** *** 27,31 **** return PyWinObject_FromIID(clsidRet); } ! // @pymethod |pythoncom|WriteClassStg|Writes a CLSID to a storage. PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args) { --- 27,32 ---- return PyWinObject_FromIID(clsidRet); } ! ! // @pymethod |pythoncom|WriteClassStg|Writes a CLSID to a storage object PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args) { *************** *** 33,37 **** PyObject *obCLSID; if (!PyArg_ParseTuple(args, "OO:WriteClassStg", ! &obStg, // @pyparm <o PyIStorage>|storage||The storage to read the CLSID from. &obCLSID)) // @pyparm <o PyIID>|iid||The IID to write return NULL; --- 34,38 ---- PyObject *obCLSID; if (!PyArg_ParseTuple(args, "OO:WriteClassStg", ! &obStg, // @pyparm <o PyIStorage>|storage||Storage object into which CLSID will be written. &obCLSID)) // @pyparm <o PyIID>|iid||The IID to write return NULL; *************** *** 54,57 **** --- 55,124 ---- } + // @pymethod <o PyIID>|pythoncom|ReadClassStm|Retrieves the CLSID from a stream + PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args) + { + PyObject *obStm; + if (!PyArg_ParseTuple(args, "O:ReadClassStm", + &obStm)) // @pyparm <o PyIStream>|Stm||An IStream interface + return NULL; + IStream *pStm; + if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE)) + return NULL; + CLSID clsidRet; + PY_INTERFACE_PRECALL; + HRESULT hr = ReadClassStm(pStm, &clsidRet); + pStm->Release(); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) return PyCom_BuildPyException(hr); + return PyWinObject_FromIID(clsidRet); + } + + // @pymethod |pythoncom|WriteClassStm|Writes a CLSID to a stream. + PyObject *pythoncom_WriteClassStm(PyObject *self, PyObject *args) + { + PyObject *obStm; + PyObject *obCLSID; + if (!PyArg_ParseTuple(args, "OO:WriteClassStm", + &obStm, // @pyparm <o PyIStream>|Stm||An IStream interface + &obCLSID)) // @pyparm <o PyIID>|clsid||The IID to write + return NULL; + + CLSID clsid; + if (!PyWinObject_AsIID(obCLSID, &clsid)) + return NULL; + + IStream *pStm; + if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE)) + return NULL; + + PY_INTERFACE_PRECALL; + HRESULT hr = WriteClassStm(pStm, clsid); + pStm->Release(); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) return PyCom_BuildPyException(hr); + Py_INCREF(Py_None); + return Py_None; + } + + // @pymethod <o PyIStream>|pythoncom|CreateStreamOnHGlobal|Creates an in-memory stream storage object + PyObject *pythoncom_CreateStreamOnHGlobal(PyObject *self, PyObject *args) + { + PyObject *obhglobal=Py_None; + HGLOBAL hglobal=NULL; + BOOL bdelete=TRUE; + IStream *pIStream=NULL; + if (!PyArg_ParseTuple(args, "|Ol:CreateStreamOnHGlobal", + &obhglobal, // @pyparm <o PyHANDLE>|hGlobal|None|Global memory handle. If None, a new global memory object is allocated. + &bdelete)) // @pyparm bool|DeleteOnRelease|True|Indicates if global memory should be freed when IStream object is destroyed. + return NULL; + if (!PyWinObject_AsHANDLE(obhglobal, &hglobal, TRUE)) + return NULL; + PY_INTERFACE_PRECALL; + HRESULT hr = CreateStreamOnHGlobal(hglobal, bdelete, &pIStream); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + return PyCom_PyObjectFromIUnknown(pIStream, IID_IStream, FALSE); + } // @pymethod <o PyIStorage>|pythoncom|StgCreateDocfile|Creates a new compound file storage object using the OLE-provided compound file implementation for the <o PyIStorage> interface. *************** *** 64,70 **** if (!PyArg_ParseTuple(args, "Oi|i:StgCreateDocfile", ! &obName, // @pyparm string|name||the path of the compound file to create. It is passed uninterpreted to the file system. This can be a relative name or None. If None, a temporary stream is created. ! &mode, // @pyparm int|mode||Specifies the access mode used to open the storage. ! &reserved)) // @pyparm int|reserved|0|A reserved value return NULL; PyWin_AutoFreeBstr bstrName; --- 131,137 ---- if (!PyArg_ParseTuple(args, "Oi|i:StgCreateDocfile", ! &obName, // @pyparm string|name||the path of the compound file to create. It is passed uninterpreted to the file system. This can be a relative name or None. If None, a temporary stream is created. ! &mode, // @pyparm int|mode||Specifies the access mode used to open the storage. ! &reserved)) // @pyparm int|reserved|0|A reserved value return NULL; PyWin_AutoFreeBstr bstrName; |
From: Roger U. <ru...@us...> - 2007-04-26 19:30:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29476/com/win32com/src Modified Files: PythonCOM.cpp Log Message: Add CoMarshalInterface and CoUnmarshalInterface Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** PythonCOM.cpp 22 Jan 2007 01:20:51 -0000 1.43 --- PythonCOM.cpp 26 Apr 2007 19:30:43 -0000 1.44 *************** *** 1154,1157 **** --- 1154,1158 ---- return PyCom_PyObjectFromIUnknown(pUnk, iid, /*BOOL bAddRef*/ FALSE); } + // @pymethod <o PyIUnknown>|pythoncom|CoCreateFreeThreadedMarshaler|Creates an aggregatable object capable of context-dependent marshaling. static PyObject *pythoncom_CoCreateFreeThreadedMarshaler(PyObject *self, PyObject*args) *************** *** 1176,1179 **** --- 1177,1264 ---- } + // @pymethod |pythoncom|CoMarshalInterface|Marshals an interface into a stream + static PyObject *pythoncom_CoMarshalInterface(PyObject *self, PyObject*args) + { + PyObject *obriid, *obIStream, *obUnk, *ret=NULL; + IID riid; + IStream *pIStream=NULL; + IUnknown *pIUnknown=NULL; + void *pvdestctxt=NULL; // reserved + DWORD destctxt, flags=MSHLFLAGS_NORMAL; + if ( !PyArg_ParseTuple(args, "OOOk|k:CoMarshalInterface", + &obIStream, // @pyparm <o PyIStream>|Stm||An IStream interface into which marshalled interface will be written + &obriid, // @pyparm <o PyIID>|riid||IID of interface to be marshalled + &obUnk, // @pyparm <o PyIUnknown>|Unk||Base IUnknown of the object to be marshalled + &destctxt, // @pyparm int|DestContext||MSHCTX_* flag indicating where object will be unmarshalled + &flags)) // @pyparm int|flags|MSHLFLAGS_NORMAL|MSHLFLAGS_* flag indicating marshalling options + return NULL; + if (PyWinObject_AsIID(obriid, &riid) + &&PyCom_InterfaceFromPyObject(obIStream, IID_IStream, (void **)&pIStream, FALSE) + &&PyCom_InterfaceFromPyObject(obUnk, IID_IUnknown, (void **)&pIUnknown, FALSE)){ + PY_INTERFACE_PRECALL; + HRESULT hr = CoMarshalInterface(pIStream, riid, pIUnknown, destctxt, pvdestctxt, flags); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + PyCom_BuildPyException(hr); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PY_INTERFACE_PRECALL; + if (pIUnknown) + pIUnknown->Release(); + if (pIStream) + pIStream->Release(); + PY_INTERFACE_POSTCALL; + return ret; + } + + // @pymethod interface|pythoncom|CoUnmarshalInterface|Unmarshals an interface + static PyObject *pythoncom_CoUnmarshalInterface(PyObject *self, PyObject*args) + { + PyObject *obriid, *obIStream, *ret=NULL; + IID riid; + IStream *pIStream=NULL; + IUnknown *pIUnknown=NULL; + if (!PyArg_ParseTuple(args, "OO:CoUnmarshalInterface", + &obIStream, // @pyparm <o PyIStream>|Stm||Stream containing marshalled interface + &obriid)) // @pyparm <o PyIID>|riid||IID of interface to be unmarshalled + return NULL; + if (PyWinObject_AsIID(obriid, &riid) + &&PyCom_InterfaceFromPyObject(obIStream, IID_IStream, (void **)&pIStream, FALSE)){ + PY_INTERFACE_PRECALL; + HRESULT hr = CoUnmarshalInterface(pIStream, riid, (void **)&pIUnknown); + pIStream->Release(); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + PyCom_BuildPyException(hr); + else + ret=PyCom_PyObjectFromIUnknown(pIUnknown, riid, FALSE); + } + return ret; + } + + // @pymethod |pythoncom|CoReleaseMarshalData|Frees resources used by a marshalled interface + // @comm This is usually only needed when the interface could not be successfully unmarshalled + static PyObject *pythoncom_CoReleaseMarshalData(PyObject *self, PyObject*args) + { + PyObject *obIStream, *ret=NULL; + IStream *pIStream=NULL; + if (!PyArg_ParseTuple(args, "O:CoReleaseMarshalData", + &obIStream)) // @pyparm <o PyIStream>|Stm||Stream containing marshalled interface + return NULL; + if (!PyCom_InterfaceFromPyObject(obIStream, IID_IStream, (void **)&pIStream, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + HRESULT hr = CoReleaseMarshalData(pIStream); + pIStream->Release(); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + Py_INCREF(Py_None); + return Py_None; + } + #endif // MS_WINCE *************** *** 1684,1687 **** --- 1769,1775 ---- { "CoGetInterfaceAndReleaseStream", pythoncom_CoGetInterfaceAndReleaseStream, 1}, // @pymeth CoGetInterfaceAndReleaseStream|Unmarshals a buffer containing an interface pointer and releases the stream when an interface pointer has been marshaled from another thread to the calling thread. { "CoMarshalInterThreadInterfaceInStream", pythoncom_CoMarshalInterThreadInterfaceInStream, 1}, // @pymeth CoMarshalInterThreadInterfaceInStream|Marshals an interface pointer from one thread to another thread in the same process. + { "CoMarshalInterface", pythoncom_CoMarshalInterface, 1}, // @pymeth CoMarshalInterface|Marshals an interface into a stream + { "CoUnmarshalInterface", pythoncom_CoUnmarshalInterface, 1}, // @pymeth CoUnmarshalInterface|Unmarshals an interface + { "CoReleaseMarshalData", pythoncom_CoReleaseMarshalData, 1}, // @pymeth CoReleaseMarshalData|Frees resources used by a marshalled interface #endif // MS_WINCE { "CoGetObject", pythoncom_CoGetObject, 1}, // @pymeth CoGetObject|Converts a display name into a moniker that identifies the object named, and then binds to the object identified by the moniker. *************** *** 2159,2162 **** --- 2247,2262 ---- ADD_CONSTANT(VT_TYPEMASK); + // DestContext for CoMarshalInterface (MSHCTX enum) + ADD_CONSTANT(MSHCTX_LOCAL); + ADD_CONSTANT(MSHCTX_NOSHAREDMEM); + ADD_CONSTANT(MSHCTX_DIFFERENTMACHINE); + ADD_CONSTANT(MSHCTX_INPROC); + + // Marshalling flags used with CoMarshalInterface (MSHLFLAGS enum) + ADD_CONSTANT(MSHLFLAGS_NORMAL); + ADD_CONSTANT(MSHLFLAGS_TABLESTRONG); + ADD_CONSTANT(MSHLFLAGS_TABLEWEAK); + ADD_CONSTANT(MSHLFLAGS_NOPING); + #ifndef NO_PYCOM_IDISPATCHEX ADD_CONSTANT(fdexNameCaseSensitive); // Request that the name lookup be done in a case-sensitive manner. May be ignored by object that does not support case-sensitive lookup. |
From: Mark H. <mha...@us...> - 2007-04-25 03:32:05
|
Update of /cvsroot/pywin32/pywin32/com/win32com/makegw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17385 Modified Files: makegw.py Log Message: replace regsub with re Index: makegw.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/makegw/makegw.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** makegw.py 26 Jan 2005 22:29:49 -0000 1.8 --- makegw.py 25 Apr 2007 03:32:05 -0000 1.9 *************** *** 47,51 **** """ ! import regsub import string import makegwparse --- 47,51 ---- """ ! import re import string import makegwparse *************** *** 172,176 **** ''' % (interface.__dict__)) ! ptr = regsub.gsub('[a-z]', '', interface.name) strdict = {'interfacename':interface.name, 'ptr': ptr} for method in interface.methods: --- 172,176 ---- ''' % (interface.__dict__)) ! ptr = re.sub('[a-z]', '', interface.name) strdict = {'interfacename':interface.name, 'ptr': ptr} for method in interface.methods: |
From: Mark H. <mha...@us...> - 2007-04-25 03:24:48
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14624/com/win32comext/shell/src Modified Files: shell.cpp Added Files: PyIExtractImage.cpp PyIExtractImage.h Log Message: IExtractImage from Steven James. --- NEW FILE: PyIExtractImage.cpp --- // This file implements the IExtractImage Interface for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyWinTypes.h" #include "PyIExtractImage.h" #define elementsof( array ) ( sizeof(array) / sizeof((array)[0]) ) BOOL PyWinObject_AsSIZE(PyObject *obsize, SIZE *psize); PyObject *PyWinObject_FromSIZE(PSIZE psize); PyObject *PyWinObject_FromSIZE(PSIZE psize) { return Py_BuildValue("ll", psize->cx, psize->cy); } BOOL PyWinObject_AsSIZE(PyObject *obsize, SIZE *psize) { if (!PyTuple_Check(obsize)){ PyErr_SetString(PyExc_TypeError, "SIZE must be a tuple of 2 ints (x,y)"); return FALSE; } return PyArg_ParseTuple(obsize, "ll;SIZE must be a tuple of 2 ints (x,y)", &psize->cx, &psize->cy); } // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIExtractImage::PyIExtractImage(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIExtractImage::~PyIExtractImage() { } /* static */ IExtractImage *PyIExtractImage::GetI(PyObject *self) { return (IExtractImage *)PyIUnknown::GetI(self); } // @pymethod |PyIExtractImage|GetLocation|Description of GetLocation. PyObject *PyIExtractImage::GetLocation(PyObject *self, PyObject *args) { IExtractImage *pIEI = GetI(self); if ( pIEI == NULL ) return NULL; DWORD dwPriority; //PyObject *obdwPriority; // @pyparm <o PyDWORD *>|dwPriority||Description for dwPriority SIZE rgSize; PyObject *obrgSize; // @pyparm <o Pyconst SIZE *>|prgSize||Description for prgSize // @pyparm int|dwRecClrDepth||Description for dwRecClrDepth DWORD dwFlags; //PyObject *obdwFlags; // @pyparm <o PyDWORD *>|pdwFlags||Description for pdwFlags WCHAR pszPathBuffer[255]; DWORD dwRecClrDepth; if ( !PyArg_ParseTuple(args, "lOll:GetLocation", &dwPriority, &obrgSize, &dwRecClrDepth, &dwFlags) ) return NULL; BOOL bPythonIsHappy = TRUE; //if (bPythonIsHappy && !PyInt_Check(obdwPriority)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsSIZE ( obrgSize, &rgSize )) bPythonIsHappy = FALSE; //if (bPythonIsHappy && !PyInt_Check(obdwFlags)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; //dwPriority = PyInt_AsLong(obdwPriority); //dwFlags = PyInt_AsLong(obdwFlags); HRESULT hr; PY_INTERFACE_PRECALL; hr = pIEI->GetLocation( pszPathBuffer, elementsof(pszPathBuffer), &dwPriority, &rgSize, dwRecClrDepth, &dwFlags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEI, IID_IExtractImage ); PyObject *obpszPathBuffer; obpszPathBuffer = MakeOLECHARToObj(pszPathBuffer); PyObject *pyretval = Py_BuildValue("O", obpszPathBuffer); CoTaskMemFree(pszPathBuffer); Py_XDECREF(obpszPathBuffer); return pyretval; } // @pymethod |PyIExtractImage|Extract|Description of Extract. PyObject *PyIExtractImage::Extract(PyObject *self, PyObject *args) { IExtractImage *pIEI = GetI(self); if ( pIEI == NULL ) return NULL; HBITMAP hBmpThumbnail; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIEI->Extract( &hBmpThumbnail ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEI, IID_IExtractImage ); return PyWinObject_FromHANDLE((HANDLE)hBmpThumbnail); //return Py_BuildValue("i", hBmpThumbnail); //return PyLong_FromVoidPtr((void*)hBmpThumbnail); //return PyString_FromString((char*)hBmpThumbnail); } // @object PyIExtractImage|Description of the interface static struct PyMethodDef PyIExtractImage_methods[] = { { "GetLocation", PyIExtractImage::GetLocation, 1 }, // @pymeth GetLocation|Description of GetLocation { "Extract", PyIExtractImage::Extract, 1 }, // @pymeth Extract|Description of Extract { NULL } }; PyComTypeObject PyIExtractImage::type("PyIExtractImage", &PyIUnknown::type, sizeof(PyIExtractImage), PyIExtractImage_methods, GET_PYCOM_CTOR(PyIExtractImage)); --- NEW FILE: PyIExtractImage.h --- // This file declares the IExtractImage Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyIExtractImage : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIExtractImage); static IExtractImage *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *GetLocation(PyObject *self, PyObject *args); static PyObject *Extract(PyObject *self, PyObject *args); protected: PyIExtractImage(IUnknown *pdisp); ~PyIExtractImage(); }; Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** shell.cpp 15 Feb 2007 13:11:02 -0000 1.51 --- shell.cpp 25 Apr 2007 03:24:40 -0000 1.52 *************** *** 43,46 **** --- 43,47 ---- #include "PyIUniformResourceLocator.h" #include "PyIActiveDesktop.h" + #include "PyIExtractImage.h" #include "PythonCOMRegister.h" // For simpler registration of IIDs etc. *************** *** 2307,2310 **** --- 2308,2312 ---- PYCOM_INTERFACE_FULL(ContextMenu), PYCOM_INTERFACE_FULL(ExtractIcon), + PYCOM_INTERFACE_CLIENT_ONLY (ExtractImage), PYCOM_INTERFACE_IID_ONLY (ExtractIconW), PYCOM_INTERFACE_FULL(ShellExtInit), |
From: Mark H. <mha...@us...> - 2007-04-25 03:24:23
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14598 Modified Files: setup.py Log Message: add PyIExtractImage Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** setup.py 15 Feb 2007 13:11:02 -0000 1.56 --- setup.py 25 Apr 2007 03:24:23 -0000 1.57 *************** *** 1239,1242 **** --- 1239,1243 ---- %(shell)s/PyIEmptyVolumeCache.cpp %(shell)s/PyIEmptyVolumeCacheCallBack.cpp + %(shell)s/PyIExtractImage.cpp %(shell)s/PyIInputObject.cpp %(shell)s/PyIPersistFolder.cpp |
From: Roger U. <ru...@us...> - 2007-04-23 00:21:05
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9159 Modified Files: CHANGES.txt Log Message: Catalog some of the changes since last release Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/CHANGES.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CHANGES.txt 23 Sep 2006 00:31:53 -0000 1.7 --- CHANGES.txt 23 Apr 2007 00:21:04 -0000 1.8 *************** *** 6,9 **** --- 6,68 ---- However contributors are encouraged to add their own entries for their work. + Since build 210: + ---------------- + * makepy accepts a program id to process its typelib + + * win32transaction: New module containing Kernel Transaction Manager (KTM) functions + as used with transacted NTFS and transacted registry functions + + * win32api: + Transacted registry functions added + RegCopyTree and RegDeleteTree + RegSaveKeyEx and RegRestoreKey + Get/SetSystemFileCacheSize + GlobalMemoryStatus and GlobalMemoryStatusEx + RegCreateKeyEx, RegQueryInfoKeyW, and RegEnumKeyExW + + * win32file: + Fixed bug in ReadDirectoryChanges that ignored 1 char filenames. + (from Niki Spahiev) + Transactional NTFS functions added + FindFiles and FindFilesIterator now accept an optional transaction handle to + perform a transacted search + FindStreams function that calls FindFirstStream and FindNextStream to enumerate + a file's data streams + CreateSymbolicLink and other new Vista API functions + System file checker (Sfc) functions + DuplicateEncryptionInfoFile + GetVolumePathNamesForVolumeName + GetFinalPathNameByHandle + FindFileNames using FindFirstFileName, FindFirstFileNameTransacted, and FindNextFileName + + * win32service: + Service and service control manager handles are now returned + as self-closing PySC_HANDLEs instead of plain int handles + Service dependencies are returned as list of Unicode strings instead + of a single string, which lost multiple dependencies (could break + code) + + * win32gui: + GDI object handles (bitmaps, fonts, regions, pens, brushes) are returned + as another PyHANDLE subclass (PyGdiHandle) + A large number of new text drawing, line and curve drawing, region, path, + and coordinate space functions + Window class name can now be used interchangeably with class atom + (fixes bug #1267366) + Add DrawTextW (feature request #1173716) + + * win32process: + Get/SetThreadPriorityBoost and Get/SetProcessPriorityBoost + GetGuiResources + GetProcessId + + * win32print: + Printer handles are now returned as self-closing PyHANDLE subclass + FlushPrinter, GetDefaultPrinterW, and SetDefaultPrinterW + + * win32security: + Added DuplicateTokenEx + + Build 210 - Sept. 23 2006 ------------------------- |
From: Roger U. <ru...@us...> - 2007-04-23 00:13:55
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6428/win32/src Modified Files: win32file.i Log Message: Add FindFileNames (FindFirstFileName/FindNextFileName) Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** win32file.i 14 Apr 2007 08:27:50 -0000 1.77 --- win32file.i 23 Apr 2007 00:13:55 -0000 1.78 *************** *** 2747,2750 **** --- 2747,2756 ---- typedef HANDLE (WINAPI *FindFirstStreamTransactedfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD, HANDLE); static FindFirstStreamTransactedfunc pfnFindFirstStreamTransacted=NULL; + typedef HANDLE (WINAPI *FindFirstFileNamefunc)(LPCWSTR,DWORD,LPDWORD,PWCHAR); + static FindFirstFileNamefunc pfnFindFirstFileName = NULL; + typedef HANDLE (WINAPI *FindFirstFileNameTransactedfunc)(LPCWSTR,DWORD,LPDWORD,PWCHAR,HANDLE); + static FindFirstFileNameTransactedfunc pfnFindFirstFileNameTransacted = NULL; + typedef BOOL (WINAPI *FindNextFileNamefunc)(HANDLE,LPDWORD,PWCHAR); + static FindNextFileNamefunc pfnFindNextFileName = NULL; typedef DWORD (WINAPI *GetFinalPathNameByHandlefunc)(HANDLE,LPWSTR,DWORD,DWORD); static GetFinalPathNameByHandlefunc pfnGetFinalPathNameByHandle = NULL; *************** *** 2755,2765 **** typedef DWORD (WINAPI *GetLongPathNameTransactedfunc)(LPCTSTR,LPTSTR,DWORD,HANDLE); static GetLongPathNameTransactedfunc pfnGetLongPathNameTransacted = NULL; - typedef HANDLE (WINAPI *FindFirstFileNamefunc)(LPCWSTR,DWORD,LPDWORD,PWCHAR); - static FindFirstFileNamefunc pfnFindFirstFileName = NULL; - typedef HANDLE (WINAPI *FindFirstFileNameTransactedfunc)(LPCWSTR,DWORD,LPDWORD,PWCHAR,HANDLE); - static FindFirstFileNameTransactedfunc pfnFindFirstFileNameTransacted = NULL; // HFILE_ERROR - // static char *keywords[]={"FileName","Flags","StringLength","LinkName","Transaction", NULL}; - typedef BOOL (WINAPI *FindNextFileNamefunc)(HANDLE,LPDWORD,PWCHAR); - static FindNextFileNamefunc pfnFindNextFileName = NULL; // ERROR_HANDLE_EOF /* FILE_INFO_BY_HANDLE_CLASS and various structs used by this function are in fileextd.h, can be downloaded here: http://www.microsoft.com/downloads/details.aspx?familyid=1decc547-ab00-4963-a360-e4130ec079b8&displaylang=en --- 2761,2764 ---- *************** *** 2775,2779 **** ! // @pyswig <o PyUnicode>|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. // @comm Accepts keyword args. static PyObject* --- 2774,2778 ---- ! // @pyswig <o PyUnicode>|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. // @comm Accepts keyword args. static PyObject* *************** *** 2812,2816 **** PyCFunction pfnpy_SetVolumeMountPoint=(PyCFunction)py_SetVolumeMountPoint; ! // @pyswig |DeleteVolumeMountPoint|Unmounts the volume from the specified volume mount point. // @comm Accepts keyword args. static PyObject* --- 2811,2815 ---- PyCFunction pfnpy_SetVolumeMountPoint=(PyCFunction)py_SetVolumeMountPoint; ! // @pyswig |DeleteVolumeMountPoint|Unmounts the volume from the specified volume mount point. // @comm Accepts keyword args. static PyObject* *************** *** 4750,4753 **** --- 4749,4856 ---- PyCFunction pfnpy_FindStreams=(PyCFunction)py_FindStreams; + // @pyswig [<o PyUnicode>,...]|FindFileNames|Enumerates hard links that point to specified file + // @comm This uses the API functions FindFirstFileNameW, FindNextFileNameW and FindClose + // @comm Available on Vista and later + // @comm If Transaction is specified, a transacted search is performed using FindFirstFileNameTransacted + static PyObject *py_FindFileNames(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(FindFirstFileName); + CHECK_PFN(FindNextFileName); + + PyObject *obfname, *obtrans=Py_None, *ret=NULL, *ret_item; + WCHAR *fname=NULL, *linkname=NULL; + HANDLE hfind=INVALID_HANDLE_VALUE, htrans=NULL; + DWORD err=0, flags=0; // flags are reserved, don't even accept as input + DWORD alloc_size=MAX_PATH, ret_size=0; + BOOL bfindfirst=TRUE, bsuccess=TRUE; + #ifdef Py_DEBUG + alloc_size=3; // test reallocation logic + #endif + static char *keywords[]={"FileName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:FindFileNames", keywords, + &obfname, // @pyparm <o PyUnicode>|FileName||Name of file for which to find links + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction, can be None + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans!=NULL) + CHECK_PFN(FindFirstFileNameTransacted); + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + + while (TRUE){ + ret_size=alloc_size; + if (linkname==NULL){ + linkname=(WCHAR *)malloc(alloc_size*sizeof(WCHAR)); + if (linkname==NULL){ + bsuccess=FALSE; + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", alloc_size*sizeof(WCHAR)); + break; + } + } + if (bfindfirst){ + if (htrans!=NULL) + hfind=(*pfnFindFirstFileNameTransacted)(fname, flags, &ret_size, linkname, htrans); + else + hfind=(*pfnFindFirstFileName)(fname, flags, &ret_size, linkname); + bsuccess=(hfind!=INVALID_HANDLE_VALUE); + if (bsuccess){ + bfindfirst=FALSE; + ret=PyList_New(0); + if (ret==NULL){ + bsuccess=FALSE; + break; + } + } + } + else + bsuccess=(*pfnFindNextFileName)(hfind, &ret_size, linkname); + if (bsuccess){ + ret_item=PyWinObject_FromWCHAR(linkname, ret_size); + if ((ret_item==NULL) || (PyList_Append(ret, ret_item)==-1)){ + Py_XDECREF(ret_item); + bsuccess=FALSE; + break; + } + Py_DECREF(ret_item); + } + else{ + err=GetLastError(); + if (err==ERROR_MORE_DATA){ + /* FindNextFileName leaks memory when it fails due to insufficient buffer ! + if (!bfindfirst) + for (int x=0; x<10000; x++){ + alloc_size=3; + (*pfnFindNextFileName)(hfind, &alloc_size, linkname); + } + */ + free(linkname); + linkname=NULL; + alloc_size=ret_size+1; + } + else if (err==ERROR_HANDLE_EOF){ + bsuccess=TRUE; + break; + } + else{ + PyWin_SetAPIError("FindFileNames", err); + break; + } + } + } + if (!bsuccess){ + Py_XDECREF(ret); + ret=NULL; + } + if (hfind!=INVALID_HANDLE_VALUE) + FindClose(hfind); + PyWinObject_FreeWCHAR(fname); + if (linkname) + free(linkname); + return ret; + } + PyCFunction pfnpy_FindFileNames=(PyCFunction)py_FindFileNames; + // @pyswig <o PyUnicode>|GetFinalPathNameByHandle|Returns the file name for an open file handle // @pyseeapi GetFinalPathNameByHandle *************** *** 4892,4895 **** --- 4995,4999 ---- %native (FindFilesIterator) pfnpy_FindFilesIterator; %native (FindStreams) pfnpy_FindStreams; + %native (FindFileNames) pfnpy_FindFileNames; %native (GetFinalPathNameByHandle) pfnpy_GetFinalPathNameByHandle; *************** *** 4919,4922 **** --- 5023,5027 ---- ||(strcmp(pmd->ml_name, "FindFilesIterator")==0) ||(strcmp(pmd->ml_name, "FindStreams")==0) + ||(strcmp(pmd->ml_name, "FindFileNames")==0) ||(strcmp(pmd->ml_name, "GetFinalPathNameByHandle")==0) ||(strcmp(pmd->ml_name, "SetVolumeMountPoint")==0) *************** *** 4928,4934 **** ||(strcmp(pmd->ml_name, "GetFullPathNameTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetLongPathNameTransacted")==0) // not impl yet - ||(strcmp(pmd->ml_name, "FindFirstFileName")==0) // not impl yet - ||(strcmp(pmd->ml_name, "FindFirstFileNameTransacted")==0) // not impl yet - ||(strcmp(pmd->ml_name, "FindNextFileName")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet ) --- 5033,5036 ---- *************** *** 4990,4993 **** --- 5092,5098 ---- pfnFindFirstStreamTransacted=(FindFirstStreamTransactedfunc)GetProcAddress(hmodule, "FindFirstStreamTransactedW"); pfnFindFirstFileTransacted=(FindFirstFileTransactedfunc)GetProcAddress(hmodule, "FindFirstFileTransactedW"); + pfnFindFirstFileName=(FindFirstFileNamefunc)GetProcAddress(hmodule, "FindFirstFileNameW"); + pfnFindFirstFileNameTransacted=(FindFirstFileNameTransactedfunc)GetProcAddress(hmodule, "FindFirstFileNameTransactedW"); + pfnFindNextFileName=(FindNextFileNamefunc)GetProcAddress(hmodule, "FindNextFileNameW"); pfnGetFinalPathNameByHandle=(GetFinalPathNameByHandlefunc)GetProcAddress(hmodule, "GetFinalPathNameByHandleW"); *************** *** 4995,5001 **** pfnGetFullPathNameTransacted=(GetFullPathNameTransactedfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); - pfnFindFirstFileName=(FindFirstFileNamefunc)GetProcAddress(hmodule, "FindFirstFileNameW"); - pfnFindFirstFileNameTransacted=(FindFirstFileNameTransactedfunc)GetProcAddress(hmodule, "FindFirstFileNameTransactedW"); - pfnFindNextFileName=(FindNextFileNamefunc)GetProcAddress(hmodule, "FindNextFileNameW"); // pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); } --- 5100,5103 ---- *************** *** 5056,5060 **** #define SETXOFF SETXOFF // Causes transmission to act as if an XOFF character has been received. #define SETXON SETXON // Causes transmission to act as if an XON character has been received. ! #define SETBREAK SETBREAK // Suspends character transmission and places the transmission line in a break state until the ClearCommBreak function is called (or EscapeCommFunction is called with the CLRBREAK extended function code). The SETBREAK extended function code is identical to the SetCommBreak function. Note that this extended function does not flush data that has not been transmitted. #define CLRBREAK CLRBREAK // Restores character transmission and places the transmission line in a nonbreak state. The CLRBREAK extended function code is identical to the ClearCommBreak function. #define PURGE_TXABORT PURGE_TXABORT // Terminates all outstanding overlapped write operations and returns immediately, even if the write operations have not been completed. --- 5158,5162 ---- #define SETXOFF SETXOFF // Causes transmission to act as if an XOFF character has been received. #define SETXON SETXON // Causes transmission to act as if an XON character has been received. ! #define SETBREAK SETBREAK // Suspends character transmission and places the transmission line in a break state until the ClearCommBreak function is called (or EscapeCommFunction is called with the CLRBREAK extended function code). The SETBREAK extended function code is identical to the SetCommBreak function. Note that this extended function does not flush data that has not been transmitted. #define CLRBREAK CLRBREAK // Restores character transmission and places the transmission line in a nonbreak state. The CLRBREAK extended function code is identical to the ClearCommBreak function. #define PURGE_TXABORT PURGE_TXABORT // Terminates all outstanding overlapped write operations and returns immediately, even if the write operations have not been completed. |
From: Roger U. <ru...@us...> - 2007-04-14 08:27:50
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4563/win32/src Modified Files: win32file.i Log Message: Add Sfc functions Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** win32file.i 17 Mar 2007 03:41:53 -0000 1.76 --- win32file.i 14 Apr 2007 08:27:50 -0000 1.77 *************** *** 17,20 **** --- 17,21 ---- #include "assert.h" #include <stddef.h> + #include "sfc.h" #endif *************** *** 2767,2770 **** --- 2768,2777 ---- */ + // From sfc.dll + typedef BOOL (WINAPI *SfcGetNextProtectedFilefunc)(HANDLE,PPROTECTED_FILE_DATA); + static SfcGetNextProtectedFilefunc pfnSfcGetNextProtectedFile = NULL; + typedef BOOL (WINAPI *SfcIsFileProtectedfunc)(HANDLE,LPCWSTR); + static SfcIsFileProtectedfunc pfnSfcIsFileProtected = NULL; + // @pyswig <o PyUnicode>|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. *************** *** 4781,4784 **** --- 4788,4849 ---- } PyCFunction pfnpy_GetFinalPathNameByHandle=(PyCFunction)py_GetFinalPathNameByHandle; + + // @pyswig [<o PyUnicode>,...]|SfcGetNextProtectedFile|Returns list of protected operating system files + // @pyseeapi SfcGetNextProtectedFile + static PyObject *py_SfcGetNextProtectedFile(PyObject *self, PyObject *args) + { + CHECK_PFN(SfcGetNextProtectedFile); + PROTECTED_FILE_DATA pfd; + DWORD err=0; + HANDLE rpchandle=NULL; // reserved + PyObject *ret, *ret_item; + + if (!PyArg_ParseTuple(args, ":SfcGetNextProtectedFile")) + return NULL; + ret=PyList_New(0); + if (ret==NULL) + return NULL; + pfd.FileNumber=0; + + while ((*pfnSfcGetNextProtectedFile)(rpchandle, &pfd)){ + ret_item=PyWinObject_FromWCHAR(pfd.FileName); + if (ret_item==NULL || PyList_Append(ret, ret_item)==-1){ + Py_XDECREF(ret_item); + Py_DECREF(ret); + return NULL; + } + Py_DECREF(ret_item); + } + err=GetLastError(); + if (err==ERROR_NO_MORE_FILES) + return ret; + Py_DECREF(ret); + return PyWin_SetAPIError("SfcGetNextProtectedFile",err); + } + + // @pyswig boolean|SfcIsFileProtected|Checks if a file is protected + static PyObject *py_SfcIsFileProtected(PyObject *self, PyObject *args) + { + CHECK_PFN(SfcIsFileProtected); + PyObject *obfname; + WCHAR *fname; + HANDLE rpchandle=NULL; // reserved + BOOL ret; + + if (!PyArg_ParseTuple(args, "O:SfcIsFileProtected", + &obfname)) // @pyparm <o PyUnicode>|ProtFileName||Name of file to be checked + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + + ret=(*pfnSfcIsFileProtected)(rpchandle, fname); + PyWinObject_FreeWCHAR(fname); + if (!ret){ + DWORD err=GetLastError(); + if (err!=ERROR_FILE_NOT_FOUND) + return PyWin_SetAPIError("SfcIsFileProtected",err); + } + return PyBool_FromLong(ret); + } %} *************** *** 4829,4832 **** --- 4894,4899 ---- %native (GetFinalPathNameByHandle) pfnpy_GetFinalPathNameByHandle; + %native (SfcGetNextProtectedFile) py_SfcGetNextProtectedFile; + %native (SfcIsFileProtected) py_SfcIsFileProtected; %init %{ *************** *** 4834,4838 **** PyDict_SetItemString(d, "INVALID_HANDLE_VALUE", PyWinLong_FromHANDLE(INVALID_HANDLE_VALUE)); ! for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++) if ((strcmp(pmd->ml_name, "CreateFileTransacted")==0) ||(strcmp(pmd->ml_name, "DeleteFileTransacted")==0) --- 4901,4905 ---- PyDict_SetItemString(d, "INVALID_HANDLE_VALUE", PyWinLong_FromHANDLE(INVALID_HANDLE_VALUE)); ! for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++) if ((strcmp(pmd->ml_name, "CreateFileTransacted")==0) ||(strcmp(pmd->ml_name, "DeleteFileTransacted")==0) *************** *** 4866,4870 **** ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet ) ! pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; HMODULE hmodule; --- 4933,4937 ---- ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet ) ! pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; HMODULE hmodule; *************** *** 4934,4937 **** --- 5001,5012 ---- } + hmodule=GetModuleHandle("sfc.dll"); + if (hmodule==NULL) + hmodule=LoadLibrary("sfc.dll"); + if (hmodule){ + pfnSfcGetNextProtectedFile=(SfcGetNextProtectedFilefunc)GetProcAddress(hmodule, "SfcGetNextProtectedFile"); + pfnSfcIsFileProtected=(SfcIsFileProtectedfunc)GetProcAddress(hmodule, "SfcIsFileProtected"); + } + %} |
From: Roger U. <ru...@us...> - 2007-04-14 07:21:51
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10701/win32/Lib Modified Files: win32con.py Log Message: Add flags for GetFinalPathNameByHandle Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** win32con.py 8 Feb 2007 09:53:23 -0000 1.19 --- win32con.py 14 Apr 2007 07:19:37 -0000 1.20 *************** *** 4935,4936 **** --- 4935,4944 ---- MM_WORKING_SET_MIN_HARD_ENABLE = 4 MM_WORKING_SET_MIN_HARD_DISABLE = 8 + + ## Flags for GetFinalPathNameByHandle + VOLUME_NAME_DOS = 0 + VOLUME_NAME_GUID = 1 + VOLUME_NAME_NT = 2 + VOLUME_NAME_NONE = 4 + FILE_NAME_NORMALIZED = 0 + FILE_NAME_OPENED = 8 |
From: Roger U. <ru...@us...> - 2007-04-07 05:23:32
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9464/Pythonwin Modified Files: win32win.cpp Log Message: Check return status of PyCWnd->GetWindowPlacement. If it fails, garbage can be written to 'Main Window' registry key Index: win32win.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32win.cpp 4 Dec 2006 22:52:24 -0000 1.11 --- win32win.cpp 7 Apr 2007 05:23:31 -0000 1.12 *************** *** 1412,1417 **** // @pyseemfc CWnd|GetWindowPlacement GUI_BGN_SAVE; ! pWnd->GetWindowPlacement( &pment ); GUI_END_SAVE; // @rdesc The result is a tuple of // (flags, showCmd, (minposX, minposY), (maxposX, maxposY), (normalposX, normalposY)) --- 1412,1419 ---- // @pyseemfc CWnd|GetWindowPlacement GUI_BGN_SAVE; ! BOOL bsuccess=pWnd->GetWindowPlacement( &pment ); GUI_END_SAVE; + if (!bsuccess) + return NULL; // @rdesc The result is a tuple of // (flags, showCmd, (minposX, minposY), (maxposX, maxposY), (normalposX, normalposY)) |