From info at therightdirection.nl Fri Nov 9 04:28:56 2018 From: info at therightdirection.nl (the Right Direction) Date: Fri, 9 Nov 2018 10:28:56 +0100 Subject: [python-win32] windows event log Message-ID: i have a custom event log called "BGT Monitoring" i want a handler to that so i can write to this eventlog from python hAppLog = win32evtlog.RegisterEventSource(None, "BGT Monitoring Log".encode("ascii")) result is: Objects of type 'bytes' can not be converted to Unicode. what can i do? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgailer at gmail.com Fri Nov 9 14:09:57 2018 From: bgailer at gmail.com (Bob Gailer) Date: Fri, 9 Nov 2018 14:09:57 -0500 Subject: [python-win32] windows event log In-Reply-To: References: Message-ID: On Nov 9, 2018 9:04 AM, "the Right Direction" wrote: > > i have a custom event log called "BGT Monitoring" > > i want a handler to that so i can write to this eventlog from python > hAppLog = win32evtlog.RegisterEventSource(None, "BGT Monitoring Log".encode("ascii")) > > result is: Objects of type 'bytes' can not be converted to Unicode. > > what can i do? Provide the entire traceback. Bob Gailer -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgailer at gmail.com Fri Nov 9 14:17:32 2018 From: bgailer at gmail.com (Bob Gailer) Date: Fri, 9 Nov 2018 14:17:32 -0500 Subject: [python-win32] windows event log In-Reply-To: References: Message-ID: > On Nov 9, 2018 9:04 AM, "the Right Direction" wrote: > > > > i have a custom event log called "BGT Monitoring" > > > > i want a handler to that so i can write to this eventlog from python > > hAppLog = win32evtlog.RegisterEventSource(None, "BGT Monitoring Log".encode("ascii")) > > > > result is: Objects of type 'bytes' can not be converted to Unicode. > > > > what can i do? > And get rid of " encode("ascii")' Bob Gailer -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml at g.nevcal.com Thu Nov 15 20:39:52 2018 From: ml at g.nevcal.com (Glenn Linderman) Date: Thu, 15 Nov 2018 17:39:52 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? Message-ID: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> No answers on stackoverflow so maybe it is a bug I should report here. I try to change a job name in Win32 spooler using Python 3.6 and win32print on Windows 10. [And I tell the spooler to save all my print jobs, so there are a bunch in there.] Here is the code I'm using. Note that the variables js and rename are the control variables if you need to tweak this to run in your environment. js contains a substring of an existing document name, and the idea is that the document name of the first matching spool job having a document name containing that fragment will be changed to the content of the rename variable by the code. import sys, os import time import win32print ##################################### def print_job_lister( js='' ): ??? """ ??? Finds a job whose name contains the passed substring. ??? """ ??? res = None ??? for p in win32print.EnumPrinters( win32print.PRINTER_ENUM_LOCAL, None, 1 ): ??????? flags, desc, name, comment = p ??????? showprinter = True ??????? phandle = win32print.OpenPrinter( name ) ??????? print_jobs = win32print.EnumJobs( phandle, 0, -1, 1 ) ??????? for job in print_jobs: ??????????? document = job["pDocument"] ??????????? if js in document: ??????????????? if showprinter: ??????????????????? print( f'printer => {name}') ??????????????????? showprinter = False ??????????????? print( f'? Document => {document}') ??????????????? print( f'? JobId => {job["JobId"]}? Status => {job["Status"]}' ?????????????????????? f'? Pages => {job["TotalPages"]}') ??????????????? if not res: ??????????????????? res = ( name, job["JobId"]) ??????? win32print.ClosePrinter( phandle ) ??? return res ##################################### if __name__ == '__main__': ??? js = '20181114' ??? rename = 'foobar' ??? res = print_job_lister( js ) ??? print( res ) ??? if res: ??????? phandle = win32print.OpenPrinter( res[ 0 ]) ??????? jobinfo = win32print.GetJob( phandle, res[ 1 ], 1 ) ??????? jobinfo['Position'] = win32print.JOB_POSITION_UNSPECIFIED ??????? if rename: ??????????? jobinfo['pDocument'] = rename ??????????? print( f'abc {win32print.JOB_POSITION_UNSPECIFIED} {jobinfo}') ??????????? win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 ) ??????? win32print.ClosePrinter( phandle ) Here is the error I'm getting: {'JobId': 27, 'pPrinterName': 'HL6180dw', 'pMachineName': '\\\\STEPHEN', 'pUserName': 'Glenn', 'pDocument': 'duh', 'pDatatype': 'NT EMF 1.008', 'pStatus': None, 'Status': 8210, 'Priority': 1, 'Position': 0, 'TotalPages': 22, 'PagesPrinted': 0, 'Submitted': pywintypes.datetime(2018, 11, 14, 21, 1, 27, 882000, tzinfo=TimeZoneInfo('GMT Standard Time', True))} Traceback (most recent call last): ? File "D:\my\py\spool.py", line 109, in ??? win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 ) pywintypes.error: (1804, 'SetJob', 'The specified datatype is invalid.') -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Nov 16 15:08:36 2018 From: timr at probo.com (Tim Roberts) Date: Fri, 16 Nov 2018 12:08:36 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> Message-ID: Glenn Linderman wrote: > > Here is the code I'm using. Note that the variables js and rename are > the control variables if you need to tweak this to run in your > environment. js contains a substring of an existing document name, and > the idea is that the document name of the first matching spool job > having a document name containing that fragment will be changed to the > content of the rename variable by the code. > ... > Here is the error I'm getting: > > {'JobId': 27, 'pPrinterName': 'HL6180dw', 'pMachineName': > '\\\\STEPHEN', 'pUserName': 'Glenn', 'pDocument': 'duh', 'pDatatype': > 'NT EMF 1.008', 'pStatus': None, 'Status': 8210, 'Priority': 1, > 'Position': 0, 'TotalPages': 22, 'PagesPrinted': 0, 'Submitted': > pywintypes.datetime(2018, 11, 14, 21, 1, 27, 882000, > tzinfo=TimeZoneInfo('GMT Standard Time', True))} > Traceback (most recent call last): > ? File "D:\my\py\spool.py", line 109, in > ??? win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 ) > pywintypes.error: (1804, 'SetJob', 'The specified datatype is invalid.') That's very odd.? This is not from the Pywin32 code --? it has correctly parsed your structure.? That error is coming from the SetJob API itself (ERROR_INVALID_DATATYPE).? As an experiment, have you tried coding up the exact same sequence as a C program to see if you get the same error? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From v+python at g.nevcal.com Fri Nov 16 15:33:20 2018 From: v+python at g.nevcal.com (Glenn Linderman) Date: Fri, 16 Nov 2018 12:33:20 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> Message-ID: <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> On 11/16/2018 12:08 PM, Tim Roberts wrote: > Glenn Linderman wrote: >> >> Here is the code I'm using. Note that the variables js and rename are >> the control variables if you need to tweak this to run in your >> environment. js contains a substring of an existing document name, >> and the idea is that the document name of the first matching spool >> job having a document name containing that fragment will be changed >> to the content of the rename variable by the code. >> ... >> Here is the error I'm getting: >> >> {'JobId': 27, 'pPrinterName': 'HL6180dw', 'pMachineName': >> '\\\\STEPHEN', 'pUserName': 'Glenn', 'pDocument': 'duh', 'pDatatype': >> 'NT EMF 1.008', 'pStatus': None, 'Status': 8210, 'Priority': 1, >> 'Position': 0, 'TotalPages': 22, 'PagesPrinted': 0, 'Submitted': >> pywintypes.datetime(2018, 11, 14, 21, 1, 27, 882000, >> tzinfo=TimeZoneInfo('GMT Standard Time', True))} >> Traceback (most recent call last): >> ? File "D:\my\py\spool.py", line 109, in >> ??? win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 ) >> pywintypes.error: (1804, 'SetJob', 'The specified datatype is invalid.') > > That's very odd.? This is not from the Pywin32 code --? it has > correctly parsed your structure.? That error is coming from the SetJob > API itself (ERROR_INVALID_DATATYPE).? As an experiment, have you tried > coding up the exact same sequence as a C program to see if you get the > same error? > Hi Tim, Thanks for your response. I've not coded up the equivalent C program, as I don't have a C compiler installed here, and haven't done any C coding for 8 or 10 years. Were you able to reproduce the problem, or is your error analysis based on code reading? Glenn -------------- next part -------------- An HTML attachment was scrubbed... URL: From Gary.Scorby at finastra.com Fri Nov 16 15:32:57 2018 From: Gary.Scorby at finastra.com (Scorby, Gary) Date: Fri, 16 Nov 2018 20:32:57 +0000 Subject: [python-win32] Login dialog user ID restriction? Message-ID: We have been using the login dialog that comes with pywin32 for over a decade. Works great. [cid:image002.jpg at 01D47DA8.65B2A050] We have a client who until recently required a 4 character max user ID. Now they want an option for up to a 19 character user ID. I told them no problem, that should work. One of their user decided to go for it and set their password to 19 characters on their server, then tried to log in via the login box. They claimed only 14 characters will fit in the User ID entry window. Really? So I ran some tests. I held down the 'a' key for user ID and 'b' key for password. Result: ('aaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbb') User ID - 14 characters PW - 21 characters Then I decided to go skinny and held the i key for both. Result: ('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiiii') User ID - 42 characters PW - 21 characters I'm a data mover and very seldom work with dialogs. The restriction appears to be entry window size based on character width. I assumed if there was any kind of a restriction it would be x number of characters. I've looked at how I send could parameters to alter this behavior but don't see anything. Feel free to verbally abuse me if I'm missing the obvious, but can anyone tell me how to expand the number of characters I can send for a user ID? Thank you Gary "FINASTRA" is the trade name of the FINASTRA group of companies. This email and any attachments have been scanned for known viruses using multiple scanners. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the named recipient of this email please notify us immediately and do not copy it or use it for any purpose, nor disclose its contents to any other person. This email does not constitute the commencement of legal relations between you and FINASTRA. Please refer to the executed contract between you and the relevant member of the FINASTRA group for the identity of the contracting party with which you are dealing. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 7739 bytes Desc: image002.jpg URL: From v+python at g.nevcal.com Sat Nov 17 01:28:37 2018 From: v+python at g.nevcal.com (Glenn Linderman) Date: Fri, 16 Nov 2018 22:28:37 -0800 Subject: [python-win32] Login dialog user ID restriction? In-Reply-To: References: Message-ID: On 11/16/2018 12:32 PM, Scorby, Gary wrote: > > We have been using the login dialog that comes with pywin32 for over a > decade.? Works great. > > We have a client who until recently required a 4 character max user > ID.? Now they want an option for up to a 19 character user ID.? I told > them no problem, that should work.? One of their user decided to go > for it and set their password to 19 characters on their server, then > tried to log in via the login box.? They claimed only 14 characters > will fit in the User ID entry window.? Really? > > So I ran some tests.? I held down the ?a? key for user ID and ?b? key > for password.? Result: > > ('aaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbb') > > User ID ? 14 characters > > PW ? 21 characters > > Then I decided to go skinny and held the i key for both.? Result: > > ('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiiii') > > User ID ? 42 characters > > PW ? 21 characters > > I?m a data mover and very seldom work with dialogs.? The restriction > appears to be entry window size based on character width.? I assumed > if there was any kind of a restriction it would be x number of > characters.? I?ve looked at how I send could parameters to alter this > behavior but don?t see anything.? Feel free to verbally abuse me if > I?m missing the obvious, but can anyone tell me how to expand the > number of characters I can send for a user ID? > > Thank you > > Gary > > One thing that might be semi-obvious is that while you can _see_ a different number of characters depending on their size, it might not be the case that only 14 characters can be accepted in the box... I'm speculating you just might have to scroll (with the cursor key) to see them all.? When you do the same character, that is not so obvious that there is scrolling going on. If you use different characters, I'm thinking you might see them scroll. Your user might have stopped because the end of the box was reached, and not tried to type the last 5 characters? Anyway, something to think about and experiment with.? I've no idea if it is possible to make that dialog box wider, so that more characters can be seen. Glenn -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 7739 bytes Desc: not available URL: From timr at probo.com Mon Nov 19 14:52:44 2018 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Nov 2018 11:52:44 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> Message-ID: <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> Glenn Linderman wrote: > > I've not coded up the equivalent C program, as I don't have a C > compiler installed here, and haven't done any C coding for 8 or 10 years. > > Were you able to reproduce the problem, or is your error analysis > based on code reading? I looked at the code.? Plus, I recognized that 1804 is a Windows errors code, not a Python error.? Let me see if I can write up a C++ test that would be useful for you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From matteo.boscolo at omniasolutions.eu Mon Nov 19 07:00:50 2018 From: matteo.boscolo at omniasolutions.eu (Matteo Boscolo) Date: Mon, 19 Nov 2018 13:00:50 +0100 Subject: [python-win32] How To Implement CoSuspendClassObjects Message-ID: Hi, I'm trying to crate an out of process com server with just one process for instance. Looking at the following documentation seems the CoSuspendClassObjects is suitable for my use https://docs.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-cosuspendclassobjects can anyone point me on how to use this function ? and if it's implemented in win32com ? best regards, Matteo -- *OmniaSolutions* /*Matteo Boscolo* Technical Manager/ Cell. +39.327.1525045 Fax. +39.041.8623730 tech at omniasolutions.eu Skype: matteo.boscolo From Gary.Scorby at finastra.com Mon Nov 19 10:10:58 2018 From: Gary.Scorby at finastra.com (Scorby, Gary) Date: Mon, 19 Nov 2018 15:10:58 +0000 Subject: [python-win32] Login dialog user ID restriction? In-Reply-To: References: Message-ID: Thanks for the response. I can hold the key down for 10 seconds or 2 minutes. The result returned when clicking OK is always the same. Also tried individual characters (like ?12345?? to confirm. When the window is full, no more characters are accepted. Gary From: python-win32 On Behalf Of Glenn Linderman Sent: Friday, November 16, 2018 10:29 PM To: python-win32 at python.org Subject: Re: [python-win32] Login dialog user ID restriction? CAUTION: This email originated from an external source. If you suspect a potential phishing email, report it to report.incident at finastra.com On 11/16/2018 12:32 PM, Scorby, Gary wrote: We have been using the login dialog that comes with pywin32 for over a decade. Works great. [cid:image002.jpg at 01D47FD6.9E912BF0] We have a client who until recently required a 4 character max user ID. Now they want an option for up to a 19 character user ID. I told them no problem, that should work. One of their user decided to go for it and set their password to 19 characters on their server, then tried to log in via the login box. They claimed only 14 characters will fit in the User ID entry window. Really? So I ran some tests. I held down the ?a? key for user ID and ?b? key for password. Result: ('aaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbb') User ID ? 14 characters PW ? 21 characters Then I decided to go skinny and held the i key for both. Result: ('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiiii') User ID ? 42 characters PW ? 21 characters I?m a data mover and very seldom work with dialogs. The restriction appears to be entry window size based on character width. I assumed if there was any kind of a restriction it would be x number of characters. I?ve looked at how I send could parameters to alter this behavior but don?t see anything. Feel free to verbally abuse me if I?m missing the obvious, but can anyone tell me how to expand the number of characters I can send for a user ID? Thank you Gary One thing that might be semi-obvious is that while you can _see_ a different number of characters depending on their size, it might not be the case that only 14 characters can be accepted in the box... I'm speculating you just might have to scroll (with the cursor key) to see them all. When you do the same character, that is not so obvious that there is scrolling going on. If you use different characters, I'm thinking you might see them scroll. Your user might have stopped because the end of the box was reached, and not tried to type the last 5 characters? Anyway, something to think about and experiment with. I've no idea if it is possible to make that dialog box wider, so that more characters can be seen. Glenn "FINASTRA" is the trade name of the FINASTRA group of companies. This email and any attachments have been scanned for known viruses using multiple scanners. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the named recipient of this email please notify us immediately and do not copy it or use it for any purpose, nor disclose its contents to any other person. This email does not constitute the commencement of legal relations between you and FINASTRA. Please refer to the executed contract between you and the relevant member of the FINASTRA group for the identity of the contracting party with which you are dealing. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 7693 bytes Desc: image002.jpg URL: From v+python at g.nevcal.com Tue Nov 20 00:52:23 2018 From: v+python at g.nevcal.com (Glenn Linderman) Date: Mon, 19 Nov 2018 21:52:23 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> Message-ID: <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> On 11/19/2018 11:52 AM, Tim Roberts wrote: > Glenn Linderman wrote: >> >> I've not coded up the equivalent C program, as I don't have a C >> compiler installed here, and haven't done any C coding for 8 or 10 >> years. >> >> Were you able to reproduce the problem, or is your error analysis >> based on code reading? > > I looked at the code.? Plus, I recognized that 1804 is a Windows > errors code, not a Python error.? Let me see if I can write up a C++ > test that would be useful for you. I looked at the win32print.cpp file. There were lots of Python-internals stuff there that I don't really follow well. I didn't see anything obviously wrong, but I got to wondering about the code that builds the structure... it puts in UTF-8 text strings (which would be same as ASCII in the cases I'm considering, but what if someone has a non-ASCII printer name, or document file name, or ???). And I'm sure the A version of the Windows API probably is happy with ASCII, but does the 64-bit compilation call the A version of the Windows API or the W version?? And would the W version be happy with ASCII? Or would that produce an 1804 error? Of course, the GetJob is decoding the structure properly... but its PyBuildValue parameter strings are much more complex than the PyArg_ParseTupleAndKewyords parameter strings, and there is mention of TCHAR in the JobToPy, but not in the PyToJob, so that makes it further seem like my speculations above might have some chance of being the problem. And then of course, I've no idea what compilation parameters were used, either for your program (which works), or for win32print.cpp (which maybe doesn't). Glenn -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Nov 20 13:30:44 2018 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Nov 2018 10:30:44 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> Message-ID: <6738ce56-1b85-9f9a-c361-0d1312b0dd71@probo.com> Glenn Linderman wrote: > > I looked at the win32print.cpp file. There were lots of > Python-internals stuff there that I don't really follow well. I didn't > see anything obviously wrong, but I got to wondering about the code > that builds the structure... it puts in UTF-8 text strings (which > would be same as ASCII in the cases I'm considering, but what if > someone has a non-ASCII printer name, or document file name, or ???). > And I'm sure the A version of the Windows API probably is happy with > ASCII, but does the 64-bit compilation call the A version of the > Windows API or the W version? 32 vs 64 makes no difference here.?? SetJobA always expects 8-bit strings, SetJobW always expects 16-bit strings.? SetJob maps to one or the other based on the absence or presence of #define UNICODE.? The routines that convert Python strings to zero-terminated strings will do the right thing. > And would the W version be happy with ASCII? Or would that produce an > 1804 error? If you pass ASCII strings to the W API, it just means the strings are interpreted as garbage.? The name will not be found.? It shouldn't cause 1804. I went to ReactOS and looked at the source code for SetJob. ERROR_INVALID_DATATYPE is returned for exactly one reason: the pDatatype value is not in the valid list of datatypes for the print processor for this job.? There's no reason for that; your structure says "NT EMF 1.008", which is almost always valid. This had to work at some point.? All of these things get tested. I just don't know what would have changed.? If I get motivated (I've already spent too much time on this ;), I'll see if I can get your script to fail here. > And then of course, I've no idea what compilation parameters were > used, either for your program (which works), or for win32print.cpp > (which maybe doesn't). I built mine for non-Unicode. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From timr at probo.com Tue Nov 20 13:36:33 2018 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Nov 2018 10:36:33 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <6738ce56-1b85-9f9a-c361-0d1312b0dd71@probo.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> <6738ce56-1b85-9f9a-c361-0d1312b0dd71@probo.com> Message-ID: Tim Roberts wrote: > > This had to work at some point.? All of these things get tested. I > just don't know what would have changed.? If I get motivated (I've > already spent too much time on this ;), I'll see if I can get your > script to fail here. For what it's worth, I AM able to duplicate the problem on my Win 10 system. I will run this in a debugger and see what SetJob is actually getting. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From timr at probo.com Tue Nov 20 13:49:26 2018 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Nov 2018 10:49:26 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> Message-ID: <391ce84e-798f-2fdf-63fd-6c3bc269b4b3@probo.com> Glenn Linderman wrote: > Of course, the GetJob is decoding the structure properly... but its > PyBuildValue parameter strings are much more complex than the > PyArg_ParseTupleAndKewyords parameter strings, and there is mention of > TCHAR in the JobToPy, but not in the PyToJob, so that makes it further > seem like my speculations above might have some chance of being the > problem. I should not have scoffed at your speculation, because your analysis was correct.? The win32print code is calling SetJobW, which expects Unicode, but the JOB_INFO_1 structure is filled with ANSI strings.? That's a very nasty bug.? I'll file a bug report. In the meantime, I'll fix up my little C++ example to do the job for you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From v+python at g.nevcal.com Tue Nov 20 14:24:33 2018 From: v+python at g.nevcal.com (Glenn Linderman) Date: Tue, 20 Nov 2018 11:24:33 -0800 Subject: [python-win32] why do I get error 1804 from win32print.SetJob? In-Reply-To: <391ce84e-798f-2fdf-63fd-6c3bc269b4b3@probo.com> References: <80bf3baf-4a60-3e36-c064-5b75ff863fa4@g.nevcal.com> <2e42df2d-8a23-efe0-1380-0b65358f1275@g.nevcal.com> <0b10f3ac-25da-077e-8aaa-d01058cac5be@probo.com> <717a8840-c4f4-2053-3ed7-b0fda89b445b@g.nevcal.com> <391ce84e-798f-2fdf-63fd-6c3bc269b4b3@probo.com> Message-ID: <18fc3dc3-f9ba-da42-202d-a66c375fd991@g.nevcal.com> On 11/20/2018 10:49 AM, Tim Roberts wrote: > Glenn Linderman wrote: >> Of course, the GetJob is decoding the structure properly... but its >> PyBuildValue parameter strings are much more complex than the >> PyArg_ParseTupleAndKewyords parameter strings, and there is mention >> of TCHAR in the JobToPy, but not in the PyToJob, so that makes it >> further seem like my speculations above might have some chance of >> being the problem. > > I should not have scoffed at your speculation, because your analysis > was correct.? The win32print code is calling SetJobW, which expects > Unicode, but the JOB_INFO_1 structure is filled with ANSI strings.? > That's a very nasty bug.? I'll file a bug report. > > In the meantime, I'll fix up my little C++ example to do the job for you. Hi Tim, I understand that it is easy to look at code and think you know what it is doing, until the debugger proves otherwise. I've been there plenty of times. Fortunately in this case, my speculations were based on _not_ thinking I knew what the code was doing, and _not_ having a clue how most of the called routines worked, so my mind was freed from such restrictions, and I could make a lucky guess! I appreciate your taking time to follow through. BTW, Google's email spam filter that hates .zip files can easily be circumvented, by adding another extension to the file... as in file.zip.removeme Glenn -------------- next part -------------- An HTML attachment was scrubbed... URL: