pywin32-checkins Mailing List for Python for Windows Extensions (Page 117)
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...> - 2005-02-17 05:47:39
|
Update of /cvsroot/pywin32/pywin32/isapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6004 Modified Files: install.py Log Message: Add support for registering "extension files" with IIS6 Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** install.py 9 Feb 2005 08:56:32 -0000 1.3 --- install.py 17 Feb 2005 05:47:29 -0000 1.4 *************** *** 47,50 **** --- 47,57 ---- Path = None Server = None + # Params that control if/how AddExtensionFile is called. + AddExtensionFile = True + AddExtensionFile_Enabled = True + AddExtensionFile_GroupID = None # defaults to Name + AddExtensionFile_CanDelete = True + AddExtensionFile_Description = None # defaults to Description. + def __init__(self, **kw): self.__dict__.update(kw) *************** *** 66,69 **** --- 73,77 ---- ScriptMapUpdate = "end" # can be 'start', 'end', 'replace' Server = None + def __init__(self, **kw): self.__dict__.update(kw) *************** *** 74,77 **** --- 82,91 ---- Flags = 5 Verbs = "" + # Params that control if/how AddExtensionFile is called. + AddExtensionFile = True + AddExtensionFile_Enabled = True + AddExtensionFile_GroupID = None # defaults to Name + AddExtensionFile_CanDelete = True + AddExtensionFile_Description = None # defaults to Description. def __init__(self, **kw): self.__dict__.update(kw) *************** *** 280,283 **** --- 294,351 ---- log (1, "Deleted Filter: %s" % (filterParams.Name,)) + def _AddExtensionFile(module, def_groupid, def_desc, params, options): + group_id = params.AddExtensionFile_GroupID or def_groupid + desc = params.AddExtensionFile_Description or def_desc + try: + ob = GetObject(_IIS_OBJECT) + ob.AddExtensionFile(module, + params.AddExtensionFile_Enabled, + group_id, + params.AddExtensionFile_CanDelete, + desc) + log(2, "Added extension file '%s' (%s)" % (module, desc)) + except pythoncom.com_error, details: + # IIS5 always fails. Probably should upgrade this to + # complain more loudly if IIS6 fails. + log(2, "Failed to add extension file '%s': %s" % (module, details)) + + def AddExtensionFiles(params, options): + """Register the modules used by the filters/extensions as a trusted + 'extension module' - required by the default IIS6 security settings.""" + # Add each module only once. + added = {} + for vd in params.VirtualDirs: + for smp in vd.ScriptMaps: + if not added.has_key(smp.Module) and smp.AddExtensionFile: + _AddExtensionFile(smp.Module, vd.Name, vd.Description, smp, + options) + added[smp.Module] = True + + for fd in params.Filters: + if not added.has_key(fd.Path) and fd.AddExtensionFile: + _AddExtensionFile(fd.Path, fd.Name, fd.Description, fd, options) + added[fd.Path] = True + + def _DeleteExtensionFileRecord(module, options): + try: + ob = GetObject(_IIS_OBJECT) + ob.DeleteExtensionFileRecord(module) + log(2, "Deleted extension file record for '%s'" % module) + except pythoncom.com_error, details: + log(2, "Failed to remove extension file '%s': %s" % (module, details)) + + def DeleteExtensionFileRecords(params, options): + deleted = {} # only remove each .dll once. + for vd in params.VirtualDirs: + for smp in vd.ScriptMaps: + if not deleted.has_key(smp.Module) and smp.AddExtensionFile: + _DeleteExtensionFileRecord(smp.Module, options) + deleted[smp.Module] = True + + for filter_def in params.Filters: + if not deleted.has_key(filter_def.Path) and filter_def.AddExtensionFile: + _DeleteExtensionFileRecord(filter_def.Path, options) + deleted[filter_def.Path] = True + def CheckLoaderModule(dll_name): suffix = "" *************** *** 319,326 **** --- 387,400 ---- for filter_def in params.Filters: CreateISAPIFilter(filter_def, options) + + AddExtensionFiles(params, options) + _CallHook(params, "PostInstall", options) def Uninstall(params, options): _CallHook(params, "PreRemove", options) + + DeleteExtensionFileRecords(params, options) + for vd in params.VirtualDirs: _CallHook(vd, "PreRemove", options) |
From: Roger U. <ru...@us...> - 2005-02-15 16:39:15
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17028/win32/src/win32print Modified Files: win32print.cpp Log Message: Support extra PRINTER_INFO_* levels in EnumPrinters Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** win32print.cpp 14 Feb 2005 19:31:20 -0000 1.20 --- win32print.cpp 15 Feb 2005 16:39:04 -0000 1.21 *************** *** 101,104 **** --- 101,165 ---- } + static PyObject *PyWinObject_FromPRINTER_INFO(LPBYTE printer_info, DWORD level) + { + switch (level){ + case 1: + PRINTER_INFO_1 *pi1; + pi1=(PRINTER_INFO_1 *)printer_info; + return Py_BuildValue("{s:l,s:s,s:s,s:s}", + "Flags",pi1->Flags, "pDescription",pi1->pDescription, + "pName",pi1->pName, "pComment",pi1->pComment); + case 2: + PRINTER_INFO_2 *pi2; + pi2=(PRINTER_INFO_2 *)printer_info; + return Py_BuildValue("{s:s,s:s,s:s,s:s,s:s,s:s,s:s,s:O&,s:s,s:s,s:s,s:s,s:O&,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", + "pServerName",pi2->pServerName, "pPrinterName",pi2->pPrinterName, + "pShareName",pi2->pShareName, "pPortName",pi2->pPortName, + "pDriverName",pi2->pDriverName, "pComment",pi2->pComment, + "pLocation",pi2->pLocation, "pDevMode",PyWinObject_FromDEVMODE,pi2->pDevMode, + "pSepFile", pi2->pSepFile, "pPrintProcessor",pi2->pPrintProcessor, + "pDatatype",pi2->pDatatype, "pParameters",pi2->pParameters, + "pSecurityDescriptor",PyWinObject_FromSECURITY_DESCRIPTOR,pi2->pSecurityDescriptor, + "Attributes",pi2->Attributes, "Priority",pi2->Priority, + "DefaultPriority",pi2->DefaultPriority, + "StartTime",pi2->StartTime, "UntilTime",pi2->UntilTime, + "Status",pi2->Status, "cJobs",pi2->cJobs, "AveragePPM",pi2->AveragePPM); + case 3: + PRINTER_INFO_3 *pi3; + pi3=(PRINTER_INFO_3 *)printer_info; + return Py_BuildValue("{s:O&}","pSecurityDescriptor",PyWinObject_FromSECURITY_DESCRIPTOR,pi3->pSecurityDescriptor); + case 4: + PRINTER_INFO_4 *pi4; + pi4=(PRINTER_INFO_4 *)printer_info; + return Py_BuildValue("{s:s,s:s,s:l}", + "pPrinterName",pi4->pPrinterName, + "pServerName",pi4->pServerName, + "Attributes",pi4->Attributes); + case 5: + PRINTER_INFO_5 *pi5; + pi5=(PRINTER_INFO_5 *)printer_info; + return Py_BuildValue("{s:s,s:s,s:l,s:l,s:l}", + "pPrinterName",pi5->pPrinterName, + "pPortName",pi5->pPortName, + "Attributes",pi5->Attributes, + "DeviceNotSelectedTimeout",pi5->DeviceNotSelectedTimeout, + "TransmissionRetryTimeout",pi5->TransmissionRetryTimeout); + case 7: + PRINTER_INFO_7 *pi7; + pi7=(PRINTER_INFO_7 *)printer_info; + return Py_BuildValue("{s:s,s:l}","ObjectGUID",pi7->pszObjectGUID, "Action",pi7->dwAction); + case 8: // global printer defaults + PRINTER_INFO_8 *pi8; + pi8=(PRINTER_INFO_8 *)printer_info; + return Py_BuildValue("{s:O&}","pDevMode", PyWinObject_FromDEVMODE, pi8->pDevMode); + case 9: // per user printer defaults + PRINTER_INFO_9 *pi9; + pi9=(PRINTER_INFO_9 *)printer_info; + return Py_BuildValue("{s:O&}","pDevMode", PyWinObject_FromDEVMODE, pi9->pDevMode); + default: + return PyErr_Format(PyExc_NotImplementedError,"Level %d is not supported",level); + } + } + // @pymethod dict|win32print|GetPrinter|Retrieves information about a printer // @rdesc Returns a dictionary containing PRINTER_INFO_* data for level, or *************** *** 111,114 **** --- 172,176 ---- LPBYTE buf=NULL; PyObject *rc=NULL; + PRINTER_INFO_2 *pi2; // @comm Original implementation used level 2 only and returned a tuple // Pass single arg as indicator to use old behaviour for backward compatibility *************** *** 135,211 **** return PyWin_SetAPIError("GetPrinter"); } ! switch (level){ ! case 1: ! PRINTER_INFO_1 *pi1; ! pi1=(PRINTER_INFO_1 *)buf; ! rc=Py_BuildValue("{s:l,s:s,s:s,s:s}", ! "Flags",pi1->Flags, "pDescription",pi1->pDescription, ! "pName",pi1->pName, "pComment",pi1->pComment); ! break; ! case 2: ! PRINTER_INFO_2 *pi2; ! pi2=(PRINTER_INFO_2 *)buf; ! if (backward_compat) ! rc = Py_BuildValue("ssssssszssssziiiiiiii", ! pi2->pServerName, pi2->pPrinterName, pi2->pShareName, pi2->pPortName, ! pi2->pDriverName, pi2->pComment, pi2->pLocation, NULL, pi2->pSepFile, ! pi2->pPrintProcessor, pi2->pDatatype, pi2->pParameters, NULL, ! pi2->Attributes, pi2->Priority, pi2->DefaultPriority, pi2->StartTime, pi2->UntilTime, ! pi2->Status, pi2->cJobs, pi2->AveragePPM); ! else ! rc = Py_BuildValue("{s:s,s:s,s:s,s:s,s:s,s:s,s:s,s:O&,s:s,s:s,s:s,s:s,s:O&,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", ! "pServerName",pi2->pServerName, "pPrinterName",pi2->pPrinterName, ! "pShareName",pi2->pShareName, "pPortName",pi2->pPortName, ! "pDriverName",pi2->pDriverName, "pComment",pi2->pComment, ! "pLocation",pi2->pLocation, "pDevMode",PyWinObject_FromDEVMODE,pi2->pDevMode, ! "pSepFile", pi2->pSepFile, "pPrintProcessor",pi2->pPrintProcessor, ! "pDatatype",pi2->pDatatype, "pParameters",pi2->pParameters, ! "pSecurityDescriptor",PyWinObject_FromSECURITY_DESCRIPTOR,pi2->pSecurityDescriptor, ! "Attributes",pi2->Attributes, "Priority",pi2->Priority, ! "DefaultPriority",pi2->DefaultPriority, ! "StartTime",pi2->StartTime, "UntilTime",pi2->UntilTime, ! "Status",pi2->Status, "cJobs",pi2->cJobs, "AveragePPM",pi2->AveragePPM); ! break; ! case 3: ! PRINTER_INFO_3 *pi3; ! pi3=(PRINTER_INFO_3 *)buf; ! rc = Py_BuildValue("{s:O&}","pSecurityDescriptor",PyWinObject_FromSECURITY_DESCRIPTOR,pi3->pSecurityDescriptor); ! break; ! case 4: ! PRINTER_INFO_4 *pi4; ! pi4=(PRINTER_INFO_4 *)buf; ! rc = Py_BuildValue("{s:s,s:s,s:l}", ! "pPrinterName",pi4->pPrinterName, ! "pServerName",pi4->pServerName, ! "Attributes",pi4->Attributes); ! break; ! case 5: ! PRINTER_INFO_5 *pi5; ! pi5=(PRINTER_INFO_5 *)buf; ! rc = Py_BuildValue("{s:s,s:s,s:l,s:l,s:l}", ! "pPrinterName",pi5->pPrinterName, ! "pPortName",pi5->pPortName, ! "Attributes",pi5->Attributes, ! "DeviceNotSelectedTimeout",pi5->DeviceNotSelectedTimeout, ! "TransmissionRetryTimeout",pi5->TransmissionRetryTimeout); ! break; ! case 7: ! PRINTER_INFO_7 *pi7; ! pi7=(PRINTER_INFO_7 *)buf; ! rc=Py_BuildValue("{s:s,s:l}","ObjectGUID",pi7->pszObjectGUID, "Action",pi7->dwAction); ! break; ! case 8: // global printer defaults ! PRINTER_INFO_8 *pi8; ! pi8=(PRINTER_INFO_8 *)buf; ! rc=Py_BuildValue("{s:O&}","pDevMode", PyWinObject_FromDEVMODE, pi8->pDevMode); ! break; ! case 9: // per user printer defaults ! PRINTER_INFO_9 *pi9; ! pi9=(PRINTER_INFO_9 *)buf; ! rc=Py_BuildValue("{s:O&}","pDevMode", PyWinObject_FromDEVMODE, pi9->pDevMode); ! break; ! default: ! PyErr_Format(PyExc_NotImplementedError,"Level %d is not supported",level); } free(buf); return rc; --- 197,211 ---- return PyWin_SetAPIError("GetPrinter"); } ! if (backward_compat){ ! pi2=(PRINTER_INFO_2 *)buf; ! rc = Py_BuildValue("ssssssszssssziiiiiiii", ! pi2->pServerName, pi2->pPrinterName, pi2->pShareName, pi2->pPortName, ! pi2->pDriverName, pi2->pComment, pi2->pLocation, NULL, pi2->pSepFile, ! pi2->pPrintProcessor, pi2->pDatatype, pi2->pParameters, NULL, ! pi2->Attributes, pi2->Priority, pi2->DefaultPriority, pi2->StartTime, pi2->UntilTime, ! pi2->Status, pi2->cJobs, pi2->AveragePPM); } + else + rc = PyWinObject_FromPRINTER_INFO(buf, level); free(buf); return rc; *************** *** 483,486 **** --- 483,489 ---- // @pymethod tuple|win32print|EnumPrinters|Enumerates printers, print servers, domains and print providers. + // @comm Use Flags=PRINTER_ENUM_NAME, Name=None, Level=1 to enumerate print providers.<nl> + // Use Flags=PRINTER_ENUM_NAME, Name=\\servername, Level=2 or 5 to list printers on another server.<nl> + // See MSDN docs for EnumPrinters for other specific combinations static PyObject *PyEnumPrinters(PyObject *self, PyObject *args) { *************** *** 492,507 **** DWORD printersreturned; char *name= NULL; ! DWORD i; ! if (!PyArg_ParseTuple(args, "i|zi:EnumPrinters", ! &flags, // @pyparm int|flag|| types of printer objects to enumerate (PRINTER_ENUM_*). &name, // @pyparm string|name|None|name of printer object. ! &level)) // @pyparm int|level|1|type of printer info structure (only PRINTER_INFO_1 is supported) ! return NULL; ! if (level != 1) ! { ! PyErr_SetString(PyExc_ValueError, "This information level is not supported"); return NULL; ! } // if call with NULL buffer succeeds, there's nothing to enumerate if (EnumPrinters(flags, name, level, NULL, 0, &bufneeded, &printersreturned)) --- 495,513 ---- DWORD printersreturned; char *name= NULL; ! DWORD i; ! PyObject *ret=NULL, *obprinter_info; ! static size_t printer_info_offset[]={ ! sizeof(PRINTER_INFO_1),sizeof(PRINTER_INFO_2),sizeof(PRINTER_INFO_3), ! sizeof(PRINTER_INFO_4),sizeof(PRINTER_INFO_5),sizeof(PRINTER_INFO_6), ! sizeof(PRINTER_INFO_7),sizeof(PRINTER_INFO_8),sizeof(PRINTER_INFO_9) ! }; if (!PyArg_ParseTuple(args, "i|zi:EnumPrinters", ! &flags, // @pyparm int|flags||types of printer objects to enumerate (combination of PRINTER_ENUM_* constants). &name, // @pyparm string|name|None|name of printer object. ! &level)) // @pyparm int|level|1|type of printer info structure (Levels 1,2,4,5 supported) return NULL; ! if (level<1 || level>9) ! return PyErr_Format(PyExc_ValueError,"Level %d is not supported", level); ! // if call with NULL buffer succeeds, there's nothing to enumerate if (EnumPrinters(flags, name, level, NULL, 0, &bufneeded, &printersreturned)) *************** *** 511,534 **** bufsize= bufneeded; if (NULL == (buf= (BYTE *)malloc(bufsize))) ! { ! PyErr_SetString(PyExc_MemoryError, "Malloc failed."); ! return NULL; ! } if (!EnumPrinters(flags, name, level, buf, bufsize, &bufneeded, &printersreturned)) ! { ! free(buf); ! return PyWin_SetAPIError("EnumPrinters"); ! } ! ! PyObject *ret = PyTuple_New(printersreturned); ! // rdesc The result is a tuple of tuples; one for each printer enumerated. ! // Each individual element is a tuple of (flags, description, name, comment) ! for (i= 0; i < printersreturned; i++) ! { ! PRINTER_INFO_1 *info; ! info= (PRINTER_INFO_1 *)(buf + i * sizeof(PRINTER_INFO_1)); ! PyTuple_SetItem(ret, i, Py_BuildValue("isss", (int)info->Flags, info->pDescription, info->pName, info->pComment)); ! } free(buf); return ret; --- 517,546 ---- bufsize= bufneeded; if (NULL == (buf= (BYTE *)malloc(bufsize))) ! return PyErr_Format(PyExc_MemoryError,"EnumPrinters: unable to allocate %d bytes", bufsize); + // @rdesc Level 1 returns a tuple of tuples for backward compatibility. + // Each individual element is a tuple of (flags, description, name, comment)<nl> + // All other levels return a tuple of dictionaries representing PRINTER_INFO_* structures if (!EnumPrinters(flags, name, level, buf, bufsize, &bufneeded, &printersreturned)) ! PyWin_SetAPIError("EnumPrinters"); ! else{ ! ret=PyTuple_New(printersreturned); ! if (ret!=NULL) ! for (i= 0; i < printersreturned; i++){ ! if (level==1){ ! PRINTER_INFO_1 *info; ! info= (PRINTER_INFO_1 *)(buf + i * sizeof(PRINTER_INFO_1)); ! obprinter_info=Py_BuildValue("isss", (int)info->Flags, info->pDescription, info->pName, info->pComment); ! } ! else ! obprinter_info=PyWinObject_FromPRINTER_INFO(buf + i * printer_info_offset[level-1], level); ! if (obprinter_info==NULL){ ! Py_DECREF(ret); ! ret=NULL; ! break; ! } ! PyTuple_SET_ITEM(ret, i, obprinter_info); ! } ! } free(buf); return ret; |
From: Roger U. <ru...@us...> - 2005-02-14 19:31:30
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9190/win32/src/win32print Modified Files: win32print.cpp Log Message: Add DeletePrinterDriver and DeletePrinterDriverEx Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** win32print.cpp 14 Feb 2005 15:06:52 -0000 1.19 --- win32print.cpp 14 Feb 2005 19:31:20 -0000 1.20 *************** *** 42,45 **** --- 42,47 ---- static GetPrintProcessorDirectoryfunc pfnGetPrintProcessorDirectory=NULL; static GetPrintProcessorDirectoryfunc pfnGetPrinterDriverDirectory=NULL; // same as GetPrintProcessorDirectory + typedef BOOL (WINAPI *DeletePrinterDriverExfunc)(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD); + static DeletePrinterDriverExfunc pfnDeletePrinterDriverEx=NULL; static PyObject *dummy_tuple=NULL; *************** *** 2215,2218 **** --- 2217,2284 ---- } + // @pymethod |win32print|DeletePrinterDriver|Removes the specified printer driver from a server + static PyObject *PyDeletePrinterDriver(PyObject *self, PyObject *args) + { + PyObject *ret=NULL; + PyObject *observername, *obenvironment, *obdrivername; + WCHAR *servername=NULL, *environment=NULL, *drivername=NULL; + // @pyparm string/<o PyUnicode>|Server||Name of print server, use None for local machine + // @pyparm string/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + // @pyparm string/<o PyUnicode>|DriverName||Name of driver to remove + // @comm Does not delete associated driver files - use <om win32print.DeletePrinterDriverEx> if this is required + if (PyArg_ParseTuple(args,"OOO:DeletePrinterDriver", &observername, &obenvironment, &obdrivername) + &&PyWinObject_AsWCHAR(observername, &servername, TRUE) + &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + if (DeletePrinterDriverW(servername, environment, drivername)){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + PyWin_SetAPIError("DeletePrinterDriver"); + + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (drivername!=NULL) + PyWinObject_FreeWCHAR(drivername); + return ret; + } + + // @pymethod |win32print|DeletePrinterDriverEx|Deletes a printer driver and its associated files + static PyObject *PyDeletePrinterDriverEx(PyObject *self, PyObject *args) + { + PyObject *ret=NULL; + PyObject *observername, *obenvironment, *obdrivername; + WCHAR *servername=NULL, *environment=NULL, *drivername=NULL; + DWORD deleteflag, versionflag; + CHECK_PFN(DeletePrinterDriverEx); + // @pyparm string/<o PyUnicode>|Server||Name of print server, use None for local machine + // @pyparm string/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + // @pyparm string/<o PyUnicode>|DriverName||Name of driver to remove + // @pyparm int|DeleteFlag||Combination of DPD_DELETE_SPECIFIC_VERSION, DPD_DELETE_UNUSED_FILES, and DPD_DELETE_ALL_FILES + // @pyparm int|VersionFlag||Can be 0,1,2, or 3. Only used if DPD_DELETE_SPECIFIC_VERSION is specified in DeleteFlag + if (PyArg_ParseTuple(args,"OOOll:DeletePrinterDriverEx", &observername, &obenvironment, &obdrivername, + &deleteflag, &versionflag) + &&PyWinObject_AsWCHAR(observername, &servername, TRUE) + &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + if ((*pfnDeletePrinterDriverEx)(servername, environment, drivername, deleteflag, versionflag)){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + PyWin_SetAPIError("DeletePrinterDriverEx"); + + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (drivername!=NULL) + PyWinObject_FreeWCHAR(drivername); + return ret; + } + /* List of functions exported by this module */ // @module win32print|A module, encapsulating the Windows Win32 API. *************** *** 2259,2262 **** --- 2325,2330 ---- {"AddPrinter", PyAddPrinter, 1}, //@pymeth AddPrinter|Adds a new printer on a server {"DeletePrinter", PyDeletePrinter, 1}, //@pymeth DeletePrinter|Deletes an existing printer + {"DeletePrinterDriver", PyDeletePrinterDriver,1}, //@pymeth DeletePrinterDriver|Deletes the specified driver from a server + {"DeletePrinterDriverEx", PyDeletePrinterDriverEx,1}, //@pymeth DeletePrinterDriverEx|Deletes a printer driver and associated files { NULL } }; *************** *** 2405,2408 **** --- 2473,2481 ---- AddConstant(dict, "PORT_TYPE_NET_ATTACHED",PORT_TYPE_NET_ATTACHED); + // DeletePrinterDriverEx DeleteFlag + AddConstant(dict, "DPD_DELETE_SPECIFIC_VERSION",DPD_DELETE_SPECIFIC_VERSION); + AddConstant(dict, "DPD_DELETE_UNUSED_FILES",DPD_DELETE_UNUSED_FILES); + AddConstant(dict, "DPD_DELETE_ALL_FILES",DPD_DELETE_ALL_FILES); + HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ *************** *** 2418,2421 **** --- 2491,2495 ---- pfnGetPrintProcessorDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrintProcessorDirectoryW"); pfnGetPrinterDriverDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrinterDriverDirectoryW"); + pfnDeletePrinterDriverEx=(DeletePrinterDriverExfunc)GetProcAddress(hmodule,"DeletePrinterDriverExW"); } dummy_tuple=PyTuple_New(0); |
From: Roger U. <ru...@us...> - 2005-02-14 15:07:03
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29969/win32/src/win32print Modified Files: win32print.cpp Log Message: Change EnumPrintProcessors to unicode Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** win32print.cpp 13 Feb 2005 22:42:41 -0000 1.18 --- win32print.cpp 14 Feb 2005 15:06:52 -0000 1.19 *************** *** 1087,1122 **** } ! // @pymethod (string,...)|win32print|EnumPrintProcessors|List printer processors for specified server and environment static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args) { ! PRINTPROCESSOR_INFO_1 *info=NULL; // currently only level that exists LPBYTE buf=NULL; ! char *servername=NULL, *environment=NULL; DWORD level=1, bufsize=0, bytes_needed, return_cnt; ! PyObject *ret, *tuple_item; ! // @pyparm string|Server|None|Name of print server, use None for local machine ! // @pyparm string|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment ! if (!PyArg_ParseTuple(args,"|zz:EnumPrintProcessors", &servername, &environment)) return NULL; ! ! EnumPrintProcessors(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt); if (bytes_needed==0){ PyWin_SetAPIError("EnumPrintProcessors"); ! return NULL; } buf=(LPBYTE)malloc(bytes_needed); if (buf==NULL){ PyErr_Format(PyExc_MemoryError,"EnumPrintProcessors: unable to allocate buffer of size %d", bytes_needed); ! return NULL; } bufsize=bytes_needed; ! if (!EnumPrintProcessors(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)) PyWin_SetAPIError("EnumPrintProcessors"); else{ ret=PyTuple_New(return_cnt); if (ret!=NULL){ ! info=(PRINTPROCESSOR_INFO_1 *)buf; for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ ! tuple_item=PyString_FromString(info->pName); if (tuple_item==NULL){ Py_DECREF(ret); --- 1087,1129 ---- } ! // @pymethod (<o PyUnicode>,...)|win32print|EnumPrintProcessors|List printer processors for specified server and environment static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args) { ! PRINTPROCESSOR_INFO_1W *info=NULL; // currently only level that exists LPBYTE buf=NULL; ! WCHAR *servername=NULL, *environment=NULL; ! PyObject *observername=Py_None, *obenvironment=Py_None; DWORD level=1, bufsize=0, bytes_needed, return_cnt; ! PyObject *ret=NULL, *tuple_item; ! // @pyparm string/<o PyUnicode>|Server|None|Name of print server, use None for local machine ! // @pyparm string/<o PyUnicode>|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment ! if (!PyArg_ParseTuple(args,"|OO:EnumPrintProcessors", &observername, &obenvironment)) return NULL; ! if (!PyWinObject_AsWCHAR(observername, &servername, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(obenvironment, &environment, TRUE)) ! goto done; ! if (EnumPrintProcessorsW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! ret=PyTuple_New(0); ! goto done; ! } if (bytes_needed==0){ PyWin_SetAPIError("EnumPrintProcessors"); ! goto done; } buf=(LPBYTE)malloc(bytes_needed); if (buf==NULL){ PyErr_Format(PyExc_MemoryError,"EnumPrintProcessors: unable to allocate buffer of size %d", bytes_needed); ! goto done; } bufsize=bytes_needed; ! if (!EnumPrintProcessorsW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)) PyWin_SetAPIError("EnumPrintProcessors"); else{ ret=PyTuple_New(return_cnt); if (ret!=NULL){ ! info=(PRINTPROCESSOR_INFO_1W *)buf; for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ ! tuple_item=PyWinObject_FromWCHAR(info->pName); if (tuple_item==NULL){ Py_DECREF(ret); *************** *** 1129,1133 **** } } ! free(buf); return ret; } --- 1136,1146 ---- } } ! done: ! if (buf!=NULL) ! free(buf); ! if (servername!=NULL) ! PyWinObject_FreeWCHAR(servername); ! if (environment!=NULL) ! PyWinObject_FreeWCHAR(environment); return ret; } |
From: Roger U. <ru...@us...> - 2005-02-13 22:43:05
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32655/win32/src/win32print Modified Files: win32print.cpp Log Message: Make Devmode and DataType optional for PRINTER_DEFAULTS Return empty tuple from EnumJobs and EnumPrinters instead of throwing an error when there are none to enumerate Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32print.cpp 11 Feb 2005 16:38:29 -0000 1.17 --- win32print.cpp 13 Feb 2005 22:42:41 -0000 1.18 *************** *** 46,57 **** // @object PRINTER_DEFAULTS|A dictionary representing a PRINTER_DEFAULTS structure ! // @prop string|pDatatype|Data type to be used for print jobs, see <om win32print.EnumPrintProcessorDatatypes>, can be None ! // @prop <o PyDEVMODE>|pDevMode|A PyDEVMODE that specifies default printer parameters, can be None // @prop int|DesiredAccess|An ACCESS_MASK specifying what level of access is needed, eg PRINTER_ACCESS_ADMINISTER, PRINTER_ACCESS_USE BOOL PyWinObject_AsPRINTER_DEFAULTS(PyObject *obdefaults, PPRINTER_DEFAULTS pdefaults) { ! static char *printer_default_keys[]={"pDataType","pDevMode","DesiredAccess",NULL}; ! static char *printer_default_format="zOl"; ! PyObject *obdevmode; if (!PyDict_Check(obdefaults)){ PyErr_SetString(PyExc_TypeError, "PRINTER_DEFAULTS must be a dictionary"); --- 46,57 ---- // @object PRINTER_DEFAULTS|A dictionary representing a PRINTER_DEFAULTS structure ! // @prop string|pDatatype|Data type to be used for print jobs, see <om win32print.EnumPrintProcessorDatatypes>, optional, can be None ! // @prop <o PyDEVMODE>|pDevMode|A PyDEVMODE that specifies default printer parameters, optional, can be None // @prop int|DesiredAccess|An ACCESS_MASK specifying what level of access is needed, eg PRINTER_ACCESS_ADMINISTER, PRINTER_ACCESS_USE BOOL PyWinObject_AsPRINTER_DEFAULTS(PyObject *obdefaults, PPRINTER_DEFAULTS pdefaults) { ! static char *printer_default_keys[]={"DesiredAccess","pDataType","pDevMode",NULL}; ! static char *printer_default_format="l|zO"; ! PyObject *obdevmode=Py_None; if (!PyDict_Check(obdefaults)){ PyErr_SetString(PyExc_TypeError, "PRINTER_DEFAULTS must be a dictionary"); *************** *** 60,64 **** ZeroMemory(pdefaults,sizeof(PRINTER_DEFAULTS)); return PyArg_ParseTupleAndKeywords(dummy_tuple,obdefaults,printer_default_format,printer_default_keys, ! &pdefaults->pDatatype, &obdevmode, &pdefaults->DesiredAccess) &&PyWinObject_AsDEVMODE(obdevmode, &pdefaults->pDevMode, TRUE); } --- 60,64 ---- ZeroMemory(pdefaults,sizeof(PRINTER_DEFAULTS)); return PyArg_ParseTupleAndKeywords(dummy_tuple,obdefaults,printer_default_format,printer_default_keys, ! &pdefaults->DesiredAccess, &pdefaults->pDatatype, &obdevmode) &&PyWinObject_AsDEVMODE(obdevmode, &pdefaults->pDevMode, TRUE); } *************** *** 502,506 **** return NULL; } ! EnumPrinters(flags, name, level, NULL, 0, &bufneeded, &printersreturned); if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("EnumPrinters"); --- 502,508 ---- return NULL; } ! // if call with NULL buffer succeeds, there's nothing to enumerate ! if (EnumPrinters(flags, name, level, NULL, 0, &bufneeded, &printersreturned)) ! return PyTuple_New(0); if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("EnumPrinters"); *************** *** 850,854 **** if ((level < 1)||(level > 3)) return PyErr_Format(PyExc_ValueError, "Information level %d is not supported", level); ! EnumJobs(hprinter, firstjob, nojobs, level, NULL, 0, &bufneeded_size, &jobsreturned); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("EnumJobs"); --- 852,857 ---- if ((level < 1)||(level > 3)) return PyErr_Format(PyExc_ValueError, "Information level %d is not supported", level); ! if (EnumJobs(hprinter, firstjob, nojobs, level, NULL, 0, &bufneeded_size, &jobsreturned)) ! return PyTuple_New(0); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("EnumJobs"); *************** *** 1240,1244 **** goto done; ! EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt); if (bytes_needed==0){ PyWin_SetAPIError("EnumPrinterDrivers"); --- 1243,1250 ---- goto done; ! if (EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! ret=PyTuple_New(0); ! goto done; ! } if (bytes_needed==0){ PyWin_SetAPIError("EnumPrinterDrivers"); *************** *** 1252,1256 **** bufsize=bytes_needed; if (!EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! PyWin_SetAPIError("EnumPrintProcessors"); goto done; } --- 1258,1262 ---- bufsize=bytes_needed; if (!EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! PyWin_SetAPIError("EnumPrinterDrivers"); goto done; } *************** *** 1317,1321 **** di4=(DRIVER_INFO_4W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di4->cVersion, "Name",di4->pName, --- 1323,1327 ---- di4=(DRIVER_INFO_4W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:u,s:u,s:u}", "Version",di4->cVersion, "Name",di4->pName, *************** *** 1325,1329 **** "ConfigFile",di4->pConfigFile, "HelpFile", di4->pHelpFile, ! "DependentFiles",di4->pDependentFiles, "MonitorName",di4->pMonitorName, "DefaultDataType",di4->pDefaultDataType, --- 1331,1335 ---- "ConfigFile",di4->pConfigFile, "HelpFile", di4->pHelpFile, ! "DependentFiles",PyWinObject_FromWCHARMultiple,di4->pDependentFiles, "MonitorName",di4->pMonitorName, "DefaultDataType",di4->pDefaultDataType, *************** *** 1363,1367 **** di6=(DRIVER_INFO_6W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:L,s:u,s:u,s:u}", "Version",di6->cVersion, "Name",di6->pName, --- 1369,1373 ---- di6=(DRIVER_INFO_6W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:u,s:u,s:u,s:O&,s:L,s:u,s:u,s:u}", "Version",di6->cVersion, "Name",di6->pName, *************** *** 1371,1375 **** "ConfigFile",di6->pConfigFile, "HelpFile", di6->pHelpFile, ! "DependentFiles",di6->pDependentFiles, "MonitorName",di6->pMonitorName, "DefaultDataType",di6->pDefaultDataType, --- 1377,1381 ---- "ConfigFile",di6->pConfigFile, "HelpFile", di6->pHelpFile, ! "DependentFiles",PyWinObject_FromWCHARMultiple,di6->pDependentFiles, "MonitorName",di6->pMonitorName, "DefaultDataType",di6->pDefaultDataType, |
From: Mark H. <mha...@us...> - 2005-02-13 12:28:37
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17659 Modified Files: pywin32_postinstall.py Log Message: import win32com.client, so the gen_py directory is created at install time. Index: pywin32_postinstall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/pywin32_postinstall.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pywin32_postinstall.py 10 Oct 2004 22:15:16 -0000 1.17 --- pywin32_postinstall.py 13 Feb 2005 12:28:29 -0000 1.18 *************** *** 308,311 **** --- 308,318 ---- print "*" * 50 + # importing win32com.client ensures the gen_py dir created - not strictly + # necessary to do now, but this makes the installation "complete" + try: + import win32com.client + except ImportError: + # Don't let this error sound fatal + pass print "The pywin32 extensions were successfully installed." |
From: Mark H. <mha...@us...> - 2005-02-13 12:28:06
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17412 Modified Files: MANIFEST.in Log Message: Include the main MSVC6 workspace in the source package. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pywin32/pywin32/MANIFEST.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MANIFEST.in 11 Oct 2004 06:42:45 -0000 1.6 --- MANIFEST.in 13 Feb 2005 12:27:54 -0000 1.7 *************** *** 10,13 **** --- 10,14 ---- include setup_win32all.py include setup.py + include Python and Extensions.dsw # Core win32 stuff include win32/src/*.rc |
From: Mark H. <mha...@us...> - 2005-02-13 12:26:43
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16172 Modified Files: pyscript.py pyscript_rexec.py Log Message: For people silly enough to really want to do it, allow a Python engine even for hosts that request a "safe" engine. pyscript_rexec.py must still be manually run to register such an engine, and it prints an explicit warning Index: pyscript.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/pyscript.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pyscript.py 6 Oct 2004 02:02:11 -0000 1.7 --- pyscript.py 13 Feb 2005 12:26:33 -0000 1.8 *************** *** 261,268 **** def RegisterNamedItem(self, item): if self.rexec_env is None: ! if self.safetyOptions & (axscript.INTERFACESAFE_FOR_UNTRUSTED_DATA | axscript.INTERFACESAFE_FOR_UNTRUSTED_CALLER): ! # Use RExec. ! self.rexec_env = AXRExec(self.globalNameSpaceModule) ! else: # DONT use RExec. self.rexec_env = AXNotRExec(self.globalNameSpaceModule) --- 261,271 ---- def RegisterNamedItem(self, item): if self.rexec_env is None: ! # RExec is not available in 2.2+. If we get here for IE, the ! # user has explicitly run axscript_rexec, so is choosing to ! # take this risk. ! # if self.safetyOptions & (axscript.INTERFACESAFE_FOR_UNTRUSTED_DATA | axscript.INTERFACESAFE_FOR_UNTRUSTED_CALLER): ! # # Use RExec. ! # self.rexec_env = AXRExec(self.globalNameSpaceModule) ! # else: # DONT use RExec. self.rexec_env = AXNotRExec(self.globalNameSpaceModule) Index: pyscript_rexec.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/pyscript_rexec.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pyscript_rexec.py 29 May 2002 01:59:20 -0000 1.2 --- pyscript_rexec.py 13 Feb 2005 12:26:33 -0000 1.3 *************** *** 3,6 **** --- 3,10 ---- # rexec module being neither completely trusted nor private, it is # *not* enabled by default. + # As of Python 2.2, rexec is simply not available - thus, if you use this, + # a HTML page can do almost *anything* at all on your machine. + + # You almost certainly do NOT want to use thus! import pythoncom *************** *** 32,34 **** --- 36,43 ---- if __name__=='__main__': + print "WARNING: By registering this engine, you are giving remote HTML code" + print "the ability to execute *any* code on your system." + print + print "You almost certainly do NOT want to do this." + print "You have been warned, and are doing this at your own (significant) risk" pyscript.Register(PyScriptRExec) |
From: Mark H. <mha...@us...> - 2005-02-13 12:24:34
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14357 Modified Files: __init__.py Log Message: Avoid zero-byte files - comments are cheap :) Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 1 Sep 1999 23:12:39 -0000 1.1 --- __init__.py 13 Feb 2005 12:24:25 -0000 1.2 *************** *** 0 **** --- 1 ---- + # This is a Python package |
From: Mark H. <mha...@us...> - 2005-02-13 12:23:39
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11860 Modified Files: shell.cpp Log Message: Autoduck clarifications. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** shell.cpp 28 Jan 2005 00:24:26 -0000 1.34 --- shell.cpp 13 Feb 2005 12:23:29 -0000 1.35 *************** *** 1521,1526 **** // @comm This method is only available in shell version 4.71. If the // function is not available, a COM Exception with HRESULT=E_NOTIMPL ! // will be raised. If the function fails, a COM Exception with ! // HRESULT=E_FAIL will be raised. HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); PFNSHGetSettings pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(hmod, "SHGetSettings"); --- 1521,1525 ---- // @comm This method is only available in shell version 4.71. If the // function is not available, a COM Exception with HRESULT=E_NOTIMPL ! // will be raised. HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); PFNSHGetSettings pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(hmod, "SHGetSettings"); |
From: Mark H. <mha...@us...> - 2005-02-13 12:16:26
|
Update of /cvsroot/pywin32/pywin32/win32/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5340 Modified Files: regsetup.py Log Message: Nuke the concept of registering a 'module' (should probably nuke this entire script) Index: regsetup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/scripts/regsetup.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** regsetup.py 15 Dec 2002 13:19:38 -0000 1.11 --- regsetup.py 13 Feb 2005 12:16:17 -0000 1.12 *************** *** 98,121 **** raise error, "The file %s can not be located for application %s" % (knownFileName, appName) - def FindRegisteredModule(moduleName, possibleRealNames, searchPaths): - """Find a registered module. - - First place looked is the registry for an existing entry. Then - the searchPaths are searched. - - Returns the full path to the .exe or None if the current registered entry is OK. - """ - import win32api, regutil, string - try: - fname = win32api.RegQueryValue(regutil.GetRootKey(), \ - regutil.BuildDefaultPythonKey() + "\\Modules\\%s" % moduleName) - - if FileExists(fname): - return None # Nothing extra needed - - except win32api.error: - pass - return LocateFileName(possibleRealNames, searchPaths) - def FindPythonExe(exeAlias, possibleRealNames, searchPaths): """Find an exe. --- 98,101 ---- *************** *** 299,315 **** regutil.RegisterNamedPath(appName, string.join(paths,";")) - def FindRegisterModule(modName, actualFileNames, searchPaths): - """Find and Register a module. - - Assumes the core registry setup correctly. - """ - import regutil - try: - fname = FindRegisteredModule(modName, actualFileNames, searchPaths) - if fname is not None: - regutil.RegisterModule(modName, fname) - except error, details: - print "*** ", details - def FindRegisterPythonExe(exeAlias, searchPaths, actualFileNames = None): """Find and Register a Python exe (not necessarily *the* python.exe) --- 279,282 ---- *************** *** 376,380 **** ver_str = hex(sys.hexversion)[2] + hex(sys.hexversion)[4] # pywintypes now has a .py stub - FindRegisterModule("pywintypes", "pywintypes%s%s.dll" % (ver_str, suffix), [".", win32api.GetSystemDirectory()]) regutil.RegisterNamedPath("win32",win32paths) --- 343,346 ---- *************** *** 419,424 **** FindRegisterPackage("pywin", "__init__.py", searchPaths, "Pythonwin") - # FindRegisterModule("win32ui", "win32ui%s.pyd" % suffix, searchPaths) - # FindRegisterModule("win32uiole", "win32uiole%s.pyd" % suffix, searchPaths) regutil.RegisterFileExtensions(defPyIcon=fnamePythonwin+",0", --- 385,388 ---- *************** *** 453,458 **** suffix = IsDebug() ver_str = hex(sys.hexversion)[2] + hex(sys.hexversion)[4] - # pythoncom now has a .py stub - FindRegisterModule("pythoncom", "pythoncom%s%s.dll" % (ver_str, suffix), [win32api.GetSystemDirectory(), '.']) usage = """\ --- 417,420 ---- *************** *** 592,603 **** print "Unregistering Pythonwin" UnregisterPythonwin() - if o=='-m': - import os - print "Registering module",a - FindRegisterModule(os.path.splitext(a)[0],a, searchPaths) - if o=='--umodule': - import os, regutil - print "Unregistering module",a - regutil.UnregisterModule(os.path.splitext(a)[0]) if o=='-p': print "Registering package", a --- 554,557 ---- |
From: Mark H. <mha...@us...> - 2005-02-13 12:09:49
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2399 Modified Files: policy.py Log Message: When we print info about a TypeError in an attempt to be helpful, be even more helpful and indicate what the specific exception is! Index: policy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/policy.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** policy.py 10 Oct 2004 23:06:08 -0000 1.19 --- policy.py 13 Feb 2005 12:09:35 -0000 1.20 *************** *** 584,588 **** # This helps you see what 'func' and 'args' actually is if str(v).find("arguments")>=0: ! print "** TypeError calling function %r(%r)" % (func, args) raise --- 584,588 ---- # This helps you see what 'func' and 'args' actually is if str(v).find("arguments")>=0: ! print "** TypeError %s calling function %r(%r)" % (v, func, args) raise |
From: Mark H. <mha...@us...> - 2005-02-13 12:08:38
|
Update of /cvsroot/pywin32/pywin32/com/win32com/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1776 Added Files: excelRTDServer.py Log Message: An Excel "real time data" provider, contributed by Chris Nilsson. --- NEW FILE: excelRTDServer.py --- """Excel IRTDServer implementation. This module is a functional example of how to implement the IRTDServer interface in python, using the pywin32 extensions. Further details, about this interface and it can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xlrtdfaq.asp """ # Copyright (c) 2003-2004 by Chris Nilsson <ch...@sl...> # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Christopher Nilsson (the author) not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. import pythoncom import win32com.client from win32com import universal from win32com.client import gencache from win32com.server.exception import COMException import threading import datetime # For the example classes... # Typelib info for version 10 - aka Excel XP. # This is the minimum version of excel that we can work with as this is when # Microsoft introduced these interfaces. EXCEL_TLB_GUID = '{00020813-0000-0000-C000-000000000046}' EXCEL_TLB_LCID = 0 EXCEL_TLB_MAJOR = 1 EXCEL_TLB_MINOR = 4 # Import the excel typelib to make sure we've got early-binding going on. # The "ByRef" parameters we use later won't work without this. gencache.EnsureModule(EXCEL_TLB_GUID, EXCEL_TLB_LCID, \ EXCEL_TLB_MAJOR, EXCEL_TLB_MINOR) # Tell pywin to import these extra interfaces. # -- # QUESTION: Why? The interfaces seem to descend from IDispatch, so # I'd have thought, for example, calling callback.UpdateNotify() (on the # IRTDUpdateEvent callback excel gives us) would work without molestation. # But the callback needs to be cast to a "real" IRTDUpdateEvent type. Hmm... # This is where my small knowledge of the pywin framework / COM gets hazy. # -- # Again, we feed in the Excel typelib as the source of these interfaces. universal.RegisterInterfaces(EXCEL_TLB_GUID, EXCEL_TLB_LCID, EXCEL_TLB_MAJOR, EXCEL_TLB_MINOR, ['IRtdServer','IRTDUpdateEvent']) class ExcelRTDServer(object): """Base RTDServer class. Provides most of the features needed to implement the IRtdServer interface. Manages topic adding, removal, and packing up the values for excel. Shouldn't be instanciated directly. Instead, descendant classes should override the CreateTopic() method. Topic objects only need to provide a GetValue() function to play nice here. The values given need to be atomic (eg. string, int, float... etc). Also note: nothing has been done within this class to ensure that we get time to check our topics for updates. I've left that up to the subclass since the ways, and needs, of refreshing your topics will vary greatly. For example, the sample implementation uses a timer thread to wake itself up. Whichever way you choose to do it, your class needs to be able to wake up occaisionally, since excel will never call your class without being asked to first. Excel will communicate with our object in this order: 1. Excel instanciates our object and calls ServerStart, providing us with an IRTDUpdateEvent callback object. 2. Excel calls ConnectData when it wants to subscribe to a new "topic". 3. When we have new data to provide, we call the UpdateNotify method of the callback object we were given. 4. Excel calls our RefreshData method, and receives a 2d SafeArray (row-major) containing the Topic ids in the 1st dim, and the topic values in the 2nd dim. 5. When not needed anymore, Excel will call our DisconnectData to unsubscribe from a topic. 6. When there are no more topics left, Excel will call our ServerTerminate method to kill us. Throughout, at undetermined periods, Excel will call our Heartbeat method to see if we're still alive. It must return a non-zero value, or we'll be killed. NOTE: By default, excel will at most call RefreshData once every 2 seconds. This is a setting that needs to be changed excel-side. To change this, you can set the throttle interval like this in the excel VBA object model: Application.RTD.ThrottleInterval = 1000 ' milliseconds """ _com_interfaces_ = ['IRtdServer'] _public_methods_ = ['ConnectData','DisconnectData','Heartbeat', 'RefreshData','ServerStart','ServerTerminate'] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER #_reg_clsid_ = "# subclass must provide this class attribute" #_reg_desc_ = "# subclass should provide this description" #_reg_progid_ = "# subclass must provide this class attribute" ALIVE = 1 NOT_ALIVE = 0 def __init__(self): """Constructor""" super(ExcelRTDServer, self).__init__() self.IsAlive = self.ALIVE self.__callback = None self.topics = {} def SignalExcel(self): """Use the callback we were given to tell excel new data is available.""" if self.__callback is None: raise COMException(desc="Callback excel provided is Null") self.__callback.UpdateNotify() def ConnectData(self, TopicID, Strings, GetNewValues): """Creates a new topic out of the Strings excel gives us.""" try: self.topics[TopicID] = self.CreateTopic(Strings) except Exception, why: raise COMException(desc=str(why)) GetNewValues = True result = self.topics[TopicID] if result is None: result = "# %s: Waiting for update" % self.__class__.__name__ else: result = result.GetValue() # fire out internal event... self.OnConnectData(TopicID) # GetNewValues as per interface is ByRef, so we need to pass it back too. return result, GetNewValues def DisconnectData(self, TopicID): """Deletes the given topic.""" self.OnDisconnectData(TopicID) if self.topics.has_key(TopicID): self.topics[TopicID] = None del self.topics[TopicID] def Heartbeat(self): """Called by excel to see if we're still here.""" return self.IsAlive def RefreshData(self, TopicCount): """Packs up the topic values. Called by excel when it's ready for an update. Needs to: * Return the current number of topics, via the "ByRef" TopicCount * Return a 2d SafeArray of the topic data. - 1st dim: topic numbers - 2nd dim: topic values We could do some caching, instead of repacking everytime... But this works for demonstration purposes.""" TopicCount = len(self.topics) self.OnRefreshData() # Grow the lists, so we don't need a heap of calls to append() results = [[None] * TopicCount, [None] * TopicCount] # Excel expects a 2-dimensional array. The first dim contains the # topic numbers, and the second contains the values for the topics. # In true VBA style (yuck), we need to pack the array in row-major format, # which looks like: # ( (topic_num1, topic_num2, ..., topic_numN), \ # (topic_val1, topic_val2, ..., topic_valN) ) for idx, topicdata in enumerate(self.topics.iteritems()): topicNum, topic = topicdata results[0][idx] = topicNum results[1][idx] = topic.GetValue() # TopicCount is meant to be passed to us ByRef, so return it as well, as per # the way pywin32 handles ByRef arguments. return tuple(results), TopicCount def ServerStart(self, CallbackObject): """Excel has just created us... We take its callback for later, and set up shop.""" self.IsAlive = self.ALIVE if CallbackObject is None: raise COMException(desc='Excel did not provide a callback') # Need to "cast" the raw PyIDispatch object to the IRTDUpdateEvent interface IRTDUpdateEventKlass = win32com.client.CLSIDToClass.GetClass('{A43788C1-D91B-11D3-8F39-00C04F3651B8}') self.__callback = IRTDUpdateEventKlass(CallbackObject) self.OnServerStart() return self.IsAlive def ServerTerminate(self): """Called when excel no longer wants us.""" self.IsAlive = self.NOT_ALIVE # On next heartbeat, excel will free us self.OnServerTerminate() def CreateTopic(self, TopicStrings=None): """Topic factory method. Subclass must override. Topic objects need to provide: * GetValue() method which returns an atomic value. Will raise NotImplemented if not overridden. """ raise NotImplemented, 'Subclass must implement' # Overridable class events... def OnConnectData(self, TopicID): """Called when a new topic has been created, at excel's request.""" pass def OnDisconnectData(self, TopicID): """Called when a topic is about to be deleted, at excel's request.""" pass def OnRefreshData(self): """Called when excel has requested all current topic data.""" pass def OnServerStart(self): """Called when excel has instanciated us.""" pass def OnServerTerminate(self): """Called when excel is about to destroy us.""" pass class RTDTopic(object): """Base RTD Topic. Only method required by our RTDServer implementation is GetValue(). The others are more for convenience.""" def __init__(self, TopicStrings): super(RTDTopic, self).__init__() self.TopicStrings = TopicStrings self.__currentValue = None self.__dirty = False def Update(self, sender): """Called by the RTD Server. Gives us a chance to check if our topic data needs to be changed (eg. check a file, quiz a database, etc).""" raise NotImplemented, 'subclass must implement' def Reset(self): """Call when this topic isn't considered "dirty" anymore.""" self.__dirty = False def GetValue(self): return self.__currentValue def SetValue(self, value): self.__dirty = True self.__currentValue = value def HasChanged(self): return self.__dirty # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ###################################### # Example classes ###################################### class TimeServer(ExcelRTDServer): """Example Time RTD server. Sends time updates back to excel. example of use, in an excel sheet: =RTD("Python.RTD.TimeServer","","seconds","5") This will cause a timestamp string to fill the cell, and update its value every 5 seconds (or as close as possible depending on how busy excel is). The empty string parameter denotes the com server is running on the local machine. Otherwise, put in the hostname to look on. For more info on this, lookup the Excel help for its "RTD" worksheet function. Obviously, you'd want to wrap this kind of thing in a friendlier VBA function. Also, remember that the RTD function accepts a maximum of 28 arguments! If you want to pass more, you may need to concatenate arguments into one string, and have your topic parse them appropriately. """ # win32com.server setup attributes... # Never copy the _reg_clsid_ value in your own classes! _reg_clsid_ = '{EA7F2CF1-11A2-45E4-B2D5-68E240DB8CB1}' _reg_progid_ = 'Python.RTD.TimeServer' _reg_desc_ = "Python class implementing Excel IRTDServer -- feeds time" # other class attributes... INTERVAL = 0.5 # secs. Threaded timer will wake us up at this interval. def __init__(self): super(TimeServer, self).__init__() # Simply timer thread to ensure we get to update our topics, and # tell excel about any changes. This is a pretty basic and dirty way to # do this. Ideally, there should be some sort of waitable (eg. either win32 # event, socket data event...) and be kicked off by that event triggering. # As soon as we set up shop here, we _must_ return control back to excel. # (ie. we can't block and do our own thing...) self.ticker = threading.Timer(self.INTERVAL, self.Update) def OnServerStart(self): self.ticker.start() def OnServerTerminate(self): if not self.ticker.finished.isSet(): self.ticker.cancel() # Cancel our wake-up thread. Excel has killed us. def Update(self): # Get our wake-up thread ready... self.ticker = threading.Timer(self.INTERVAL, self.Update) try: # Check if any of our topics have new info to pass on if len(self.topics): refresh = False for topic in self.topics.itervalues(): topic.Update(self) if topic.HasChanged(): refresh = True topic.Reset() if refresh: self.SignalExcel() finally: self.ticker.start() # Make sure we get to run again def CreateTopic(self, TopicStrings=None): """Topic factory. Builds a TimeTopic object out of the given TopicStrings.""" return TimeTopic(TopicStrings) class TimeTopic(RTDTopic): """Example topic for example RTD server. Will accept some simple commands to alter how long to delay value updates. Commands: * seconds, delay_in_seconds * minutes, delay_in_minutes * hours, delay_in_hours """ def __init__(self, TopicStrings): super(TimeTopic, self).__init__(TopicStrings) try: self.cmd, self.delay = self.TopicStrings except Exception, E: # We could simply return a "# ERROR" type string as the # topic value, but explosions like this should be able to get handled by # the VBA-side "On Error" stuff. raise ValueError, "Invalid topic strings: %s" % str(TopicStrings) #self.cmd = str(self.cmd) self.delay = float(self.delay) # setup our initial value self.checkpoint = self.timestamp() self.SetValue(str(self.checkpoint)) def timestamp(self): return datetime.datetime.now() def Update(self, sender): now = self.timestamp() delta = now - self.checkpoint refresh = False if self.cmd == "seconds": if delta.seconds >= self.delay: refresh = True elif self.cmd == "minutes": if delta.minutes >= self.delay: refresh = True elif self.cmd == "hours": if delta.hours >= self.delay: refresh = True else: self.SetValue("#Unknown command: " + self.cmd) if refresh: self.SetValue(str(now)) self.checkpoint = now if __name__ == "__main__": import win32com.server.register # Register/Unregister TimeServer example # eg. at the command line: excelrtd.py --register # Then type in an excel cell something like: # =RTD("Python.RTD.TimeServer","","seconds","5") win32com.server.register.UseCommandLine(TimeServer) |
From: Mark H. <mha...@us...> - 2005-02-13 12:05:57
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32119 Modified Files: build.py gencache.py genpy.py makepy.py Log Message: Revert my previous checking that was supposed to fix "[ 1085454 ] Py 2.4 + MS Excel COM --> crash", and provide a real fix - insanely long lines are wrapped (which seems worthwhile even though Python itself is to blame). Thanks to Roger Upole to pointing this out to me. Thus, bForDefault again defaults to False. Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** genpy.py 19 Oct 2004 23:02:56 -0000 1.44 --- genpy.py 13 Feb 2005 12:05:46 -0000 1.45 *************** *** 24,28 **** error = "makepy.error" ! makepy_version = "0.4.92" # Written to generated file. GEN_FULL="full" --- 24,28 ---- error = "makepy.error" ! makepy_version = "0.4.93" # Written to generated file. GEN_FULL="full" *************** *** 230,239 **** print >> stream, "%s_vtables_ = [" % (self.python_name, ) for v in self.vtableFuncs: - chunks = [] names, dispid, desc = v arg_desc = desc[2] arg_reprs = [] for arg in arg_desc: defval = build.MakeDefaultArgRepr(arg) if arg[3] is None: --- 230,250 ---- print >> stream, "%s_vtables_ = [" % (self.python_name, ) for v in self.vtableFuncs: names, dispid, desc = v arg_desc = desc[2] arg_reprs = [] + # more hoops so we don't generate huge lines. + item_num = 0 + print >> stream, "\t((", + for name in names: + print >> stream, repr(name), ",", + item_num = item_num + 1 + if item_num % 5 == 0: + print >> stream, "\n\t\t\t", + print >> stream, "), %d, (%r, %r, [" % (dispid, desc[0], desc[1]), for arg in arg_desc: + item_num = item_num + 1 + if item_num % 5 == 0: + print >> stream, "\n\t\t\t", defval = build.MakeDefaultArgRepr(arg) if arg[3] is None: *************** *** 241,248 **** else: arg3_repr = repr(arg[3]) ! arg_reprs.append((arg[0], arg[1], defval, arg3_repr)) ! desc = desc[:2] + (arg_reprs,) + desc[3:] ! chunks.append("\t(%r, %d, %r)," % (names, dispid, desc)) ! print >> stream, "".join(chunks) print >> stream, "]" print >> stream --- 252,260 ---- else: arg3_repr = repr(arg[3]) ! print >> stream, repr((arg[0], arg[1], defval, arg3_repr)), ",", ! print >> stream, "],", ! for d in desc[3:]: ! print >> stream, repr(d), ",", ! print >> stream, "))," print >> stream, "]" print >> stream *************** *** 340,344 **** fdesc = entry.desc methName = MakeEventMethodName(entry.names[0]) ! print >> stream, '#\tdef ' + methName + '(self' + build.BuildCallList(fdesc, entry.names, "defaultNamedOptArg", "defaultNamedNotOptArg","defaultUnnamedArg", "pythoncom.Missing") + '):' if entry.doc and entry.doc[1]: print >> stream, '#\t\t' + build._safeQuotedString(entry.doc[1]) --- 352,356 ---- fdesc = entry.desc methName = MakeEventMethodName(entry.names[0]) ! print >> stream, '#\tdef ' + methName + '(self' + build.BuildCallList(fdesc, entry.names, "defaultNamedOptArg", "defaultNamedNotOptArg","defaultUnnamedArg", "pythoncom.Missing", is_comment = True) + '):' if entry.doc and entry.doc[1]: print >> stream, '#\t\t' + build._safeQuotedString(entry.doc[1]) Index: makepy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** makepy.py 25 Jan 2005 09:51:23 -0000 1.19 --- makepy.py 13 Feb 2005 12:05:46 -0000 1.20 *************** *** 51,60 **** from win32com.client import NeedUnicodeConversions ! # Python 2.4 will crash on a huge typelib (eg, Excel) if bForDemand is False. ! # That looks like a good excuse to try and move to that more efficient ! # (for large typelibs) scheme. ! # Default value of bForDemand - override this (also in gencache.py) to ! # change the world. ! bForDemandDefault = sys.hexversion >= 0x2040000 error = "makepy.error" --- 51,55 ---- from win32com.client import NeedUnicodeConversions ! bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py error = "makepy.error" *************** *** 185,191 **** sys.exit(1) ! def GenerateFromTypeLibSpec(typelibInfo, file = None, verboseLevel = None, progressInstance = None, bUnicodeToString=NeedUnicodeConversions, bForDemand = bForDemandDefault, bBuildHidden = 1): if verboseLevel is None: ! verboseLevel = 0 if bForDemand and file is not None: raise RuntimeError, "You can only perform a demand-build when the output goes to the gen_py directory" --- 180,190 ---- sys.exit(1) ! def GenerateFromTypeLibSpec(typelibInfo, file = None, verboseLevel = None, progressInstance = None, bUnicodeToString=NeedUnicodeConversions, bQuiet = None, bGUIProgress = None, bForDemand = bForDemandDefault, bBuildHidden = 1): ! if bQuiet is not None or bGUIProgress is not None: ! print "Please dont use the bQuiet or bGUIProgress params" ! print "use the 'verboseLevel', and 'progressClass' params" if verboseLevel is None: ! verboseLevel = 0 # By default, we use a gui, and no verbose level! ! if bForDemand and file is not None: raise RuntimeError, "You can only perform a demand-build when the output goes to the gen_py directory" Index: gencache.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** gencache.py 25 Jan 2005 09:51:23 -0000 1.30 --- gencache.py 13 Feb 2005 12:05:46 -0000 1.31 *************** *** 29,38 **** import operator ! # Python 2.4 will crash on a huge typelib (eg, Excel) if bForDemand is False. ! # That looks like a good excuse to try and move to that more efficient ! # (for large typelibs) scheme. ! # Default value of bForDemand - override this (also in makepy.py) to ! # change the world. ! bForDemandDefault = sys.hexversion >= 0x2040000 # The global dictionary --- 29,33 ---- import operator ! bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also makepy.py # The global dictionary Index: build.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** build.py 9 Apr 2004 11:21:13 -0000 1.27 --- build.py 13 Feb 2005 12:05:46 -0000 1.28 *************** *** 486,491 **** --- 486,497 ---- names[i] = "arg%d" % (i,) names = map(MakePublicAttributeName, names[1:]) + name_num = 0 while len(names) < numArgs: names.append("arg%d" % (len(names),)) + # As per BuildCallList(), avoid huge lines. + # Hack a "\n" at the end of every 5th name - "strides" would be handy + # here but don't exist in 2.2 + for i in range(0, len(names), 5): + names[i] = names[i] + "\n\t\t\t" return "," + string.join(names, ", ") *************** *** 547,551 **** return None ! def BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg): "Builds a Python declaration for a method." # Names[0] is the func name - param names are from 1. --- 553,557 ---- return None ! def BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg, is_comment = False): "Builds a Python declaration for a method." # Names[0] is the func name - param names are from 1. *************** *** 584,587 **** --- 590,602 ---- argName = MakePublicAttributeName(argName) + # insanely long lines with an 'encoding' flag crashes python 2.4.0 + # keep 5 args per line + # This may still fail if the arg names are insane, but that seems + # unlikely. See also _BuildArgList() + if (arg+1) % 5 == 0: + strval = strval + "\n" + if is_comment: + strval = strval + "#" + strval = strval + "\t\t\t" strval = strval + ", " + argName if defArgVal: |
From: Mark H. <mha...@us...> - 2005-02-13 12:01:30
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31294 Modified Files: testShell.py Log Message: Skip a test in 2.2 that uses a 2.3-ism Index: testShell.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testShell.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** testShell.py 26 May 2004 09:40:21 -0000 1.6 --- testShell.py 13 Feb 2005 12:01:20 -0000 1.7 *************** *** 108,111 **** --- 108,114 ---- def testComplex(self): + if sys.hexversion < 0x2030000: + # no kw-args to dict in 2.2 - not worth converting! + return clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}") d = dict(cFileName="foo.txt", |
From: Roger U. <ru...@us...> - 2005-02-12 17:15:08
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15533/com/win32com/src Modified Files: PyStorage.cpp Log Message: Load module handle and function pointers once Index: PyStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyStorage.cpp 10 Feb 2005 02:23:21 -0000 1.7 --- PyStorage.cpp 12 Feb 2005 17:14:51 -0000 1.8 *************** *** 6,10 **** #include "PythonCOM.h" #include "PythonCOMServer.h" ! // @doc --- 6,10 ---- #include "PythonCOM.h" #include "PythonCOMServer.h" ! static HMODULE ole32=NULL; // @doc *************** *** 163,169 **** if (myStgOpenStorageEx==NULL) { // Haven't tried to fetch it yet. myStgOpenStorageEx = (PFNStgOpenStorageEx)-1; ! HMODULE hmodule=GetModuleHandle("Ole32.dll"); ! if (hmodule!=NULL){ ! FARPROC fp = GetProcAddress(hmodule,"StgOpenStorageEx"); if (fp!=NULL) myStgOpenStorageEx=(PFNStgOpenStorageEx)fp; --- 163,170 ---- if (myStgOpenStorageEx==NULL) { // Haven't tried to fetch it yet. myStgOpenStorageEx = (PFNStgOpenStorageEx)-1; ! if (ole32==NULL) ! ole32=GetModuleHandle("Ole32.dll"); ! if (ole32!=NULL){ ! FARPROC fp = GetProcAddress(ole32,"StgOpenStorageEx"); if (fp!=NULL) myStgOpenStorageEx=(PFNStgOpenStorageEx)fp; *************** *** 218,221 **** --- 219,236 ---- FMTID fmtid; PyObject *obfmtid=NULL; + + typedef HRESULT (WINAPI * PFNFmtIdToPropStgName)(const FMTID*, LPOLESTR); + static PFNFmtIdToPropStgName pfnFmtIdToPropStgName=NULL; + static BOOL pfnchecked=FALSE; + if (!pfnchecked){ + if (ole32==NULL) + ole32=GetModuleHandle("Ole32.dll"); + if (ole32!=NULL) + pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(ole32, "FmtIdToPropStgName"); + pfnchecked=TRUE; + } + if (pfnFmtIdToPropStgName==NULL) + return PyErr_Format(PyExc_NotImplementedError,"FmtIdToPropStgName is not available on this platform"); + if (!PyArg_ParseTuple(args, "O:FmtIdToPropStgName", &obfmtid)) return NULL; *************** *** 223,231 **** return NULL; ! typedef HRESULT (WINAPI * PFNFmtIdToPropStgName)(const FMTID*, LPOLESTR); ! HMODULE hmod = GetModuleHandle(TEXT("ole32.dll")); ! PFNFmtIdToPropStgName pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(hmod, "FmtIdToPropStgName"); ! if (pfnFmtIdToPropStgName==NULL) ! return PyCom_BuildPyException(E_NOTIMPL); PY_INTERFACE_PRECALL; err = (*pfnFmtIdToPropStgName)(&fmtid, oszName); --- 238,242 ---- return NULL; ! PY_INTERFACE_PRECALL; err = (*pfnFmtIdToPropStgName)(&fmtid, oszName); *************** *** 245,248 **** --- 256,273 ---- HRESULT err; PyObject *obName=NULL; + + typedef HRESULT (WINAPI * PFNPropStgNameToFmtId)(const LPOLESTR, FMTID*); + static PFNPropStgNameToFmtId pfnPropStgNameToFmtId=NULL; + static BOOL pfnchecked=FALSE; + if (!pfnchecked){ + if (ole32==NULL) + ole32=GetModuleHandle("Ole32.dll"); + if (ole32!=NULL) + pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(ole32, "PropStgNameToFmtId"); + pfnchecked=TRUE; + } + if (pfnPropStgNameToFmtId==NULL) + return PyErr_Format(PyExc_NotImplementedError,"PropStgNameToFmtId is not available on this platform"); + if (!PyArg_ParseTuple(args, "O:PropStgNameToFmtId", &obName)) return NULL; *************** *** 250,258 **** return NULL; - typedef HRESULT (WINAPI * PFNPropStgNameToFmtId)(const LPOLESTR, FMTID*); - HMODULE hmod = GetModuleHandle(TEXT("ole32.dll")); - PFNPropStgNameToFmtId pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(hmod, "PropStgNameToFmtId"); - if (pfnPropStgNameToFmtId==NULL) - return PyCom_BuildPyException(E_NOTIMPL); PY_INTERFACE_PRECALL; err = (*pfnPropStgNameToFmtId)(oszName, &fmtid); --- 275,278 ---- |
From: Roger U. <ru...@us...> - 2005-02-11 16:38:39
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18971/win32/src/win32print Modified Files: win32print.cpp Log Message: Parse out pDependentFiles of DRIVER_INFO_3 Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32print.cpp 10 Feb 2005 13:01:11 -0000 1.16 --- win32print.cpp 11 Feb 2005 16:38:29 -0000 1.17 *************** *** 1186,1189 **** --- 1186,1217 ---- } + PyObject * PyWinObject_FromWCHARMultiple(WCHAR *multistring) + { + PyObject *obelement, *ret=NULL; + // takes a consecutive sequence of NULL terminated unicode strings, + // terminated by an additional NULL and returns a list + int elementlen; + if (multistring==NULL){ + Py_INCREF(Py_None); + return Py_None; + } + ret=PyList_New(0); + if (ret==NULL) + return NULL; + elementlen=wcslen(multistring); + do{ + obelement=PyWinObject_FromWCHAR(multistring, elementlen); + if ((obelement==NULL)||(PyList_Append(ret,obelement)==-1)){ + Py_DECREF(ret); + return NULL; + } + Py_DECREF(obelement); + multistring+=elementlen+1; + elementlen=wcslen(multistring); + } + while (elementlen>0); + return ret; + } + // @pymethod (dict,...)|win32print|EnumPrinterDrivers|Lists installed printer drivers static PyObject *PyEnumPrinterDrivers(PyObject *self, PyObject *args) *************** *** 1266,1270 **** di3=(DRIVER_INFO_3W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di3->cVersion, "Name",di3->pName, --- 1294,1298 ---- di3=(DRIVER_INFO_3W *)buf; for (i=0; i<return_cnt; i++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:u,s:u}", "Version",di3->cVersion, "Name",di3->pName, *************** *** 1274,1279 **** "ConfigFile",di3->pConfigFile, "HelpFile", di3->pHelpFile, ! "DependentFiles",di3->pDependentFiles, ! // ???? pDependentFiles can contain multiple null-terminated strings, need to parse them out ???? "MonitorName",di3->pMonitorName, "DefaultDataType",di3->pDefaultDataType); --- 1302,1306 ---- "ConfigFile",di3->pConfigFile, "HelpFile", di3->pHelpFile, ! "DependentFiles",PyWinObject_FromWCHARMultiple,di3->pDependentFiles, "MonitorName",di3->pMonitorName, "DefaultDataType",di3->pDefaultDataType); *************** *** 1759,1764 **** } // @flag DC_MEDIATYPES|Sequence of ints, DMMEDIA_* constants ! case DC_MEDIATYPES:{ ! // need to add DMMEDIA_STANDARD, DMMEDIA_GLOSSY, DMMEDIA_TRANSPARENCY, DMMEDIA_USER to win32con DWORD *pdword; retsize=sizeof(DWORD); --- 1786,1790 ---- } // @flag DC_MEDIATYPES|Sequence of ints, DMMEDIA_* constants ! case DC_MEDIATYPES:{ DWORD *pdword; retsize=sizeof(DWORD); |
From: Mark H. <mha...@us...> - 2005-02-10 23:57:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19854 Modified Files: .cvsignore Log Message: Ignore generated _winxpthememodule.cpp Index: .cvsignore =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/.cvsignore,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** .cvsignore 22 Jul 2004 08:34:02 -0000 1.3 --- .cvsignore 10 Feb 2005 23:57:30 -0000 1.4 *************** *** 14,15 **** --- 14,16 ---- win32inetmodule.cpp winxpguimodule.cpp + _winxpthememodule.cpp |
From: Mark H. <mha...@us...> - 2005-02-10 23:56:11
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19222 Modified Files: win32gui.i Log Message: Add _TrackMouseEvent and GetDlgCtrlID Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** win32gui.i 30 Jan 2005 13:42:30 -0000 1.56 --- win32gui.i 10 Feb 2005 23:56:02 -0000 1.57 *************** *** 425,428 **** --- 425,442 ---- } + // @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime) + %typemap(python,in) TRACKMOUSEEVENT *INPUT { + TRACKMOUSEEVENT e; + e.cbSize = sizeof e; + if (PyTuple_Check($source)) { + if (PyArg_ParseTuple($source, "lll", &e.dwFlags, &e.hwndTrack, &e.dwHoverTime) == 0) { + return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); + } + $target = &e; + } else { + return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); + } + } + %typemap(python,except) LRESULT { Py_BEGIN_ALLOW_THREADS *************** *** 1750,1753 **** --- 1764,1771 ---- HWND GetDlgItem( HWND hDlg, int nIDDlgItem ); + // @pyswig int|GetDlgCtrlID|Retrieves the identifier of the specified control. + // @pyparm int|hwnd||The handle to the control + HWND GetDlgCtrlID( HWND hwnd); + // @pyswig HWND|SetDlgItemText|Sets the text for a window or control BOOLAPI SetDlgItemText( HWND hDlg, int nIDDlgItem, TCHAR *text ); *************** *** 2964,2967 **** --- 2982,2988 ---- // @pyswig |SetCapture|Captures the mouse for the specified window. BOOLAPI SetCapture(HWND hWnd); + // @pyswig |_TrackMouseEvent|Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. + // @pyparm <o TRACKMOUSEEVENT>|tme|| + BOOLAPI _TrackMouseEvent(TRACKMOUSEEVENT *INPUT); // @pyswig int|ReleaseDC|Releases a device context. |
From: Roger U. <ru...@us...> - 2005-02-10 13:55:51
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4651/win32/Lib Modified Files: win32con.py Log Message: Add DMMEDIA_* constants Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32con.py 6 Feb 2005 07:57:43 -0000 1.10 --- win32con.py 10 Feb 2005 13:55:38 -0000 1.11 *************** *** 3075,3078 **** --- 3075,3084 ---- DMICM_USER = 256 + # DEVMODE.dmMediaType + DMMEDIA_STANDARD = 1 + DMMEDIA_TRANSPARENCY = 2 + DMMEDIA_GLOSSY = 3 + DMMEDIA_USER = 256 + RDH_RECTANGLES = 1 GGO_METRICS = 0 |
From: Roger U. <ru...@us...> - 2005-02-10 13:01:23
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13312/win32/src/win32print Modified Files: win32print.cpp Log Message: Add EnumPorts, EnumMonitors, GetPrintProcessorDirectory, GetPrinterDriverDirectory, AddPrinter, DeletePrinter Also rename function pointers so they can be checked with a macro Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32print.cpp 7 Feb 2005 16:21:05 -0000 1.15 --- win32print.cpp 10 Feb 2005 13:01:11 -0000 1.16 *************** *** 20,37 **** #include <stdarg.h> typedef BOOL (WINAPI *EnumFormsfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); ! static EnumFormsfunc enumforms=NULL; typedef BOOL (WINAPI *AddFormfunc)(HANDLE,DWORD,LPBYTE); ! static AddFormfunc addform=NULL; typedef BOOL (WINAPI *DeleteFormfunc)(HANDLE, LPWSTR); ! static DeleteFormfunc deleteform=NULL; typedef BOOL (WINAPI *GetFormfunc)(HANDLE,LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD); ! static GetFormfunc getform=NULL; typedef BOOL (WINAPI *SetFormfunc)(HANDLE, LPWSTR, DWORD, LPBYTE); ! static SetFormfunc setform=NULL; typedef BOOL (WINAPI *AddJobfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD); ! static AddJobfunc addjob=NULL; typedef BOOL (WINAPI *ScheduleJobfunc)(HANDLE, DWORD); ! static ScheduleJobfunc schedulejob=NULL; static PyObject *dummy_tuple=NULL; --- 20,45 ---- #include <stdarg.h> + #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); + typedef BOOL (WINAPI *EnumFormsfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); ! static EnumFormsfunc pfnEnumForms=NULL; typedef BOOL (WINAPI *AddFormfunc)(HANDLE,DWORD,LPBYTE); ! static AddFormfunc pfnAddForm=NULL; typedef BOOL (WINAPI *DeleteFormfunc)(HANDLE, LPWSTR); ! static DeleteFormfunc pfnDeleteForm=NULL; typedef BOOL (WINAPI *GetFormfunc)(HANDLE,LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD); ! static GetFormfunc pfnGetForm=NULL; typedef BOOL (WINAPI *SetFormfunc)(HANDLE, LPWSTR, DWORD, LPBYTE); ! static SetFormfunc pfnSetForm=NULL; typedef BOOL (WINAPI *AddJobfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD); ! static AddJobfunc pfnAddJob=NULL; typedef BOOL (WINAPI *ScheduleJobfunc)(HANDLE, DWORD); ! static ScheduleJobfunc pfnScheduleJob=NULL; ! typedef BOOL (WINAPI * EnumPortsfunc)(LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); ! static EnumPortsfunc pfnEnumPorts=NULL; ! static EnumPortsfunc pfnEnumMonitors=NULL; // same args as EnumPorts ! typedef BOOL (WINAPI *GetPrintProcessorDirectoryfunc)(LPWSTR,LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD); ! static GetPrintProcessorDirectoryfunc pfnGetPrintProcessorDirectory=NULL; ! static GetPrintProcessorDirectoryfunc pfnGetPrinterDriverDirectory=NULL; // same as GetPrintProcessorDirectory static PyObject *dummy_tuple=NULL; *************** *** 1009,1012 **** --- 1017,1022 ---- // @pymethod None|win32print|SetJob|Pause, cancel, resume, set priority levels on a print job. + // @comm If printer is not opened with at least PRINTER_ACCESS_ADMINISTER access, 'Position' member of + // JOB_INFO_1 and JOB_INFO_2 must be set to JOB_POSITION_UNSPECIFIED static PyObject *PySetJob(PyObject *self, PyObject *args) { *************** *** 1394,1404 **** FORM_INFO_1W *fi1; LPBYTE buf=NULL; ! if (enumforms==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"EnumForms does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args,"l:EnumForms",&hprinter)) return NULL; ! (*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt); if (bytes_needed==0){ PyWin_SetAPIError("EnumForms"); --- 1404,1412 ---- FORM_INFO_1W *fi1; LPBYTE buf=NULL; ! CHECK_PFN(EnumForms); ! if (!PyArg_ParseTuple(args,"l:EnumForms",&hprinter)) return NULL; ! (*pfnEnumForms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt); if (bytes_needed==0){ PyWin_SetAPIError("EnumForms"); *************** *** 1411,1416 **** } bufsize=bytes_needed; ! if (!(*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! PyWin_SetAPIError("EnumPrintProcessors"); goto done; } --- 1419,1424 ---- } bufsize=bytes_needed; ! if (!(*pfnEnumForms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt)){ ! PyWin_SetAPIError("EnumForms"); goto done; } *************** *** 1495,1505 **** FORM_INFO_1W fi1; HANDLE hprinter; ! if (addform==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"AddForm does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args, "lO&:AddForm", &hprinter, PyWinObject_AsFORM_INFO_1, &fi1)) return NULL; ! if (!(*addform)(hprinter, 1, (LPBYTE)&fi1)) return PyWin_SetAPIError("AddForm"); Py_INCREF(Py_None); --- 1503,1511 ---- FORM_INFO_1W fi1; HANDLE hprinter; ! CHECK_PFN(AddForm); ! if (!PyArg_ParseTuple(args, "lO&:AddForm", &hprinter, PyWinObject_AsFORM_INFO_1, &fi1)) return NULL; ! if (!(*pfnAddForm)(hprinter, 1, (LPBYTE)&fi1)) return PyWin_SetAPIError("AddForm"); Py_INCREF(Py_None); *************** *** 1515,1526 **** HANDLE hprinter; WCHAR *formname; ! if (deleteform==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"DeleteForm does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args, "lu:DeleteForm", &hprinter, &formname)) return NULL; ! if (!(*deleteform)(hprinter, formname)) return PyWin_SetAPIError("DeleteForm"); Py_INCREF(Py_None); --- 1521,1529 ---- HANDLE hprinter; WCHAR *formname; ! CHECK_PFN(DeleteForm); if (!PyArg_ParseTuple(args, "lu:DeleteForm", &hprinter, &formname)) return NULL; ! if (!(*pfnDeleteForm)(hprinter, formname)) return PyWin_SetAPIError("DeleteForm"); Py_INCREF(Py_None); *************** *** 1539,1550 **** LPBYTE buf=NULL; PyObject *ret=NULL; - if (getform==NULL){ - PyErr_SetString(PyExc_NotImplementedError,"GetForm does not exist on this version of Windows"); - return NULL; - } if (!PyArg_ParseTuple(args,"lu:GetForm", &hprinter, &formname)) return NULL; ! (*getform)(hprinter, formname, level, buf, bufsize, &bytes_needed); if (bytes_needed==0) return PyWin_SetAPIError("GetForm"); --- 1542,1550 ---- LPBYTE buf=NULL; PyObject *ret=NULL; + CHECK_PFN(GetForm); if (!PyArg_ParseTuple(args,"lu:GetForm", &hprinter, &formname)) return NULL; ! (*pfnGetForm)(hprinter, formname, level, buf, bufsize, &bytes_needed); if (bytes_needed==0) return PyWin_SetAPIError("GetForm"); *************** *** 1553,1557 **** return PyErr_Format(PyExc_MemoryError,"GetForm: Unable to allocate %d bytes",bytes_needed); bufsize=bytes_needed; ! if (!(*getform)(hprinter, formname, level, buf, bufsize, &bytes_needed)) PyWin_SetAPIError("GetForm"); else{ --- 1553,1557 ---- return PyErr_Format(PyExc_MemoryError,"GetForm: Unable to allocate %d bytes",bytes_needed); bufsize=bytes_needed; ! if (!(*pfnGetForm)(hprinter, formname, level, buf, bufsize, &bytes_needed)) PyWin_SetAPIError("GetForm"); else{ *************** *** 1573,1583 **** HANDLE hprinter; WCHAR *formname; ! if (setform==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"SetForm does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args, "luO&:SetForm", &hprinter, &formname, PyWinObject_AsFORM_INFO_1, &fi1)) return NULL; ! if (!(*setform)(hprinter, formname, 1, (LPBYTE)&fi1)) return PyWin_SetAPIError("SetForm"); Py_INCREF(Py_None); --- 1573,1581 ---- HANDLE hprinter; WCHAR *formname; ! CHECK_PFN(SetForm); ! if (!PyArg_ParseTuple(args, "luO&:SetForm", &hprinter, &formname, PyWinObject_AsFORM_INFO_1, &fi1)) return NULL; ! if (!(*pfnSetForm)(hprinter, formname, 1, (LPBYTE)&fi1)) return PyWin_SetAPIError("SetForm"); Py_INCREF(Py_None); *************** *** 1595,1602 **** PyObject *ret=NULL; BOOL bsuccess; ! if (addjob==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"AddJob does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args,"l:AddJob", &hprinter)) --- 1593,1597 ---- PyObject *ret=NULL; BOOL bsuccess; ! CHECK_PFN(AddJob); if (!PyArg_ParseTuple(args,"l:AddJob", &hprinter)) *************** *** 1606,1610 **** if (buf==NULL) return PyErr_Format(PyExc_MemoryError,"AddJob: unable to allocate %d bytes",bufsize); ! bsuccess=(*addjob)(hprinter, level, buf, bufsize, &bytes_needed); if (!bsuccess) if (bytes_needed > bufsize){ --- 1601,1605 ---- if (buf==NULL) return PyErr_Format(PyExc_MemoryError,"AddJob: unable to allocate %d bytes",bufsize); ! bsuccess=(*pfnAddJob)(hprinter, level, buf, bufsize, &bytes_needed); if (!bsuccess) if (bytes_needed > bufsize){ *************** *** 1614,1618 **** return PyErr_Format(PyExc_MemoryError,"AddJob: unable to allocate %d bytes",bytes_needed); bufsize=bytes_needed; ! bsuccess=(*addjob)(hprinter, level, buf, bufsize, &bytes_needed); } if (!bsuccess) --- 1609,1613 ---- return PyErr_Format(PyExc_MemoryError,"AddJob: unable to allocate %d bytes",bytes_needed); bufsize=bytes_needed; ! bsuccess=(*pfnAddJob)(hprinter, level, buf, bufsize, &bytes_needed); } if (!bsuccess) *************** *** 1632,1643 **** HANDLE hprinter; DWORD jobid; ! if (schedulejob==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"ScheduleJob does not exist on this version of Windows"); ! return NULL; ! } if (!PyArg_ParseTuple(args,"ll:ScheduleJob", &hprinter, &jobid)) return NULL; ! if (!(*schedulejob)(hprinter, jobid)){ PyWin_SetAPIError("ScheduleJob"); return NULL; --- 1627,1635 ---- HANDLE hprinter; DWORD jobid; ! CHECK_PFN(ScheduleJob); if (!PyArg_ParseTuple(args,"ll:ScheduleJob", &hprinter, &jobid)) return NULL; ! if (!(*pfnScheduleJob)(hprinter, jobid)){ PyWin_SetAPIError("ScheduleJob"); return NULL; *************** *** 1889,1892 **** --- 1881,2173 ---- } + // @pymethod (dict,...)|win32print|EnumMonitors|Lists installed printer port monitors + static PyObject *PyEnumMonitors(PyObject *self, PyObject *args) + { + // @pyparm str/<o PyUnicode>|Name||Name of server, use None for local machine + // @pyparm int|Level||Level of information to return, 1 and 2 supported + // @rdesc Returns a sequence of dicts representing MONITOR_INFO_* structures depending on level + PyObject *ret=NULL, *tuple_item, *observer_name; + WCHAR *server_name=NULL; + DWORD level, bufsize=0, bytes_needed=0, return_cnt, buf_ind; + LPBYTE buf=NULL; + CHECK_PFN(EnumMonitors); + + if (!PyArg_ParseTuple(args,"Ol:EnumMonitors", &observer_name, &level)) + return NULL; + if (!PyWinObject_AsWCHAR(observer_name, &server_name, TRUE)) + return NULL; + (*pfnEnumMonitors)(server_name, level, buf, bufsize, &bytes_needed, &return_cnt); + if (bytes_needed==0){ + PyWin_SetAPIError("EnumMonitors"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"EnumMonitors: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!(*pfnEnumMonitors)(server_name, level, buf, bufsize, &bytes_needed, &return_cnt)){ + PyWin_SetAPIError("EnumMonitors"); + goto done; + } + ret=PyTuple_New(return_cnt); + if (ret==NULL) + goto done; + switch (level){ + case 1:{ + MONITOR_INFO_1W *mi1; + mi1=(MONITOR_INFO_1W *)buf; + for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=Py_BuildValue("{s:u}","Name",mi1->pName); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + mi1++; + } + break; + } + case 2:{ + MONITOR_INFO_2W *mi2; + mi2=(MONITOR_INFO_2W *)buf; + for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=Py_BuildValue("{s:u,s:u,s:u}", "Name",mi2->pName, + "Environment",mi2->pEnvironment, "DLLName",mi2->pDLLName); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + mi2++; + } + break; + } + default: + PyErr_Format(PyExc_NotImplementedError,"EnumMonitors: Level %d is not supported", level); + } + done: + if (server_name!=NULL) + PyWinObject_FreeWCHAR(server_name); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod (dict,...)|win32print|EnumPorts|Lists printer port on a server + static PyObject *PyEnumPorts(PyObject *self, PyObject *args) + { + // @pyparm str/<o PyUnicode>|Name||Name of server, use None for local machine + // @pyparm int|Level||Level of information to return, 1 and 2 supported + // @rdesc Returns a sequence of dicts representing PORT_INFO_* structures depending on level + PyObject *ret=NULL, *tuple_item, *observer_name; + WCHAR *server_name=NULL; + DWORD level, bufsize=0, bytes_needed=0, return_cnt, buf_ind; + LPBYTE buf=NULL; + CHECK_PFN(EnumPorts); + + if (!PyArg_ParseTuple(args,"Ol:EnumPorts", &observer_name, &level)) + return NULL; + if (!PyWinObject_AsWCHAR(observer_name, &server_name, TRUE)) + return NULL; + (*pfnEnumPorts)(server_name, level, buf, bufsize, &bytes_needed, &return_cnt); + if (bytes_needed==0){ + PyWin_SetAPIError("EnumPorts"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"EnumPorts: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!(*pfnEnumPorts)(server_name, level, buf, bufsize, &bytes_needed, &return_cnt)){ + PyWin_SetAPIError("EnumPorts"); + goto done; + } + ret=PyTuple_New(return_cnt); + if (ret==NULL) + goto done; + switch (level){ + case 1:{ + PORT_INFO_1W *pi1; + pi1=(PORT_INFO_1W *)buf; + for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=Py_BuildValue("{s:u}","Name",pi1->pName); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + pi1++; + } + break; + } + case 2:{ + PORT_INFO_2W *pi2; + pi2=(PORT_INFO_2W *)buf; + for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=Py_BuildValue("{s:u,s:u,s:u,s:l,s:l}", "Name",pi2->pPortName, + "MonitorName",pi2->pMonitorName, "Description",pi2->pDescription, + "PortType",pi2->fPortType, "Reserved",pi2->Reserved); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + pi2++; + } + break; + } + default: + PyErr_Format(PyExc_NotImplementedError,"EnumPorts: Level %d is not supported", level); + } + done: + if (server_name!=NULL) + PyWinObject_FreeWCHAR(server_name); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod <o PyUnicode>|win32print|GetPrintProcessorDirectory|Returns the directory where print processor files reside + static PyObject *PyGetPrintProcessorDirectory(PyObject *self, PyObject *args) + { + // @pyparm str/<o PyUnicode>|Name||Name of server, use None for local machine + // @pyparm str/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + PyObject *ret=NULL, *observer_name=Py_None, *obenvironment=Py_None; + WCHAR *server_name=NULL, *environment=NULL; + DWORD level=1, bufsize=0, bytes_needed=0, bytes_returned=0; + LPBYTE buf=NULL; + CHECK_PFN(GetPrintProcessorDirectory); + + if (!PyArg_ParseTuple(args,"|OO:GetPrintProcessorDirectory", &observer_name, &obenvironment)) + return NULL; + if (!PyWinObject_AsWCHAR(observer_name, &server_name, TRUE)) + return NULL; + if (!PyWinObject_AsWCHAR(obenvironment, &environment, TRUE)) + return NULL; + + (*pfnGetPrintProcessorDirectory)(server_name, environment, level, buf, bufsize, &bytes_needed); + if (bytes_needed==0){ + PyWin_SetAPIError("GetPrintProcessorDirectory"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"GetPrintProcessorDirectory: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!(*pfnGetPrintProcessorDirectory)(server_name, environment, level, buf, bufsize, &bytes_needed)) + PyWin_SetAPIError("GetPrintProcessorDirectory"); + else + ret=PyWinObject_FromWCHAR((WCHAR *)buf); + done: + if (server_name!=NULL) + PyWinObject_FreeWCHAR(server_name); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod <o PyUnicode>|win32print|GetPrinterDriverDirectory|Returns the directory where printer drivers are installed + static PyObject *PyGetPrinterDriverDirectory(PyObject *self, PyObject *args) + { + // @pyparm str/<o PyUnicode>|Name||Name of server, use None for local machine + // @pyparm str/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + PyObject *ret=NULL, *observer_name=Py_None, *obenvironment=Py_None; + WCHAR *server_name=NULL, *environment=NULL; + DWORD level=1, bufsize=0, bytes_needed=0, bytes_returned=0; + LPBYTE buf=NULL; + CHECK_PFN(GetPrinterDriverDirectory); + + if (!PyArg_ParseTuple(args,"|OO:GetPrinterDriverDirectory", &observer_name, &obenvironment)) + return NULL; + if (!PyWinObject_AsWCHAR(observer_name, &server_name, TRUE)) + return NULL; + if (!PyWinObject_AsWCHAR(obenvironment, &environment, TRUE)) + return NULL; + + (*pfnGetPrinterDriverDirectory)(server_name, environment, level, buf, bufsize, &bytes_needed); + if (bytes_needed==0){ + PyWin_SetAPIError("GetPrinterDriverDirectory"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"GetPrinterDriverDirectory: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!(*pfnGetPrinterDriverDirectory)(server_name, environment, level, buf, bufsize, &bytes_needed)) + PyWin_SetAPIError("GetPrinterDriverDirectory"); + else + ret=PyWinObject_FromWCHAR((WCHAR *)buf); + done: + if (server_name!=NULL) + PyWinObject_FreeWCHAR(server_name); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod int|win32print|AddPrinter|Installs a printer on a server + // @rdesc Returns a handle to the new printer + static PyObject *PyAddPrinter(PyObject *self, PyObject *args) + { + HANDLE hprinter; + LPBYTE buf=NULL; + DWORD level; + PyObject *obinfo; + char *server_name; + // @pyparm string|Name||Name of server on which to install printer, None indicates local machine + // @pyparm int|Level||Level of data contained in pPrinter, only level 2 currently supported + // @pyparm dict|pPrinter||PRINTER_INFO_2 dict as returned by <om win32print.GetPrinter> + // @comm pPrinterName, pPortName, pDriverName, and pPrintProcessor are required + if (!PyArg_ParseTuple(args, "zlO:AddPrinter", &server_name, &level, &obinfo)) + return NULL; + if (level!=2){ + PyErr_SetString(PyExc_ValueError,"AddPrinter only accepts level 2"); + return NULL; + } + if (!PyWinObject_AsPRINTER_INFO(level, obinfo, &buf)) + return NULL; + hprinter=AddPrinter(server_name, level, buf); + if (buf!=NULL) + free(buf); + if (hprinter==NULL){ + PyWin_SetAPIError("AddPrinter"); + return NULL; + } + return Py_BuildValue("l",hprinter); + } + + // @pymethod |win32print|DeletePrinter|Deletes an existing printer + // @comm Printer handle must be opened for PRINTER_ACCESS_ADMINISTER + // If there are any pending print jobs for the printer, actual deletion does not happen until they are done + static PyObject *PyDeletePrinter(PyObject *self, PyObject *args) + { + // @pyparm int|hPrinter||Handle to printer as returned by <om win32print.OpenPrinter> or <om win32print.AddPrinter> + HANDLE hprinter; + if (!PyArg_ParseTuple(args, "l:DeletePrinter", &hprinter)) + return NULL; + if (!DeletePrinter(hprinter)){ + PyWin_SetAPIError("DeletePrinter"); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + /* List of functions exported by this module */ // @module win32print|A module, encapsulating the Windows Win32 API. *************** *** 1927,1930 **** --- 2208,2217 ---- {"ScheduleJob", PyScheduleJob, 1}, //@pymeth ScheduleJob|Schedules a spooled job to be printed {"DeviceCapabilities", PyDeviceCapabilities, 1}, //@pymeth DeviceCapabilities|Queries a printer for its capabilities + {"EnumMonitors", PyEnumMonitors, 1}, //@pymeth EnumMonitors|Lists installed printer port monitors + {"EnumPorts", PyEnumPorts, 1}, //@pymeth EnumPorts|Lists printer ports on a server + {"GetPrintProcessorDirectory", PyGetPrintProcessorDirectory, 1}, //@pymeth GetPrintProcessorDirectory|Returns the directory where print processor files reside + {"GetPrinterDriverDirectory", PyGetPrinterDriverDirectory, 1}, //@pymeth GetPrinterDriverDirectory|Returns the directory where printer drivers are installed + {"AddPrinter", PyAddPrinter, 1}, //@pymeth AddPrinter|Adds a new printer on a server + {"DeletePrinter", PyDeletePrinter, 1}, //@pymeth DeletePrinter|Deletes an existing printer { NULL } }; *************** *** 2067,2094 **** AddConstant(dict, "DSPRINT_REPUBLISH",DSPRINT_REPUBLISH); ! FARPROC fp; HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ ! fp=GetProcAddress(hmodule,"EnumFormsW"); ! if (fp!=NULL) ! enumforms=(EnumFormsfunc)fp; ! fp=GetProcAddress(hmodule,"AddFormW"); ! if (fp!=NULL) ! addform=(AddFormfunc)fp; ! fp=GetProcAddress(hmodule,"DeleteFormW"); ! if (fp!=NULL) ! deleteform=(DeleteFormfunc)fp; ! fp=GetProcAddress(hmodule,"GetFormW"); ! if (fp!=NULL) ! getform=(GetFormfunc)fp; ! fp=GetProcAddress(hmodule,"SetFormW"); ! if (fp!=NULL) ! setform=(SetFormfunc)fp; ! fp=GetProcAddress(hmodule,"AddJobW"); ! if (fp!=NULL) ! addjob=(AddJobfunc)fp; ! fp=GetProcAddress(hmodule,"ScheduleJob"); ! if (fp!=NULL) ! schedulejob=(ScheduleJobfunc)fp; } dummy_tuple=PyTuple_New(0); --- 2354,2376 ---- AddConstant(dict, "DSPRINT_REPUBLISH",DSPRINT_REPUBLISH); ! // port types from PORT_INFO_2 ! AddConstant(dict, "PORT_TYPE_WRITE",PORT_TYPE_WRITE); ! AddConstant(dict, "PORT_TYPE_READ",PORT_TYPE_READ); ! AddConstant(dict, "PORT_TYPE_REDIRECTED",PORT_TYPE_REDIRECTED); ! AddConstant(dict, "PORT_TYPE_NET_ATTACHED",PORT_TYPE_NET_ATTACHED); ! HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ ! pfnEnumForms=(EnumFormsfunc)GetProcAddress(hmodule,"EnumFormsW"); ! pfnAddForm=(AddFormfunc)GetProcAddress(hmodule,"AddFormW"); ! pfnDeleteForm=(DeleteFormfunc)GetProcAddress(hmodule,"DeleteFormW"); ! pfnGetForm=(GetFormfunc)GetProcAddress(hmodule,"GetFormW"); ! pfnSetForm=(SetFormfunc)GetProcAddress(hmodule,"SetFormW"); ! pfnAddJob=(AddJobfunc)GetProcAddress(hmodule,"AddJobW"); ! pfnScheduleJob=(ScheduleJobfunc)GetProcAddress(hmodule,"ScheduleJob"); ! pfnEnumPorts=(EnumPortsfunc)GetProcAddress(hmodule,"EnumPortsW"); ! pfnEnumMonitors=(EnumPortsfunc)GetProcAddress(hmodule,"EnumMonitorsW"); ! pfnGetPrintProcessorDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrintProcessorDirectoryW"); ! pfnGetPrinterDriverDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrinterDriverDirectoryW"); } dummy_tuple=PyTuple_New(0); |
From: Trent M. <tm...@us...> - 2005-02-10 02:23:30
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15678 Modified Files: PyStorage.cpp Log Message: Patch to remove a dep on a specific version of ole32.dll that kills "import pythoncom" on WinNT and Win98 (at least). r=mhammond Index: PyStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyStorage.cpp 7 Jan 2005 06:54:55 -0000 1.6 --- PyStorage.cpp 10 Feb 2005 02:23:21 -0000 1.7 *************** *** 222,226 **** if (!PyWinObject_AsIID(obfmtid, &fmtid)) return NULL; ! err=FmtIdToPropStgName(&fmtid, oszName); if (err!=S_OK) return PyCom_BuildPyException(err); --- 222,235 ---- if (!PyWinObject_AsIID(obfmtid, &fmtid)) return NULL; ! ! typedef HRESULT (WINAPI * PFNFmtIdToPropStgName)(const FMTID*, LPOLESTR); ! HMODULE hmod = GetModuleHandle(TEXT("ole32.dll")); ! PFNFmtIdToPropStgName pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(hmod, "FmtIdToPropStgName"); ! if (pfnFmtIdToPropStgName==NULL) ! return PyCom_BuildPyException(E_NOTIMPL); ! PY_INTERFACE_PRECALL; ! err = (*pfnFmtIdToPropStgName)(&fmtid, oszName); ! PY_INTERFACE_POSTCALL; ! if (err!=S_OK) return PyCom_BuildPyException(err); *************** *** 240,244 **** if (!PyWinObject_AsWCHAR(obName,&oszName)) return NULL; ! err=PropStgNameToFmtId(oszName,&fmtid); PyWinObject_FreeWCHAR(oszName); if (err!=S_OK) --- 249,262 ---- if (!PyWinObject_AsWCHAR(obName,&oszName)) return NULL; ! ! typedef HRESULT (WINAPI * PFNPropStgNameToFmtId)(const LPOLESTR, FMTID*); ! HMODULE hmod = GetModuleHandle(TEXT("ole32.dll")); ! PFNPropStgNameToFmtId pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(hmod, "PropStgNameToFmtId"); ! if (pfnPropStgNameToFmtId==NULL) ! return PyCom_BuildPyException(E_NOTIMPL); ! PY_INTERFACE_PRECALL; ! err = (*pfnPropStgNameToFmtId)(oszName, &fmtid); ! PY_INTERFACE_POSTCALL; ! PyWinObject_FreeWCHAR(oszName); if (err!=S_OK) |
From: Mark H. <mha...@us...> - 2005-02-09 08:56:42
|
Update of /cvsroot/pywin32/pywin32/isapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22534 Modified Files: install.py Log Message: * Remove existing virtual directories/filters before installing. * Allow --server to have the server description specified. Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** install.py 28 Jan 2005 04:43:09 -0000 1.2 --- install.py 9 Feb 2005 08:56:32 -0000 1.3 *************** *** 115,124 **** # command-line options get first go. if options.server: ! server = options.server # If the config passed by the caller doesn't specify one, use the default ! elif server_desc is None: server = _IIS_OBJECT+"/1" else: ! server = server_desc # Check it is good. try: --- 115,135 ---- # command-line options get first go. if options.server: ! server_desc = options.server # If the config passed by the caller doesn't specify one, use the default ! if not server_desc: server = _IIS_OBJECT+"/1" else: ! # Assume the user has passed a "server description" - loop over ! # all objects until we find it. ! ob = GetObject(_IIS_OBJECT) ! look = server_desc.lower().strip() ! for sub in ob: ! this_comment = getattr(sub, "ServerComment", "") ! if this_comment.lower().strip() == look: ! server = sub.AdsPath ! break ! else: ! raise ItemNotFound, \ ! "No web sites match the description '%s'" % (server_desc,) # Check it is good. try: *************** *** 150,178 **** keyType = _IIS_WEBVIRTUALDIR _CallHook(params, "PreInstall", options) try: ! newDir = webDir.Create(keyType, name) ! except pythoncom.com_error, details: ! rc = _GetWin32ErrorCode(details) ! if rc != winerror.ERROR_ALREADY_EXISTS: ! raise ! newDir = GetObject(FindPath(options, params.Server, params.Name)) ! log(2, "Updating existing directory '%s'..." % (params.Name,)) ! if newDir.Class != keyType: ! log(2, "but it has the wrong class (is %s, expecting %s) - recreating" \ ! % (newDir.Class, keyType)) ! webDir.Delete(newDir.Class, newDir.Name) ! newDir = webDir.Create(keyType, name) ! else: ! log(2, "Creating new directory '%s'..." % (params.Name,)) ! ! friendly = params.Description or params.Name ! newDir.AppFriendlyName = friendly ! try: ! path = params.Path or webDir.Path ! newDir.Path = path ! except AttributeError: ! pass ! newDir.AppCreate2(params.AppProtection) ! newDir.HttpCustomHeaders = params.Headers log(2, "Setting directory options...") --- 161,190 ---- keyType = _IIS_WEBVIRTUALDIR _CallHook(params, "PreInstall", options) + # We used to go to lengths to keep an existing virtual directory + # in place. However, in some cases the existing directories got + # into a bad state, and an update failed to get them working. + # So we nuke it first. If this is a problem, we could consider adding + # a --keep-existing option. try: ! # Also seen the Class change to a generic IISObject - so nuke ! # *any* existing object, regardless of Class ! existing = GetObject(FindPath(options, params.Server, params.Name)) ! webDir.Delete(existing.Class, existing.Name) ! log(2, "Deleted old directory '%s'" % (params.Name,)) ! except pythoncom.com_error: ! pass ! ! newDir = webDir.Create(keyType, name) ! log(2, "Creating new directory '%s'..." % (params.Name,)) ! ! friendly = params.Description or params.Name ! newDir.AppFriendlyName = friendly ! try: ! path = params.Path or webDir.Path ! newDir.Path = path ! except AttributeError: ! pass ! newDir.AppCreate2(params.AppProtection) ! newDir.HttpCustomHeaders = params.Headers log(2, "Setting directory options...") *************** *** 225,236 **** filters.FilterLoadOrder = "" filters.SetInfo() try: ! newFilter = filters.Create(_IIS_FILTER, filterParams.Name) ! log(2, "Created new ISAPI filter...") ! except pythoncom.com_error, (hr, msg, exc, narg): ! if exc is None or exc[-1]!=-2147024713: ! raise ! log(2, "Updating existing filter '%s'..." % (filterParams.Name,)) ! newFilter = GetObject(server+"/Filters/"+filterParams.Name) assert os.path.isfile(filterParams.Path) newFilter.FilterPath = filterParams.Path --- 237,249 ---- filters.FilterLoadOrder = "" filters.SetInfo() + + # As for VirtualDir, delete an existing one. try: ! filters.Delete(_IIS_FILTER, filterParams.Name) ! log(2, "Deleted old filter '%s'" % (filterParams.Name,)) ! except pythoncom.com_error: ! pass ! newFilter = filters.Create(_IIS_FILTER, filterParams.Name) ! log(2, "Created new ISAPI filter...") assert os.path.isfile(filterParams.Path) newFilter.FilterPath = filterParams.Path |
From: Roger U. <ru...@us...> - 2005-02-09 08:19:02
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7060/win32/src Modified Files: win32apimodule.cpp Log Message: Add SetSysColors Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** win32apimodule.cpp 25 Jan 2005 13:39:21 -0000 1.44 --- win32apimodule.cpp 9 Feb 2005 08:18:52 -0000 1.45 *************** *** 1849,1852 **** --- 1849,1920 ---- } + // @pymethod |win32api|SetSysColors|Changes color of various window elements + static PyObject *PySetSysColors(PyObject *self, PyObject *args) + { + int element_cnt=NULL, element_ind; + int *elements=NULL, *element; + COLORREF *rgbs=NULL, *rgb; + PyObject *obelements, *obelement, *obrgbs, *ret=NULL; + + // @pyparm tuple|Elements||A tuple of ints, COLOR_* constants indicating which window element to change + // @pyparm tuple|RgbValues||An equal length tuple of ints representing RGB values (see <om win32api.RGB>) + if (!PyArg_ParseTuple(args, "OO:SetSysColors", &obelements, &obrgbs)) + return NULL; + if (!PyTuple_Check(obelements)||!PyTuple_Check(obrgbs) + ||((element_cnt=PyTuple_Size(obelements))!=PyTuple_Size(obrgbs))){ + PyErr_SetString(PyExc_TypeError,"SetSysColors: Arguments must be equal length tuples of ints"); + return NULL; + } + + elements=(int *)malloc(element_cnt*sizeof(int)); + if (elements==NULL){ + PyErr_Format(PyExc_MemoryError,"SetSysColors: Unable to allocate array of %d ints",element_cnt); + goto done; + } + rgbs=(COLORREF *)malloc(element_cnt*sizeof(COLORREF)); + if (rgbs==NULL){ + PyErr_Format(PyExc_MemoryError,"SetSysColors: Unable to allocate array of %d COLORREF's",element_cnt); + goto done; + } + + rgb=rgbs; + element=elements; + for (element_ind=0;element_ind<element_cnt;element_ind++){ + obelement=PyTuple_GetItem(obelements,element_ind); + if (obelement==NULL) + goto done; + *element=PyLong_AsLong(obelement); + if ((*element==-1) && PyErr_Occurred()){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"Color element must be an int"); + goto done; + } + obelement=PyTuple_GetItem(obrgbs,element_ind); + if (obelement==NULL) + goto done; + *rgb=PyLong_AsLong(obelement); + if ((*rgb==-1) && PyErr_Occurred()){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"RGB value must be an int"); + goto done; + } + element++; + rgb++; + } + if (!SetSysColors(element_cnt, elements, rgbs)) + PyWin_SetAPIError("SetSysColors"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + + done: + if (elements!=NULL) + free(elements); + if (rgbs!=NULL) + free(rgbs); + return ret; + } + // @pymethod string|win32api|GetSystemDirectory|Returns the path of the Windows system directory. static PyObject * *************** *** 4625,4628 **** --- 4693,4697 ---- {"SetErrorMode", PySetErrorMode, 1}, // @pymeth SetErrorMode|Controls whether the system will handle the specified types of serious errors, or whether the process will handle them. {"SetFileAttributes", PySetFileAttributes,1}, // @pymeth SetFileAttributes|Sets the named file's attributes. + {"SetSysColors", PySetSysColors, 1}, // @pymeth SetSysColors|Changes color of various window elements {"SetSystemTime", PySetSystemTime, 1}, // @pymeth SetSystemTime|Sets the system time. {"SetClassLong", PySetClassLong,1}, // @pymeth SetClassLong|Replaces the specified 32-bit (long) value at the specified offset into the extra class memory for the window. |
From: Roger U. <ru...@us...> - 2005-02-07 16:21:15
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19130/win32/src/win32print Modified Files: win32print.cpp Log Message: Add DeviceCapabilities Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32print.cpp 5 Feb 2005 08:37:50 -0000 1.14 --- win32print.cpp 7 Feb 2005 16:21:05 -0000 1.15 *************** *** 1265,1268 **** --- 1265,1269 ---- "HelpFile", di3->pHelpFile, "DependentFiles",di3->pDependentFiles, + // ???? pDependentFiles can contain multiple null-terminated strings, need to parse them out ???? "MonitorName",di3->pMonitorName, "DefaultDataType",di3->pDefaultDataType); *************** *** 1646,1649 **** --- 1647,1892 ---- } + // @pymethod |win32print|DeviceCapabilities|Queries a printer for its capabilities + static PyObject *PyDeviceCapabilities(PyObject *self, PyObject *args) + { + // @pyparm string|Device||Name of printer + // @pyparm string|Port||Port that printer is using + // @pyparm int|Capability||Type of capability to return - DC_* constant + // @pyparm <o PyDEVMODE>|DEVMODE|None|If present, function returns values from it, otherwise the printer defaults are used + char *device, *port; + WORD capability; + LPTSTR buf=NULL; + PDEVMODE pdevmode; + PyObject *obdevmode=Py_None, *ret=NULL, *tuple_item; + DWORD result, bufsize, bufindex; + static size_t papernamesize=64; // same for DC_PAPERNAMES, DC_MEDIATYPENAMES, DC_MEDIAREADY, DC_FILEDEPENDENCIES + static size_t binnamesize=24; // DC_BINNAMES + static size_t personalitysize=32; // DC_PERSONALITY + size_t retsize; + + if (!PyArg_ParseTuple(args,"ssh|O:DeviceCapabilities", &device, &port, &capability, &obdevmode)) + return NULL; + if (!PyWinObject_AsDEVMODE(obdevmode, &pdevmode, TRUE)) + return NULL; + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1){ + PyWin_SetAPIError("DeviceCapabilities"); + return NULL; + } + // @flagh Capability|Returned value + switch (capability){ + // none of these use the output pointer, just the returned DWORD + case DC_BINADJUST: + case DC_COLLATE: + case DC_COPIES: + case DC_COLORDEVICE: + case DC_DUPLEX: + case DC_DRIVER: + case DC_EMF_COMPLIANT: + case DC_EXTRA: + case DC_FIELDS: + case DC_NUP: + case DC_ORIENTATION: + case DC_PRINTRATE: + case DC_PRINTRATEPPM: + case DC_PRINTRATEUNIT: + case DC_PRINTERMEM: + case DC_SIZE: + case DC_STAPLE: + case DC_TRUETYPE: + case DC_VERSION: + ret=Py_BuildValue("l",result); + break; + // @flag DC_MINEXTENT|Dictionary containing minimum paper width and height + // @flag DC_MAXEXTENT|Dictionary containing maximum paper width and height + case DC_MINEXTENT: + case DC_MAXEXTENT: + ret=Py_BuildValue("{s:h,s:h}","Width",LOWORD(result),"Length",HIWORD(result)); + break; + // @flag DC_ENUMRESOLUTIONS|Sequence of dictionaries containing x and y resolutions in DPI + case DC_ENUMRESOLUTIONS:{ + // output is pairs of LONGs, result indicates number of pairs + PLONG presolutions; + LONG xres, yres; + bufsize=result*2*sizeof(LONG); + buf=(LPTSTR)malloc(bufsize); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"DeviceCapabilites: Unable to allocate %d bytes",bufsize); + break; + } + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1) + break; + ret=PyTuple_New(result); + if (ret==NULL) + break; + presolutions=(PLONG)buf; + for (bufindex=0;bufindex<result;bufindex++){ + xres=*presolutions++; + yres=*presolutions++; + tuple_item=Py_BuildValue("{s:l,s:l}", "xdpi", xres, "ydpi", yres); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret,bufindex,tuple_item); + } + break; + } + // @flag DC_PAPERS|Returns a sequence of ints, DMPAPER_* constants + // @flag DC_BINS|Returns a sequence of ints, DMBIN_* constants + case DC_PAPERS: + case DC_BINS:{ + // output is an array of WORDs + WORD *pword; + retsize=sizeof(WORD); + bufsize=result*retsize; + buf=(LPTSTR)malloc(bufsize); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"DeviceCapabilites: Unable to allocate %d bytes",bufsize); + break; + } + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1) + break; + ret=PyTuple_New(result); + if (ret==NULL) + break; + pword=(WORD *)buf; + for (bufindex=0;bufindex<result;bufindex++){ + tuple_item=Py_BuildValue("h", *pword++); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret,bufindex,tuple_item); + } + break; + } + // @flag DC_MEDIATYPES|Sequence of ints, DMMEDIA_* constants + case DC_MEDIATYPES:{ + // need to add DMMEDIA_STANDARD, DMMEDIA_GLOSSY, DMMEDIA_TRANSPARENCY, DMMEDIA_USER to win32con + DWORD *pdword; + retsize=sizeof(DWORD); + bufsize=result*retsize; + buf=(LPTSTR)malloc(bufsize); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"DeviceCapabilites: Unable to allocate %d bytes",bufsize); + break; + } + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1) + break; + ret=PyTuple_New(result); + if (ret==NULL) + break; + pdword=(DWORD *)buf; + for (bufindex=0;bufindex<result;bufindex++){ + tuple_item=Py_BuildValue("l", *pdword++); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret,bufindex,tuple_item); + } + break; + } + // @flag DC_PAPERNAMES|Sequence of strings + // @flag DC_MEDIATYPENAMES|Sequence of strings + // @flag DC_MEDIAREADY|Sequence of strings + // @flag DC_FILEDEPENDENCIES|Sequence of strings + // @flag DC_PERSONALITY|Sequence of strings + // @flag DC_BINNAMES|Sequence of strings + case DC_PAPERNAMES: + case DC_MEDIATYPENAMES: + case DC_MEDIAREADY: + case DC_FILEDEPENDENCIES: // first 4 return array of 64-char strings + case DC_PERSONALITY: // returns 32-char strings + case DC_BINNAMES:{ // returns array of 24-char strings + char *retname; + if (capability==DC_BINNAMES) + retsize=binnamesize; + else if (capability==DC_PERSONALITY) + retsize=personalitysize; + else + retsize=papernamesize; + bufsize=result*retsize*sizeof(char); + buf=(LPTSTR)malloc(bufsize); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"DeviceCapabilites: Unable to allocate %d bytes",bufsize); + break; + } + ZeroMemory(buf,bufsize); + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1) + break; + ret=PyTuple_New(result); + if (ret==NULL) + break; + retname=(char *)buf; + for (bufindex=0;bufindex<result;bufindex++){ + if (*(retname+retsize-1)==0) + tuple_item=PyString_FromString(retname); + else // won't be null-terminated if string occupies entire space + tuple_item=PyString_FromStringAndSize(retname,retsize); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret,bufindex,tuple_item); + retname+=retsize; + } + break; + } + // @flag DC_PAPERSIZE|Sequence of dicts containing paper sizes, in 1/10 millimeter units + // @flag All others|Output is an int + case DC_PAPERSIZE:{ + // output is an array of POINTs + POINT *ppoint; + retsize=sizeof(POINT); + bufsize=result*retsize; + buf=(LPTSTR)malloc(bufsize); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"DeviceCapabilites: Unable to allocate %d bytes",bufsize); + break; + } + result=DeviceCapabilities(device,port,capability,buf,pdevmode); + if (result==-1) + break; + ret=PyTuple_New(result); + if (ret==NULL) + break; + ppoint=(POINT *)buf; + for (bufindex=0;bufindex<result;bufindex++){ + tuple_item=Py_BuildValue("{s:l,s:l}", "x",ppoint->x, "y",ppoint->y); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret,bufindex,tuple_item); + ppoint++; + } + break; + } + // last 3 are 95/98/Me only + case DC_DATATYPE_PRODUCED: + case DC_MANUFACTURER: + case DC_MODEL: + default: + PyErr_Format(PyExc_NotImplementedError,"Type %d is not supported", capability); + } + + if (result==-1) + PyWin_SetAPIError("DeviceCapabilities"); + if (buf!=NULL) + free(buf); + return ret; + } + /* List of functions exported by this module */ // @module win32print|A module, encapsulating the Windows Win32 API. *************** *** 1683,1686 **** --- 1926,1930 ---- {"AddJob", PyAddJob, 1}, //@pymeth AddJob|Adds a job to be spooled to a printer queue {"ScheduleJob", PyScheduleJob, 1}, //@pymeth ScheduleJob|Schedules a spooled job to be printed + {"DeviceCapabilities", PyDeviceCapabilities, 1}, //@pymeth DeviceCapabilities|Queries a printer for its capabilities { NULL } }; |