pywin32-checkins Mailing List for Python for Windows Extensions (Page 118)
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: Roger U. <ru...@us...> - 2005-02-06 07:57:56
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20819/win32/Lib Modified Files: win32con.py Log Message: Add extra printer and DEVMODE constants, add some comments categorizing them Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32con.py 6 Jan 2005 22:29:15 -0000 1.9 --- win32con.py 6 Feb 2005 07:57:43 -0000 1.10 *************** *** 2847,2850 **** --- 2847,2852 ---- # Generated by h2py from \msvcnt\include\wingdi.h # hacked and split manually by mhammond. + + # DEVMODE.dmFields DM_SPECVERSION = 800 DM_ORIENTATION = 1 *************** *** 2862,2867 **** --- 2864,2897 ---- DM_COLLATE = 32768 DM_FORMNAME = 65536 + DM_LOGPIXELS = 131072 + DM_BITSPERPEL = 262144 + DM_PELSWIDTH = 524288 + DM_PELSHEIGHT = 1048576 + DM_DISPLAYFLAGS = 2097152 + DM_DISPLAYFREQUENCY = 4194304 + DM_ICMMETHOD = 8388608 + DM_ICMINTENT = 16777216 + DM_MEDIATYPE = 33554432 + DM_DITHERTYPE = 67108864 + DM_PANNINGWIDTH = 134217728 + DM_PANNINGHEIGHT = 268435456 + DM_DISPLAYFIXEDOUTPUT = 536870912 + + # DEVMODE.dmOrientation DMORIENT_PORTRAIT = 1 DMORIENT_LANDSCAPE = 2 + + # DEVMODE.dmDisplayOrientation + DMDO_DEFAULT = 0 + DMDO_90 = 1 + DMDO_180 = 2 + DMDO_270 = 3 + + # DEVMODE.dmDisplayFixedOutput + DMDFO_DEFAULT = 0 + DMDFO_STRETCH = 1 + DMDFO_CENTER = 2 + + # DEVMODE.dmPaperSize DMPAPER_LETTER = 1 DMPAPER_LETTERSMALL = 2 *************** *** 2905,2910 **** DMPAPER_FANFOLD_STD_GERMAN = 40 DMPAPER_FANFOLD_LGL_GERMAN = 41 ! DMPAPER_LAST = DMPAPER_FANFOLD_LGL_GERMAN DMPAPER_USER = 256 DMBIN_UPPER = 1 DMBIN_ONLYONE = 1 --- 2935,3019 ---- DMPAPER_FANFOLD_STD_GERMAN = 40 DMPAPER_FANFOLD_LGL_GERMAN = 41 ! DMPAPER_ISO_B4 = 42 ! DMPAPER_JAPANESE_POSTCARD = 43 ! DMPAPER_9X11 = 44 ! DMPAPER_10X11 = 45 ! DMPAPER_15X11 = 46 ! DMPAPER_ENV_INVITE = 47 ! DMPAPER_RESERVED_48 = 48 ! DMPAPER_RESERVED_49 = 49 ! DMPAPER_LETTER_EXTRA = 50 ! DMPAPER_LEGAL_EXTRA = 51 ! DMPAPER_TABLOID_EXTRA = 52 ! DMPAPER_A4_EXTRA = 53 ! DMPAPER_LETTER_TRANSVERSE = 54 ! DMPAPER_A4_TRANSVERSE = 55 ! DMPAPER_LETTER_EXTRA_TRANSVERSE = 56 ! DMPAPER_A_PLUS = 57 ! DMPAPER_B_PLUS = 58 ! DMPAPER_LETTER_PLUS = 59 ! DMPAPER_A4_PLUS = 60 ! DMPAPER_A5_TRANSVERSE = 61 ! DMPAPER_B5_TRANSVERSE = 62 ! DMPAPER_A3_EXTRA = 63 ! DMPAPER_A5_EXTRA = 64 ! DMPAPER_B5_EXTRA = 65 ! DMPAPER_A2 = 66 ! DMPAPER_A3_TRANSVERSE = 67 ! DMPAPER_A3_EXTRA_TRANSVERSE = 68 ! DMPAPER_DBL_JAPANESE_POSTCARD = 69 ! DMPAPER_A6 = 70 ! DMPAPER_JENV_KAKU2 = 71 ! DMPAPER_JENV_KAKU3 = 72 ! DMPAPER_JENV_CHOU3 = 73 ! DMPAPER_JENV_CHOU4 = 74 ! DMPAPER_LETTER_ROTATED = 75 ! DMPAPER_A3_ROTATED = 76 ! DMPAPER_A4_ROTATED = 77 ! DMPAPER_A5_ROTATED = 78 ! DMPAPER_B4_JIS_ROTATED = 79 ! DMPAPER_B5_JIS_ROTATED = 80 ! DMPAPER_JAPANESE_POSTCARD_ROTATED = 81 ! DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82 ! DMPAPER_A6_ROTATED = 83 ! DMPAPER_JENV_KAKU2_ROTATED = 84 ! DMPAPER_JENV_KAKU3_ROTATED = 85 ! DMPAPER_JENV_CHOU3_ROTATED = 86 ! DMPAPER_JENV_CHOU4_ROTATED = 87 ! DMPAPER_B6_JIS = 88 ! DMPAPER_B6_JIS_ROTATED = 89 ! DMPAPER_12X11 = 90 ! DMPAPER_JENV_YOU4 = 91 ! DMPAPER_JENV_YOU4_ROTATED = 92 ! DMPAPER_P16K = 93 ! DMPAPER_P32K = 94 ! DMPAPER_P32KBIG = 95 ! DMPAPER_PENV_1 = 96 ! DMPAPER_PENV_2 = 97 ! DMPAPER_PENV_3 = 98 ! DMPAPER_PENV_4 = 99 ! DMPAPER_PENV_5 = 100 ! DMPAPER_PENV_6 = 101 ! DMPAPER_PENV_7 = 102 ! DMPAPER_PENV_8 = 103 ! DMPAPER_PENV_9 = 104 ! DMPAPER_PENV_10 = 105 ! DMPAPER_P16K_ROTATED = 106 ! DMPAPER_P32K_ROTATED = 107 ! DMPAPER_P32KBIG_ROTATED = 108 ! DMPAPER_PENV_1_ROTATED = 109 ! DMPAPER_PENV_2_ROTATED = 110 ! DMPAPER_PENV_3_ROTATED = 111 ! DMPAPER_PENV_4_ROTATED = 112 ! DMPAPER_PENV_5_ROTATED = 113 ! DMPAPER_PENV_6_ROTATED = 114 ! DMPAPER_PENV_7_ROTATED = 115 ! DMPAPER_PENV_8_ROTATED = 116 ! DMPAPER_PENV_9_ROTATED = 117 ! DMPAPER_PENV_10_ROTATED = 118 ! DMPAPER_LAST = DMPAPER_PENV_10_ROTATED DMPAPER_USER = 256 + + # DEVMODE.dmDefaultSource DMBIN_UPPER = 1 DMBIN_ONLYONE = 1 *************** *** 2922,2941 **** --- 3031,3078 ---- DMBIN_LAST = DMBIN_CASSETTE DMBIN_USER = 256 + + # DEVMODE.dmPrintQuality DMRES_DRAFT = (-1) DMRES_LOW = (-2) DMRES_MEDIUM = (-3) DMRES_HIGH = (-4) + + # DEVMODE.dmColor DMCOLOR_MONOCHROME = 1 DMCOLOR_COLOR = 2 + + # DEVMODE.dmDuplex DMDUP_SIMPLEX = 1 DMDUP_VERTICAL = 2 DMDUP_HORIZONTAL = 3 + + # DEVMODE.dmTTOption DMTT_BITMAP = 1 DMTT_DOWNLOAD = 2 DMTT_SUBDEV = 3 + DMTT_DOWNLOAD_OUTLINE = 4 + + # DEVMODE.dmCollate DMCOLLATE_FALSE = 0 DMCOLLATE_TRUE = 1 + + # DEVMODE.dmDisplayFlags DM_GRAYSCALE = 1 DM_INTERLACED = 2 + + # DEVMODE.dmICMMethod + DMICMMETHOD_NONE = 1 + DMICMMETHOD_SYSTEM = 2 + DMICMMETHOD_DRIVER = 3 + DMICMMETHOD_DEVICE = 4 + DMICMMETHOD_USER = 256 + + # DEVMODE.dmICMIntent + DMICM_SATURATE = 1 + DMICM_CONTRAST = 2 + DMICM_COLORIMETRIC = 3 + DMICM_ABS_COLORIMETRIC = 4 + DMICM_USER = 256 + RDH_RECTANGLES = 1 GGO_METRICS = 0 *************** *** 2955,2958 **** --- 3092,3097 ---- DM_OUT_BUFFER = DM_COPY DM_OUT_DEFAULT = DM_UPDATE + + # DeviceCapabilities types DC_FIELDS = 1 DC_PAPERS = 2 *************** *** 2973,2979 **** --- 3112,3144 ---- DC_ORIENTATION = 17 DC_COPIES = 18 + DC_BINADJUST = 19 + DC_EMF_COMPLIANT = 20 + DC_DATATYPE_PRODUCED = 21 + DC_COLLATE = 22 + DC_MANUFACTURER = 23 + DC_MODEL = 24 + DC_PERSONALITY = 25 + DC_PRINTRATE = 26 + DC_PRINTRATEUNIT = 27 + DC_PRINTERMEM = 28 + DC_MEDIAREADY = 29 + DC_STAPLE = 30 + DC_PRINTRATEPPM = 31 + DC_COLORDEVICE = 32 + DC_NUP = 33 + DC_MEDIATYPENAMES = 34 + DC_MEDIATYPES = 35 + + PRINTRATEUNIT_PPM = 1 + PRINTRATEUNIT_CPS = 2 + PRINTRATEUNIT_LPM = 3 + PRINTRATEUNIT_IPM = 4 + + # TrueType constants DCTT_BITMAP = 1 DCTT_DOWNLOAD = 2 DCTT_SUBDEV = 4 + DCTT_DOWNLOAD_OUTLINE = 8 + CA_NEGATIVE = 1 CA_LOG_FILTER = 2 *************** *** 2992,2995 **** --- 3157,3161 ---- ILLUMINANT_FLUORESCENT = ILLUMINANT_F2 ILLUMINANT_NTSC = ILLUMINANT_C + # Generated by h2py from \msvcnt\include\wingdi.h # hacked and split manually by mhammond. |
From: Roger U. <ru...@us...> - 2005-02-05 08:38:01
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16893/win32/src/win32print Modified Files: win32print.cpp Log Message: Add SetPrinter, extra PRINTER_INFO_* levels for GetPrinter, optional PRINTER_DEFAULTS parm to OpenPrinter so access level can be specified Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** win32print.cpp 3 Feb 2005 05:56:40 -0000 1.13 --- win32print.cpp 5 Feb 2005 08:37:50 -0000 1.14 *************** *** 37,40 **** --- 37,58 ---- static PyObject *dummy_tuple=NULL; + // @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"); + return FALSE; + } + 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); + } // Printer stuff. // @pymethod int|win32print|OpenPrinter|Retrieves a handle to a printer. *************** *** 42,50 **** { char *printer; - if (!PyArg_ParseTuple(args, "s:OpenPrinter", - &printer)) // @pyparm string|printer||printer or print server name. - return NULL; HANDLE handle; ! if (!OpenPrinter(printer, &handle, NULL)) return PyWin_SetAPIError("OpenPrinter"); return Py_BuildValue("i", (int)handle); --- 60,77 ---- { char *printer; HANDLE handle; ! PRINTER_DEFAULTS printer_defaults; ! PRINTER_DEFAULTS *pprinter_defaults=NULL; ! PyObject *obdefaults=Py_None; ! if (!PyArg_ParseTuple(args, "s|O:OpenPrinter", ! &printer, // @pyparm string|printer||printer or print server name. ! &obdefaults)) // @pyparm dict|Defaults|None|<o PRINTER_DEFAULTS> dict, or None ! return NULL; ! if (obdefaults!=Py_None){ ! if (!PyWinObject_AsPRINTER_DEFAULTS(obdefaults, &printer_defaults)) ! return NULL; ! pprinter_defaults=&printer_defaults; ! } ! if (!OpenPrinter(printer, &handle, pprinter_defaults)) return PyWin_SetAPIError("OpenPrinter"); return Py_BuildValue("i", (int)handle); *************** *** 64,96 **** } ! // @pymethod tuple|win32print|GetPrinter|Retrieves information about a printer static PyObject *PyGetPrinter(PyObject *self, PyObject *args) { int handle; ! DWORD needed; ! if (!PyArg_ParseTuple(args, "i:GetPrinter", ! &handle)) // @pyparm int|handle||handle to printer object ! return NULL; // first allocate memory. ! GetPrinter((HANDLE)handle, 2, NULL, 0, &needed ); if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("GetPrinter"); ! PRINTER_INFO_2 *pInfo = (PRINTER_INFO_2 *)malloc(needed); ! if (pInfo==NULL) ! PyWin_SetAPIError("No memory for printer information"); ! if (!GetPrinter((HANDLE)handle, 2, (LPBYTE)pInfo, needed, &needed )) { ! free(pInfo); return PyWin_SetAPIError("GetPrinter"); } ! PyObject *rc = Py_BuildValue("ssssssszssssziiiiiiii", ! pInfo->pServerName, pInfo->pPrinterName, pInfo->pShareName, pInfo->pPortName, ! pInfo->pDriverName, pInfo->pComment, pInfo->pLocation, NULL, pInfo->pSepFile, ! pInfo->pPrintProcessor, pInfo->pDatatype, pInfo->pParameters, NULL, ! pInfo->Attributes, pInfo->Priority, pInfo->DefaultPriority, pInfo->StartTime, pInfo->UntilTime, ! pInfo->Status, pInfo->cJobs, pInfo->AveragePPM); ! free(pInfo); return rc; } // @pymethod None|win32print|AddPrinterConnection|Connects to remote printer --- 91,373 ---- } ! // @pymethod dict|win32print|GetPrinter|Retrieves information about a printer ! // @rdesc Returns a dictionary containing PRINTER_INFO_* data for level, or ! // returns a tuple of PRINTER_INFO_2 data if no level is passed in. static PyObject *PyGetPrinter(PyObject *self, PyObject *args) { int handle; ! DWORD needed, level; ! BOOL backward_compat; ! LPBYTE buf=NULL; ! PyObject *rc=NULL; ! // @comm Original implementation used level 2 only and returned a tuple ! // Pass single arg as indicator to use old behaviour for backward compatibility ! if (PyArg_ParseTuple(args, "i:GetPrinter", ! &handle)){ // @pyparm int|handle||handle to printer object as returned by <om win32print.OpenPrinter> ! backward_compat=TRUE; ! level=2; ! } ! else{ ! PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "ii:GetPrinter", &handle, &level)) // @pyparm int|Level|2|Level of data returned (1,2,3,4,5,7,8,9) ! return NULL; ! backward_compat=FALSE; ! } // first allocate memory. ! GetPrinter((HANDLE)handle, level, NULL, 0, &needed ); if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("GetPrinter"); ! buf=(LPBYTE)malloc(needed); ! if (buf==NULL) ! return PyErr_Format(PyExc_MemoryError,"GetPrinter: Unable to allocate buffer of %d bytes", needed); ! if (!GetPrinter((HANDLE)handle, level, buf, needed, &needed )) { ! free(buf); 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; } + BOOL PyWinObject_AsPRINTER_INFO(DWORD level, PyObject *obinfo, LPBYTE *pbuf) + { + static char *pi2_keys[]={"pServerName","pPrinterName","pShareName","pPortName", + "pDriverName","pComment","pLocation","pDevMode","pSepFile","pPrintProcessor", + "pDatatype","pParameters","pSecurityDescriptor","Attributes","Priority", + "DefaultPriority","StartTime","UntilTime","Status","cJobs","AveragePPM", NULL}; + static char *pi2_format="zzzzzzzOzzzzOllllllll:PRINTER_INFO_2"; + + static char *pi3_keys[]={"pSecurityDescriptor", NULL}; + static char *pi3_format="O:PRINTER_INFO_3"; + + static char *pi4_keys[]={"pPrinterName","pServerName","Attributes", NULL}; + static char *pi4_format="zzl:PRINTER_INFO_4"; + + static char *pi5_keys[]={"pPrinterName","pPortName","Attributes", + "DeviceNotSelectedTimeout","TransmissionRetryTimeout", NULL}; + static char *pi5_format="zzlll:PRINTER_INFO_5"; + + static char *pi7_keys[]={"ObjectGUID","Action", NULL}; + static char *pi7_format="zl:PRINTER_INFO_7"; + + static char *pi8_keys[]={"pDevMode", NULL}; + static char *pi8_format="O:PRINTER_INFO_8"; + + PyObject *obdevmode, *obsecurity_descriptor; + BOOL ret=FALSE; + size_t bufsize; + + *pbuf=NULL; + if (level==0) + if (obinfo==Py_None) + return TRUE; + else{ + *pbuf = (LPBYTE)PyInt_AsLong(obinfo); + if ((*pbuf==(LPBYTE)-1)&&PyErr_Occurred()){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,"Info must be None or a PRINTER_STATUS_* integer when level is 0."); + return FALSE; + } + return TRUE; + } + + if (!PyDict_Check (obinfo)){ + PyErr_Format(PyExc_TypeError, "PRINTER_INFO_%d must be a dictionary", level); + return FALSE; + } + switch(level){ + case 2: + PRINTER_INFO_2 *pi2; + bufsize=sizeof(PRINTER_INFO_2); + if (NULL == (*pbuf= (LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi2=(PRINTER_INFO_2 *)*pbuf; + + if (PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi2_format, pi2_keys, + &pi2->pServerName, &pi2->pPrinterName, &pi2->pShareName, &pi2->pPortName, + &pi2->pDriverName, &pi2->pComment, &pi2->pLocation, &obdevmode, + &pi2->pSepFile, &pi2->pPrintProcessor, &pi2->pDatatype, &pi2->pParameters, + &obsecurity_descriptor, &pi2->Attributes, &pi2->Priority, &pi2->DefaultPriority, + &pi2->StartTime, &pi2->UntilTime, &pi2->Status, &pi2->cJobs, &pi2->AveragePPM) + &&PyWinObject_AsDEVMODE(obdevmode, &pi2->pDevMode,FALSE) + &&PyWinObject_AsSECURITY_DESCRIPTOR(obsecurity_descriptor, &pi2->pSecurityDescriptor, TRUE)) + ret=TRUE; + break; + case 3: + PRINTER_INFO_3 *pi3; + bufsize=sizeof(PRINTER_INFO_3); + if (NULL == (*pbuf=(LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi3=(PRINTER_INFO_3 *)*pbuf; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi3_format, pi3_keys, &obsecurity_descriptor) + &&PyWinObject_AsSECURITY_DESCRIPTOR(obsecurity_descriptor, &pi3->pSecurityDescriptor, FALSE); + break; + case 4: + PRINTER_INFO_4 *pi4; + bufsize=sizeof(PRINTER_INFO_4); + if (NULL == (*pbuf=(LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi4=(PRINTER_INFO_4 *)*pbuf; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi4_format, pi4_keys, + &pi4->pPrinterName, &pi4->pServerName, &pi4->Attributes); + break; + case 5: + PRINTER_INFO_5 *pi5; + bufsize=sizeof(PRINTER_INFO_5); + if (NULL == (*pbuf=(LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi5=(PRINTER_INFO_5 *)*pbuf; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi5_format, pi5_keys, + &pi5->pPrinterName, &pi5->pPortName, &pi5->Attributes, + &pi5->DeviceNotSelectedTimeout, &pi5->TransmissionRetryTimeout); + break; + case 7: + PRINTER_INFO_7 *pi7; + bufsize=sizeof(PRINTER_INFO_7); + if (NULL == (*pbuf=(LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi7=(PRINTER_INFO_7 *)*pbuf; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi7_format, pi7_keys, + &pi7->pszObjectGUID, &pi7->dwAction); + break; + case 8: + case 9: //identical structs, 8 is for global defaults and 9 is for user defaults + PRINTER_INFO_8 *pi8; + bufsize=sizeof(PRINTER_INFO_8); + if (NULL == (*pbuf=(LPBYTE)malloc(bufsize))){ + PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", bufsize); + break; + } + ZeroMemory(*pbuf,bufsize); + pi8=(PRINTER_INFO_8 *)*pbuf; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, pi8_format, pi8_keys,&obdevmode) + &&PyWinObject_AsDEVMODE(obdevmode,&pi8->pDevMode,FALSE); + break; + default: + PyErr_Format(PyExc_NotImplementedError,"Information level %d is not supported", level); + } + if (!ret){ + if ((*pbuf!=NULL) && (level!=0)) + free(*pbuf); + *pbuf=NULL; + } + return ret; + } + + // @pymethod |win32print|SetPrinter|Change printer configuration and status + static PyObject *PySetPrinter(PyObject *self, PyObject *args) + { + HANDLE hprinter; + LPBYTE buf=NULL; + DWORD level, command; + PyObject *obinfo=NULL, *ret=NULL; + // @pyparm int|hPrinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm int|Level||Level of data contained in pPrinter + // @pyparm dict|pPrinter||PRINTER_INFO_* dict as returned by <om win32print.GetPrinter>, can be None if level is 0 + // @pyparm int|Command||Command to send to printer - one of the PRINTER_CONTROL_* constants, or 0 + // @comm If Level is 0 and Command is PRINTER_CONTROL_SET_STATUS, pPrinter should be an integer, + // and is interpreted as the new printer status to set (one of the PRINTER_STATUS_* constants). + if (!PyArg_ParseTuple(args, "llOl:SetPrinter", + &hprinter, &level, &obinfo, &command)) + return NULL; + if (!PyWinObject_AsPRINTER_INFO(level, obinfo, &buf)) + return NULL; + if (!SetPrinter(hprinter, level, buf, command)) + PyWin_SetAPIError("SetPrinter"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if ((level!=0)&&(buf!=NULL)) + free(buf); + return ret; + } // @pymethod None|win32print|AddPrinterConnection|Connects to remote printer *************** *** 654,658 **** PyObject *obdevmode, *obsecurity_descriptor, *obsubmitted=Py_None; - char *err= NULL; BOOL ret=FALSE; --- 931,934 ---- *************** *** 1375,1378 **** --- 1651,1655 ---- {"OpenPrinter", PyOpenPrinter, 1}, // @pymeth OpenPrinter|Retrieves a handle to a printer. {"GetPrinter", PyGetPrinter ,1}, // @pymeth GetPrinter|Retrieves information about a printer + {"SetPrinter", PySetPrinter, 1}, // @pymeth SetPrinter|Changes printer configuration and status {"ClosePrinter", PyClosePrinter, 1}, // @pymeth ClosePrinter|Closes a handle to a printer. {"AddPrinterConnection", PyAddPrinterConnection, 1}, // @pymeth AddPrinterConnection|Connects to a network printer. *************** *** 1488,1491 **** --- 1765,1826 ---- AddConstant(dict, "JOB_EXECUTE",JOB_EXECUTE); + // Command values for SetPrinter + AddConstant(dict, "PRINTER_CONTROL_PAUSE",PRINTER_CONTROL_PAUSE); + AddConstant(dict, "PRINTER_CONTROL_PURGE",PRINTER_CONTROL_PURGE); + AddConstant(dict, "PRINTER_CONTROL_SET_STATUS",PRINTER_CONTROL_SET_STATUS); + AddConstant(dict, "PRINTER_CONTROL_RESUME",PRINTER_CONTROL_RESUME); + + // printer status constants + AddConstant(dict, "PRINTER_STATUS_PAUSED",PRINTER_STATUS_PAUSED); + AddConstant(dict, "PRINTER_STATUS_ERROR",PRINTER_STATUS_ERROR); + AddConstant(dict, "PRINTER_STATUS_PENDING_DELETION",PRINTER_STATUS_PENDING_DELETION); + AddConstant(dict, "PRINTER_STATUS_PAPER_JAM",PRINTER_STATUS_PAPER_JAM); + AddConstant(dict, "PRINTER_STATUS_PAPER_OUT",PRINTER_STATUS_PAPER_OUT); + AddConstant(dict, "PRINTER_STATUS_MANUAL_FEED",PRINTER_STATUS_MANUAL_FEED); + AddConstant(dict, "PRINTER_STATUS_PAPER_PROBLEM",PRINTER_STATUS_PAPER_PROBLEM); + AddConstant(dict, "PRINTER_STATUS_OFFLINE",PRINTER_STATUS_OFFLINE); + AddConstant(dict, "PRINTER_STATUS_IO_ACTIVE",PRINTER_STATUS_IO_ACTIVE); + AddConstant(dict, "PRINTER_STATUS_BUSY",PRINTER_STATUS_BUSY); + AddConstant(dict, "PRINTER_STATUS_PRINTING",PRINTER_STATUS_PRINTING); + AddConstant(dict, "PRINTER_STATUS_OUTPUT_BIN_FULL",PRINTER_STATUS_OUTPUT_BIN_FULL); + AddConstant(dict, "PRINTER_STATUS_NOT_AVAILABLE",PRINTER_STATUS_NOT_AVAILABLE); + AddConstant(dict, "PRINTER_STATUS_WAITING",PRINTER_STATUS_WAITING); + AddConstant(dict, "PRINTER_STATUS_PROCESSING",PRINTER_STATUS_PROCESSING); + AddConstant(dict, "PRINTER_STATUS_INITIALIZING",PRINTER_STATUS_INITIALIZING); + AddConstant(dict, "PRINTER_STATUS_WARMING_UP",PRINTER_STATUS_WARMING_UP); + AddConstant(dict, "PRINTER_STATUS_TONER_LOW",PRINTER_STATUS_TONER_LOW); + AddConstant(dict, "PRINTER_STATUS_NO_TONER",PRINTER_STATUS_NO_TONER); + AddConstant(dict, "PRINTER_STATUS_PAGE_PUNT",PRINTER_STATUS_PAGE_PUNT); + AddConstant(dict, "PRINTER_STATUS_USER_INTERVENTION",PRINTER_STATUS_USER_INTERVENTION); + AddConstant(dict, "PRINTER_STATUS_OUT_OF_MEMORY",PRINTER_STATUS_OUT_OF_MEMORY); + AddConstant(dict, "PRINTER_STATUS_DOOR_OPEN",PRINTER_STATUS_DOOR_OPEN); + AddConstant(dict, "PRINTER_STATUS_SERVER_UNKNOWN",PRINTER_STATUS_SERVER_UNKNOWN); + AddConstant(dict, "PRINTER_STATUS_POWER_SAVE",PRINTER_STATUS_POWER_SAVE); + + // attribute flags for PRINTER_INFO_2 + AddConstant(dict, "PRINTER_ATTRIBUTE_QUEUED",PRINTER_ATTRIBUTE_QUEUED); + AddConstant(dict, "PRINTER_ATTRIBUTE_DIRECT",PRINTER_ATTRIBUTE_DIRECT); + AddConstant(dict, "PRINTER_ATTRIBUTE_DEFAULT",PRINTER_ATTRIBUTE_DEFAULT); + AddConstant(dict, "PRINTER_ATTRIBUTE_SHARED",PRINTER_ATTRIBUTE_SHARED); + AddConstant(dict, "PRINTER_ATTRIBUTE_NETWORK",PRINTER_ATTRIBUTE_NETWORK); + AddConstant(dict, "PRINTER_ATTRIBUTE_HIDDEN",PRINTER_ATTRIBUTE_HIDDEN); + AddConstant(dict, "PRINTER_ATTRIBUTE_LOCAL",PRINTER_ATTRIBUTE_LOCAL); + AddConstant(dict, "PRINTER_ATTRIBUTE_ENABLE_DEVQ",PRINTER_ATTRIBUTE_ENABLE_DEVQ); + AddConstant(dict, "PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS",PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS); + AddConstant(dict, "PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST",PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST); + AddConstant(dict, "PRINTER_ATTRIBUTE_WORK_OFFLINE",PRINTER_ATTRIBUTE_WORK_OFFLINE); + AddConstant(dict, "PRINTER_ATTRIBUTE_ENABLE_BIDI",PRINTER_ATTRIBUTE_ENABLE_BIDI); + AddConstant(dict, "PRINTER_ATTRIBUTE_RAW_ONLY",PRINTER_ATTRIBUTE_RAW_ONLY); + AddConstant(dict, "PRINTER_ATTRIBUTE_PUBLISHED",PRINTER_ATTRIBUTE_PUBLISHED); + AddConstant(dict, "PRINTER_ATTRIBUTE_FAX",PRINTER_ATTRIBUTE_FAX); + AddConstant(dict, "PRINTER_ATTRIBUTE_TS",PRINTER_ATTRIBUTE_TS); + + // directory service contants for Action member of PRINTER_INFO_7 + AddConstant(dict, "DSPRINT_PUBLISH",DSPRINT_PUBLISH); + AddConstant(dict, "DSPRINT_UNPUBLISH",DSPRINT_UNPUBLISH); + AddConstant(dict, "DSPRINT_UPDATE",DSPRINT_UPDATE); + AddConstant(dict, "DSPRINT_PENDING",DSPRINT_PENDING); + AddConstant(dict, "DSPRINT_REPUBLISH",DSPRINT_REPUBLISH); + FARPROC fp; HMODULE hmodule=LoadLibrary("winspool.drv"); |
From: Roger U. <ru...@us...> - 2005-02-03 05:56:52
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16080/win32/src/win32print Modified Files: win32print.cpp Log Message: JOB_INFO_2 and JOB_INFO_3 support for GetJob and SetJob Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32print.cpp 1 Feb 2005 13:37:24 -0000 1.12 --- win32print.cpp 3 Feb 2005 05:56:40 -0000 1.13 *************** *** 472,502 **** PyObject *JobtoPy(DWORD level, LPBYTE buf) { ! if (level != 1) ! return NULL; ! ! JOB_INFO_1 *job1= (JOB_INFO_1 *)buf; SYSTEMTIME localSubmitted; ! ! SystemTimeToTzSpecificLocalTime(NULL, &(job1->Submitted), &localSubmitted); ! PyObject *pylocalsubmitted= new PyTime(localSubmitted); ! PyObject *ret= Py_BuildValue("{s:i, s:s, s:s, s:s, s:s, s:s, s:s, s:i, s:i, s:i, s:i, s:i, s:O}", ! "JobID", job1->JobId, ! "pPrinterName", job1->pPrinterName, ! "pMachineName", job1->pMachineName, ! "pUserName", job1->pUserName, ! "pDocument", job1->pDocument, ! "pDatatype", job1->pDatatype, ! "pStatus", job1->pStatus, ! "Status", job1->Status, ! "Priority", job1->Priority, ! "Position", job1->Position, ! "TotalPages", job1->TotalPages, ! "PagesPrinted", job1->PagesPrinted, ! "Submitted", pylocalsubmitted); ! Py_XDECREF(pylocalsubmitted); ! return ret; } // @pymethod tuple|win32print|EnumJobs|Enumerates print jobs on specified printer. static PyObject *PyEnumJobs(PyObject *self, PyObject *args) { --- 472,548 ---- PyObject *JobtoPy(DWORD level, LPBYTE buf) { ! JOB_INFO_1 *job1; ! JOB_INFO_2 *job2; ! JOB_INFO_3 *job3; SYSTEMTIME localSubmitted; ! PyObject *pylocalsubmitted, *ret; ! switch (level){ ! case 1:{ ! job1= (JOB_INFO_1 *)buf; ! SystemTimeToTzSpecificLocalTime(NULL, &(job1->Submitted), &localSubmitted); ! pylocalsubmitted= new PyTime(localSubmitted); ! ret= Py_BuildValue("{s:i, s:s, s:s, s:s, s:s, s:s, s:s, s:i, s:i, s:i, s:i, s:i, s:O}", ! "JobId", job1->JobId, ! "pPrinterName", job1->pPrinterName, ! "pMachineName", job1->pMachineName, ! "pUserName", job1->pUserName, ! "pDocument", job1->pDocument, ! "pDatatype", job1->pDatatype, ! "pStatus", job1->pStatus, ! "Status", job1->Status, ! "Priority", job1->Priority, ! "Position", job1->Position, ! "TotalPages", job1->TotalPages, ! "PagesPrinted", job1->PagesPrinted, ! "Submitted", pylocalsubmitted); ! Py_XDECREF(pylocalsubmitted); ! return ret; ! } ! case 2:{ ! job2=(JOB_INFO_2 *)buf; ! SystemTimeToTzSpecificLocalTime(NULL, &(job2->Submitted), &localSubmitted); ! pylocalsubmitted= new PyTime(localSubmitted); ! ret= Py_BuildValue("{s:i, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:O&, s:s, s:O&, s:i, s:i, s:i, s:i, s:i, s:i, s:i, s:O, s:i, s:i}", ! "JobId", job2->JobId, ! "pPrinterName", job2->pPrinterName, ! "pMachineName", job2->pMachineName, ! "pUserName", job2->pUserName, ! "pDocument", job2->pDocument, ! "pNotifyName", job2->pNotifyName, ! "pDatatype", job2->pDatatype, ! "pPrintProcessor", job2->pPrintProcessor, ! "pParameters", job2->pParameters, ! "pDriverName", job2->pDriverName, ! "pDevMode", PyWinObject_FromDEVMODE, job2->pDevMode, ! "pStatus", job2->pStatus, ! "pSecurityDescriptor", PyWinObject_FromSECURITY_DESCRIPTOR, job2->pSecurityDescriptor, ! "Status", job2->Status, ! "Priority", job2->Priority, ! "Position", job2->Position, ! "StartTime", job2->StartTime, ! "UntilTime", job2->UntilTime, ! "TotalPages", job2->TotalPages, ! "Size", job2->Size, ! "Submitted", pylocalsubmitted, ! "Time", job2->Time, ! "PagesPrinted", job2->PagesPrinted); ! Py_XDECREF(pylocalsubmitted); ! return ret; ! } ! case 3:{ ! job3=(JOB_INFO_3 *)buf; ! ret=Py_BuildValue("{s:l, s:l, s:l}", ! "JobId", job3->JobId, ! "NextJobId",job3->NextJobId, ! "Reserved",job3->Reserved); ! return ret; ! } ! default: ! return PyErr_Format(PyExc_NotImplementedError,"Job info level %d is not yet supported", level); ! } } // @pymethod tuple|win32print|EnumJobs|Enumerates print jobs on specified printer. + // @rdesc Returns a sequence of dictionaries representing JOB_INFO_* structures, depending on level static PyObject *PyEnumJobs(PyObject *self, PyObject *args) { *************** *** 509,525 **** DWORD bufneeded_size; DWORD jobsreturned; ! ! if (!PyArg_ParseTuple(args, "iiii:EnumJobs", &hprinter, // @pyparm int|hPrinter||Handle of printer. &firstjob, // @pyparm int|FirstJob||location of first job in print queue to enumerate. &nojobs, // @pyparm int|NoJobs||Number of jobs to enumerate. ! &level // @pyparm int|Level|1|Level of information to return (only JOB_INFO_1 is supported). )) return NULL; ! if (level != 1) ! { ! PyErr_SetString(PyExc_ValueError, "This information level is not supported"); ! return NULL; ! } EnumJobs(hprinter, firstjob, nojobs, level, NULL, 0, &bufneeded_size, &jobsreturned); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) --- 555,568 ---- DWORD bufneeded_size; DWORD jobsreturned; ! size_t job_info_offset[]={sizeof(JOB_INFO_1),sizeof(JOB_INFO_2),sizeof(JOB_INFO_3)}; ! if (!PyArg_ParseTuple(args, "iii|i:EnumJobs", &hprinter, // @pyparm int|hPrinter||Handle of printer. &firstjob, // @pyparm int|FirstJob||location of first job in print queue to enumerate. &nojobs, // @pyparm int|NoJobs||Number of jobs to enumerate. ! &level // @pyparm int|Level|1|Level of information to return (JOB_INFO_1, JOB_INFO_2, JOB_INFO_3 supported). )) return NULL; ! 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) *************** *** 527,534 **** buf_size= bufneeded_size; if (NULL == (buf= (LPBYTE)malloc(buf_size))) ! { ! PyErr_SetString(PyExc_MemoryError, "Malloc failed."); ! return NULL; ! } if (!EnumJobs(hprinter, firstjob, nojobs, level, buf, buf_size, &bufneeded_size, &jobsreturned)) { --- 570,574 ---- buf_size= bufneeded_size; if (NULL == (buf= (LPBYTE)malloc(buf_size))) ! return PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", buf_size); if (!EnumJobs(hprinter, firstjob, nojobs, level, buf, buf_size, &bufneeded_size, &jobsreturned)) { *************** *** 538,546 **** DWORD i; PyObject *ret = PyTuple_New(jobsreturned); ! for (i= 0; i < jobsreturned; i++) ! { ! PyTuple_SetItem(ret, i, JobtoPy(1, (buf + i * sizeof(JOB_INFO_1)))); ! } free(buf); return ret; --- 578,594 ---- DWORD i; + PyObject *job_info; PyObject *ret = PyTuple_New(jobsreturned); ! if (ret!=NULL) ! for (i= 0; i < jobsreturned; i++) ! { ! job_info=JobtoPy(level, (buf + i * job_info_offset[level-1])); ! if (job_info == NULL){ ! Py_DECREF(ret); ! ret=NULL; ! break; ! } ! PyTuple_SetItem(ret, i, job_info); ! } free(buf); return ret; *************** *** 549,552 **** --- 597,601 ---- // @pymethod dictionary|win32print|GetJob|Returns dictionary of information about a specified print job. + // @rdesc Returns a dict representing a JOB_INFO_* struct, depending on level static PyObject *PyGetJob(PyObject *self, PyObject *args) { *************** *** 554,558 **** DWORD jobid; DWORD level= 1; ! JOB_INFO_1 *buf; DWORD buf_size; DWORD bufneeded_size; --- 603,607 ---- DWORD jobid; DWORD level= 1; ! LPBYTE buf; DWORD buf_size; DWORD bufneeded_size; *************** *** 561,587 **** &hprinter,// @pyparm int|hPrinter||Handle of printer. &jobid, // @pyparm int|JobID||Job Identifier. ! &level // @pyparm int|Level|1|Level of information to return (only JOB_INFO_1 is supported). )) return NULL; ! if (level != 1) ! { ! PyErr_SetString(PyExc_ValueError, "This information level is not supported"); ! return NULL; ! } GetJob(hprinter, jobid, level, NULL, 0, &bufneeded_size); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("GetJob"); buf_size= bufneeded_size; ! if (NULL == (buf= (JOB_INFO_1 *)malloc(buf_size))) { PyErr_SetString(PyExc_MemoryError, "Malloc failed."); return NULL; } ! if (!GetJob(hprinter, jobid, level, (LPBYTE)buf, buf_size, &bufneeded_size)) { free(buf); return PyWin_SetAPIError("GetJob"); } ! PyObject *ret= JobtoPy(1, (LPBYTE)buf); free(buf); return ret; --- 610,634 ---- &hprinter,// @pyparm int|hPrinter||Handle of printer. &jobid, // @pyparm int|JobID||Job Identifier. ! &level // @pyparm int|Level|1|Level of information to return (JOB_INFO_1, JOB_INFO_2, JOB_INFO_3 supported). )) return NULL; ! if ((level < 1)||(level > 3)) ! return PyErr_Format(PyExc_ValueError, "Information level %d is not supported", level); ! GetJob(hprinter, jobid, level, NULL, 0, &bufneeded_size); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return PyWin_SetAPIError("GetJob"); buf_size= bufneeded_size; ! if (NULL == (buf= (LPBYTE)malloc(buf_size))) { PyErr_SetString(PyExc_MemoryError, "Malloc failed."); return NULL; } ! if (!GetJob(hprinter, jobid, level, buf, buf_size, &bufneeded_size)) { free(buf); return PyWin_SetAPIError("GetJob"); } ! PyObject *ret= JobtoPy(level, buf); free(buf); return ret; *************** *** 589,672 **** ! // Convert a python dictionary to a job structure. Only works for level 1 ! // There has got to be an easier way to do this... // Returned buffer must be freed. ! LPBYTE PytoJob(DWORD level, PyObject *pyjobinfo) { ! PyObject* temp; ! char *err= NULL; ! if (level != 1) ! return NULL; ! JOB_INFO_1 *job1; ! if (!PyDict_Check (pyjobinfo)) ! { ! PyErr_SetString(PyExc_ValueError, "JOB_INFO must be a dictionary."); ! return NULL; ! } ! if (NULL == (job1= (JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)))) ! { ! PyErr_SetString(PyExc_MemoryError, "Malloc failed."); ! return NULL; ! } ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "JobID")) && PyInt_Check(temp)) ! job1->JobId= PyInt_AsLong(temp); ! else ! err= "JobID invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pPrinterName")) && PyString_Check(temp)) ! job1->pPrinterName= PyString_AsString(temp); ! else ! err= "pPrinterName invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pMachineName")) && PyString_Check(temp)) ! job1->pMachineName= PyString_AsString(temp); ! else ! err= "pMachineName invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pUserName")) && PyString_Check(temp)) ! job1->pUserName= PyString_AsString(temp); ! else ! err= "pUsername invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pDocument")) && PyString_Check(temp)) ! job1->pDocument= PyString_AsString(temp); ! else ! err= "pDocument invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pDatatype")) && PyString_Check(temp)) ! job1->pDatatype= PyString_AsString(temp); ! else ! err= "pDatatype invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "pStatus"))) ! if (PyString_Check(temp)) ! job1->pStatus= PyString_AsString(temp); ! else ! job1->pStatus= NULL; ! else ! err= "pStatus invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "Status")) && PyInt_Check(temp)) ! job1->Status= PyInt_AsLong(temp); ! else ! err= "Status invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "Priority")) && PyInt_Check(temp)) ! job1->Priority= PyInt_AsLong (temp); ! else ! err= "Priority invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "Position")) && PyInt_Check(temp)) ! job1->Position= PyInt_AsLong (temp); ! else ! err= "Position invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "TotalPages")) && PyInt_Check(temp)) ! job1->TotalPages= PyInt_AsLong (temp); ! else ! err= "TotalPages invalid"; ! if (NULL != (temp= PyDict_GetItemString(pyjobinfo, "PagesPrinted")) && PyInt_Check(temp)) ! job1->PagesPrinted= PyInt_AsLong(temp); ! else ! err= "PagesPrinted invalid"; ! if (err != NULL) ! { ! free(job1); ! PyErr_SetString(PyExc_ValueError, err); ! return NULL; ! } ! return (LPBYTE)job1; } --- 636,732 ---- ! // Convert a python dictionary to a JOB_INFO_* structure. // Returned buffer must be freed. ! BOOL PytoJob(DWORD level, PyObject *pyjobinfo, LPBYTE *pbuf) { ! static char *job1_keys[]={"JobId","pPrinterName","pMachineName","pUserName","pDocument","pDatatype", ! "pStatus","Status","Priority","Position","TotalPages","PagesPrinted","Submitted", NULL}; ! static char *job1_format="lzzzzzzlllll|O:JOB_INFO_1"; ! static char *job2_keys[]={"JobId","pPrinterName","pMachineName","pUserName","pDocument","pNotifyName", ! "pDatatype","pPrintProcessor","pParameters","pDriverName","pDevMode","pStatus","pSecurityDescriptor", ! "Status","Priority","Position","StartTime","UntilTime","TotalPages","Size", ! "Submitted","Time","PagesPrinted", NULL}; ! static char *job2_format="lzzzzzzzzzOzOlllllllOll:JOB_INFO_2"; ! static char *job3_keys[]={"JobId","NextJobId","Reserved", NULL}; ! static char *job3_format="ll|l:JOB_INFO_3"; ! ! PyObject *obdevmode, *obsecurity_descriptor, *obsubmitted=Py_None; ! char *err= NULL; ! BOOL ret=FALSE; ! ! *pbuf=NULL; ! switch(level){ ! case 0: ! if (pyjobinfo==Py_None) ! ret=TRUE; ! else ! PyErr_SetString(PyExc_TypeError,"Info must be None when level is 0."); ! break; ! case 1: ! if (!PyDict_Check (pyjobinfo)){ ! PyErr_SetString(PyExc_TypeError, "JOB_INFO_1 must be a dictionary"); ! break; ! } ! JOB_INFO_1 *job1; ! if (NULL == (*pbuf= (LPBYTE)malloc(sizeof(JOB_INFO_1)))){ ! PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", sizeof(JOB_INFO_1)); ! break; ! } ! job1=(JOB_INFO_1 *)*pbuf; ! ZeroMemory(job1,sizeof(JOB_INFO_1)); ! if (PyArg_ParseTupleAndKeywords(dummy_tuple, pyjobinfo, job1_format, job1_keys, ! &job1->JobId, &job1->pPrinterName, &job1->pMachineName, &job1->pUserName, &job1->pDocument, ! &job1->pDatatype, &job1->pStatus, &job1->Status, &job1->Priority, &job1->Position, ! &job1->TotalPages, &job1->PagesPrinted, &obsubmitted) ! &&((obsubmitted==Py_None)||PyWinObject_AsSYSTEMTIME(obsubmitted, &job1->Submitted))) ! ret=TRUE; ! break; ! case 2: ! if (!PyDict_Check (pyjobinfo)){ ! PyErr_SetString(PyExc_TypeError, "JOB_INFO_2 must be a dictionary"); ! break; ! } ! JOB_INFO_2 *job2; ! if (NULL == (*pbuf=(LPBYTE)malloc(sizeof(JOB_INFO_2)))){ ! PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", sizeof(JOB_INFO_2)); ! break; ! } ! job2=(JOB_INFO_2 *)*pbuf; ! ZeroMemory(job2,sizeof(JOB_INFO_2)); ! if (PyArg_ParseTupleAndKeywords(dummy_tuple, pyjobinfo, job2_format, job2_keys, ! &job2->JobId, &job2->pPrinterName, &job2->pMachineName, &job2->pUserName, &job2->pDocument, ! &job2->pNotifyName, &job2->pDatatype, &job2->pPrintProcessor, &job2->pParameters, ! &job2->pDriverName, &obdevmode, &job2->pStatus, &obsecurity_descriptor, &job2->Status, ! &job2->Priority, &job2->Position, &job2->StartTime, &job2->UntilTime, ! &job2->TotalPages, &job2->Size, &obsubmitted, &job2->Time, &job2->PagesPrinted) ! &&PyWinObject_AsDEVMODE(obdevmode, &job2->pDevMode, TRUE) ! &&PyWinObject_AsSECURITY_DESCRIPTOR(obsecurity_descriptor, &job2->pSecurityDescriptor, TRUE) ! &&((obsubmitted==Py_None)||PyWinObject_AsSYSTEMTIME(obsubmitted, &job2->Submitted))) ! ret=TRUE; ! break; ! case 3: ! if (!PyDict_Check (pyjobinfo)){ ! PyErr_SetString(PyExc_TypeError, "JOB_INFO_3 must be a dictionary"); ! break; ! } ! JOB_INFO_3 *job3; ! if (NULL == (*pbuf=(LPBYTE)malloc(sizeof(JOB_INFO_3)))){ ! PyErr_Format(PyExc_MemoryError, "Malloc failed for %d bytes", sizeof(JOB_INFO_3)); ! break; ! } ! job3=(JOB_INFO_3 *)*pbuf; ! ZeroMemory(job3,sizeof(JOB_INFO_3)); ! ret=PyArg_ParseTupleAndKeywords(dummy_tuple, pyjobinfo, job3_format, job3_keys, ! &job3->JobId, &job3->NextJobId, &job3->Reserved); ! break; ! default: ! PyErr_Format(PyExc_NotImplementedError,"Information level %d is not supported", level); ! } ! if (!ret) ! if (*pbuf!=NULL) ! free(*pbuf); ! return ret; } *************** *** 682,705 **** LPBYTE buf; ! if (!PyArg_ParseTuple(args, "iiiOi:GetJob", &hprinter,// @pyparm int|hPrinter||Handle of printer. &jobid, // @pyparm int|JobID||Job Identifier. ! &level, // @pyparm int|Level|1|Level of information to return (only 0 and JOB_INFO_1 are supported). ! &pyjobinfo, // @pyparm dict|JobInfo||JOB_INFO_1 Dictionary (can be None if Level is 0). Position should be JOB_POSITION_UNSPECIFIED. &command // @pyparm int|Command||Job command value (JOB_CONTROL_*). )) return NULL; ! if (level != 1 && level != 0) ! { ! PyErr_SetString(PyExc_ValueError, "This information level is not supported"); return NULL; ! } ! if (pyjobinfo == Py_None) ! buf= NULL; ! else ! { ! if (NULL == (buf= PytoJob(1, pyjobinfo))) ! return NULL; ! } if (!SetJob(hprinter, jobid, level, buf, command)) { --- 742,756 ---- LPBYTE buf; ! if (!PyArg_ParseTuple(args, "iiiOi:SetJob", &hprinter,// @pyparm int|hPrinter||Handle of printer. &jobid, // @pyparm int|JobID||Job Identifier. ! &level, // @pyparm int|Level|1|Level of information in JobInfo dict (0, 1, 2, and 3 are supported). ! &pyjobinfo, // @pyparm dict|JobInfo||JOB_INFO_* Dictionary as returned by <om win32print.GetJob> or <om win32print.EnumJobs> (can be None if Level is 0). &command // @pyparm int|Command||Job command value (JOB_CONTROL_*). )) return NULL; ! if (!PytoJob(level, pyjobinfo, &buf)) return NULL; ! if (!SetJob(hprinter, jobid, level, buf, command)) { *************** *** 1417,1420 **** --- 1468,1491 ---- AddConstant(dict, "FORM_PRINTER", FORM_PRINTER); + // Printer, print server, and print job access rights + AddConstant(dict, "SERVER_ACCESS_ADMINISTER",SERVER_ACCESS_ADMINISTER); + AddConstant(dict, "SERVER_ACCESS_ENUMERATE",SERVER_ACCESS_ENUMERATE); + AddConstant(dict, "PRINTER_ACCESS_ADMINISTER",PRINTER_ACCESS_ADMINISTER); + AddConstant(dict, "PRINTER_ACCESS_USE",PRINTER_ACCESS_USE); + AddConstant(dict, "JOB_ACCESS_ADMINISTER",JOB_ACCESS_ADMINISTER); + AddConstant(dict, "JOB_ACCESS_READ",JOB_ACCESS_READ); + AddConstant(dict, "SERVER_ALL_ACCESS",SERVER_ALL_ACCESS); + AddConstant(dict, "SERVER_READ",SERVER_READ); + AddConstant(dict, "SERVER_WRITE",SERVER_WRITE); + AddConstant(dict, "SERVER_EXECUTE",SERVER_EXECUTE); + AddConstant(dict, "PRINTER_ALL_ACCESS",PRINTER_ALL_ACCESS); + AddConstant(dict, "PRINTER_READ",PRINTER_READ); + AddConstant(dict, "PRINTER_WRITE",PRINTER_WRITE); + AddConstant(dict, "PRINTER_EXECUTE",PRINTER_EXECUTE); + AddConstant(dict, "JOB_ALL_ACCESS",JOB_ALL_ACCESS); + AddConstant(dict, "JOB_READ",JOB_READ); + AddConstant(dict, "JOB_WRITE",JOB_WRITE); + AddConstant(dict, "JOB_EXECUTE",JOB_EXECUTE); + FARPROC fp; HMODULE hmodule=LoadLibrary("winspool.drv"); *************** *** 1444,1445 **** --- 1515,1517 ---- dummy_tuple=PyTuple_New(0); } + |
From: Roger U. <ru...@us...> - 2005-02-01 13:37:38
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1629/win32/src/win32print Modified Files: win32print.cpp Log Message: Add AddJob and ScheduleJob, fix DOCINFO parsing Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32print.cpp 24 Jan 2005 09:45:27 -0000 1.11 --- win32print.cpp 1 Feb 2005 13:37:24 -0000 1.12 *************** *** 30,33 **** --- 30,37 ---- 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; *************** *** 352,356 **** return FALSE; } ! if (!PyArg_ParseTuple(obdocinfo, "zzzl", &di->lpszDocName, &di->lpszOutput, &di->lpszOutput, &di->fwType)) return FALSE; return TRUE; --- 356,361 ---- return FALSE; } ! di->cbSize=sizeof(DOCINFO); ! if (!PyArg_ParseTuple(obdocinfo, "zzzl", &di->lpszDocName, &di->lpszOutput, &di->lpszDatatype, &di->fwType)) return FALSE; return TRUE; *************** *** 1252,1255 **** --- 1257,1321 ---- } + // @pymethod |win32print|AddJob|Add a job to be spooled to a printer queue + static PyObject *PyAddJob(PyObject *self, PyObject *args) + { + // @rdesc Returns the file name to which data should be written and the job id of the new job + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + HANDLE hprinter; + DWORD level=1, bufsize, bytes_needed; + LPBYTE buf=NULL; + 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)) + return NULL; + bufsize=sizeof(ADDJOB_INFO_1)+ (MAX_PATH*sizeof(WCHAR)); + buf=(LPBYTE)malloc(bufsize); + 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){ + free(buf); + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL) + 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) + PyWin_SetAPIError("AddJob"); + else + ret=Py_BuildValue("ul",((ADDJOB_INFO_1 *)buf)->Path,((ADDJOB_INFO_1 *)buf)->JobId); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod |win32print|ScheduleJob|Schedules a spooled job to be printed + static PyObject *PyScheduleJob(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm int|JobId||Job Id as returned by <om win32print.AddJob> + 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; + } + Py_INCREF(Py_None); + return Py_None; + } /* List of functions exported by this module */ *************** *** 1287,1290 **** --- 1353,1358 ---- {"GetForm", PyGetForm, 1}, //@pymeth GetForm|Retrieves information about a defined form {"SetForm", PySetForm, 1}, //@pymeth SetForm|Change information for a form + {"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 { NULL } }; *************** *** 1367,1370 **** --- 1435,1444 ---- 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); |
From: Roger U. <ru...@us...> - 2005-01-31 04:12:08
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19664/win32/Lib Modified Files: win32serviceutil.py Log Message: Add optional service description Index: win32serviceutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32serviceutil.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32serviceutil.py 27 Sep 2004 21:39:37 -0000 1.15 --- win32serviceutil.py 31 Jan 2005 04:12:00 -0000 1.16 *************** *** 138,142 **** return exeName ! def InstallService(pythonClassString, serviceName, displayName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, perfMonIni = None, perfMonDll = None, exeArgs = None): # Handle the default arguments. if startType is None: --- 138,142 ---- return exeName ! def InstallService(pythonClassString, serviceName, displayName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, perfMonIni = None, perfMonDll = None, exeArgs = None, description = None): # Handle the default arguments. if startType is None: *************** *** 165,168 **** --- 165,173 ---- userName, password) + if description is not None: + try: + win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description) + except NotImplementedError: + pass ## ChangeServiceConfig2 and description do not exist on NT win32service.CloseServiceHandle(hs) finally: *************** *** 173,177 **** InstallPerfmonForService(serviceName, perfMonIni, perfMonDll) ! def ChangeServiceConfig(pythonClassString, serviceName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, displayName = None, perfMonIni = None, perfMonDll = None, exeArgs = None): # Before doing anything, remove any perfmon counters. try: --- 178,182 ---- InstallPerfmonForService(serviceName, perfMonIni, perfMonDll) ! def ChangeServiceConfig(pythonClassString, serviceName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, displayName = None, perfMonIni = None, perfMonDll = None, exeArgs = None, description = None): # Before doing anything, remove any perfmon counters. try: *************** *** 207,211 **** userName, password, ! displayName) finally: win32service.CloseServiceHandle(hs) --- 212,222 ---- userName, password, ! displayName) ! if description is not None: ! try: ! win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description) ! except NotImplementedError: ! pass ## ChangeServiceConfig2 and description do not exist on NT ! finally: win32service.CloseServiceHandle(hs) *************** *** 562,565 **** --- 573,580 ---- except AttributeError: exeArgs = None + try: + description = cls._svc_description_ + except AttributeError: + description = None print "Installing service %s to Python class %s" % (serviceName,serviceClassString) # Note that we install the service before calling the custom option *************** *** 568,572 **** # we remove the service if the first bit works, but the second doesnt! try: ! InstallService(serviceClassString, serviceName, serviceDisplayName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs) if customOptionHandler: apply( customOptionHandler, (opts,) ) --- 583,587 ---- # we remove the service if the first bit works, but the second doesnt! try: ! InstallService(serviceClassString, serviceName, serviceDisplayName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs,description=description) if customOptionHandler: apply( customOptionHandler, (opts,) ) *************** *** 605,611 **** except AttributeError: exeArgs = None print "Changing service configuration" try: ! ChangeServiceConfig(serviceClassString, serviceName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, displayName = serviceDisplayName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs) print "Service updated" except win32service.error, (hr, fn, msg): --- 620,630 ---- except AttributeError: exeArgs = None + try: + description=cls._svc_description_ + except AttributeError: + description=None print "Changing service configuration" try: ! ChangeServiceConfig(serviceClassString, serviceName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, displayName = serviceDisplayName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs,description=description) print "Service updated" except win32service.error, (hr, fn, msg): *************** *** 651,654 **** --- 670,674 ---- _exe_name_ = None # Default to PythonService.exe _exe_args_ = None # Default to no arguments + _svc_description_ = None # Only exists on Windows 2000 or later, ignored on windows NT def __init__(self, args): |
From: Roger U. <ru...@us...> - 2005-01-31 04:12:08
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/service In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19664/win32/Demos/service Modified Files: pipeTestService.py Log Message: Add optional service description Index: pipeTestService.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/service/pipeTestService.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pipeTestService.py 10 Sep 2004 06:20:36 -0000 1.5 --- pipeTestService.py 31 Jan 2005 04:11:59 -0000 1.6 *************** *** 36,39 **** --- 36,41 ---- _svc_name_ = "PyPipeTestService" _svc_display_name_ = "Python Pipe Test Service" + _svc_description_ = "Tests Python service framework by receiving and echoing messages over a named pipe" + def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) |
From: Roger U. <ru...@us...> - 2005-01-31 03:28:17
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11477/win32/src Modified Files: win32service.i Log Message: Add QueryServiceConfig2 and ChangeServiceConfig2 Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32service.i 30 Jan 2005 13:38:37 -0000 1.7 --- win32service.i 31 Jan 2005 03:28:08 -0000 1.8 *************** *** 10,14 **** #undef PyHANDLE #include "PyWinObjects.h" ! static BOOL (WINAPI *fpQueryServiceStatusEx)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD) = NULL; // according to msdn, 256 is limit for service names and service display names #define MAX_SERVICE_NAME_LEN 256 --- 10,21 ---- #undef PyHANDLE #include "PyWinObjects.h" ! ! typedef BOOL (WINAPI *QueryServiceStatusExfunc)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD); ! QueryServiceStatusExfunc fpQueryServiceStatusEx=NULL; ! typedef BOOL (WINAPI *ChangeServiceConfig2func)(SC_HANDLE,DWORD,LPVOID); ! ChangeServiceConfig2func fpChangeServiceConfig2=NULL; ! typedef BOOL (WINAPI *QueryServiceConfig2func)(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD); ! QueryServiceConfig2func fpQueryServiceConfig2=NULL; ! // according to msdn, 256 is limit for service names and service display names #define MAX_SERVICE_NAME_LEN 256 *************** *** 29,33 **** fp=GetProcAddress(hmod,"QueryServiceStatusEx"); if (fp!=NULL) ! fpQueryServiceStatusEx=(BOOL (WINAPI *)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD))fp; } %} --- 36,46 ---- fp=GetProcAddress(hmod,"QueryServiceStatusEx"); if (fp!=NULL) ! fpQueryServiceStatusEx=(QueryServiceStatusExfunc)fp; ! fp=GetProcAddress(hmod,"ChangeServiceConfig2W"); ! if (fp!=NULL) ! fpChangeServiceConfig2=(ChangeServiceConfig2func)fp; ! fp=GetProcAddress(hmod,"QueryServiceConfig2W"); ! if (fp!=NULL) ! fpQueryServiceConfig2=(QueryServiceConfig2func)fp; } %} *************** *** 394,398 **** // @pyswig |GetUserObjectInformation|Returns specified type of info about a window station or desktop ! // @comm Return type is dependent on UOI_* constant passed in %native(GetUserObjectInformation) PyGetUserObjectInformation; %{ --- 407,411 ---- // @pyswig |GetUserObjectInformation|Returns specified type of info about a window station or desktop ! // @rdesc Return type is dependent on UOI_* constant passed in %native(GetUserObjectInformation) PyGetUserObjectInformation; %{ *************** *** 839,843 **** // @pyswig (tuple,...)|EnumServicesStatus|Returns a tuple of status info for each service that meets specified criteria ! // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumServicesStatus) MyEnumServicesStatus; --- 852,856 ---- // @pyswig (tuple,...)|EnumServicesStatus|Returns a tuple of status info for each service that meets specified criteria ! // @rdesc Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumServicesStatus) MyEnumServicesStatus; *************** *** 908,912 **** // @pyswig (tuple,...)|EnumDependentServices|Lists services that depend on a service ! // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumDependentServices) MyEnumDependentServices; %{ --- 921,925 ---- // @pyswig (tuple,...)|EnumDependentServices|Lists services that depend on a service ! // @rdesc Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumDependentServices) MyEnumDependentServices; %{ *************** *** 974,978 **** // @pyswig tuple|QueryServiceConfig|Retrieves configuration parameters for a service ! // @comm Returns a tuple representing a QUERY_SERVICE_CONFIG struct: // (ServiceType, StartType, ErrorControl, BinaryPathName, LoadOrderGroup, TagId, Dependencies, ServiceStartName, DisplayName) %native (QueryServiceConfig) MyQueryServiceConfig; --- 987,991 ---- // @pyswig tuple|QueryServiceConfig|Retrieves configuration parameters for a service ! // @rdesc Returns a tuple representing a QUERY_SERVICE_CONFIG struct: // (ServiceType, StartType, ErrorControl, BinaryPathName, LoadOrderGroup, TagId, Dependencies, ServiceStartName, DisplayName) %native (QueryServiceConfig) MyQueryServiceConfig; *************** *** 1349,1352 **** --- 1362,1581 ---- %native (QueryServiceLockStatus) PyQueryServiceLockStatus; + // @object SC_ACTION|Tuple of 2 ints (Type,Delay) used to represent an SC_ACTION structure + // @prop int|Type|One of SC_ACTION_NONE, SC_ACTION_REBOOT, SC_ACTION_RESTART, SC_ACTION_RUN_COMMAND + // @prop int|Delay|Time delay before specified action is taken (in milliseconds) + + // @object SERVICE_FAILURE_ACTIONS|A dictionary representing a SERVICE_FAILURE_ACTIONS structure + // @prop int|ResetPeriod|Indicates how many seconds to wait to reset the failure count, can be INFINITE + // @prop str/<o PyUnicode>|RebootMsg|Message displayed when reboot action is taken + // @prop str/<o PyUnicode>|Command|Command line to execute for SC_ACTION_RUN_COMMAND + // @prop tuple|Actions|A tuple of <o SC_ACTION> tuples + + %{ + BOOL PyWinObject_AsSC_ACTION(PyObject *obAction, SC_ACTION *Action) + { + static char* err="SC_ACTION must be a tuple of 2 ints (Type, Delay)"; + if (!PyTuple_Check(obAction)){ + PyErr_SetString(PyExc_TypeError,err); + return FALSE; + } + if (!PyArg_ParseTuple(obAction,"ll", &Action->Type, &Action->Delay)){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,err); + return FALSE; + } + return TRUE; + } + + BOOL PyWinObject_AsSC_ACTIONS(PyObject *obActions, SC_ACTION **ppActions, LPDWORD cActions) + { + static char* err="SC_ACTIONS must be a tuple of 2-tuples ((int, int),...)"; + DWORD action_ind; + BOOL ret=TRUE; + SC_ACTION *pAction; + if (obActions==Py_None){ + *ppActions=NULL; + return TRUE; + } + if (!PyTuple_Check(obActions)){ + PyErr_SetString(PyExc_TypeError,err); + return FALSE; + } + *cActions=PyTuple_Size(obActions); + *ppActions=(SC_ACTION *)malloc(*cActions*sizeof(SC_ACTION)); + if (*ppActions==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d SC_ACTION structures", *cActions); + return FALSE; + } + pAction=*ppActions; + for (action_ind=0;action_ind<*cActions;action_ind++){ + ret=PyWinObject_AsSC_ACTION(PyTuple_GET_ITEM(obActions, action_ind), pAction); + if (!ret){ + free(*ppActions); + *ppActions=NULL; + *cActions=0; + break; + } + pAction++; + } + return ret; + } + + void PyWinObject_FreeSERVICE_FAILURE_ACTIONS(LPSERVICE_FAILURE_ACTIONSW psfa) + { + if (psfa->lpRebootMsg!=NULL) + PyWinObject_FreeWCHAR(psfa->lpRebootMsg); + if (psfa->lpCommand!=NULL) + PyWinObject_FreeWCHAR(psfa->lpCommand); + if (psfa->lpsaActions!=NULL) + free(psfa->lpsaActions); + } + + BOOL PyWinObject_AsSERVICE_FAILURE_ACTIONS(PyObject *obinfo, LPSERVICE_FAILURE_ACTIONSW psfa) + { + static char *sfa_keys[]={"ResetPeriod","RebootMsg","Command","Actions",0}; + static char *err="SERVICE_FAILURE_ACTIONS must be a dictionary containing {'ResetPeriod':int,'RebootMsg':unicode,'lpCommand':unicode,'Actions':sequence of 2 tuples(int,int)"; + PyObject *dummy_tuple, *obActions, *obRebootMsg, *obCommand; + BOOL ret; + ZeroMemory(psfa, sizeof(SERVICE_FAILURE_ACTIONSW)); + if (!PyDict_Check(obinfo)){ + PyErr_SetString(PyExc_TypeError,err); + return FALSE; + } + dummy_tuple=PyTuple_New(0); + if (dummy_tuple==NULL) + return FALSE; + ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obinfo, "lOOO:SERVICE_FAILURE_ACTIONS", sfa_keys, + &psfa->dwResetPeriod, &obRebootMsg, &obCommand, &obActions); + Py_DECREF(dummy_tuple); + if (!ret){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,err); + return FALSE; + } + if (PyWinObject_AsWCHAR(obRebootMsg, &psfa->lpRebootMsg, TRUE) + &&PyWinObject_AsWCHAR(obCommand, &psfa->lpCommand, TRUE) + &&PyWinObject_AsSC_ACTIONS(obActions,&psfa->lpsaActions, &psfa->cActions)) + return TRUE; + PyWinObject_FreeSERVICE_FAILURE_ACTIONS(psfa); + return FALSE; + } + + PyObject *PyWinObject_FromSERVICE_FAILURE_ACTIONS(LPSERVICE_FAILURE_ACTIONSW psfa) + { + PyObject *obActions, *obAction; + SC_ACTION *pAction; + DWORD action_ind; + obActions=PyTuple_New(psfa->cActions); + if (obActions==NULL) + return NULL; + pAction=psfa->lpsaActions; + for (action_ind=0;action_ind<psfa->cActions;action_ind++){ + obAction=Py_BuildValue("ll",pAction->Type,pAction->Delay); + if (obAction==NULL){ + Py_DECREF(obActions); + return NULL; + } + PyTuple_SET_ITEM(obActions, action_ind, obAction); + pAction++; + } + return Py_BuildValue("{s:l,s:u,s:u,s:N}", + "ResetPeriod", psfa->dwResetPeriod, + "RebootMsg", psfa->lpRebootMsg, + "Command", psfa->lpCommand, + "Actions", obActions); + } + + %} + + // @pyswig |ChangeServiceConfig2|Modifies service parameters that were introduced in Windows 2000 + %native (ChangeServiceConfig2) PyChangeServiceConfig2; + %{ + PyObject *PyChangeServiceConfig2(PyObject *self, PyObject *args) + { + if (fpChangeServiceConfig2==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"ChangeServiceConfig2 is not available on this operating system"); + return NULL; + } + SC_HANDLE hService; + DWORD level; + BOOL bsuccess; + SERVICE_DESCRIPTIONW description_buf; + SERVICE_FAILURE_ACTIONSW failure_actions_buf; + PyObject *obinfo; + // @pyparm int|hService||Service handle as returned by <om win32service.OpenService> + // @pyparm int|InfoLevel||Indicates type of config parameters being set, one of SERVICE_CONFIG_DESCRIPTION or SERVICE_CONFIG_FAILURE_ACTIONS + // @pyparm object|info||For SERVICE_CONFIG_DESCRIPTION a string For SERVICE_CONFIG_FAILURE_ACTIONS a <o SERVICE_FAILURE_ACTIONS> dictionary + if (!PyArg_ParseTuple(args,"llO:ChangeServiceConfig2", &hService, &level, &obinfo)) + return NULL; + switch (level){ + case SERVICE_CONFIG_DESCRIPTION: + if (!PyWinObject_AsWCHAR(obinfo,&description_buf.lpDescription,TRUE)) + return NULL; + bsuccess=(*fpChangeServiceConfig2)(hService,level, (LPVOID)&description_buf); + PyWinObject_FreeWCHAR(description_buf.lpDescription); + break; + case SERVICE_CONFIG_FAILURE_ACTIONS: + if (!PyWinObject_AsSERVICE_FAILURE_ACTIONS(obinfo, &failure_actions_buf)) + return NULL; + bsuccess=(*fpChangeServiceConfig2)(hService,level, (LPVOID)&failure_actions_buf); + PyWinObject_FreeSERVICE_FAILURE_ACTIONS(&failure_actions_buf); + break; + default: + return PyErr_Format(PyExc_ValueError,"Info type %d is not supported",level); + } + if (!bsuccess) + return PyWin_SetAPIError("ChangeServiceConfig2"); + Py_INCREF(Py_None); + return Py_None; + } + %} + + // @pyswig |QueryServiceConfig2|Retrieves advanced service configuration options + // @rdesc Returns a unicode string for SERVICE_CONFIG_DESCRIPTION, or a <o SERVICE_FAILURE_ACTIONS> dict for SERVICE_CONFIG_FAILURE_ACTIONS + %native (QueryServiceConfig2) PyQueryServiceConfig2; + %{ + PyObject *PyQueryServiceConfig2(PyObject *self, PyObject *args) + { + if (fpQueryServiceConfig2==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"QueryServiceConfig2 is not available on this operating system"); + return NULL; + } + SC_HANDLE hService; + DWORD level, bytes_needed=0, bufsize=0; + LPBYTE buf=NULL; + PyObject *ret=NULL; + // @pyparm int|hService||Service handle as returned by <om win32service.OpenService> + // @pyparm int|InfoLevel||SERVICE_CONFIG_DESCRIPTION or SERVICE_CONFIG_FAILURE_ACTIONS + if (!PyArg_ParseTuple(args,"ll:QueryServiceConfig2", &hService, &level)) + return NULL; + (*fpQueryServiceConfig2)(hService, level, buf, bufsize, &bytes_needed); + if (bytes_needed==0){ + PyWin_SetAPIError("QueryServiceConfig2"); + return NULL; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL) + return PyErr_Format(PyExc_MemoryError,"QueryServiceConfig2: Unable to allocate buffer of %d bytes",bytes_needed); + bufsize=bytes_needed; + if ((*fpQueryServiceConfig2)(hService, level, buf, bufsize, &bytes_needed)) + switch(level){ + case SERVICE_CONFIG_DESCRIPTION: + ret=PyWinObject_FromWCHAR(((SERVICE_DESCRIPTIONW *)buf)->lpDescription); + break; + case SERVICE_CONFIG_FAILURE_ACTIONS: + ret=PyWinObject_FromSERVICE_FAILURE_ACTIONS((LPSERVICE_FAILURE_ACTIONSW)buf); + break; + default: + PyErr_Format(PyExc_NotImplementedError,"QueryServiceConfig2: Level %d is not supported", level); + } + else + PyWin_SetAPIError("QueryServiceConfig2"); + free(buf); + return ret; + } + %} + + #define SERVICE_WIN32 SERVICE_WIN32 *************** *** 1485,1486 **** --- 1714,1723 ---- #define DF_ALLOWOTHERACCOUNTHOOK DF_ALLOWOTHERACCOUNTHOOK // #define CWF_CREATE_ONLY CWF_CREATE_ONLY + + #define SERVICE_CONFIG_DESCRIPTION SERVICE_CONFIG_DESCRIPTION + #define SERVICE_CONFIG_FAILURE_ACTIONS SERVICE_CONFIG_FAILURE_ACTIONS + #define SC_ACTION_NONE SC_ACTION_NONE + #define SC_ACTION_REBOOT SC_ACTION_REBOOT + #define SC_ACTION_RESTART SC_ACTION_RESTART + #define SC_ACTION_RUN_COMMAND SC_ACTION_RUN_COMMAND + |
From: Mark H. <mha...@us...> - 2005-01-30 22:57:39
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15558 Modified Files: commctrl.py Log Message: Add LVN_KEYDOWN, INDEXTOOVERLAYMASK and INDEXTOSTATEIMAGEMASK Index: commctrl.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/commctrl.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** commctrl.py 13 Jul 2004 07:44:13 -0000 1.4 --- commctrl.py 30 Jan 2005 22:57:29 -0000 1.5 *************** *** 1053,1056 **** --- 1053,1057 ---- LVN_SETDISPINFO = LVN_SETDISPINFOA LVIF_DI_SETITEM = 4096 + LVN_KEYDOWN = (LVN_FIRST-55) LVN_MARQUEEBEGIN = (LVN_FIRST-56) LVGIT_UNFOLDED = 1 *************** *** 1541,1542 **** --- 1542,1549 ---- FSB_ENCARTA_MODE = 1 FSB_REGULAR_MODE = 0 + + def INDEXTOOVERLAYMASK(i): + return i << 8 + + def INDEXTOSTATEIMAGEMASK(i): + return i << 12 |
From: Mark H. <mha...@us...> - 2005-01-30 13:42:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18606 Modified Files: win32gui.i Log Message: * Autoduck stubs for existing functions. * Add CreateFontIndirect, ImageList_DrawEx, ImageList_SetOverlayImage, SetTextColor and SetBkMode Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** win32gui.i 20 Jan 2005 06:49:50 -0000 1.55 --- win32gui.i 30 Jan 2005 13:42:30 -0000 1.56 *************** *** 148,151 **** --- 148,154 ---- typedef long HWND + %apply HFONT {long}; + typedef long HFONT + %apply HDC {long}; typedef long HDC *************** *** 970,977 **** --- 973,992 ---- } %} + + %typemap(python,in) LOGFONT *{ + if (!PyLOGFONT_Check($source)) + return PyErr_Format(PyExc_TypeError, "Must be a LOGFONT object (got %s)", + $source->ob_type->tp_name); + $target = &(((PyLOGFONT *)$source)->m_LOGFONT); + } + // @pyswig <o PyLOGFONT>|LOGFONT|Creates a LOGFONT object. %native (LOGFONT) MakeLOGFONT; %native (EnumFontFamilies) PyEnumFontFamilies; + // @pyswig int|CreateFontIndirect|function creates a logical font that has the specified characteristics. + // The font can subsequently be selected as the current font for any device context. + HFONT CreateFontIndirect(LOGFONT *lf); + %{ // @pyswig object|GetObject| *************** *** 1974,1977 **** --- 1989,1995 ---- BOOLAPI ImageList_Draw(HIMAGELIST himl,int i,HDC hdcDst, int x, int y, UINT fStyle); + // @pyswig BOOL |ImageList_DrawEx|Draw an image on an HDC + BOOLAPI ImageList_DrawEx(HIMAGELIST himl,int i,HDC hdcDst, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle); + #define ILD_BLEND25 ILD_BLEND25 #define ILD_FOCUS ILD_FOCUS *************** *** 2009,2012 **** --- 2027,2038 ---- COLORREF ImageList_SetBkColor(HIMAGELIST himl,COLORREF clrbk); + // @pyswig |ImageList_SetOverlayImage|Adds a specified image to the list of images to be used as overlay masks. An image list can have up to four overlay masks in version 4.70 and earlier and up to 15 in version 4.71. The function assigns an overlay mask index to the specified image. + BOOLAPI ImageList_SetOverlayImage( + HIMAGELIST himl, // @pyparm int|hImageList|| + int iImage, // @pyparm int|iImage|| + int iOverlay // @pyparm int|iOverlay|| + ); + + #define CLR_NONE CLR_NONE *************** *** 2839,2851 **** --- 2865,2891 ---- + // @pyswig |DrawFocusRect| BOOLAPI DrawFocusRect(HDC hDC, RECT *INPUT); + // @pyswig |DrawText| int DrawText(HDC hDC, LPCTSTR lpString, int nCount, RECT *INPUT, UINT uFormat); + // @pyswig |SetTextColor| + int SetTextColor(HDC hdc, COLORREF color); + // @pyswig |SetBkMode| + int SetBkMode(HDC hdc, int mode); + // @pyswig |DrawEdge| BOOLAPI DrawEdge(HDC hdc, RECT *INPUT, UINT edge, UINT grfFlags); + // @pyswig |FillRect| int FillRect(HDC hDC, RECT *INPUT, HBRUSH hbr); + // @pyswig |CreateSolidBrush| HBRUSH CreateSolidBrush(COLORREF color); + // @pyswig |GetSysColor| DWORD GetSysColor(int nIndex); + // @pyswig |GetSysColorBrush| HBRUSH GetSysColorBrush(int nIndex); + // @pyswig |InvalidateRect| BOOLAPI InvalidateRect(HWND hWnd, RECT *INPUT_NULLOK , BOOL bErase); + // @pyswig |FrameRect| int FrameRect(HDC hDC, RECT *INPUT, HBRUSH hbr); + // @pyswig |GetUpdateRgn| int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); |
From: Mark H. <mha...@us...> - 2005-01-30 13:40:50
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18452 Modified Files: win32event.i Log Message: Autoduck corrections. Index: win32event.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32event.i,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32event.i 25 Jan 2005 07:53:34 -0000 1.6 --- win32event.i 30 Jan 2005 13:40:41 -0000 1.7 *************** *** 289,293 **** PyHANDLE OpenWaitableTimer( DWORD dwDesiredAccess, // @pyparm int|desiredAccess||access flag ! BOOL bInheritHandle, // @pyparm bInheritHandle||inherit flag TCHAR *lpTimerName // @pyparm string|timerName||pointer to timer object name ); --- 289,293 ---- PyHANDLE OpenWaitableTimer( DWORD dwDesiredAccess, // @pyparm int|desiredAccess||access flag ! BOOL bInheritHandle, // @pyparm int|bInheritHandle||inherit flag TCHAR *lpTimerName // @pyparm string|timerName||pointer to timer object name ); |
From: Mark H. <mha...@us...> - 2005-01-30 13:39:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18154 Modified Files: win32pipe.i Log Message: Autoduck fixes - @pymeth is not required for methods implemented in .i Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32pipe.i 13 Sep 2004 01:46:13 -0000 1.10 --- win32pipe.i 30 Jan 2005 13:39:26 -0000 1.11 *************** *** 136,149 **** %native(popen4) PyPopen4; - // @pymeth GetNamedPipeHandleState|Returns the state of a named pipe. %native(GetNamedPipeHandleState) MyGetNamedPipeHandleState; - // @pymeth SetNamedPipeHandleState|Sets the state of a named pipe. %native(SetNamedPipeHandleState) MySetNamedPipeHandleState; - // @pymeth ConnectNamedPipe|Connects to a named pipe %native(ConnectNamedPipe) MyConnectNamedPipe; - // @pymeth CallNamedPipe|Calls a named pipe %native(CallNamedPipe) MyCallNamedPipe; --- 136,145 ---- |
From: Mark H. <mha...@us...> - 2005-01-30 13:38:47
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18031 Modified Files: win32service.i Log Message: Autoduck correction. Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32service.i 8 Jan 2005 00:15:07 -0000 1.6 --- win32service.i 30 Jan 2005 13:38:37 -0000 1.7 *************** *** 133,137 **** ! // @object PyHDESK|Object representing a handle to a desktop, created by CreateDesktop, GetThreadDesktop, and OpenDesktop. class PyHDESK : public PyHANDLE --- 133,138 ---- ! // @object PyHDESK|Object representing a handle to a desktop, created by ! // <om win32service.CreateDesktop>, <om win32service.GetThreadDesktop> and <om win32service.OpenDesktop>. class PyHDESK : public PyHANDLE *************** *** 263,267 **** } ! // @pymethod (PyUNICODE,...)|PyHWINSTA|EnumDesktops|Lists names of desktops in the window station PyObject *PyHWINSTA::EnumDesktops(PyObject *self, PyObject *args) { --- 264,268 ---- } ! // @pymethod (PyUNICODE,...)|<o PyHWINSTA>|EnumDesktops|Lists names of desktops in the window station PyObject *PyHWINSTA::EnumDesktops(PyObject *self, PyObject *args) { |
From: Mark H. <mha...@us...> - 2005-01-30 13:37:40
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17753 Modified Files: makedfromi.py Log Message: Fix a number of issues found when Roger pointed out many @pyparms were being dropped. Index: makedfromi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/makedfromi.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** makedfromi.py 8 Nov 2004 02:58:35 -0000 1.6 --- makedfromi.py 30 Jan 2005 13:37:24 -0000 1.7 *************** *** 29,33 **** def make_doc_summary(inFile, outFile): methods = [] - nativeMethods = [] modDoc = "" modName = "" --- 29,32 ---- *************** *** 55,74 **** doc, lineNo = GetComments(line, lineNo, lines) constants.append((cname, doc)) ! elif line[:2]=="//": ! rest = line[2:].strip() ! if rest.startswith("@pyswig"): ! doc, lineNo = GetComments(line, lineNo, lines) ! curMethod = doc[8:], [] ! methods.append(curMethod) ! elif rest.startswith("@pymeth "): ! doc, lineNo = GetComments(line, lineNo, lines) ! nativeMethods.append(line+doc) else: ! if rest.startswith("@"): doc, lineNo = GetComments(line, lineNo, lines) ! if curMethod: ! curMethod[1].append("// " + doc + '\n') ! else: ! extra_tags.append("// " + doc + '\n') except: print "Line %d is badly formed - %s" % (lineNo, str(sys.exc_value)) --- 54,82 ---- doc, lineNo = GetComments(line, lineNo, lines) constants.append((cname, doc)) ! else: ! try: ! pos = line.index("//") ! except ValueError: ! pass else: ! rest = line[pos+2:].strip() ! if rest.startswith("@pymeth"): ! # manual markup - reset the current method. ! curMethod = None ! if rest.startswith("@doc"): ! pass ! elif rest.startswith("@pyswig"): doc, lineNo = GetComments(line, lineNo, lines) ! curMethod = doc[8:], [] ! methods.append(curMethod) ! elif rest.startswith("@const"): ! doc, lineNo = GetComments(line, lineNo, lines) ! else: ! if rest.startswith("@"): ! doc, lineNo = GetComments(line, lineNo, lines) ! if curMethod: ! curMethod[1].append("// " + doc + '\n') ! else: ! extra_tags.append("// " + doc + '\n') except: print "Line %d is badly formed - %s" % (lineNo, str(sys.exc_value)) *************** *** 79,85 **** # creating a synthetic module name when this happens. max_methods = 90 ! # native ones first - hopefully never more than 90 of them! ! assert len(nativeMethods) < max_methods ! method_num = len(nativeMethods) chunk_number = 0 while 1: --- 87,91 ---- # creating a synthetic module name when this happens. max_methods = 90 ! method_num = 0 chunk_number = 0 while 1: *************** *** 97,100 **** --- 103,107 ---- thisModName = thisModName + " (more %d)" % (chunk_number+1,) + outFile.write("\n") for (meth, extras) in these_methods: fields = string.split(meth,'|') *************** *** 102,106 **** print "**Error - %s does not have enough fields" % meth else: ! outFile.write("\n// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2])) for extra in extras: outFile.write(extra) --- 109,113 ---- print "**Error - %s does not have enough fields" % meth else: ! outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2])) for extra in extras: outFile.write(extra) *************** *** 113,128 **** fields = string.split(meth,'|') outFile.write("// @pymeth %s|%s\n" % (fields[1], fields[2])) - if chunk_number == 0: - for meth in nativeMethods: - outFile.write(meth) - outFile.write("\n") chunk_number += 1 method_num += max_methods outFile.write("\n") - for (cname, doc) in constants: - outFile.write("// @const %s|%s|%s\n" % (modName, cname, doc) ) for extra in extra_tags: outFile.write("%s\n" % (extra) ) --- 120,131 ---- fields = string.split(meth,'|') outFile.write("// @pymeth %s|%s\n" % (fields[1], fields[2])) chunk_number += 1 method_num += max_methods outFile.write("\n") for extra in extra_tags: outFile.write("%s\n" % (extra) ) + for (cname, doc) in constants: + outFile.write("// @const %s|%s|%s\n" % (modName, cname, doc) ) |
From: Mark H. <mha...@us...> - 2005-01-28 22:40:19
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13384 Modified Files: win32template.cpp win32uiole.cpp Log Message: * Inlcude the type of the object received when raising a TypeError. * Move to the new COM error functions. Index: win32uiole.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiole.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32uiole.cpp 20 Jan 2004 22:27:16 -0000 1.4 --- win32uiole.cpp 28 Jan 2005 22:40:01 -0000 1.5 *************** *** 93,97 **** HRESULT hr = pEngine->QueryInterface(IID_IDispatch, (void **)&pDisp); if (FAILED(hr)) ! return OleSetOleError(hr); pEngine->Release(); return PyCom_PyObjectFromIUnknown(pDisp, IID_IDispatch, FALSE); --- 93,97 ---- HRESULT hr = pEngine->QueryInterface(IID_IDispatch, (void **)&pDisp); if (FAILED(hr)) ! return PyCom_BuildPyException(hr); pEngine->Release(); return PyCom_PyObjectFromIUnknown(pDisp, IID_IDispatch, FALSE); Index: win32template.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32template.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32template.cpp 27 Nov 1999 08:03:41 -0000 1.2 --- win32template.cpp 28 Jan 2005 22:40:01 -0000 1.3 *************** *** 443,447 **** if (PyErr_Occurred()) gui_print_error(); ! PyErr_SetString(PyExc_TypeError,"PyCTemplate::CreateNewFrame must return a PyCFrameWnd object."); gui_print_error(); return NULL; --- 443,450 ---- if (PyErr_Occurred()) gui_print_error(); ! const char *typ_str = retObject ? retObject->ob_type->tp_name : "<null>"; ! PyErr_Format(PyExc_TypeError, ! "PyCTemplate::CreateNewFrame must return a PyCFrameWnd object (got %s).", ! typ_str); gui_print_error(); return NULL; *************** *** 472,476 **** if (PyErr_Occurred()) gui_print_error(); ! PyErr_SetString(PyExc_TypeError,"PyCTemplate::CreateNewDocument must return a PyCDocument object."); TRACE0("CPythonDocTemplate::CreateNewDocument fails due to return type error\n"); return NULL; --- 475,482 ---- if (PyErr_Occurred()) gui_print_error(); ! const char *typ_str = retObject ? retObject->ob_type->tp_name : "<null>"; ! PyErr_Format(PyExc_TypeError, ! "PyCTemplate::CreateNewDocument must return a PyCDocument object (got %s).", ! typ_str); TRACE0("CPythonDocTemplate::CreateNewDocument fails due to return type error\n"); return NULL; *************** *** 499,503 **** if (PyErr_Occurred()) gui_print_error(); ! PyErr_SetString(PyExc_TypeError,"PyCTemplate::OpenDocumentFile must return a PyCDocument object."); TRACE0("CPythonDocTemplate::CreateNewDocument fails due to return type error\n"); return NULL; --- 505,512 ---- if (PyErr_Occurred()) gui_print_error(); ! const char *typ_str = retObject ? retObject->ob_type->tp_name : "<null>"; ! PyErr_Format(PyExc_TypeError, ! "PyCTemplate::OpenDocumentFile must return a PyCDocument object (got %s).", ! typ_str); TRACE0("CPythonDocTemplate::CreateNewDocument fails due to return type error\n"); return NULL; *************** *** 535,539 **** } CEnterLeavePython _celp; ! PyErr_SetString(PyExc_TypeError,"PyCTemplate::MatchDocType must return an integer or PyCDocument object."); gui_print_error(); return CDocTemplate::noAttempt; --- 544,550 ---- } CEnterLeavePython _celp; ! const char *typ_str = ret ? ret->ob_type->tp_name : "<null>"; ! PyErr_Format(PyExc_TypeError,"PyCTemplate::MatchDocType must return an integer or PyCDocument object (got %s).", ! typ_str); gui_print_error(); return CDocTemplate::noAttempt; |
From: Roger U. <ru...@us...> - 2005-01-28 08:50:32
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13579/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Check for NULL security descriptor pointer in PyWinMethod_NewSECURITY_DESCRIPTOR Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PySECURITY_DESCRIPTOR.cpp 27 Jan 2005 01:46:44 -0000 1.15 --- PySECURITY_DESCRIPTOR.cpp 28 Jan 2005 08:50:20 -0000 1.16 *************** *** 84,89 **** { int descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; ! if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)) ! return new PySECURITY_DESCRIPTOR(descriptor_len); PyErr_Clear(); --- 84,97 ---- { int descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; ! if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)){ ! PyObject *ret=new PySECURITY_DESCRIPTOR(descriptor_len); ! if (((PySECURITY_DESCRIPTOR *)ret)->GetSD()==NULL){ ! if (!PyErr_Occurred()) ! PyErr_SetString(PyExc_NotImplementedError,"Security descriptors are not supported on this platform"); ! Py_DECREF(ret); ! ret=NULL; ! } ! return ret; ! } PyErr_Clear(); *************** *** 239,242 **** --- 247,251 ---- // SECURITY_DESCRIPTOR stuff is not supported. this->m_psd = NULL; + return TRUE; } else if (_IsSelfRelative(psd)){ |
From: Mark H. <mha...@us...> - 2005-01-28 04:43:21
|
Update of /cvsroot/pywin32/pywin32/isapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29172 Modified Files: install.py Log Message: * When removing an extension, don't bother checking the DLL is up to date. * Be more robust in creating and removing virtual directories Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** install.py 6 Oct 2004 05:11:52 -0000 1.1 --- install.py 28 Jan 2005 04:43:09 -0000 1.2 *************** *** 158,161 **** --- 158,166 ---- 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,)) *************** *** 309,319 **** try: directory = GetObject(FindPath(options, vd.Server, vd.Name)) - directory.AppUnload() - parent = GetObject(directory.Parent) - parent.Delete(directory.Class, directory.Name) except pythoncom.com_error, details: rc = _GetWin32ErrorCode(details) if rc != winerror.ERROR_PATH_NOT_FOUND: raise _CallHook(vd, "PostRemove", options) log (1, "Deleted Virtual Directory: %s" % (vd.Name,)) --- 314,338 ---- try: directory = GetObject(FindPath(options, vd.Server, vd.Name)) except pythoncom.com_error, details: rc = _GetWin32ErrorCode(details) if rc != winerror.ERROR_PATH_NOT_FOUND: raise + log(2, "VirtualDirectory '%s' did not exist" % vd.Name) + directory = None + if directory is not None: + # Be robust should IIS get upset about unloading. + try: + directory.AppUnLoad() + except: + exc_val = sys.exc_info()[1] + log(2, "AppUnLoad() for %s failed: %s" % (vd.Name, exc_val)) + # Continue trying to delete it. + try: + parent = GetObject(directory.Parent) + parent.Delete(directory.Class, directory.Name) + except: + exc_val = sys.exc_info()[1] + log(1, "Failed to remove directory %s: %s" % (vd.Name, exc_val)) + _CallHook(vd, "PostRemove", options) log (1, "Deleted Virtual Directory: %s" % (vd.Name,)) *************** *** 337,341 **** if sm.Module is None: sm.Module = dll_name ! def GetLoaderModuleName(mod_name): # find the name of the DLL hosting us. # By default, this is "_{module_base_name}.dll" --- 356,360 ---- if sm.Module is None: sm.Module = dll_name ! def GetLoaderModuleName(mod_name, check_module = None): # find the name of the DLL hosting us. # By default, this is "_{module_base_name}.dll" *************** *** 357,361 **** dll_name = os.path.abspath(os.path.join(path, "_" + base + ".dll")) # Check we actually have it. ! if not hasattr(sys, "frozen"): CheckLoaderModule(dll_name) return dll_name --- 376,381 ---- dll_name = os.path.abspath(os.path.join(path, "_" + base + ".dll")) # Check we actually have it. ! if check_module is None: check_module = not hasattr(sys, "frozen") ! if check_module: CheckLoaderModule(dll_name) return dll_name *************** *** 372,376 **** def UninstallModule(conf_module_name, params, options): ! loader_dll = GetLoaderModuleName(conf_module_name) _PatchParamsModule(params, loader_dll, False) Uninstall(params, options) --- 392,396 ---- def UninstallModule(conf_module_name, params, options): ! loader_dll = GetLoaderModuleName(conf_module_name, False) _PatchParamsModule(params, loader_dll, False) Uninstall(params, options) |
From: Mark H. <mha...@us...> - 2005-01-28 02:12:32
|
Update of /cvsroot/pywin32/pywin32/SWIG/swig_lib/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30547 Modified Files: pywintypes.i Log Message: Enhance LARGE_INTEGER support. Index: pywintypes.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/SWIG/swig_lib/python/pywintypes.i,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pywintypes.i 8 Nov 2003 12:18:40 -0000 1.3 --- pywintypes.i 28 Jan 2005 02:12:23 -0000 1.4 *************** *** 387,395 **** //--------------------------------------------------------------------------- %typemap(python,in) LARGE_INTEGER { ! if (!PyWinObject_AsLARGE_INTEGER($source, &$target, FALSE)) return NULL; } %typemap(python,in) ULARGE_INTEGER { ! if (!PyWinObject_AsULARGE_INTEGER($source, &$target, FALSE)) return NULL; } --- 387,405 ---- //--------------------------------------------------------------------------- %typemap(python,in) LARGE_INTEGER { ! if (!PyWinObject_AsLARGE_INTEGER($source, &$target)) ! return NULL; ! } ! %typemap(python,in) LARGE_INTEGER * (LARGE_INTEGER temp) { ! $target = &temp; ! if (!PyWinObject_AsLARGE_INTEGER($source, $target)) return NULL; } %typemap(python,in) ULARGE_INTEGER { ! if (!PyWinObject_AsULARGE_INTEGER($source, &$target)) ! return NULL; ! } ! %typemap(python,in) ULARGE_INTEGER * (ULARGE_INTEGER temp) { ! $target = &temp; ! if (!PyWinObject_AsULARGE_INTEGER($source, $target)) return NULL; } |
From: Trent M. <tm...@us...> - 2005-01-28 00:24:35
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7513/shell/src Modified Files: shell.cpp Log Message: This patch to PyWin32 in March 2004 added the SHGetSettings shell API method to win32com.shell.shell without dynamically loading the DLL (because this function is only available on later versions of shell32.dll that WinNT may not have): http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/com/win32comext/shell/src/shell.cpp?r1=1.25&r2=1.26 Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** shell.cpp 25 Jan 2005 12:13:41 -0000 1.33 --- shell.cpp 28 Jan 2005 00:24:26 -0000 1.34 *************** *** 1516,1521 **** if (!PyArg_ParseTuple(args, "|l:SHGetSettings", &mask)) return NULL; SHELLFLAGSTATE state; ! SHGetSettings(&state, mask); PyObject *ret = PyDict_New(); CHECK_SET_VAL(SSF_DESKTOPHTML, mask, fDesktopHTML); --- 1516,1536 ---- if (!PyArg_ParseTuple(args, "|l:SHGetSettings", &mask)) return NULL; + + typedef void (WINAPI * PFNSHGetSettings)(LPSHELLFLAGSTATE, DWORD); + + // @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"); + if (pfnSHGetSettings==NULL) + return OleSetOleError(E_NOTIMPL); + SHELLFLAGSTATE state; ! PY_INTERFACE_PRECALL; ! (*pfnSHGetSettings)(&state, mask); ! PY_INTERFACE_POSTCALL; ! PyObject *ret = PyDict_New(); CHECK_SET_VAL(SSF_DESKTOPHTML, mask, fDesktopHTML); |
From: Mark H. <mha...@us...> - 2005-01-28 00:02:35
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv806 Modified Files: win32trace.cpp Log Message: Hack so that win32event again works on NT. Index: win32trace.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32trace.cpp 9 Sep 2004 01:20:52 -0000 1.12 --- win32trace.cpp 28 Jan 2005 00:02:23 -0000 1.13 *************** *** 46,49 **** --- 46,61 ---- const char *EVENT_EMPTY_OBJECT_NAME = "Global\\PythonTraceOutputEmptyEvent"; + // Function to remove the "Global\\" prefix on NT4/9x + static const char *FixupObjectName(const char *global_name) + { + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + if (info.dwMajorVersion <= 4) // NT, 9x + return strchr(global_name, '\\')+1; + // 2000 or later - "Global\\" prefix OK. + return global_name; + } + // no const because of python api, this is the name of the entry // in the sys module that we store our PyTraceObject pointer *************** *** 221,225 **** } Py_BEGIN_ALLOW_THREADS ! *pHandle = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, 0, BUFFER_SIZE, MAP_OBJECT_NAME); Py_END_ALLOW_THREADS if (*pHandle==NULL) { --- 233,237 ---- } Py_BEGIN_ALLOW_THREADS ! *pHandle = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, 0, BUFFER_SIZE, FixupObjectName(MAP_OBJECT_NAME)); Py_END_ALLOW_THREADS if (*pHandle==NULL) { *************** *** 572,576 **** }; - extern "C" __declspec(dllexport) void initwin32trace(void) --- 584,587 ---- *************** *** 603,607 **** assert(hMutex == NULL); ! hMutex = CreateMutex(&sa, FALSE, MUTEX_OBJECT_NAME); if (hMutex==NULL) { PyWin_SetAPIError("CreateMutex"); --- 614,618 ---- assert(hMutex == NULL); ! hMutex = CreateMutex(&sa, FALSE, FixupObjectName(MUTEX_OBJECT_NAME)); if (hMutex==NULL) { PyWin_SetAPIError("CreateMutex"); *************** *** 609,613 **** } assert (hEvent==NULL); ! hEvent = CreateEvent(&sa, FALSE, FALSE, EVENT_OBJECT_NAME); if (hEvent==NULL) { PyWin_SetAPIError("CreateEvent"); --- 620,624 ---- } assert (hEvent==NULL); ! hEvent = CreateEvent(&sa, FALSE, FALSE, FixupObjectName(EVENT_OBJECT_NAME)); if (hEvent==NULL) { PyWin_SetAPIError("CreateEvent"); *************** *** 615,619 **** } assert (hEventEmpty==NULL); ! hEventEmpty = CreateEvent(&sa, FALSE, FALSE, EVENT_EMPTY_OBJECT_NAME); if (hEventEmpty==NULL) { PyWin_SetAPIError("CreateEvent"); --- 626,630 ---- } assert (hEventEmpty==NULL); ! hEventEmpty = CreateEvent(&sa, FALSE, FALSE, FixupObjectName(EVENT_EMPTY_OBJECT_NAME)); if (hEventEmpty==NULL) { PyWin_SetAPIError("CreateEvent"); |
From: Trent M. <tm...@us...> - 2005-01-27 01:46:53
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19651 Modified Files: PySECURITY_ATTRIBUTES.cpp PySECURITY_DESCRIPTOR.cpp Log Message: Patch to fix the use of pywintypes.SECURITY_ATTRIBUTES() on Win9x; ultimately to allow one to use the SECURITY_ATTRIBUTES.bInheritHandles boolean with win32pipe.CreatePipe without being required to support the SECURITY_DESCRIPTOR structure, whose use is not supported on Win9x. The breaks was in these checkins: http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/win32/src/PySECURITY_ATTRIBUTES.cpp?r1=1.3&r2=1.4 http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp?r1=1.7&r2=1.8 Most of this patch is from Roger Upole. My change involved changing the trigger from a failure in InitializeSecurityDescriptor (which doesn't actually fail on Win9x) to a zero retval from GetSecurityDescriptorLength. Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PySECURITY_DESCRIPTOR.cpp 19 Jan 2005 21:16:20 -0000 1.14 --- PySECURITY_DESCRIPTOR.cpp 27 Jan 2005 01:46:44 -0000 1.15 *************** *** 235,239 **** free (this->m_psd); DWORD sdsize = GetSecurityDescriptorLength(psd); ! if (_IsSelfRelative(psd)){ this->m_psd = malloc(sdsize); memcpy(this->m_psd, psd, sdsize); --- 235,244 ---- free (this->m_psd); DWORD sdsize = GetSecurityDescriptorLength(psd); ! if (sdsize == 0){ ! // GetSecurityDescriptorLength returns 0 on Win9x where the ! // SECURITY_DESCRIPTOR stuff is not supported. ! this->m_psd = NULL; ! } ! else if (_IsSelfRelative(psd)){ this->m_psd = malloc(sdsize); memcpy(this->m_psd, psd, sdsize); *************** *** 688,694 **** cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); PSECURITY_DESCRIPTOR psd = malloc(cb); - ::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION); this->m_psd=NULL; ! this->SetSD(psd); free(psd); } --- 693,699 ---- cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); PSECURITY_DESCRIPTOR psd = malloc(cb); this->m_psd=NULL; ! if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)) ! this->SetSD(psd); free(psd); } Index: PySECURITY_ATTRIBUTES.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_ATTRIBUTES.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PySECURITY_ATTRIBUTES.cpp 30 Mar 2004 04:14:27 -0000 1.6 --- PySECURITY_ATTRIBUTES.cpp 27 Jan 2005 01:46:44 -0000 1.7 *************** *** 49,54 **** *ppSECURITY_ATTRIBUTES = pysa->GetSA(); // in case the PySECURITY_DESCRIPTOR has been manipulated and points to a different address now ! ((SECURITY_ATTRIBUTES *)*ppSECURITY_ATTRIBUTES)->lpSecurityDescriptor = ! ((PySECURITY_DESCRIPTOR *)pysa->m_obSD)->GetSD(); } return TRUE; --- 49,56 ---- *ppSECURITY_ATTRIBUTES = pysa->GetSA(); // in case the PySECURITY_DESCRIPTOR has been manipulated and points to a different address now ! if (pysa->m_obSD==Py_None) ! (*ppSECURITY_ATTRIBUTES)->lpSecurityDescriptor=NULL; ! else ! (*ppSECURITY_ATTRIBUTES)->lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)pysa->m_obSD)->GetSD(); } return TRUE; *************** *** 87,93 **** /*static*/ struct memberlist PySECURITY_ATTRIBUTES::memberlist[] = { {"bInheritHandle", T_INT, OFF(m_sa.bInheritHandle)}, // @prop integer|bInheritHandle|Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. ! {"SECURITY_DESCRIPTOR", T_OBJECT, OFF(m_obSD)}, ! {NULL} /* Sentinel */ }; PySECURITY_ATTRIBUTES::PySECURITY_ATTRIBUTES(void) --- 89,102 ---- /*static*/ struct memberlist PySECURITY_ATTRIBUTES::memberlist[] = { {"bInheritHandle", T_INT, OFF(m_sa.bInheritHandle)}, // @prop integer|bInheritHandle|Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. ! {"SECURITY_DESCRIPTOR", T_OBJECT, OFF(m_obSD)}, // @prop <o PySECURITY_DESCRIPTOR>|SECURITY_DESCRIPTOR|A PySECURITY_DESCRIPTOR, or None ! {NULL} }; + // @comm On platforms that support security descriptor operations, SECURITY_DESCRIPTOR + // defaults to a blank security descriptor with no owner, group, dacl, or sacl. + // Set to None to use a NULL security descriptor instead. + // When PySECURITY_ATTRIBUTES is created on Windows 95/98/Me, SECURITY_DESCRIPTOR defaults + // to None and should not be changed. + // When SECURITY_DESCRIPTOR is not None, any of its methods can be invoked directly + // on the PySECURITY_ATTRIBUTES object PySECURITY_ATTRIBUTES::PySECURITY_ATTRIBUTES(void) *************** *** 96,104 **** _Py_NewReference(this); m_sa.nLength = sizeof(SECURITY_ATTRIBUTES); ! m_obSD = new PySECURITY_DESCRIPTOR(); ! m_sa.lpSecurityDescriptor = ((PySECURITY_DESCRIPTOR *)m_obSD)->GetSD(); m_sa.bInheritHandle = TRUE; } - PySECURITY_ATTRIBUTES::PySECURITY_ATTRIBUTES(const SECURITY_ATTRIBUTES &sa) { --- 105,120 ---- _Py_NewReference(this); m_sa.nLength = sizeof(SECURITY_ATTRIBUTES); ! m_obSD = new PySECURITY_DESCRIPTOR(SECURITY_DESCRIPTOR_MIN_LENGTH); ! m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)m_obSD)->GetSD(); ! // On win95/98/me (or any platform that doesn't have NT security) the ! // initialization of the SECURITY_DESCRIPTOR shoudl fail, leaving the ! // sd NULL. ! if (m_sa.lpSecurityDescriptor==NULL){ ! Py_DECREF(m_obSD); ! Py_INCREF(Py_None); ! m_obSD=Py_None; ! } m_sa.bInheritHandle = TRUE; } PySECURITY_ATTRIBUTES::PySECURITY_ATTRIBUTES(const SECURITY_ATTRIBUTES &sa) { *************** *** 106,112 **** _Py_NewReference(this); m_sa = sa; ! m_obSD = new PySECURITY_DESCRIPTOR(sa.lpSecurityDescriptor); ! // above creates a copy, put pointer to copy back in SECURITY_ATTRIBUTES structure ! m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)m_obSD)->GetSD(); } --- 122,136 ---- _Py_NewReference(this); m_sa = sa; ! if (sa.lpSecurityDescriptor==NULL){ ! // ???? could change existing behaviour - what happened with a NULL previously ???? ! // This is consistent with PyWinObject_FromSECURITY_DESCRIPTOR ! Py_INCREF(Py_None); ! m_obSD=Py_None; ! } ! else{ ! m_obSD = new PySECURITY_DESCRIPTOR(sa.lpSecurityDescriptor); ! // above creates a copy, put pointer to copy back in SECURITY_ATTRIBUTES structure ! m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)m_obSD)->GetSD(); ! } } *************** *** 129,135 **** return res; // let it inherit methods from PySECURITY_DESCRIPTOR for backward compatibility - PyErr_Clear(); PySECURITY_ATTRIBUTES *This = (PySECURITY_ATTRIBUTES *)self; ! return ((PySECURITY_DESCRIPTOR *)(This->m_obSD))->getattr(This->m_obSD, name); } --- 153,162 ---- return res; // let it inherit methods from PySECURITY_DESCRIPTOR for backward compatibility PySECURITY_ATTRIBUTES *This = (PySECURITY_ATTRIBUTES *)self; ! if (This->m_obSD!=Py_None){ ! PyErr_Clear(); ! res=((PySECURITY_DESCRIPTOR *)(This->m_obSD))->getattr(This->m_obSD, name); ! } ! return res; } *************** *** 141,151 **** } if (strcmp(name, "SECURITY_DESCRIPTOR")==0){ ! if (!PySECURITY_DESCRIPTOR_Check(v)){ ! PyErr_SetString(PyExc_TypeError, "The object is not a PySECURITY_DESCRIPTOR object"); return -1; } - PySECURITY_ATTRIBUTES *This=(PySECURITY_ATTRIBUTES *)self; - // Py_DECREF(This->m_obSD); - This->m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)This->m_obSD)->GetSD(); } return PyMember_Set((char *)self, memberlist, name, v); --- 168,180 ---- } if (strcmp(name, "SECURITY_DESCRIPTOR")==0){ ! PySECURITY_ATTRIBUTES *This=(PySECURITY_ATTRIBUTES *)self; ! if (v==Py_None) ! This->m_sa.lpSecurityDescriptor=NULL; ! else if (PySECURITY_DESCRIPTOR_Check(v)) ! This->m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)This->m_obSD)->GetSD(); ! else{ ! PyErr_SetString(PyExc_TypeError, "SECURITY_DESCRIPTOR must be a PySECURITY_DESCRIPTOR, or None"); return -1; } } return PyMember_Set((char *)self, memberlist, name, v); |
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8013 Modified Files: PyIAsyncOperation.cpp PyIColumnProvider.cpp PyIContextMenu.cpp PyICopyHook.cpp PyIDropTargetHelper.cpp PyIExtractIcon.cpp PyIShellView.cpp Log Message: Have the shell dump all gateway errors to the log. Index: PyIDropTargetHelper.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIDropTargetHelper.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIDropTargetHelper.cpp 19 Mar 2004 04:33:16 -0000 1.1 --- PyIDropTargetHelper.cpp 26 Jan 2005 22:31:09 -0000 1.2 *************** *** 177,181 **** PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obpDataObj; obpDataObj = PyCom_PyObjectFromIUnknown(pDataObj, IID_IDataObject, TRUE); --- 177,181 ---- PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("DragEnter"); PyObject *obpDataObj; obpDataObj = PyCom_PyObjectFromIUnknown(pDataObj, IID_IDataObject, TRUE); *************** *** 195,199 **** PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *result; HRESULT hr=InvokeViaPolicy("DragOver", &result, "Ol", obpt, dwEffect); --- 195,199 ---- PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("DragOver"); PyObject *result; HRESULT hr=InvokeViaPolicy("DragOver", &result, "Ol", obpt, dwEffect); *************** *** 219,223 **** PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obpDataObj; obpDataObj = PyCom_PyObjectFromIUnknown(pDataObj, IID_IDataObject, TRUE); --- 219,223 ---- PY_GATEWAY_METHOD; PyObject *obpt = PyObject_FromPOINT(*pt); ! if (obpt==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Drop"); PyObject *obpDataObj; obpDataObj = PyCom_PyObjectFromIUnknown(pDataObj, IID_IDataObject, TRUE); Index: PyIContextMenu.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIContextMenu.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIContextMenu.cpp 12 Mar 2004 08:35:10 -0000 1.2 --- PyIContextMenu.cpp 26 Jan 2005 22:31:09 -0000 1.3 *************** *** 153,157 **** PY_GATEWAY_METHOD; PyObject *oblpici = PyObject_FromCMINVOKECOMMANDINFO(lpici); ! if (oblpici==NULL) return PyCom_HandlePythonFailureToCOM(); HRESULT hr=InvokeViaPolicy("InvokeCommand", NULL, "(O)", oblpici); Py_DECREF(oblpici); --- 153,157 ---- PY_GATEWAY_METHOD; PyObject *oblpici = PyObject_FromCMINVOKECOMMANDINFO(lpici); ! if (oblpici==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("InvokeCommand"); HRESULT hr=InvokeViaPolicy("InvokeCommand", NULL, "(O)", oblpici); Py_DECREF(oblpici); Index: PyIColumnProvider.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIColumnProvider.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIColumnProvider.cpp 12 Mar 2004 08:40:23 -0000 1.2 --- PyIColumnProvider.cpp 26 Jan 2005 22:31:09 -0000 1.3 *************** *** 143,147 **** PY_GATEWAY_METHOD; PyObject *obpsci = PyObject_FromSHCOLUMNINIT(psci); ! if (obpsci==NULL) return PyCom_HandlePythonFailureToCOM(); HRESULT hr=InvokeViaPolicy("Initialize", NULL, "(O)", obpsci); Py_DECREF(obpsci); --- 143,147 ---- PY_GATEWAY_METHOD; PyObject *obpsci = PyObject_FromSHCOLUMNINIT(psci); ! if (obpsci==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Initialize"); HRESULT hr=InvokeViaPolicy("Initialize", NULL, "(O)", obpsci); Py_DECREF(obpsci); *************** *** 174,180 **** PY_GATEWAY_METHOD; PyObject *obpscid = PyObject_FromSHCOLUMNID(pscid); ! if (obpscid==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obpscd = PyObject_FromSHCOLUMNDATA(pscd); ! if (obpscd==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *result; HRESULT hr=InvokeViaPolicy("GetItemData", &result, "OO", obpscid, obpscd); --- 174,180 ---- PY_GATEWAY_METHOD; PyObject *obpscid = PyObject_FromSHCOLUMNID(pscid); ! if (obpscid==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetItemData"); PyObject *obpscd = PyObject_FromSHCOLUMNDATA(pscd); ! if (obpscd==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetItemData"); PyObject *result; HRESULT hr=InvokeViaPolicy("GetItemData", &result, "OO", obpscid, obpscd); Index: PyIExtractIcon.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIExtractIcon.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIExtractIcon.cpp 9 Apr 2004 11:17:27 -0000 1.3 --- PyIExtractIcon.cpp 26 Jan 2005 22:31:09 -0000 1.4 *************** *** 122,126 **** else { PyArg_ParseTuple(result, "ii", phiconLarge, phiconSmall); ! hr = PyCom_HandlePythonFailureToCOM(); } Py_DECREF(result); --- 122,126 ---- else { PyArg_ParseTuple(result, "ii", phiconLarge, phiconSmall); ! hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("Extract"); } Py_DECREF(result); *************** *** 160,164 **** } } ! hr = PyCom_HandlePythonFailureToCOM(); } Py_DECREF(result); --- 160,164 ---- } } ! hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetIconLocation"); } Py_DECREF(result); Index: PyIShellView.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellView.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIShellView.cpp 25 Jan 2005 09:39:05 -0000 1.4 --- PyIShellView.cpp 26 Jan 2005 22:31:09 -0000 1.5 *************** *** 328,332 **** PY_GATEWAY_METHOD; PyObject *obpmsg = PyObject_FromMSG(pmsg); ! if (obpmsg==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *result; HRESULT hr=InvokeViaPolicy("TranslateAccelerator", &result, "(O)", obpmsg); --- 328,332 ---- PY_GATEWAY_METHOD; PyObject *obpmsg = PyObject_FromMSG(pmsg); ! if (obpmsg==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("TranslateAccelerator"); PyObject *result; HRESULT hr=InvokeViaPolicy("TranslateAccelerator", &result, "(O)", obpmsg); *************** *** 373,379 **** PY_GATEWAY_METHOD; PyObject *obpfs = PyObject_FromFOLDERSETTINGS(pfs); ! if (obpfs==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obrect = PyObject_FromRECT(prcView); ! if (obrect==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obpsvPrevious; PyObject *obpsb; --- 373,379 ---- PY_GATEWAY_METHOD; PyObject *obpfs = PyObject_FromFOLDERSETTINGS(pfs); ! if (obpfs==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); PyObject *obrect = PyObject_FromRECT(prcView); ! if (obrect==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); PyObject *obpsvPrevious; PyObject *obpsb; *************** *** 412,416 **** PyObject_AsFOLDERSETTINGS(result, pfs); Py_DECREF(result); ! return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); } --- 412,416 ---- PyObject_AsFOLDERSETTINGS(result, pfs); Py_DECREF(result); ! return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCurrentInfo"); } *************** *** 426,430 **** PyObject *obpfn = Py_None; Py_INCREF(Py_None); ! if (obpfn==NULL) return PyCom_HandlePythonFailureToCOM(); HRESULT hr=InvokeViaPolicy("AddPropertySheetPages", NULL, "lOl", dwReserved, obpfn, lparam); Py_DECREF(obpfn); --- 426,430 ---- PyObject *obpfn = Py_None; Py_INCREF(Py_None); ! if (obpfn==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("AddPropertySheetPages"); HRESULT hr=InvokeViaPolicy("AddPropertySheetPages", NULL, "lOl", dwReserved, obpfn, lparam); Py_DECREF(obpfn); *************** *** 467,475 **** // Process the Python results, and convert back to the real params PyObject *obppv; ! if (!PyArg_Parse(result, "O" , &obppv)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obppv, riid, ppv, FALSE/* bNoneOK */)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 467,475 ---- // Process the Python results, and convert back to the real params PyObject *obppv; ! if (!PyArg_Parse(result, "O" , &obppv)) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetItemObject"); BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obppv, riid, ppv, FALSE/* bNoneOK */)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetItemObject"); Py_DECREF(result); return hr; Index: PyICopyHook.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyICopyHook.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyICopyHook.cpp 7 Oct 2003 05:13:22 -0000 1.1 --- PyICopyHook.cpp 26 Jan 2005 22:31:09 -0000 1.2 *************** *** 104,108 **** if (!PyInt_Check(result) || !PyLong_Check(result)) { PyErr_Format(PyExc_TypeError, "CopyCallBack should return an int, not a '%s'", result->ob_type->tp_name); ! hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); } else hr = PyInt_AsLong(result); --- 104,108 ---- if (!PyInt_Check(result) || !PyLong_Check(result)) { PyErr_Format(PyExc_TypeError, "CopyCallBack should return an int, not a '%s'", result->ob_type->tp_name); ! hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("CopyCallBack"); } else hr = PyInt_AsLong(result); Index: PyIAsyncOperation.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIAsyncOperation.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIAsyncOperation.cpp 2 Jul 2004 04:11:44 -0000 1.1 --- PyIAsyncOperation.cpp 26 Jan 2005 22:31:09 -0000 1.2 *************** *** 188,192 **** "Result for GetAsyncMode must be a bool (got '%s')", result->ob_type->tp_name); ! hr = PyCom_HandlePythonFailureToCOM(); } else // NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work! --- 188,192 ---- "Result for GetAsyncMode must be a bool (got '%s')", result->ob_type->tp_name); ! hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetAsyncMode"); } else // NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work! *************** *** 220,224 **** "Result for InOperation must be a bool (got '%s')", result->ob_type->tp_name); ! hr = PyCom_HandlePythonFailureToCOM(); } else // NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work! --- 220,224 ---- "Result for InOperation must be a bool (got '%s')", result->ob_type->tp_name); ! hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("InOperation"); } else // NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work! |
From: Mark H. <mha...@us...> - 2005-01-26 22:29:59
|
Update of /cvsroot/pywin32/pywin32/com/win32com/makegw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7664 Modified Files: makegw.py Log Message: Have makegw use the correct error handlers. Index: makegw.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/makegw/makegw.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** makegw.py 6 Oct 2003 13:07:02 -0000 1.7 --- makegw.py 26 Jan 2005 22:29:49 -0000 1.8 *************** *** 390,394 **** f.write('// *** The input argument %s of type "%s" was not processed ***\n// - Please ensure this conversion function exists, and is appropriate\n// - %s\n' % (arg.name, arg.raw_type, why)) f.write('\tPyObject *ob%s = PyObject_From%s(%s);\n' % (arg.name, arg.type, arg.name)) ! f.write('\tif (ob%s==NULL) return PyCom_HandlePythonFailureToCOM();\n' % arg.name) codePost = codePost + "\tPy_DECREF(ob%s);\n" % arg.name formatChars = formatChars + "O" --- 390,394 ---- f.write('// *** The input argument %s of type "%s" was not processed ***\n// - Please ensure this conversion function exists, and is appropriate\n// - %s\n' % (arg.name, arg.raw_type, why)) f.write('\tPyObject *ob%s = PyObject_From%s(%s);\n' % (arg.name, arg.type, arg.name)) ! f.write('\tif (ob%s==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("%s");\n' % (arg.name, method.name)) codePost = codePost + "\tPy_DECREF(ob%s);\n" % arg.name formatChars = formatChars + "O" *************** *** 439,447 **** parseFn = "PyArg_ParseTuple" if codePobjects: f.write(codePobjects) ! f.write('\tif (!%s(result, "%s" %s)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);\n' % (parseFn, formatChars, argsParseTuple)) if codePost: f.write('\tBOOL bPythonIsHappy = TRUE;\n') f.write(codePost) ! f.write('\tif (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);\n') f.write('\tPy_DECREF(result);\n'); f.write('\treturn hr;\n}\n\n') --- 439,447 ---- parseFn = "PyArg_ParseTuple" if codePobjects: f.write(codePobjects) ! f.write('\tif (!%s(result, "%s" %s))\n\t\treturn MAKE_PYCOM_GATEWAY_FAILURE_CODE("%s");\n' % (parseFn, formatChars, argsParseTuple, method.name)) if codePost: f.write('\tBOOL bPythonIsHappy = TRUE;\n') f.write(codePost) ! f.write('\tif (!bPythonIsHappy) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("%s");\n' % method.name) f.write('\tPy_DECREF(result);\n'); f.write('\treturn hr;\n}\n\n') |
From: Mark H. <mha...@us...> - 2005-01-26 02:31:15
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31473/include Modified Files: PythonCOMServer.h Log Message: Correct a couple of error messages. Index: PythonCOMServer.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PythonCOMServer.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PythonCOMServer.h 25 Jan 2005 13:33:16 -0000 1.5 --- PythonCOMServer.h 26 Jan 2005 02:29:43 -0000 1.6 *************** *** 151,155 **** // B/W compat hack for gateways. #define PyCom_HandlePythonFailureToCOM() \ ! PyCom_SetAndLogCOMErrorFromPyExceptionEx(this->m_pPyObject, "gateway method", GetIID()) // F/W compat hack for gateways! Must be careful about updating --- 151,155 ---- // B/W compat hack for gateways. #define PyCom_HandlePythonFailureToCOM() \ ! PyCom_SetAndLogCOMErrorFromPyExceptionEx(this->m_pPyObject, "<unknown>", GetIID()) // F/W compat hack for gateways! Must be careful about updating |
From: Mark H. <mha...@us...> - 2005-01-26 02:30:24
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31473 Modified Files: PyComHelpers.cpp Log Message: Correct a couple of error messages. Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyComHelpers.cpp 30 Mar 2004 04:26:07 -0000 1.7 --- PyComHelpers.cpp 26 Jan 2005 02:29:47 -0000 1.8 *************** *** 160,164 **** else { ! PyErr_SetString(PyExc_TypeError, "None is not a invalid interface object in this context"); return FALSE; } --- 160,164 ---- else { ! PyErr_SetString(PyExc_TypeError, "None is not a valid interface object in this context"); return FALSE; } |
From: Mark H. <mha...@us...> - 2005-01-26 02:28:36
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31237 Modified Files: ErrorUtils.cpp Log Message: exc_type and exc_tb may both be NULL - pass None to the logger to prevent crash. Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ErrorUtils.cpp 25 Jan 2005 13:33:12 -0000 1.23 --- ErrorUtils.cpp 26 Jan 2005 02:27:54 -0000 1.24 *************** *** 499,503 **** PyObject *kw = PyDict_New(); if (kw && exc_typ) { ! PyObject *exc_info = Py_BuildValue("OOO", exc_typ, exc_val, exc_tb); PyDict_SetItemString(kw, "exc_info", exc_info); Py_XDECREF(exc_info); --- 499,505 ---- PyObject *kw = PyDict_New(); if (kw && exc_typ) { ! PyObject *exc_info = Py_BuildValue("OOO", exc_typ, ! exc_val ? exc_val : Py_None, ! exc_tb ? exc_tb : Py_None); PyDict_SetItemString(kw, "exc_info", exc_info); Py_XDECREF(exc_info); |