From skippy.hammond at gmail.com Wed Feb 1 01:10:39 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 01 Feb 2012 11:10:39 +1100 Subject: [python-win32] problem AddLine AutoCAD win32com.client In-Reply-To: References: Message-ID: <4F2882FF.9040707@gmail.com> Sadly not many people have access to autocad so it is hard to test. What errors do you get using win32com? Mark On 1/02/2012 5:11 AM, DANIEL POSE wrote: > Hello, > > Recently I try to write some code to automate AutoCAD from Python. I > have to draw lines from Python using win32com.client module, but I > obtain error. By other hand I solved the problem using comtypes module. > However, If I try to obtain block attributes information, comtypes > doesn't work but win32com.client work properly. > > AutoCAD attributes working code (work for win32com.client but no for > comtypes): > [code] > import win32com.client > acad= win32com.client.Dispatch("AutoCAD.Application") > doc = acad.ActiveDocument > seleccion=doc.SelectionSets.Add('selection1') > seleccion.SelectOnScreen() > for objeto in seleccion: > if objeto.ObjectName=='AcDbBlockReference': > bloque=objeto.GetAttributes() > bloque[0].TagString='newattributename' #This change the name > for the first attribute in the selected block > [/code] > > Draw line (work for comtypes but doesn't work for win32com.client): > [code] > import comtypes.client > import array > acad = comtypes.client.GetActiveObject("AutoCAD.Application") > doc = acad.ActiveDocument > ms = doc.ModelSpace > pt1 = array.array('d', [0.0,0.0,0.0]) > pt2=array.array('d',[1.0,1.0,0.0]) > line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD > [\code] > > My question is: Is posible to fix the problem using win32com to draw > autocad line in order to avoid comtypes use? > I found on the web several coments to the problem, but no solution. > > Thanks for help, > Daniel Pose. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From lists at morawek.at Wed Feb 1 20:56:12 2012 From: lists at morawek.at (Roman Morawek) Date: Wed, 01 Feb 2012 20:56:12 +0100 Subject: [python-win32] python 3 support Message-ID: <4F2998DC.9030801@morawek.at> Hello, I am just starting a new activity where I need to intact with MS Project. Since this is a new topic, I intend to start using Python 3.2. However, as I understand I need to use the pywin32 package, which is not supporting Python 3. Is this assumption correct? Is there any alternativ package available, which allows me to import/export MS project files? Is there a plan to support Python 3 in pywin32 in future? Thanks a lot for your feedback, Roman Morawek From timr at probo.com Wed Feb 1 21:13:32 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 1 Feb 2012 12:13:32 -0800 Subject: [python-win32] python 3 support In-Reply-To: <4F2998DC.9030801@morawek.at> References: <4F2998DC.9030801@morawek.at> Message-ID: <4F299CEC.2080101@probo.com> Roman Morawek wrote: > I am just starting a new activity where I need to intact with MS > Project. Since this is a new topic, I intend to start using Python 3.2. In my opinion -- and it is ONLY my opinion -- the smartest place to begin a new project today is with Python 2.7. The third-party library support is still too spotty in Python 3. It's getting there, but it's not there yet. (It is actually taking longer than I expected.) > Is there any alternativ package available, which allows me to > import/export MS project files? Remember that Python doesn't know anything about Project. You will be interactive with the Project application as a COM server. Python (with PyWin32) understands how to communicate with COM servers, but you won't find anything specific about Python and Project. You will need to translate the Project object model documentation from C++ or C# to Python. It's usually not that hard. There are LOTS of examples of controlling Word and Excel from Python, and the concepts are very similar. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From brian at python.org Wed Feb 1 21:51:48 2012 From: brian at python.org (Brian Curtin) Date: Wed, 1 Feb 2012 14:51:48 -0600 Subject: [python-win32] python 3 support In-Reply-To: <4F2998DC.9030801@morawek.at> References: <4F2998DC.9030801@morawek.at> Message-ID: On Wed, Feb 1, 2012 at 13:56, Roman Morawek wrote: > Hello, > > I am just starting a new activity where I need to intact with MS > Project. Since this is a new topic, I intend to start using Python 3.2. > However, as I understand I need to use the pywin32 package, which is not > supporting Python 3. It has supported Python 3 since at least 2009. From lists at morawek.at Wed Feb 1 22:43:31 2012 From: lists at morawek.at (Roman Morawek) Date: Wed, 01 Feb 2012 22:43:31 +0100 Subject: [python-win32] python 3 support In-Reply-To: References: <4F2998DC.9030801@morawek.at> Message-ID: <4F29B203.50006@morawek.at> On 01.02.2012 21:51, Brian Curtin wrote: > It has supported Python 3 since at least 2009. Interesting. It seems I just got confused by the list of the 25 most often nominated packages where users desire Python 3 support: http://python.org/3kpoll There is a hint on how to unlist the package there. The package author may want to do this. Best regards, Roman From maillist at schwertberger.de Wed Feb 1 22:48:19 2012 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Wed, 01 Feb 2012 22:48:19 +0100 Subject: [python-win32] python 3 support In-Reply-To: <4F2998DC.9030801@morawek.at> References: <4F2998DC.9030801@morawek.at> Message-ID: <4F29B323.3060703@schwertberger.de> Am 01.02.2012 20:56, schrieb Roman Morawek: > Is there any alternativ package available, which allows me to > import/export MS project files? MS Project can write and read XML files. Maybe that's good enough for you. Just save a project as XML and have a look. The structure is not too complicated. Much easier to use than e.g. XML files from Word or Excel. Regards, Dietmar From mhammond at skippinet.com.au Wed Feb 1 23:13:07 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 02 Feb 2012 09:13:07 +1100 Subject: [python-win32] problem AddLine AutoCAD win32com.client In-Reply-To: References: <4F2882FF.9040707@gmail.com> Message-ID: <4F29B8F3.1090809@skippinet.com.au> Re-added the python-win32 list - please keep replies on list. Your code uses: > pt1 = array.array('d', [0.0,0.0,0.0]) > pt2=array.array('d',[1.0,1.0,__0.0]) But these aren't supported by pywin32 in the way you expect - what happens if you change this to: pt1 = [0.0,0.0,0.0] pt2 =[1.0,1.0,0.0] ? Mark On 2/02/2012 7:12 AM, DANIEL POSE wrote: > Hello Mark, > > I understand the AutoCAD problem, but in my profession it is the most > extended software for CAD. In my opinion it justify the efford to make > automation tools. > Here I post the answer from Python when I try to draw a line using > win32com.client code in my last mail: > > Traceback (most recent call last): > File "", line 1, in > File > "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", > line 128, in runfile > execfile(filename, glbs) > File "C:\Documents and Settings\Usuario\Escritorio\borrar.py", line > 15, in > line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD > File ">", line 3, in AddLine > com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, > None, 0, -2147024809), None) > > Thank you in advance, > Daniel Pose. > > 2012/2/1 Mark Hammond > > > Sadly not many people have access to autocad so it is hard to test. > What errors do you get using win32com? > > Mark > > > On 1/02/2012 5:11 AM, DANIEL POSE wrote: > > Hello, > > Recently I try to write some code to automate AutoCAD from Python. I > have to draw lines from Python using win32com.client module, but I > obtain error. By other hand I solved the problem using comtypes > module. > However, If I try to obtain block attributes information, comtypes > doesn't work but win32com.client work properly. > > AutoCAD attributes working code (work for win32com.client but no for > comtypes): > [code] > import win32com.client > acad= win32com.client.Dispatch("__AutoCAD.Application") > doc = acad.ActiveDocument > seleccion=doc.SelectionSets.__Add('selection1') > seleccion.SelectOnScreen() > for objeto in seleccion: > if objeto.ObjectName=='__AcDbBlockReference': > bloque=objeto.GetAttributes() > bloque[0].TagString='__newattributename' #This change > the name > for the first attribute in the selected block > [/code] > > Draw line (work for comtypes but doesn't work for win32com.client): > [code] > import comtypes.client > import array > acad = comtypes.client.__GetActiveObject("AutoCAD.__Application") > doc = acad.ActiveDocument > ms = doc.ModelSpace > pt1 = array.array('d', [0.0,0.0,0.0]) > pt2=array.array('d',[1.0,1.0,__0.0]) > line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD > [\code] > > My question is: Is posible to fix the problem using win32com to draw > autocad line in order to avoid comtypes use? > I found on the web several coments to the problem, but no solution. > > Thanks for help, > Daniel Pose. > > > _________________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/__mailman/listinfo/python-win32 > > > > From iinjdpa at gmail.com Thu Feb 2 00:29:57 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Thu, 2 Feb 2012 00:29:57 +0100 Subject: [python-win32] problem AddLine AutoCAD win32com.client In-Reply-To: <4F29B8F3.1090809@skippinet.com.au> References: <4F2882FF.9040707@gmail.com> <4F29B8F3.1090809@skippinet.com.au> Message-ID: I have used array module because it worked with comtypes module. If I use simple list it doesn't work with comtypes nor pywin32. If I use: pt1 = [0.0,0.0,0.0] pt2 =[1.0,1.0,0.0] Then Python responds: Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", line 128, in runfile execfile(filename, glbs) File "C:\Documents and Settings\Administrador\Mis documentos\DropboxDani\Dropbox\PYTHON\PruebaAutoCADLinea.py", line 16, in line = ms.AddLine(pt1, pt2) File ">", line 3, in AddLine com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, None, 0, -2147024809), None) 2012/2/1 Mark Hammond > Re-added the python-win32 list - please keep replies on list. > > Your code uses: > > > > pt1 = array.array('d', [0.0,0.0,0.0]) > > pt2=array.array('d',[1.0,1.0,_**_0.0]) > > But these aren't supported by pywin32 in the way you expect - what happens > if you change this to: > > pt1 = [0.0,0.0,0.0] > pt2 =[1.0,1.0,0.0] > > ? > > Mark > > > > On 2/02/2012 7:12 AM, DANIEL POSE wrote: > >> Hello Mark, >> >> I understand the AutoCAD problem, but in my profession it is the most >> extended software for CAD. In my opinion it justify the efford to make >> automation tools. >> Here I post the answer from Python when I try to draw a line using >> win32com.client code in my last mail: >> >> Traceback (most recent call last): >> File "", line 1, in >> File >> "C:\Python27\lib\site-**packages\spyderlib\widgets\** >> externalshell\startup.py", >> line 128, in runfile >> execfile(filename, glbs) >> File "C:\Documents and Settings\Usuario\Escritorio\**borrar.py", line >> 15, in >> line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD >> File ">", line 3, in AddLine >> com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, >> None, 0, -2147024809), None) >> >> Thank you in advance, >> Daniel Pose. >> >> 2012/2/1 Mark Hammond > >> >> >> >> Sadly not many people have access to autocad so it is hard to test. >> What errors do you get using win32com? >> >> Mark >> >> >> On 1/02/2012 5:11 AM, DANIEL POSE wrote: >> >> Hello, >> >> Recently I try to write some code to automate AutoCAD from Python. >> I >> have to draw lines from Python using win32com.client module, but I >> obtain error. By other hand I solved the problem using comtypes >> module. >> However, If I try to obtain block attributes information, comtypes >> doesn't work but win32com.client work properly. >> >> AutoCAD attributes working code (work for win32com.client but no >> for >> comtypes): >> [code] >> import win32com.client >> acad= win32com.client.Dispatch("__**AutoCAD.Application") >> doc = acad.ActiveDocument >> seleccion=doc.SelectionSets.__**Add('selection1') >> >> seleccion.SelectOnScreen() >> for objeto in seleccion: >> if objeto.ObjectName=='__**AcDbBlockReference': >> bloque=objeto.GetAttributes() >> bloque[0].TagString='__**newattributename' #This change >> >> the name >> for the first attribute in the selected block >> [/code] >> >> Draw line (work for comtypes but doesn't work for win32com.client): >> [code] >> import comtypes.client >> import array >> acad = comtypes.client.__**GetActiveObject("AutoCAD.__** >> Application") >> >> doc = acad.ActiveDocument >> ms = doc.ModelSpace >> pt1 = array.array('d', [0.0,0.0,0.0]) >> pt2=array.array('d',[1.0,1.0,_**_0.0]) >> >> line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD >> [\code] >> >> My question is: Is posible to fix the problem using win32com to >> draw >> autocad line in order to avoid comtypes use? >> I found on the web several coments to the problem, but no solution. >> >> Thanks for help, >> Daniel Pose. >> >> >> ______________________________**___________________ >> python-win32 mailing list >> python-win32 at python.org >> > >> http://mail.python.org/__**mailman/listinfo/python-win32 >> >> > >> >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Feb 2 01:18:27 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 02 Feb 2012 11:18:27 +1100 Subject: [python-win32] python 3 support In-Reply-To: <4F29B203.50006@morawek.at> References: <4F2998DC.9030801@morawek.at> <4F29B203.50006@morawek.at> Message-ID: <4F29D653.2070101@gmail.com> On 2/02/2012 8:43 AM, Roman Morawek wrote: > On 01.02.2012 21:51, Brian Curtin wrote: >> It has supported Python 3 since at least 2009. > > Interesting. It seems I just got confused by the list of the 25 most > often nominated packages where users desire Python 3 support: > http://python.org/3kpoll > > There is a hint on how to unlist the package there. The package author > may want to do this. Thanks for pointing that out - I think I've followed the instructions so it should be removed soon. Cheers, Mark From dan.glassman at gmail.com Thu Feb 2 05:07:15 2012 From: dan.glassman at gmail.com (Dan Glassman) Date: Wed, 1 Feb 2012 22:07:15 -0600 Subject: [python-win32] problem AddLine AutoCAD win32com.client In-Reply-To: References: <4F2882FF.9040707@gmail.com> <4F29B8F3.1090809@skippinet.com.au> Message-ID: Daniel, I've tested a prerelease version of pywin32 that contains the new win32com.client.VARIANT class and it works well with AutoCAD. Once released, you can write something like this: import win32com.client import pythoncom def POINT(x,y,z): return win32com.client.VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_R8, (x,y,z)) acad = win32com.client.Dispatch('AutoCAD.Application') ms = acad.ActiveDocument.ModelSpace ms.AddLine(POINT(0,0,0), POINT(1,1,0)) Additional information in Mark's original post on win32com.client.VARIANT: http://mail.python.org/pipermail/python-win32/2011-October/011844.html -drg On Wed, Feb 1, 2012 at 5:29 PM, DANIEL POSE wrote: > I have used array module because it worked with comtypes module. If I use > simple list it doesn't work with comtypes nor pywin32. > If I use: > > pt1 = [0.0,0.0,0.0] > pt2 =[1.0,1.0,0.0] > > Then Python responds: > > > > Traceback (most recent call last): > File "", line 1, in > File > "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", > line 128, in runfile > execfile(filename, glbs) > File "C:\Documents and Settings\Administrador\Mis > documentos\DropboxDani\Dropbox\PYTHON\PruebaAutoCADLinea.py", line 16, in > > line = ms.AddLine(pt1, pt2) > > File ">", line 3, in AddLine > com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, > None, 0, -2147024809), None) > > > > > 2012/2/1 Mark Hammond > >> Re-added the python-win32 list - please keep replies on list. >> >> Your code uses: >> >> >> > pt1 = array.array('d', [0.0,0.0,0.0]) >> > pt2=array.array('d',[1.0,1.0,_**_0.0]) >> >> But these aren't supported by pywin32 in the way you expect - what >> happens if you change this to: >> >> pt1 = [0.0,0.0,0.0] >> pt2 =[1.0,1.0,0.0] >> >> ? >> >> Mark >> >> >> >> On 2/02/2012 7:12 AM, DANIEL POSE wrote: >> >>> Hello Mark, >>> >>> I understand the AutoCAD problem, but in my profession it is the most >>> extended software for CAD. In my opinion it justify the efford to make >>> automation tools. >>> Here I post the answer from Python when I try to draw a line using >>> win32com.client code in my last mail: >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> File >>> "C:\Python27\lib\site-**packages\spyderlib\widgets\** >>> externalshell\startup.py", >>> line 128, in runfile >>> execfile(filename, glbs) >>> File "C:\Documents and Settings\Usuario\Escritorio\**borrar.py", line >>> 15, in >>> line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD >>> File ">", line 3, in AddLine >>> com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, >>> None, 0, -2147024809), None) >>> >>> Thank you in advance, >>> Daniel Pose. >>> >>> 2012/2/1 Mark Hammond >> >> >>> >>> >>> Sadly not many people have access to autocad so it is hard to test. >>> What errors do you get using win32com? >>> >>> Mark >>> >>> >>> On 1/02/2012 5:11 AM, DANIEL POSE wrote: >>> >>> Hello, >>> >>> Recently I try to write some code to automate AutoCAD from >>> Python. I >>> have to draw lines from Python using win32com.client module, but I >>> obtain error. By other hand I solved the problem using comtypes >>> module. >>> However, If I try to obtain block attributes information, comtypes >>> doesn't work but win32com.client work properly. >>> >>> AutoCAD attributes working code (work for win32com.client but no >>> for >>> comtypes): >>> [code] >>> import win32com.client >>> acad= win32com.client.Dispatch("__**AutoCAD.Application") >>> doc = acad.ActiveDocument >>> seleccion=doc.SelectionSets.__**Add('selection1') >>> >>> seleccion.SelectOnScreen() >>> for objeto in seleccion: >>> if objeto.ObjectName=='__**AcDbBlockReference': >>> bloque=objeto.GetAttributes() >>> bloque[0].TagString='__**newattributename' #This change >>> >>> the name >>> for the first attribute in the selected block >>> [/code] >>> >>> Draw line (work for comtypes but doesn't work for >>> win32com.client): >>> [code] >>> import comtypes.client >>> import array >>> acad = comtypes.client.__**GetActiveObject("AutoCAD.__** >>> Application") >>> >>> doc = acad.ActiveDocument >>> ms = doc.ModelSpace >>> pt1 = array.array('d', [0.0,0.0,0.0]) >>> pt2=array.array('d',[1.0,1.0,_**_0.0]) >>> >>> line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD >>> [\code] >>> >>> My question is: Is posible to fix the problem using win32com to >>> draw >>> autocad line in order to avoid comtypes use? >>> I found on the web several coments to the problem, but no >>> solution. >>> >>> Thanks for help, >>> Daniel Pose. >>> >>> >>> ______________________________**___________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> > >>> http://mail.python.org/__**mailman/listinfo/python-win32 >>> >>> > >>> >>> >>> >>> >> > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacobk at mailzone.co.za Fri Feb 3 10:15:22 2012 From: jacobk at mailzone.co.za (Jacob Kruger) Date: Fri, 3 Feb 2012 11:15:22 +0200 Subject: [python-win32] mouse cursor coordinates Message-ID: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> Wondering off-hand if there's a simple/easy way to obtain mouse cursor coordinates, and, also, how simple is it to interact with operating system, in terms of if the mouse cursor is in fact outside the GUI as such - if that makes sense? TIA Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Feb 3 19:22:22 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 3 Feb 2012 10:22:22 -0800 Subject: [python-win32] mouse cursor coordinates In-Reply-To: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> References: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> Message-ID: <4F2C25DE.6070101@probo.com> Jacob Kruger wrote: > Wondering off-hand if there's a simple/easy way to obtain mouse cursor > coordinates, and, also, how simple is it to interact with operating > system, in terms of if the mouse cursor is in fact outside the GUI as > such - if that makes sense? win32gui.GetCursorPos will return the current mouse position in screen coordinates. Your second question is not clear to me. An application does not receive mouse messages when the mouse goes outside its window, unless it is using "mouse capture". If you click on a button control and hold the mouse button down, then drag the mouse outside the button, you'll notice that the button window stays depressed until you release the mouse. That happens because the button control "captures the mouse". All mouse messages are directed only to the button until it releases capture, which it will do when the mouse button is released. Beyond that, you'll have to ask a more specific question. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jacobk at mailzone.co.za Fri Feb 3 20:09:03 2012 From: jacobk at mailzone.co.za (Jacob Kruger) Date: Fri, 3 Feb 2012 21:09:03 +0200 Subject: [python-win32] mouse cursor coordinates In-Reply-To: <4F2C25DE.6070101@probo.com> References: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> <4F2C25DE.6070101@probo.com> Message-ID: Thanks. What primarily meant is wondered if an app would only be able to get hold of mouse cursor coordinates if mouse cursor was over parts of it's interface, or would it still be able to get real coordinates, as opposed to relative coordinates even if the mouse moved out off it's interface/window, etc.? This is partly since another VI guy was asking me about a way to in fact sort of track mouse cursor movement over other parts of the operating system as such, since while you can do certain similar things using various screen reader software packages, they're not exactly what he was looking for, and this also makes me again wonder, related to second part of question, how possible would it be to do something like get the app to run off somewhere like the system tray, but still catch certain keystrokes? Alternatively, I suppose it could just run in background, but not hidden/minimised as such, but don't think that would help it catch certain keystroke combinations as such. Sorry if these are silly questions... Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: "Tim Roberts" To: "Python-Win32 List" Sent: Friday, February 03, 2012 8:22 PM Subject: Re: [python-win32] mouse cursor coordinates > Jacob Kruger wrote: >> Wondering off-hand if there's a simple/easy way to obtain mouse cursor >> coordinates, and, also, how simple is it to interact with operating >> system, in terms of if the mouse cursor is in fact outside the GUI as >> such - if that makes sense? > > win32gui.GetCursorPos will return the current mouse position in screen > coordinates. > > Your second question is not clear to me. An application does not > receive mouse messages when the mouse goes outside its window, unless it > is using "mouse capture". If you click on a button control and hold the > mouse button down, then drag the mouse outside the button, you'll notice > that the button window stays depressed until you release the mouse. > That happens because the button control "captures the mouse". All mouse > messages are directed only to the button until it releases capture, > which it will do when the mouse button is released. > > Beyond that, you'll have to ask a more specific question. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From jacobk at mailzone.co.za Fri Feb 3 20:43:30 2012 From: jacobk at mailzone.co.za (Jacob Kruger) Date: Fri, 3 Feb 2012 21:43:30 +0200 Subject: [python-win32] mouse cursor coordinates In-Reply-To: <4F2C25DE.6070101@probo.com> References: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> <4F2C25DE.6070101@probo.com> Message-ID: <8C75DEFB8E1E419F9ECF2502923F7ED7@jakesPC> Ok, just tested it using win32gui.GetCursorPos function, and it does seem to obtain coordinates outside primary window as well, so let's see - thanks. Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: "Tim Roberts" To: "Python-Win32 List" Sent: Friday, February 03, 2012 8:22 PM Subject: Re: [python-win32] mouse cursor coordinates > Jacob Kruger wrote: >> Wondering off-hand if there's a simple/easy way to obtain mouse cursor >> coordinates, and, also, how simple is it to interact with operating >> system, in terms of if the mouse cursor is in fact outside the GUI as >> such - if that makes sense? > > win32gui.GetCursorPos will return the current mouse position in screen > coordinates. > > Your second question is not clear to me. An application does not > receive mouse messages when the mouse goes outside its window, unless it > is using "mouse capture". If you click on a button control and hold the > mouse button down, then drag the mouse outside the button, you'll notice > that the button window stays depressed until you release the mouse. > That happens because the button control "captures the mouse". All mouse > messages are directed only to the button until it releases capture, > which it will do when the mouse button is released. > > Beyond that, you'll have to ask a more specific question. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Fri Feb 3 22:26:57 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 3 Feb 2012 13:26:57 -0800 Subject: [python-win32] mouse cursor coordinates In-Reply-To: <8C75DEFB8E1E419F9ECF2502923F7ED7@jakesPC> References: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC> <4F2C25DE.6070101@probo.com> <8C75DEFB8E1E419F9ECF2502923F7ED7@jakesPC> Message-ID: <4F2C5121.7000706@probo.com> Jacob Kruger wrote: > Ok, just tested it using win32gui.GetCursorPos function, and it does seem to > obtain coordinates outside primary window as well, so let's see - thanks. Right -- you can go fetch the coordinates any time, no matter where the mouse is on the desktop. But you only get mouse messages when the cursor is over your window (unless you have captured it). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bill at tutts.org Fri Feb 3 23:52:50 2012 From: bill at tutts.org (Bill Tutt) Date: Fri, 3 Feb 2012 17:52:50 -0500 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <045e01c8de32$1cdaede0$5690c9a0$@com.au> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> Message-ID: Hrm. Is it just embedding via COM servers and services or something else? i.e. If I wrote a C++ WTL based UI to drive some embedded Python COM client logic or SQL queries do you think I'd need to do anything extra special? For various scary reasons I need to write a log collection tool to run on Win2k and Win2k8 R2. The tool needs to collect some WMI, SQL, and eventlog data. I can't reboot the computer the tool runs on, so I can't install any additional software. The job ought to be substantially simpler if I could write the data collection bits in Python instead of C++. Thanks, Bill On Fri, Jul 4, 2008 at 8:00 PM, Mark Hammond wrote: > > I know it's possible with Python - but does pywin32 "work" if the > > postinstall hasn't been run? Specifically, I don't care about > > embedding Python, or about creating COM servers or services, but I do > > want to be able to run "normal" Python scripts and COM clients. > > In the simple case, it works fine without the post_install script execute, > and so long as no embedding is attempted. > > Cheers, > > Mark > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Feb 4 00:13:48 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 3 Feb 2012 15:13:48 -0800 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> Message-ID: <4F2C6A2C.6010405@probo.com> Bill Tutt wrote: > > For various scary reasons I need to write a log collection tool to run > on Win2k and Win2k8 R2. The tool needs to collect some WMI, SQL, and > eventlog data. > I can't reboot the computer the tool runs on, so I can't install any > additional software. > Why does that conclusion follow from that premise? Installing software should never requires a reboot. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Sat Feb 4 00:44:46 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 3 Feb 2012 15:44:46 -0800 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> <4F2C6A2C.6010405@probo.com> Message-ID: <4F2C716E.30103@probo.com> Bill Tutt wrote: > Installing .net 2.0 would. It would require doing the requisite > security updates for .net 2.0 for Win2k, etc.... Why do you need .NET 2.0 to install a Python app? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bill at tutts.org Sat Feb 4 00:54:37 2012 From: bill at tutts.org (Bill Tutt) Date: Fri, 3 Feb 2012 18:54:37 -0500 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <4F2C716E.30103@probo.com> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> <4F2C6A2C.6010405@probo.com> <4F2C716E.30103@probo.com> Message-ID: I don't. IF I could install anything I'd install .Net 2.0 since we're a C#/C++ house. I need to keep the size of this log collection tool small and don't want to waste space on bits of .py/.pyc/.pyds that I don't need. I'd rather save space on my technicians USB key for the collected logs/database backup. Bill On Fri, Feb 3, 2012 at 6:44 PM, Tim Roberts wrote: > Bill Tutt wrote: > > Installing .net 2.0 would. It would require doing the requisite > > security updates for .net 2.0 for Win2k, etc.... > > Why do you need .NET 2.0 to install a Python app? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sat Feb 4 02:38:45 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 04 Feb 2012 12:38:45 +1100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> Message-ID: <4F2C8C25.1030108@gmail.com> Hi Bill, On 4/02/2012 9:52 AM, Bill Tutt wrote: > Hrm. Is it just embedding via COM servers and services or something else? > i.e. If I wrote a C++ WTL based UI to drive some embedded Python COM > client logic or SQL queries do you think I'd need to do anything extra > special? Not running the postinstall script just means that pywintypesxx.dll and pythoncomxx.dll aren't in system32. Assuming you have control over the environment this is running in, just ensuring those files are on the PATH should be sufficient. Hope this clarifies... Mark > > For various scary reasons I need to write a log collection tool to run > on Win2k and Win2k8 R2. The tool needs to collect some WMI, SQL, and > eventlog data. > I can't reboot the computer the tool runs on, so I can't install any > additional software. The job ought to be substantially simpler if I > could write the data collection bits in Python instead of C++. > > Thanks, > Bill > > On Fri, Jul 4, 2008 at 8:00 PM, Mark Hammond > wrote: > > > I know it's possible with Python - but does pywin32 "work" if the > > postinstall hasn't been run? Specifically, I don't care about > > embedding Python, or about creating COM servers or services, but I do > > want to be able to run "normal" Python scripts and COM clients. > > In the simple case, it works fine without the post_install script > execute, > and so long as no embedding is attempted. > > Cheers, > > Mark > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From maillist at schwertberger.de Sun Feb 5 14:37:06 2012 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Sun, 05 Feb 2012 14:37:06 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <4F2C8C25.1030108@gmail.com> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> <4F2C8C25.1030108@gmail.com> Message-ID: <4F2E8602.9060506@schwertberger.de> Am 04.02.2012 02:38, schrieb Mark Hammond: > Not running the postinstall script just means that pywintypesxx.dll and > pythoncomxx.dll aren't in system32. Assuming you have control over the > environment this is running in, just ensuring those files are on the > PATH should be sufficient. Yes, I have been running portable Python installations for years. In the sitecustomize.py I'm just adding the required directories to the path: import sys, os # add DLL directories to path environment variable path = original_path = os.environ["path"] splitted = path.split(";") splitted_l = path.lower().split(";") dlls = os.path.join(sys.exec_prefix, "DLLs") pythonwin = os.path.join(sys.exec_prefix, r"Lib\site-packages\pythonwin") pythonwin_system32 = os.path.join(sys.exec_prefix, r"Lib\site-packages\pywin32_system32") dlldirs = [sys.exec_prefix, dlls, pythonwin, pythonwin_system32] for dlldir in dlldirs: if dlldir.lower() in splitted_l: continue path = path+";"+dlldir if path!=original_path: os.environ["path"] = path del dlls, dlldir, dlldirs, pythonwin, pythonwin_system32 Regards, Dietmar From sleerssen at gmail.com Mon Feb 6 16:45:30 2012 From: sleerssen at gmail.com (Scott Leerssen) Date: Mon, 6 Feb 2012 10:45:30 -0500 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW Message-ID: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> I'm trying to open files with names that contain Japanese characters, and found that win32file.CreateFile would raise an exception indicating that 'The filename, directory name, or volume label syntax is incorrect'. I found win32file.CreateFileW (documented to deal with 'unicode'), and that did return a handle for me. What puzzles me is that both functions take a PyUNICODE filename, so I just assumed that CreateFile would deal with the unicode pathname I was giving it. So, my question is, should I just use win32file.CreateFileW instead of win32file.CreateFile, and is it safe to use for all file handles, including those that do not have wide characters? Thanks, Scott From amauryfa at gmail.com Mon Feb 6 17:03:47 2012 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Mon, 6 Feb 2012 17:03:47 +0100 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW In-Reply-To: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> References: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> Message-ID: 2012/2/6 Scott Leerssen > I'm trying to open files with names that contain Japanese characters, and > found that win32file.CreateFile would raise an exception indicating that > 'The filename, directory name, or volume label syntax is incorrect'. I > found win32file.CreateFileW (documented to deal with 'unicode'), and that > did return a handle for me. What puzzles me is that both functions take a > PyUNICODE filename, so I just assumed that CreateFile would deal with the > unicode pathname I was giving it. So, my question is, should I just use > win32file.CreateFileW instead of win32file.CreateFile, and is it safe to > use for all file handles, including those that do not have wide characters? > Yes, win32file.CreateFileW will accept all file names: unicode strings are passed as is to the C function, and byte strings are properly converted to a wide string. But do you really need CreateFile? the plain open() function also accept unicode with Japanese characters... -- Amaury Forgeot d'Arc -------------- next part -------------- An HTML attachment was scrubbed... URL: From sleerssen at gmail.com Mon Feb 6 17:21:39 2012 From: sleerssen at gmail.com (Scott Leerssen) Date: Mon, 6 Feb 2012 11:21:39 -0500 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW In-Reply-To: References: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> Message-ID: <4F5E37C7-CB4A-4888-B0F9-4AB4A0BB1EE1@gmail.com> On Feb 6, 2012, at 11:03 AM, Amaury Forgeot d'Arc wrote: > 2012/2/6 Scott Leerssen > I'm trying to open files with names that contain Japanese characters, and found that win32file.CreateFile would raise an exception indicating that 'The filename, directory name, or volume label syntax is incorrect'. I found win32file.CreateFileW (documented to deal with 'unicode'), and that did return a handle for me. What puzzles me is that both functions take a PyUNICODE filename, so I just assumed that CreateFile would deal with the unicode pathname I was giving it. So, my question is, should I just use win32file.CreateFileW instead of win32file.CreateFile, and is it safe to use for all file handles, including those that do not have wide characters? > > Yes, win32file.CreateFileW will accept all file names: unicode strings are passed as is to the C function, > and byte strings are properly converted to a wide string. > But do you really need CreateFile? the plain open() function also accept unicode with Japanese characters... I need to get the pyHANDLE to call win32file.DeviceIoControl (to set reparse data) and win32file.SetFileShortName, but if there's an easier way to programmatically set the 8.3 name on a file, please let me know. -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Mon Feb 6 23:40:08 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Feb 2012 09:40:08 +1100 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW In-Reply-To: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> References: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> Message-ID: <4F3056C8.9070702@gmail.com> On 7/02/2012 2:45 AM, Scott Leerssen wrote: > I'm trying to open files with names that contain Japanese characters, > and found that win32file.CreateFile would raise an exception > indicating that 'The filename, directory name, or volume label syntax > is incorrect'. I found win32file.CreateFileW (documented to deal > with 'unicode'), and that did return a handle for me. What puzzles > me is that both functions take a PyUNICODE filename, so I just > assumed that CreateFile would deal with the unicode pathname I was > giving it. So, my question is, should I just use > win32file.CreateFileW instead of win32file.CreateFile, and is it safe > to use for all file handles, including those that do not have wide > characters? The short story is that CreateFile will take unicode strings and use the "mbcs" codec to convert them to the bytes required by CreateFile. Sadly that codec doesn't throw an error on characters that can't be converted (ie, characters outside the current code-page) - you just get a string with "?" chars in it. You could try manually doing 'filename.encode("mbcs")' and see if you get such chars. CreateFileW should be safe for any filename (although if you pass a str object to it, it will attempt to decode using mbcs - ie, the str must already be in mbcs format). As mbcs==ascii for all ascii chars, you never see the problem on filenames with only ascii chars. Mark > > Thanks, Scott _______________________________________________ > python-win32 mailing list python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From jacobk at mailzone.co.za Tue Feb 7 07:26:25 2012 From: jacobk at mailzone.co.za (Jacob Kruger) Date: Tue, 7 Feb 2012 08:26:25 +0200 Subject: [python-win32] mouse cursor coordinates In-Reply-To: <8C75DEFB8E1E419F9ECF2502923F7ED7@jakesPC> References: <6F6F378DAF5B48CFB3C5F8B4FC480F93@jakesPC><4F2C25DE.6070101@probo.com> <8C75DEFB8E1E419F9ECF2502923F7ED7@jakesPC> Message-ID: OK, did another web search relating to this now, and found the following page: http://atcoalition.org/article/large-computer-pointerscursors Either way, there they mention that on windows, if you go to mouse pointer options, there's an option you can enable/turn on: Show location of pointer when I press the CTRL key And it apparently makes the mouse cursor turn into a relatively visible bulls eye type pointer then...? Also means that if partially sighted guys find the right .cur file to maybe replace the specifically used bullseye file with, they should easily enough be able to implement something like a large cross hair cursor based on a keystroke as such, using built in windows functionality. Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: "Jacob Kruger" To: Sent: Friday, February 03, 2012 9:43 PM Subject: Re: [python-win32] mouse cursor coordinates > Ok, just tested it using win32gui.GetCursorPos function, and it does seem > to obtain coordinates outside primary window as well, so let's see - > thanks. > > Stay well > > Jacob Kruger > Blind Biker > Skype: BlindZA > '...fate had broken his body, but not his spirit...' > > ----- Original Message ----- > From: "Tim Roberts" > To: "Python-Win32 List" > Sent: Friday, February 03, 2012 8:22 PM > Subject: Re: [python-win32] mouse cursor coordinates > > >> Jacob Kruger wrote: >>> Wondering off-hand if there's a simple/easy way to obtain mouse cursor >>> coordinates, and, also, how simple is it to interact with operating >>> system, in terms of if the mouse cursor is in fact outside the GUI as >>> such - if that makes sense? >> >> win32gui.GetCursorPos will return the current mouse position in screen >> coordinates. >> >> Your second question is not clear to me. An application does not >> receive mouse messages when the mouse goes outside its window, unless it >> is using "mouse capture". If you click on a button control and hold the >> mouse button down, then drag the mouse outside the button, you'll notice >> that the button window stays depressed until you release the mouse. >> That happens because the button control "captures the mouse". All mouse >> messages are directed only to the button until it releases capture, >> which it will do when the mouse button is released. >> >> Beyond that, you'll have to ask a more specific question. >> >> -- >> Tim Roberts, timr at probo.com >> Providenza & Boekelheide, Inc. >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From lyeoh at pop.jaring.my Tue Feb 7 07:18:09 2012 From: lyeoh at pop.jaring.my (Lincoln Yeoh) Date: Tue, 07 Feb 2012 14:18:09 +0800 Subject: [python-win32] Python Windows Service and registering for preshutdown? Message-ID: <3Thwq14BV3zMVD@mail.python.org> Hi, Is it easy to create a python windows service that registers for the preshutdown event[1]? Basically I would like a window service that will help shutdown .Net (and possibly other) services in the right order. Because: http://connect.microsoft.com/VisualStudio/feedback/details/641737/add-windows-service-preshutdown "A Windows service in C# cannot be registered to preshutdown notifications. It is possible in C++ but not in C# with the current .net framework" http://support.microsoft.com/kb/203878 "When a service is dependendent on other services, the Service Control Manager (SCM) will automatically start the dependencies before starting the dependent service itself. However, during system shutdown, the SCM does not take dependencies into consideration when stopping services. It simply enumerates the list of running services and sends a SERVICE_CONTROL_SHUTDOWN command to all of them. Thus, a service may stop responding or fail because another service it depends upon has already stopped." (yeah weird right?) And, since I'm a crappy and lazy programmer I think it'll be easier for me to write such a thing in Python than C++, reasonably quickly, with the features I want and with not too many bugs. Regards, Link. [1] http://msdn.microsoft.com/en-us/magazine/cc164252.aspx#S2 From skippy.hammond at gmail.com Tue Feb 7 07:54:41 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Feb 2012 17:54:41 +1100 Subject: [python-win32] Python Windows Service and registering for preshutdown? In-Reply-To: <3Thwq14BV3zMVD@mail.python.org> References: <3Thwq14BV3zMVD@mail.python.org> Message-ID: <4F30CAB1.6000509@gmail.com> On 7/02/2012 5:18 PM, Lincoln Yeoh wrote: > Hi, > > Is it easy to create a python windows service that registers for the > preshutdown event[1]? It sounds like it should be easy, although you will need to define your own new constants which have been introduced. It would be great if you do get it working you contribute a working sample which I can add to pywin32. Cheers, Mark > > Basically I would like a window service that will help shutdown .Net > (and possibly other) services in the right order. > > Because: > http://connect.microsoft.com/VisualStudio/feedback/details/641737/add-windows-service-preshutdown > > "A Windows service in C# cannot be registered to preshutdown > notifications. It is possible in C++ but not in C# with the current .net > framework" > > http://support.microsoft.com/kb/203878 > > "When a service is dependendent on other services, the Service Control > Manager (SCM) will automatically start the dependencies before starting > the dependent service itself. However, during system shutdown, the SCM > does not take dependencies into consideration when stopping services. It > simply enumerates the list of running services and sends a > SERVICE_CONTROL_SHUTDOWN command to all of them. Thus, a service may > stop responding or fail because another service it depends upon has > already stopped." > > (yeah weird right?) > > And, since I'm a crappy and lazy programmer I think it'll be easier for > me to write such a thing in Python than C++, reasonably quickly, with > the features I want and with not too many bugs. > > Regards, > > Link. > > [1] http://msdn.microsoft.com/en-us/magazine/cc164252.aspx#S2 > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Tue Feb 7 23:36:39 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Feb 2012 09:36:39 +1100 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW In-Reply-To: References: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> <4F3056C8.9070702@gmail.com> Message-ID: <4F31A777.306@skippinet.com.au> Re-added python-win32 - please follow-up there. On 8/02/2012 1:06 AM, Scott Leerssen wrote: > Thanks Mark. You wouldn't happen to know the encoding of the 8.3 > filename, would you? I'm having a heck of a time setting that value > with Japanese characters in it. win32file.SetFileShortName purports > to take a PyUNICODE, but I get invalid parameter exceptions with > unicode Japanese strings. win32file.SetFileShortName always calls SetFileShortNameW - thus, passing a Unicode object avoids any encoding at all. I can't find much in the way of references, but it seems that shortnames are restricted to bytes and I'd expect Japanese characters to be multi-byte - so may simply be invalid. Have you tried an ascii name? If that also fails, then the API docs for that function list some additional restrictions you might need to follow. Cheers, Mark > > Thanks, Scott > > On Feb 6, 2012, at 5:40 PM, Mark Hammond wrote: > >> On 7/02/2012 2:45 AM, Scott Leerssen wrote: >>> I'm trying to open files with names that contain Japanese >>> characters, and found that win32file.CreateFile would raise an >>> exception indicating that 'The filename, directory name, or >>> volume label syntax is incorrect'. I found win32file.CreateFileW >>> (documented to deal with 'unicode'), and that did return a handle >>> for me. What puzzles me is that both functions take a PyUNICODE >>> filename, so I just assumed that CreateFile would deal with the >>> unicode pathname I was giving it. So, my question is, should I >>> just use win32file.CreateFileW instead of win32file.CreateFile, >>> and is it safe to use for all file handles, including those that >>> do not have wide characters? >> >> The short story is that CreateFile will take unicode strings and >> use the "mbcs" codec to convert them to the bytes required by >> CreateFile. Sadly that codec doesn't throw an error on characters >> that can't be converted (ie, characters outside the current >> code-page) - you just get a string with "?" chars in it. You could >> try manually doing 'filename.encode("mbcs")' and see if you get >> such chars. CreateFileW should be safe for any filename (although >> if you pass a str object to it, it will attempt to decode using >> mbcs - ie, the str must already be in mbcs format). As mbcs==ascii >> for all ascii chars, you never see the problem on filenames with >> only ascii chars. >> >> Mark >> >>> >>> Thanks, Scott _______________________________________________ >>> python-win32 mailing list python-win32 at python.org >>> http://mail.python.org/mailman/listinfo/python-win32 >> > From sleerssen at gmail.com Wed Feb 8 04:29:49 2012 From: sleerssen at gmail.com (Scott Leerssen) Date: Tue, 7 Feb 2012 22:29:49 -0500 Subject: [python-win32] win32file.CreateFile versus win32file.CreateFileW In-Reply-To: <4F31A777.306@skippinet.com.au> References: <95F72970-2F26-4397-8700-98AFA5A9A22F@gmail.com> <4F3056C8.9070702@gmail.com> <4F31A777.306@skippinet.com.au> Message-ID: <05A7A060-C55E-45FA-81D1-472AA32F322B@gmail.com> On Feb 7, 2012, at 5:36 PM, Mark Hammond wrote: > Re-added python-win32 - please follow-up there. > > On 8/02/2012 1:06 AM, Scott Leerssen wrote: >> Thanks Mark. You wouldn't happen to know the encoding of the 8.3 >> filename, would you? I'm having a heck of a time setting that value >> with Japanese characters in it. win32file.SetFileShortName purports >> to take a PyUNICODE, but I get invalid parameter exceptions with >> unicode Japanese strings. > > win32file.SetFileShortName always calls SetFileShortNameW - thus, passing a Unicode object avoids any encoding at all. > It looks like I may be missing something environmental resulting in a unicode conversion that produces a value that SetFileShortName[W] doesn't like. I'm using WinPE to try to set them; possibly a locale issue. > I can't find much in the way of references, but it seems that shortnames are restricted to bytes and I'd expect Japanese characters to be multi-byte - so may simply be invalid. Have you tried an ascii name? If that also fails, then the API docs for that function list some additional restrictions you might need to follow. I'm fairly certain the shortname will accept wide characters. 'dir /x' on a japanese install shows japanese shortnames (3 symbols plus tilde, number and extension, consuming 12 bytes). I can extract a utf-8 form of multibyte character shortnames using the ntfs-3g linux hooks in getfattr and replace them with setfattr, preserving the japanese version of shortnames from one system to another. Using SetFileShortName, ascii shortnames do indeed work, but any multibyte (even accented characters) result in an exception. I think I'm going to punt and just set them with 'fsutil file setshortname' on the target after restoring the files to their original paths. Thanks for the replies! Scott > > >> >> Thanks, Scott >> >> On Feb 6, 2012, at 5:40 PM, Mark Hammond wrote: >> >>> On 7/02/2012 2:45 AM, Scott Leerssen wrote: >>>> I'm trying to open files with names that contain Japanese >>>> characters, and found that win32file.CreateFile would raise an >>>> exception indicating that 'The filename, directory name, or >>>> volume label syntax is incorrect'. I found win32file.CreateFileW >>>> (documented to deal with 'unicode'), and that did return a handle >>>> for me. What puzzles me is that both functions take a PyUNICODE >>>> filename, so I just assumed that CreateFile would deal with the >>>> unicode pathname I was giving it. So, my question is, should I >>>> just use win32file.CreateFileW instead of win32file.CreateFile, >>>> and is it safe to use for all file handles, including those that >>>> do not have wide characters? >>> >>> The short story is that CreateFile will take unicode strings and >>> use the "mbcs" codec to convert them to the bytes required by >>> CreateFile. Sadly that codec doesn't throw an error on characters >>> that can't be converted (ie, characters outside the current >>> code-page) - you just get a string with "?" chars in it. You could >>> try manually doing 'filename.encode("mbcs")' and see if you get >>> such chars. CreateFileW should be safe for any filename (although >>> if you pass a str object to it, it will attempt to decode using >>> mbcs - ie, the str must already be in mbcs format). As mbcs==ascii >>> for all ascii chars, you never see the problem on filenames with >>> only ascii chars. >>> >>> Mark >>> >>>> >>>> Thanks, Scott _______________________________________________ >>>> python-win32 mailing list python-win32 at python.org >>>> http://mail.python.org/mailman/listinfo/python-win32 >>> >> > From anywho.scoggins at gmail.com Wed Feb 8 19:48:42 2012 From: anywho.scoggins at gmail.com (Daniel Scoggins) Date: Wed, 8 Feb 2012 13:48:42 -0500 Subject: [python-win32] Active Directory Terminal Services Properties Message-ID: I'm trying to set the values for TerminalServicesHomeDrive and TerminalServicesHomeDirectory through Python. I have this code that works in Powershell but need to get the same functionality in python. It looks like IADsTSUserEx object owns those permissions but how would I access that object. #Powershell code that works $TSHomeDrive = 'I:' $TSHomeDirectory = '\\myserver\homehomedrive$\' $aduser = [adsi] $ldapstr $aduser.TerminalServicesHomeDirectory = $TSHomeDirectory+$aduser.samaccountname $aduser.TerminalServicesHomeDrive = $TSHomeDrive $aduser.setinfo() I've tried these below but get property not found errors: #Python code that doesn't work import active_directory as ad aduser = ad.find_user() aduser.TerminalServicesHomeDirectory #fails with attribute error aduser.com_object.TerminalServicesHomeDirectory #fails with attribute error #as you would expect, these fail too, with attribute not found errors aduser.com_object.Put('TerminalServicesHomeDirectory', tdhdir) aduser.com_object.SetInfo() Any thoughts how I could modify those attributes via Python? Thanks in advance, Daniel Scoggins -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.george.hammond at gmail.com Thu Feb 9 02:17:11 2012 From: andrew.george.hammond at gmail.com (Andrew Hammond) Date: Wed, 8 Feb 2012 17:17:11 -0800 Subject: [python-win32] lingering open filehandle? Message-ID: We're using pycurl to download a file. The file is written to disk in the context of a with statement. Once the file is written, we exit the context and then do an os.rename() to move the downloaded file to it's final destination. Immediately before doing the rename, I confirm that the filehandle is closed. However, it appears that there is some lag between when it says the filehandle is close and when it actually gets closed because I often get a "[Error 32] The process cannot access the file because it is being used by another process" exception raised on the rename operation. Is this a known issue? Running python 2.6 on win32. -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Feb 9 02:37:19 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 09 Feb 2012 12:37:19 +1100 Subject: [python-win32] lingering open filehandle? In-Reply-To: References: Message-ID: <4F33234F.3060201@gmail.com> On 9/02/2012 12:17 PM, Andrew Hammond wrote: > We're using pycurl to download a file. The file is written to disk in > the context of a with statement. Once the file is written, we exit the > context and then do an os.rename() to move the downloaded file to it's > final destination. Immediately before doing the rename, I confirm that > the filehandle is closed. However, it appears that there is some lag > between when it says the filehandle is close and when it actually gets > closed because I often get a "[Error 32] The process cannot access the > file because it is being used by another process" exception raised on > the rename operation. Is this a known issue? Running python 2.6 on win32. A virus scanner or indexer can cause this problem - it sees the new file then opens it to do its thing. If that sounds like the problem you could either disable whatever tool is causing the problem, or just have a loop which tries once per second for a few seconds... Mark From junkoi2004 at gmail.com Thu Feb 9 07:51:08 2012 From: junkoi2004 at gmail.com (Jun Koi) Date: Thu, 9 Feb 2012 14:51:08 +0800 Subject: [python-win32] Anti-reverse Python-based binaries? Message-ID: hi, sorry if this is a bit off-topic, but i think many people here must have the same concern, and have to cope with it somehow. i am developing a Windows project using Python. the final executable file .EXE and its libs will be generated with py2exe. my concern is that: even if the binary is without the source, the code is still Python bytecode. and as far as i am aware, it is pretty trivial to reverse the binary back to the Python code. (i am not very sure which tools can be used to reverse Python-based .exe files, though) i have few questions: 1) how serious this problem is in your opinion? is it really true that it is impossible to protect the binaries from reversing? 2) how efficient are the reversing tools on Python binaries now? would be great if somebody can share some experiences on using those tools. 3) if it is true that it is quite trivial to reverse the Python binaries, how are you currently protecting your binaries? perhaps with some obfuscated tools, making it much harder to reverse? please share your ideas. thanks so much, Jun From niki at vintech.bg Thu Feb 9 09:42:19 2012 From: niki at vintech.bg (niki) Date: Thu, 09 Feb 2012 10:42:19 +0200 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: <4F3386EB.5010300@vintech.bg> On 9.02.2012 08:51, Jun Koi wrote: > > 3) if it is true that it is quite trivial to reverse the Python > binaries, how are you currently protecting your binaries? perhaps with > some obfuscated tools, making it much harder to reverse? We are using Wibu Keys for our software http://www.vintech.bg Without the key files are unusable. Niki From patrick.szabo at lexisnexis.at Thu Feb 9 13:45:32 2012 From: patrick.szabo at lexisnexis.at (Szabo, Patrick (LNG-VIE)) Date: Thu, 9 Feb 2012 13:45:32 +0100 Subject: [python-win32] Searching in Word-document Message-ID: Hi, I'm trying to find words in a document that are Bold or Italic and have a format called "Standard text"." Is this possible without checking every word ? Right now I'm doing this: for word in doc.Words: if unicode(word.Style) == u"Standard Text" and word.Font.Bold == -1: errors.append(["",u"'%s' ist Bold aber als 'Standard Text' ausgezeichnet!" % word, ""]) elif unicode(word.Style) == u"Standard Text" and word.Font.Italic == -1: errors.append(["",u"'%s' ist Italic aber als 'Standard Text' ausgezeichnet!" % word, ""]) But it takes forever :( Thx in advance! . . . . . . . . . . . . . . . . . . . . . . . . . . Ing. Patrick Szabo XSLT Developer LexisNexis A-1030 Wien, Marxergasse 25 mailto:patrick.szabo at lexisnexis.at Tel.: +43 1 53452 1573 Fax: +43 1 534 52 146 From aahz at pythoncraft.com Thu Feb 9 17:21:42 2012 From: aahz at pythoncraft.com (Aahz) Date: Thu, 9 Feb 2012 08:21:42 -0800 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: <20120209162141.GA7063@panix.com> On Thu, Feb 09, 2012, Jun Koi wrote: > > sorry if this is a bit off-topic, but i think many people here must > have the same concern, and have to cope with it somehow. > > my concern is that: even if the binary is without the source, the > code is still Python bytecode. and as far as i am aware, it is pretty > trivial to reverse the binary back to the Python code. (i am not very > sure which tools can be used to reverse Python-based .exe files, > though) Most people have learned to not have this concern. > 1) how serious this problem is in your opinion? is it really true that > it is impossible to protect the binaries from reversing? Not serious enough to warrant your time and money. Absolutely true. The only way to protect your code is to put it on a server. But then people can only use your software when connected to the Internet. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich From stonebeat at gmail.com Thu Feb 9 18:22:35 2012 From: stonebeat at gmail.com (StoneBeat) Date: Thu, 9 Feb 2012 18:22:35 +0100 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: Check this http://www.depython.com/ :) On Thu, Feb 9, 2012 at 7:51 AM, Jun Koi wrote: > hi, > > sorry if this is a bit off-topic, but i think many people here must > have the same concern, and have to cope with it somehow. > > i am developing a Windows project using Python. the final executable > file .EXE and its libs will be generated with py2exe. > > my concern is that: even if the binary is without the source, the code > is still Python bytecode. > and as far as i am aware, it is pretty trivial to reverse the binary > back to the Python code. (i am not very sure which tools can be used > to reverse Python-based .exe files, though) > > i have few questions: > > 1) how serious this problem is in your opinion? is it really true that > it is impossible to protect the binaries from reversing? > > 2) how efficient are the reversing tools on Python binaries now? would > be great if somebody can share some experiences on using those tools. > > 3) if it is true that it is quite trivial to reverse the Python > binaries, how are you currently protecting your binaries? perhaps with > some obfuscated tools, making it much harder to reverse? > > please share your ideas. thanks so much, > Jun > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anywho.scoggins at gmail.com Thu Feb 9 19:02:57 2012 From: anywho.scoggins at gmail.com (Daniel Scoggins) Date: Thu, 9 Feb 2012 13:02:57 -0500 Subject: [python-win32] Active Directory Terminal Services Properties In-Reply-To: References: Message-ID: With a little bit of digging and scouring the MSDN site, I finally got this to work. import active_directory import win32com aduser = active_directory.find_user(userid) adsi=win32com.client.Dispatch("ADsNameSpaces") ldap = adsi.getobject("","%s"%aduser) ldap.TerminalServicesHomeDrive = tsHomeDrive ldap.TerminalServicesHomeDirectory = "%s\\%s"%(tsHomeDirectory,aduser.samaccountname) ldap.SetInfo() Thanks, Daniel Scoggins On Wed, Feb 8, 2012 at 1:48 PM, Daniel Scoggins wrote: > I'm trying to set the values for TerminalServicesHomeDrive and > TerminalServicesHomeDirectory through Python. > > I have this code that works in Powershell but need to get the same > functionality in python. It looks like IADsTSUserEx > object > owns those permissions but how would I access that object. > > #Powershell code that works > > $TSHomeDrive = 'I:' > $TSHomeDirectory = '\\myserver\homehomedrive$\' > $aduser = [adsi] $ldapstr > $aduser.TerminalServicesHomeDirectory = > $TSHomeDirectory+$aduser.samaccountname > $aduser.TerminalServicesHomeDrive = $TSHomeDrive > $aduser.setinfo() > > > I've tried these below but get property not found errors: > > #Python code that doesn't work > > import active_directory as ad > > aduser = ad.find_user() > aduser.TerminalServicesHomeDirectory #fails with attribute error > aduser.com_object.TerminalServicesHomeDirectory #fails with attribute error > > #as you would expect, these fail too, with attribute not found errors > aduser.com_object.Put('TerminalServicesHomeDirectory', tdhdir) > aduser.com_object.SetInfo() > > > Any thoughts how I could modify those attributes via Python? > > Thanks in advance, > > Daniel Scoggins > -- Daniel Scoggins Jr 571-345-4864 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Feb 9 19:41:51 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 9 Feb 2012 10:41:51 -0800 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: <4F34136F.3060303@probo.com> Jun Koi wrote: > sorry if this is a bit off-topic, but i think many people here must > have the same concern, and have to cope with it somehow. > > i am developing a Windows project using Python. the final executable > file .EXE and its libs will be generated with py2exe. > > my concern is that: even if the binary is without the source, the code > is still Python bytecode. > and as far as i am aware, it is pretty trivial to reverse the binary > back to the Python code. It won't necessarily be READABLE Python code. It won't have local variable names, and it won't have comments, but it's usually pretty understandable. > 1) how serious this problem is in your opinion? is it really true that > it is impossible to protect the binaries from reversing? Yes. If this is an issue for you, then you should not be using an interpreted language at all. You need to use something that is compiled, like C++. Even compiled code can be reverse-engineered, but it's much harder. Note that this same issue exists with C#. The binaries for a C# program are in an Intermediate Language that is very similar to Python byte codes, and which can be decompiled back to barely readable C# code. What are you protecting here? In many cases, Python code is a front-end for a core library where the real IP lives. There's no point in protecting a user interface, for example. > 3) if it is true that it is quite trivial to reverse the Python > binaries, how are you currently protecting your binaries? perhaps with > some obfuscated tools, making it much harder to reverse? Remember that Python comes from the open source world, where obfuscation is eschewed. Most Python projects ship the source code. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From anywho.scoggins at gmail.com Fri Feb 10 03:56:18 2012 From: anywho.scoggins at gmail.com (Daniel Scoggins) Date: Thu, 9 Feb 2012 21:56:18 -0500 Subject: [python-win32] Active Directory Security Descriptors Message-ID: It is my understanding that the value msExchMailboxSecurityDescriptor returns the security descriptor for the mailbox rights. Is there a way to modify this with win32security module? -- Daniel Scoggins -------------- next part -------------- An HTML attachment was scrubbed... URL: From niki at vintech.bg Fri Feb 10 09:03:20 2012 From: niki at vintech.bg (niki) Date: Fri, 10 Feb 2012 10:03:20 +0200 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: <4F34136F.3060303@probo.com> References: <4F34136F.3060303@probo.com> Message-ID: <4F34CF48.9010601@vintech.bg> On 9.02.2012 20:41, Tim Roberts wrote: > Jun Koi wrote: >> 1) how serious this problem is in your opinion? is it really true that >> it is impossible to protect the binaries from reversing? > > Yes. If this is an issue for you, then you should not be using an > interpreted language at all. You need to use something that is > compiled, like C++. Even compiled code can be reverse-engineered, but > it's much harder. IMHO not true. Professional decompilers for C++ are much better than python decompilers. Example: hex-rays Niki From haraldarminmassa at gmail.com Fri Feb 10 11:14:10 2012 From: haraldarminmassa at gmail.com (Harald Armin Massa[legacy]) Date: Fri, 10 Feb 2012 11:14:10 +0100 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: <4F34CF48.9010601@vintech.bg> References: <4F34136F.3060303@probo.com> <4F34CF48.9010601@vintech.bg> Message-ID: > > ...decompiling "protection".. the correct answer is of course "put the code on a server" BUT there is code that cannot reside on a server. Especially client code in a client-server-environment. Example: the dropbox client. OnlineGameClients. As much as I learned Dropbox took a quite effective approach: reshuffle the Python bytecodes, compile your own Python. Rises the costs of reengeneering quite a bit. Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - Using PostgreSQL is mostly about sleeping well at night. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Fri Feb 10 16:56:21 2012 From: aahz at pythoncraft.com (Aahz) Date: Fri, 10 Feb 2012 07:56:21 -0800 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: <4F34136F.3060303@probo.com> <4F34CF48.9010601@vintech.bg> Message-ID: <20120210155621.GA1223@panix.com> On Fri, Feb 10, 2012, Harald Armin Massa[legacy] wrote: > > As much as I learned Dropbox took a quite effective approach: reshuffle the > Python bytecodes, compile your own Python. > > Rises the costs of reengeneering quite a bit. Not enough to make a difference (speaking as someone who works for a Dropbox competitor -- one of my coworkers spent some time poking through the Dropbox code). Also, Dropbox's goal is a bit different because you can't run the client without Dropbox's server. At my company, we don't even care enough to put a minimal bit of protection in -- you need our servers, and our code isn't particularly clever. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich From kris at rhs.com Fri Feb 10 17:46:59 2012 From: kris at rhs.com (Kris Hardy) Date: Fri, 10 Feb 2012 09:46:59 -0700 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: <4F354A03.7070805@rhs.com> A few notes regarding intellectual property protection... If I remember correctly, Microsoft's first Commerce Server was written in Python by a company that they acquired, and Microsoft actually shipped it as .pyc files. (I may be wrong, but that's what I remember hearing). Whether or not to protect your code (and how to do it) depends on what you are building. If it has a large audience, especially a consumer audience, and is high-value, it's an issue. In that case, my suggestion is to look at Cython. Move the "special sauce" code into Cython modules, and compile them down to .so/.dll files. I know of a few companies that do this, one of which has a full desktop app using Qt/PySide, and they're really happy with using a blend of Python and Cython. If your code has a limited customer base, especially if they are not especially technical, you might be good enough just giving them the .py files and enforcing your rights legally. At a company I used to work for, a large portion of our released application was in source files, but the market was small and the users were non-technical, so there really wasn't any reason to protect it other than enforce our license agreement. -Kris From maillist at schwertberger.de Fri Feb 10 21:50:00 2012 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Fri, 10 Feb 2012 21:50:00 +0100 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: <4F34CF48.9010601@vintech.bg> References: <4F34136F.3060303@probo.com> <4F34CF48.9010601@vintech.bg> Message-ID: <4F3582F8.9040007@schwertberger.de> Am 10.02.2012 09:03, schrieb niki: > On 9.02.2012 20:41, Tim Roberts wrote: >> Yes. If this is an issue for you, then you should not be using an >> interpreted language at all. You need to use something that is >> compiled, like C++. Even compiled code can be reverse-engineered, but >> it's much harder. > > IMHO not true. Professional decompilers for C++ are much better than > python decompilers. Example: hex-rays Might be. But I would think that the most C[++] sources are still harder to understand than Python bytecode... To the OP: Cross-posting is not nice. Posting to two lists without any indication is even worse. Regards, Dietmar From breamoreboy at yahoo.co.uk Sat Feb 11 03:17:23 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 02:17:23 +0000 Subject: [python-win32] Editor find and replace can't count - off by one error Message-ID: Hi all, I assume that this is a long time known problem that is regarded as a joke but when I do a find and replace the number of items reported as replaced is always one less than it should be. Fix and/or workaround pretty please. -- Cheers. Mark Lawrence. From RDahlstrom at directedge.com Sat Feb 11 03:27:32 2012 From: RDahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 10 Feb 2012 21:27:32 -0500 Subject: [python-win32] Editor find and replace can't count - off by one error In-Reply-To: Message-ID: <78C91C6FD63DD04BB8812EE9288C1E8133F61736DF@EXCHANGE01.office.directedge.net> Count from zero? Via Blackberry ----- Original Message ----- From: Mark Lawrence [mailto:breamoreboy at yahoo.co.uk] Sent: Friday, February 10, 2012 09:17 PM To: python-win32 at python.org Subject: [python-win32] Editor find and replace can't count - off by one error Hi all, I assume that this is a long time known problem that is regarded as a joke but when I do a find and replace the number of items reported as replaced is always one less than it should be. Fix and/or workaround pretty please. -- Cheers. Mark Lawrence. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Direct Edge may, at its discretion, monitor and review the content of all e-mail communications. From breamoreboy at yahoo.co.uk Sat Feb 11 03:42:28 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 02:42:28 +0000 Subject: [python-win32] Editor find and replace can't count - off by one error In-Reply-To: <78C91C6FD63DD04BB8812EE9288C1E8133F61736DF@EXCHANGE01.office.directedge.net> References: <78C91C6FD63DD04BB8812EE9288C1E8133F61736DF@EXCHANGE01.office.directedge.net> Message-ID: On 11/02/2012 02:27, Dahlstrom, Roger wrote: > Count from zero? > > > > Via Blackberry > > ----- Original Message ----- > From: Mark Lawrence [mailto:breamoreboy at yahoo.co.uk] > Sent: Friday, February 10, 2012 09:17 PM > To: python-win32 at python.org > Subject: [python-win32] Editor find and replace can't count - off by one error > > Hi all, > > I assume that this is a long time known problem that is regarded as a > joke but when I do a find and replace the number of items reported as > replaced is always one less than it should be. Fix and/or workaround > pretty please. > > -- > Cheers. > > Mark Lawrence. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > DISCLAIMER: > This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Direct Edge may, at its discretion, monitor and review the content of all e-mail communications. I'm sorry but I have no idea what you're talking about. I do know that when you do find and replace in the editor and seven items are replaced you are told that six have been replaced. Not a show stopper but it's finally driving me nuts, hence my original request for a fix and/or workaround. -- Cheers. Mark Lawrence. From breamoreboy at yahoo.co.uk Sat Feb 11 03:58:03 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 02:58:03 +0000 Subject: [python-win32] Cannot resize interactive window Message-ID: Hi all, I think I've fouled up by hitting a key combination that prevents me from resizing, i.e. the Minimize, Maximize and Close options don't show at all on the top right of the window. All the code windows are just fine. Any ideas as to what the hell I've done wrong? -- Cheers. Mark Lawrence. From lyeoh at pop.jaring.my Sat Feb 11 12:19:48 2012 From: lyeoh at pop.jaring.my (Lincoln Yeoh) Date: Sat, 11 Feb 2012 19:19:48 +0800 Subject: [python-win32] Anti-reverse Python-based binaries? In-Reply-To: References: Message-ID: <3TlVzY2ZSVzNMZ@mail.python.org> You can't protect any binary from being reversed either. The CPU has to execute it. The antivirus and antimalware people reverse stuff all the time[1]. There are only a few good reasons to obfuscate the python code: 1) Embarassing/bad/evil code/comments. 2) you're in the US or similar and want to also add DRM so you qualify for DMCA protection (I personally am against the DMCA laws). But what is your end objective? If it's to make money, most paying customers aren't going to look. Competitors could learn stuff, but they can't copy stuff exactly or they'd break copyright laws. They could copy ideas, but cool ideas are a dime a dozen, the difficult parts are elsewhere. Marketing, execution, polish. Even artwork and design can be more important, customers are more likely to buy a product that looks beautiful on the outside with ugly code inside, than one with ugly artwork but beautiful code. Apple weren't the first company to come up with a touchscreen phone or tablet. McDonalds weren't the first company to sell burgers, nor do they sell the best burgers, even in the "fast food burger" category. Starbucks is one of the pioneers in overpriced coffee. I don't think being first or not has anything to do with their success. Regards, Link. [1] Easier nowadays with virtual machine technology. The difficulty for them would be if a trojan contained innocuous code, but fetched commands from a server that are OK but could one day be evil. That said I wonder how well they'd do against polymorphic perl viruses ;). At 02:51 PM 2/9/2012, Jun Koi wrote: >1) how serious this problem is in your opinion? is it really true that >it is impossible to protect the binaries from reversing? > >2) how efficient are the reversing tools on Python binaries now? would >be great if somebody can share some experiences on using those tools. > >3) if it is true that it is quite trivial to reverse the Python >binaries, how are you currently protecting your binaries? perhaps with >some obfuscated tools, making it much harder to reverse? > >please share your ideas. thanks so much, >Jun >_______________________________________________ >python-win32 mailing list >python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From breamoreboy at yahoo.co.uk Sat Feb 11 12:38:45 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 11:38:45 +0000 Subject: [python-win32] Fwd: Cannot resize interactive window In-Reply-To: References: Message-ID: Please accept my apologies if this shows up twice. -------- Original Message -------- Subject: Cannot resize interactive window Date: Sat, 11 Feb 2012 02:58:03 +0000 From: Mark Lawrence Newsgroups: gmane.comp.python.windows Hi all, I think I've fouled up by hitting a key combination that prevents me from resizing, i.e. the Minimize, Maximize and Close options don't show at all on the top right of the window. All the code windows are just fine. What have I done? -- Cheers. Mark Lawrence. From yaoyansi2 at yahoo.com.cn Sat Feb 11 12:46:02 2012 From: yaoyansi2 at yahoo.com.cn (yaoyansi) Date: Sat, 11 Feb 2012 19:46:02 +0800 (CST) Subject: [python-win32] Problem when I install PIL on WinXP as non-admin In-Reply-To: <1328926771.87520.YahooMailNeo@web15605.mail.cnb.yahoo.com> References: <1328926771.87520.YahooMailNeo@web15605.mail.cnb.yahoo.com> Message-ID: <1328960762.9251.YahooMailNeo@web15608.mail.cnb.yahoo.com> Hi all, I installed python-2.6.5.msi on my WinXP long time ago, Today I installed PIL-1.1.7.win32-py2.6.exe as non-admin. Then I make a simple test: >python >>> import Image Traceback (most recent call last): ? File "", line 1, in ImportError: No module named Image Then I logon as the admin,and run the following command >python >>> import Image It is fine, there is no any complain any more. But there must be something wrong when I install PIL as non-admin, how to deal with this problem? Regards yaoyansi From rupole at hotmail.com Sat Feb 11 21:18:38 2012 From: rupole at hotmail.com (Roger Upole) Date: Sat, 11 Feb 2012 15:18:38 -0500 Subject: [python-win32] Editor find and replace can't count - off by oneerror References: Message-ID: Mark Lawrence wrote: > Hi all, > > I assume that this is a long time known problem that is regarded as a joke but when I do a find and replace the number of items > reported as replaced is always one less than it should be. Fix and/or workaround pretty please. > > -- > Cheers. > > Mark Lawrence. Yep, that's been around for a while. Not really a joke, just that noone's gotten around to fixing it yet. In site-packages\pythonwin\pywin\scintilla\find.py, add num = 1 at line 324. Roger From breamoreboy at yahoo.co.uk Sat Feb 11 22:46:09 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 21:46:09 +0000 Subject: [python-win32] Editor find and replace can't count - off by oneerror In-Reply-To: References: Message-ID: On 11/02/2012 20:18, Roger Upole wrote: > Mark Lawrence wrote: >> Hi all, >> >> I assume that this is a long time known problem that is regarded as a joke but when I do a find and replace the number of items >> reported as replaced is always one less than it should be. Fix and/or workaround pretty please. >> >> -- >> Cheers. >> >> Mark Lawrence. > > Yep, that's been around for a while. Not really a joke, just that noone's gotten > around to fixing it yet. > > In site-packages\pythonwin\pywin\scintilla\find.py, add > num = 1 > at line 324. > > > Roger Thank you Roger. For the record line 298 for my 2.7.2 version of pywin. -- Cheers. Mark Lawrence. From mhammond at skippinet.com.au Mon Feb 13 00:52:22 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 13 Feb 2012 10:52:22 +1100 Subject: [python-win32] [ANN] pywin32 build 217 released. Message-ID: <4F3850B6.7070103@skippinet.com.au> Hi all, I'm happy to announce the release of pywin32 build 217. This release has addressed a number of issues with previous builds, has improved support for Python 3.x and 64bit builds and a number of new features - I've appended the change log at the end of this mail. For initial support (eg, to ask questions about the release etc), please contact this mailing-list (python-win32 at python.org). If you want to report a bug, please do so at https://sf.net/projects/pywin32. As always, thanks to everyone who contributed to this release, both in terms of code and reporting bugs to the tracker. Cheers, Mark Changelog: * ISAPI extension works with Python 3.x * Python service module will now have their directory added to the start of sys.path rather than the end to avoid cryptic error messages if a module of the same name is already on the path (rvolpe via #3194663) * Various Pythonwin autocomplete enhancements (kxroberto via #3468282 and Oliver Tengler via #3433953) * The Pythonwin editor now remembers previous searches made in this session. (patch #3468280 from kxroberto). * The LOGFONT struct implementation (win32util) was extended to support the full LOGFONT struct as published by Microsoft. This includes changes to win32util.LogFontToDict and win32util.DictToLogFont. (Feature request 3433757 by Kris Hardy) * Remove some duplicated menu code from pythonwin which should avoid having py2exe pulling in most of the pythonwin framework in some cases (patch 3433527 from kxroberto.) * A new win32com.client.VARIANT object can be used for advanced control over the parameter types passed to some COM methods. See the documentation in win32com/HTML/variant.html (also included in the help file) * The win32com.adsi and win32com.mapi packages have been upgraded to work on Python 3.x and as a result, there is a slight risk that regressions to these packages have been introduced in the Python 2.x versions. Please file a bug if any problems are found. * Pythonwin now warns, but allows you to continue, when saving a file with an invalid encoding line (bug 3139486) * Fix win32com.client.WithEvents on py3k (bug 3199843) * When passing integers/unsigned integers to COM objects which did not fit into 32bits, OverflowErrors were silently discarded and -1 was silently passed. This has been fixed for signed integers (an OverflowError is now raised) and unsigned integers now allow for values with the high-bit set to be passed correctly. * Fix win32com.client.WithEvents() on py3k. * makepy may have generated syntax errors if 'helpstring' elements in typelibs had strange quoting or slashes (bug 3199631) * Fixed that in some cases win32file.GetOpenFileName and GetSaveFileName could have returned trailing garbage after an embedded NULL character. (bug 3277647) * Some functions which accepted a DWORD did not accept long integers which fit in 32bits with the most signficant bit set (eg, 0x80000000). * Source-code management moved from CVS to Mercurual. * win32com.shell - Added SHCreateShellItem and fixed some 64bit issues. * win32evtlog - Added some of the new event log functions introduced in Vista/Windows 7 * win32service - Added EnumServicesStatusEx, and support startup type "delayed" for Python services * win32net - Fix a problem with NetFileEnum on 64-bit (bug #3376041) From skippy.hammond at gmail.com Mon Feb 13 01:01:45 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 13 Feb 2012 11:01:45 +1100 Subject: [python-win32] Fwd: Cannot resize interactive window In-Reply-To: References: Message-ID: <4F3852E9.7080202@gmail.com> It sounds like the interactive Window has been made a "docking" window but is undocked. Try View->Options->General Options and make sure the "dockable window" option is unchecked. Or if you just want to re-dock it, drag the caption to one of the edges of the main Pythonwin window. Hope I've understood the problem - I can't think of anything else it might be... Mark On 11/02/2012 10:38 PM, Mark Lawrence wrote: > Please accept my apologies if this shows up twice. > > -------- Original Message -------- > Subject: Cannot resize interactive window > Date: Sat, 11 Feb 2012 02:58:03 +0000 > From: Mark Lawrence > Newsgroups: gmane.comp.python.windows > > Hi all, > > I think I've fouled up by hitting a key combination that prevents me > from resizing, i.e. the Minimize, Maximize and Close options don't show > at all on the top right of the window. All the code windows are just > fine. What have I done? > From breamoreboy at yahoo.co.uk Mon Feb 13 13:05:29 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 13 Feb 2012 12:05:29 +0000 Subject: [python-win32] Fwd: Cannot resize interactive window In-Reply-To: <4F3852E9.7080202@gmail.com> References: <4F3852E9.7080202@gmail.com> Message-ID: Nothing suggested worked but normality was restored by using the Window Cascade or Tile options (I'd forgotten these as I rarely use them). I've still no idea how I screwed up in the first place. On 13/02/2012 00:01, Mark Hammond wrote: > It sounds like the interactive Window has been made a "docking" window > but is undocked. Try View->Options->General Options and make sure the > "dockable window" option is unchecked. Or if you just want to re-dock > it, drag the caption to one of the edges of the main Pythonwin window. > > Hope I've understood the problem - I can't think of anything else it > might be... > > Mark > > On 11/02/2012 10:38 PM, Mark Lawrence wrote: >> Please accept my apologies if this shows up twice. >> >> -------- Original Message -------- >> Subject: Cannot resize interactive window >> Date: Sat, 11 Feb 2012 02:58:03 +0000 >> From: Mark Lawrence >> Newsgroups: gmane.comp.python.windows >> >> Hi all, >> >> I think I've fouled up by hitting a key combination that prevents me >> from resizing, i.e. the Minimize, Maximize and Close options don't show >> at all on the top right of the window. All the code windows are just >> fine. What have I done? >> -- Cheers. Mark Lawrence. From skippy.hammond at gmail.com Mon Feb 13 23:47:19 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 14 Feb 2012 09:47:19 +1100 Subject: [python-win32] Problem when I install PIL on WinXP as non-admin In-Reply-To: <1328960762.9251.YahooMailNeo@web15608.mail.cnb.yahoo.com> References: <1328926771.87520.YahooMailNeo@web15605.mail.cnb.yahoo.com> <1328960762.9251.YahooMailNeo@web15608.mail.cnb.yahoo.com> Message-ID: <4F3992F7.5030003@gmail.com> On 11/02/2012 10:46 PM, yaoyansi wrote: > > > Hi all, > I installed python-2.6.5.msi on my WinXP long time ago, > Today I installed PIL-1.1.7.win32-py2.6.exe as non-admin. > Then I make a simple test: >> python >>>> import Image > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named Image > > Then I logon as the admin,and run the following command >> python >>>> import Image > It is fine, there is no any complain any more. > > But there must be something wrong when I install PIL as non-admin, how to deal with this problem? The only thing I can think of is that the PIL directory can only be read by the admin user. Try 'python -v -c "import Image"' as both users, compare the outputs, then try to determine why the path that worked for the admin user doesn't for the regular user. Mark From trevor.rowland at goldtoothcreative.com Mon Feb 13 23:52:11 2012 From: trevor.rowland at goldtoothcreative.com (Trevor Rowland) Date: Mon, 13 Feb 2012 14:52:11 -0800 Subject: [python-win32] remote machine file query Message-ID: Hi all, I'm new to the list, and have a question: where self.c is a wmi.WMI() connection to a remote machine using my username and password (I am admin) why does the line below ALWAYS return an empty list ??? aFile = self.c.Win32_Directory(Name = "C:\\Users"): print aFile [] I have tried various permutations of Name (raw string, single/ double backslashes, different filenames) but all returned an empty list. I also tried the Query version: aTest = self.c.Query('Select * from Win32_Directory WHERE Name=\"C:\\Users\"') Ultimately I am trying to delete or rename a folder on a remote machine that may contain a file that is open by the user, but it seems as though this whole thing is a non-starter Any help greatly appreciated! Trevor -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Feb 14 10:51:30 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 14 Feb 2012 09:51:30 +0000 Subject: [python-win32] remote machine file query In-Reply-To: References: Message-ID: <4F3A2EA2.8030102@timgolden.me.uk> On 13/02/2012 22:52, Trevor Rowland wrote: > where self.c is a wmi.WMI() connection to a remote machine using my > username and password (I am admin) > why does the line below ALWAYS return an empty list ??? > > aFile = self.c.Win32_Directory(Name = "C:\\Users"): > print aFile > [] > > I have tried various permutations of Name (raw string, single/ double > backslashes, different filenames) but all returned an empty list. > I also tried the Query version: > aTest = self.c.Query('Select * from Win32_Directory WHERE > Name=\"C:\\Users\"') Ah. That would be a bug in the wmi module, by the look of it. Basically it's a symptom of backslash madness where every system in the chain does its own thing with backslashes. As a workaround (while I try to work around what to do), you can drop down a level at least for this operation: import wmi c = wmi.WMI ("svr-heat") for d in c.wmi.ExecQuery (""" SELECT * FROM Win32_Directory WHERE Name = 'c:\\\\temp' """): directory = wmi._wmi_object (d) break The wmi attribute of the WMI connection is the underlying WMI COM object so you can call any of its methods including the ubiquious ExecQuery. The wmi._wmi_object class attempts to wrap any WMI object you can throw at it. So what you're doing here is temporarily bypassing the plumbling which underlies the more Python c.Win32_Directory (...) stuff. TJG From rodperson at rodperson.com Fri Feb 17 19:26:44 2012 From: rodperson at rodperson.com (Rod Person) Date: Fri, 17 Feb 2012 13:26:44 -0500 Subject: [python-win32] Getting Remote Share User Group Names and Permissions Message-ID: <20120217132644.0000431b@unknown> Hi, I'm trying to get a list of User Groups that have access to shares on a remote server. I am able to get a listing of all the shares on the server using wmi. This is the cloesest I got so far: import win32security as win32s sd = win32s.GetFileSecurity(sh,win32security.GROUP_SECURITY_INFORMATION) sid = sd.GetSecurityDescriptorGroup() print win32security.ConvertSidToStringSid(sid) this outputs: S-1-5-21-2085290006-574818053-1202159320-513 And I recognized that a group string as the usually appear like that when a group is deleted and you view permission in windows explorer. So how do I get that to display as Administrator, for example. My goal is to be able to create this share on another remote server with the same groups and permissions. Thanks, Rod -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From mail at timgolden.me.uk Fri Feb 17 21:20:09 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 17 Feb 2012 20:20:09 +0000 Subject: [python-win32] Getting Remote Share User Group Names and Permissions In-Reply-To: <20120217132644.0000431b@unknown> References: <20120217132644.0000431b@unknown> Message-ID: <4F3EB679.1030402@timgolden.me.uk> On 17/02/2012 18:26, Rod Person wrote: > Hi, > > I'm trying to get a list of User Groups that have access to shares on a > remote server. I am able to get a listing of all the shares on the > server using wmi. This is the cloesest I got so far: > > import win32security as win32s > > sd = win32s.GetFileSecurity(sh,win32security.GROUP_SECURITY_INFORMATION) Assuming that "sh" here is the name of of the share (eg \\server\share1) then be aware that the result of GetFileSecurity is the security on the underlying folder, not the security of the share itself. Now, share-level security is, I think, relatively unusual and you might well want to know the file security as well, but they're not the same thing. (Just in case). Another caveat: you almost certainly don't want the group security from that share, either. That's a pretty much defunct relic of the Windows Posix layer which would mimic the Unix security model by giving every file a group and an owner. The owner is still used sometimes. The group, probably never. Have a look at this: http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html to see if it helps you out. There's definitely more I can add (and I would almost certainly be combining the wmi & winsys modules to do this) but I'd like to hear back from you first before I start going off down the wrong track in my attempts to help. TJG From vernondcole at gmail.com Sat Feb 18 17:53:25 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Sat, 18 Feb 2012 09:53:25 -0700 Subject: [python-win32] How do I detect a 64 bit version of Windows? Message-ID: This is a reworded re-post of a question which I just placed to the IronPython list. I repeat it here, because I hope to get a general answer which will work on CPython, too, since the database driver I support works on both implementations. I have code which detects the "width" of the Python I am running, but that is unimportant. I need to know which size of Windows is running. I am testing adodbapi using my new laptop which I have set up as an everything in 64-bit test bed. My default test database is an .mdb (so-called ACCESS database) file. Microsoft has decided that the JET engine, which has historically been used to read and write that format is to be deprecated, so there is no 64 bit version of it. It is replaced by the Access Database Engine 2010 redistributable.Of course, the new software requires a different connection string, one containing "Provider=Microsoft.ACE.OLEDB.12.0;". So, how can I tell which "width" of Windows I am running, so I know which connection string to use? -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From gremlin at armarize.com Sat Feb 18 20:22:08 2012 From: gremlin at armarize.com (Gremlin) Date: Sat, 18 Feb 2012 20:22:08 +0100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: Message-ID: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> This may help: WIN64 = 'PROGRAMFILES(X86)' in os.environ Best regards _____ Von: python-win32-bounces+gremlin=armarize.com at python.org [mailto:python-win32-bounces+gremlin=armarize.com at python.org] Im Auftrag von Vernon Cole Gesendet: Samstag, 18. Februar 2012 17:53 An: python-win32 at python.org Betreff: [python-win32] How do I detect a 64 bit version of Windows? This is a reworded re-post of a question which I just placed to the IronPython list. I repeat it here, because I hope to get a general answer which will work on CPython, too, since the database driver I support works on both implementations. I have code which detects the "width" of the Python I am running, but that is unimportant. I need to know which size of Windows is running. I am testing adodbapi using my new laptop which I have set up as an everything in 64-bit test bed. My default test database is an .mdb (so-called ACCESS database) file. Microsoft has decided that the JET engine, which has historically been used to read and write that format is to be deprecated, so there is no 64 bit version of it. It is replaced by the Access Database Engine 2010 redistributable. Of course, the new software requires a different connection string, one containing "Provider=Microsoft.ACE.OLEDB.12.0;". So, how can I tell which "width" of Windows I am running, so I know which connection string to use? -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian at python.org Sat Feb 18 21:07:00 2012 From: brian at python.org (Brian Curtin) Date: Sat, 18 Feb 2012 14:07:00 -0600 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: > This may help: > > WIN64 = 'PROGRAMFILES(X86)' in os.environ > > Best regards > ________________________________ > > Von: python-win32-bounces+gremlin=armarize.com at python.org > [mailto:python-win32-bounces+gremlin=armarize.com at python.org] Im Auftrag von > Vernon Cole > Gesendet: Samstag, 18. Februar 2012 17:53 > An: python-win32 at python.org > Betreff: [python-win32] How do I detect a 64 bit version of Windows? > >So, how can I tell which "width" of Windows I am running, so I know which > connection string to use? import platform platform.machine() That will return "AMD64" on 64 bit. I don't have a 32-bit machine available but I believe it returns "x86". ps, I can't find your thread on the IronPython list right now, but platform.architecture() will help you find the architecture Python is compiled for. From rodperson at rodperson.com Sun Feb 19 00:22:29 2012 From: rodperson at rodperson.com (Rod Person) Date: Sat, 18 Feb 2012 18:22:29 -0500 Subject: [python-win32] Getting Remote Share User Group Names and Permissions In-Reply-To: <4F3EB679.1030402@timgolden.me.uk> References: <20120217132644.0000431b@unknown> <4F3EB679.1030402@timgolden.me.uk> Message-ID: <20120218182229.09d9d9ba@ATOMIZER64> On Fri, 17 Feb 2012 20:20:09 +0000 Tim Golden wrote: > On 17/02/2012 18:26, Rod Person wrote: > > > > import win32security as win32s > > > > sd = > > win32s.GetFileSecurity(sh,win32security.GROUP_SECURITY_INFORMATION) > > Assuming that "sh" here is the name of of the share > (eg \\server\share1) then be aware that the result > of GetFileSecurity is the security on the underlying > folder, not the security of the share itself. Thanks for the reply, Tim. Would have replied earlier but somehow this ended up as spam. You are correct here, sh is the share. I making a leap - for our organization - that the share and folder have the same permissions. There have been cases where the permission were different. Some of these shares have existed since NT 3.1 and just migrated with permission since that time. > Now, share-level security is, I think, relatively unusual > and you might well want to know the file security as well, > but they're not the same thing. (Just in case). > > Another caveat: you almost certainly don't want the group security > from that share, either. That's a pretty much defunct relic of > the Windows Posix layer which would mimic the Unix security > model by giving every file a group and an owner. The owner > is still used sometimes. The group, probably never. > > Have a look at this: > > http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html This what I used to get as far as I have :) But, I think the mistake I making is using the share as you point out. I should be using the actual folder name, in which case I'd need to be making a connection to the serve with wmi. Is that what your saying to me? -- Rod Person http://www.rodperson.com rodperson at rodperson.com "Let us in the name of the Holy Trinity, go on sending all the slaves that can be sold." - Letter from Christopher Columbus. J.A. Rawley, The Trans-Atlantic Slave Trade: A History. Pg.3 From gelonida at gmail.com Sun Feb 19 04:11:39 2012 From: gelonida at gmail.com (Gelonida N) Date: Sun, 19 Feb 2012 04:11:39 +0100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: On 02/18/2012 09:07 PM, Brian Curtin wrote: > On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: > > import platform > platform.machine() > > That will return "AMD64" on 64 bit. I don't have a 32-bit machine > available but I believe it returns "x86". This suggestion will not work for the OP. It will tell you the platform, for which python was compiled and not the real platform of the machine you're running on. If you installed a 32 bit version of python on a 64 bit machine You will get 'x86', which would be the wrong answer considering the OP's requirements. > > > ps, I can't find your thread on the IronPython list right now, but > platform.architecture() will help you find the architecture Python is > compiled for. From skippy.hammond at gmail.com Sun Feb 19 04:43:13 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 19 Feb 2012 14:43:13 +1100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: Message-ID: <4F406FD1.7080100@gmail.com> You can check for "64 bit" in sys.version (or use the platform module as suggested by Brian) - if it is there it *must* be a 64bit Windows. If it is not there (ie, it is a 32bit Python), then call win32process.IsWow64Process() - if it returns True it is a 64bit windows, otherwise 32bits. This is basically the same advice as in http://blogs.msdn.com/b/oldnewthing/archive/2005/02/01/364563.aspx Cheers, Mark On 19/02/2012 3:53 AM, Vernon Cole wrote: > This is a reworded re-post of a question which I just placed to the > IronPython list. I repeat it here, because I hope to get a general > answer which will work on CPython, too, since the database driver I > support works on both implementations. I have code which detects the > "width" of the Python I am running, but that is unimportant. I need to > know which size of Windows is running. > > I am testing adodbapi using my new laptop which I have set up as an > everything in 64-bit test bed. > > My default test database is an .mdb (so-called ACCESS database) file. > Microsoft has decided that the JET engine, which has historically been > used to read and write that format is to be deprecated, so there is no > 64 bit version of it. It is replaced by the Access Database Engine 2010 > redistributable. > > Of course, the new software requires a different connection string, one > containing "Provider=Microsoft.ACE.OLEDB.12.0;". > > So, how can I tell which "width" of Windows I am running, so I know > which connection string to use? > -- > Vernon > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From brian at python.org Sun Feb 19 08:20:47 2012 From: brian at python.org (Brian Curtin) Date: Sun, 19 Feb 2012 01:20:47 -0600 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: On Sat, Feb 18, 2012 at 21:11, Gelonida N wrote: > On 02/18/2012 09:07 PM, Brian Curtin wrote: >> On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: >> >> import platform >> platform.machine() >> >> That will return "AMD64" on 64 bit. I don't have a 32-bit machine >> available but I believe it returns "x86". > This suggestion will not work for the OP. > > It will tell you the platform, for which python was compiled and not the > real platform of the machine you're running on. > > If you installed a 32 bit version of python on a 64 bit machine You will > get 'x86', which would be the wrong answer considering the OP's > requirements. This is false. platform.machine() is about the the computer itself - I fixed it in 2.6 to function properly, as it used to operate similar to platform.architecture() due to looking in the wrong place. platform.architecture() is about how Python was compiled. From luc.kesters at hotmail.com Sun Feb 19 19:10:37 2012 From: luc.kesters at hotmail.com (luc.k) Date: Sun, 19 Feb 2012 10:10:37 -0800 (PST) Subject: [python-win32] [ANN] pywin32 build 217 released. In-Reply-To: <4F3850B6.7070103@skippinet.com.au> References: <4F3850B6.7070103@skippinet.com.au> Message-ID: <1329675037155-4485616.post@n6.nabble.com> Hi Marc, I recently encounterd some problems with pyTables en Pandas. (certain pyd files generated an "Import DLL...."problem) After some research i came accross the folowing issues - http://bugs.python.org/issue4120 - http://bugs.python.org/issue7833 and It's unclear to me how this will be solved. Maybe you can shed some light? Luc -- View this message in context: http://python.6.n6.nabble.com/ANN-pywin32-build-217-released-tp4463462p4485616.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From gelonida at gmail.com Sun Feb 19 21:53:49 2012 From: gelonida at gmail.com (Gelonida N) Date: Sun, 19 Feb 2012 21:53:49 +0100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: On 02/19/2012 08:20 AM, Brian Curtin wrote: > On Sat, Feb 18, 2012 at 21:11, Gelonida N wrote: >> On 02/18/2012 09:07 PM, Brian Curtin wrote: >>> On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: >>> >>> import platform >>> platform.machine() >>> >>> That will return "AMD64" on 64 bit. I don't have a 32-bit machine >>> available but I believe it returns "x86". >> This suggestion will not work for the OP. >> >> It will tell you the platform, for which python was compiled and not the >> real platform of the machine you're running on. >> >> If you installed a 32 bit version of python on a 64 bit machine You will >> get 'x86', which would be the wrong answer considering the OP's >> requirements. > > This is false. > > platform.machine() is about the the computer itself - I fixed it in > 2.6 to function properly, as it used to operate similar to > platform.architecture() due to looking in the wrong place. > platform.architecture() is about how Python was compiled. Hmmm. I use python 2.6.4 on a 64 bit machine and get 'x86' as result. perhaps it's only fixed in the newer 2.6 releases? From skippy.hammond at gmail.com Sun Feb 19 23:57:39 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 20 Feb 2012 09:57:39 +1100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: <4F417E63.8090900@gmail.com> On 19/02/2012 6:20 PM, Brian Curtin wrote: > On Sat, Feb 18, 2012 at 21:11, Gelonida N wrote: >> On 02/18/2012 09:07 PM, Brian Curtin wrote: >>> On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: >>> >>> import platform >>> platform.machine() >>> >>> That will return "AMD64" on 64 bit. I don't have a 32-bit machine >>> available but I believe it returns "x86". >> This suggestion will not work for the OP. >> >> It will tell you the platform, for which python was compiled and not the >> real platform of the machine you're running on. >> >> If you installed a 32 bit version of python on a 64 bit machine You will >> get 'x86', which would be the wrong answer considering the OP's >> requirements. > > This is false. > > platform.machine() is about the the computer itself - I fixed it in > 2.6 to function properly, as it used to operate similar to > platform.architecture() due to looking in the wrong place. > platform.architecture() is about how Python was compiled. Cool - that is good to know! However, like gelonida, on 2.6 (and from a 2 week old hg build which is reporting itself as 2.6.7+) I don't see the behaviour you suggest: % py -2.6-32 -c "import platform, sys; print sys.version; print platform.machine()" 2.6.7+ (unknown, Feb 20 2012, 09:54:27) [MSC v.1500 32 bit (Intel)] x86 but it does work as you describe in 3.3: % py -3.3-32 -c "import platform, sys; print(sys.version); print(platform.machine())" 3.3.0a0 (default, Jan 28 2012, 15:39:56) [MSC v.1500 32 bit (Intel)] AMD64 Mark From skippy.hammond at gmail.com Mon Feb 20 00:36:36 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 20 Feb 2012 10:36:36 +1100 Subject: [python-win32] [ANN] pywin32 build 217 released. In-Reply-To: <1329675037155-4485616.post@n6.nabble.com> References: <4F3850B6.7070103@skippinet.com.au> <1329675037155-4485616.post@n6.nabble.com> Message-ID: <4F418784.4020603@gmail.com> On 20/02/2012 5:10 AM, luc.k wrote: > Hi Marc, > I recently encounterd some problems with pyTables en Pandas. (certain pyd > files generated an "Import DLL...."problem) After some research i came > accross the folowing issues > - http://bugs.python.org/issue4120 > - http://bugs.python.org/issue7833 and > It's unclear to me how this will be solved. Maybe you can shed some light? Both those issues have had fixed checked in and the new pywin32 has been built with those changes. The end result should be that (almost) none of the .pyd files in pywin32 have a manifest, while pythoncomloaderxx.dll does have a manifest to enable COM objects to be loaded. Are you having the problems with pywin32 extensions or others? If others, then the only solution is probably to have those other extensions rebuilt. Mark From marc at marchankin.com Mon Feb 20 03:28:34 2012 From: marc at marchankin.com (Marc Hankin) Date: Sun, 19 Feb 2012 18:28:34 -0800 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: Dear Gelonida: The following is a vbscript that will return the info you want. You might want to run it in a python subprocess. On Error Resume Next ' ------ SCRIPT CONFIGURATION ------ strComputer = "." ' e.g. rallen-srv01 ' ------ END CONFIGURATION --------- set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime") set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colOS = objWMI.InstancesOf("Win32_OperatingSystem") for each objOS in colOS strOs32OR64bit = objOS.OSArchitecture sOSname = objOS.Caption Next ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' WScript.Echo "Line 21: strOs32OR64bit = objOS.OSArchitecture = " & strOs32OR64bit Hope that helps. Marc On Sun, Feb 19, 2012 at 12:53 PM, Gelonida N wrote: > On 02/19/2012 08:20 AM, Brian Curtin wrote: > > On Sat, Feb 18, 2012 at 21:11, Gelonida N wrote: > >> On 02/18/2012 09:07 PM, Brian Curtin wrote: > >>> On Sat, Feb 18, 2012 at 13:22, Gremlin wrote: > >>> > >>> import platform > >>> platform.machine() > >>> > >>> That will return "AMD64" on 64 bit. I don't have a 32-bit machine > >>> available but I believe it returns "x86". > >> This suggestion will not work for the OP. > >> > >> It will tell you the platform, for which python was compiled and not the > >> real platform of the machine you're running on. > >> > >> If you installed a 32 bit version of python on a 64 bit machine You will > >> get 'x86', which would be the wrong answer considering the OP's > >> requirements. > > > > This is false. > > > > platform.machine() is about the the computer itself - I fixed it in > > 2.6 to function properly, as it used to operate similar to > > platform.architecture() due to looking in the wrong place. > > platform.architecture() is about how Python was compiled. > > Hmmm. > I use python 2.6.4 on a 64 bit machine and get 'x86' as result. > perhaps it's only fixed in the newer 2.6 releases? > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- ******************************************************************** The Law Offices of Marc B. Hankin, Inc. Post Office Box 3668, Beverly Hills, California 90212 (Not for mail:509S.BeverlyDr.) Tel: (310) 552-3005 Fax: (310) 382-2416 Email: marc at marchankin.com Website: www.marchankin.com This e-mail message is generated from the law firm of the Law Offices of Marc B. Hankin, Inc., and may contain information that is confidential and may be privileged as an attorney/client communication or as attorney work product. The information is intended to be disclosed solely to the addressee(s). If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this e-mail information is prohibited. If you have received this e-mail in error, please notify the sender by return e-mail and delete it from your computer system. ******************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From gelonida at gmail.com Mon Feb 20 11:31:07 2012 From: gelonida at gmail.com (Gelonida N) Date: Mon, 20 Feb 2012 11:31:07 +0100 Subject: [python-win32] How do I detect a 64 bit version of Windows? In-Reply-To: References: <5DFC544B47B1481E9041165B75724C31@HeimDesktop> Message-ID: Thanks Mark, On 02/20/2012 03:28 AM, Marc Hankin wrote: > Dear Gelonida: > > The following is a vbscript that will return the info you want. You > might want to run it in a python subprocess. > > > > On Error Resume Next > > ' ------ SCRIPT CONFIGURATION ------ > strComputer = "." ' e.g. rallen-srv01 > ' ------ END CONFIGURATION --------- > > set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime") > > set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") > set colOS = objWMI.InstancesOf("Win32_OperatingSystem") > for each objOS in colOS > strOs32OR64bit = objOS.OSArchitecture > sOSname = objOS.Caption > Next > > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' > WScript.Echo "Line 21: strOs32OR64bit = objOS.OSArchitecture = " & > strOs32OR64bit > The solution in your other post works as well if you have win32process process installed. Y> ou can check for "64 bit" in sys.version (or use the platform module > as suggested by Brian) - if it is there it *must* be a 64bit Windows. > If it is not there (ie, it is a 32bit Python), then call > win32process.IsWow64Process() - if it returns True it is a 64bit > windows, otherwise 32bits. From mail at timgolden.me.uk Mon Feb 20 12:53:46 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 20 Feb 2012 11:53:46 +0000 Subject: [python-win32] Getting Remote Share User Group Names and Permissions In-Reply-To: <20120218182229.09d9d9ba@ATOMIZER64> References: <20120217132644.0000431b@unknown> <4F3EB679.1030402@timgolden.me.uk> <20120218182229.09d9d9ba@ATOMIZER64> Message-ID: <4F42344A.70700@timgolden.me.uk> On 18/02/2012 23:22, Rod Person wrote: > On Fri, 17 Feb 2012 20:20:09 +0000 > Tim Golden wrote: >> On 17/02/2012 18:26, Rod Person wrote: >>> >>> import win32security as win32s >>> >>> sd = >>> win32s.GetFileSecurity(sh,win32security.GROUP_SECURITY_INFORMATION) >> >> Assuming that "sh" here is the name of of the share >> (eg \\server\share1) then be aware that the result >> of GetFileSecurity is the security on the underlying >> folder, not the security of the share itself. > > Thanks for the reply, Tim. Would have replied earlier but somehow this > ended up as spam. > > You are correct here, sh is the share. I making a leap - for our > organization - that the share and folder have the same permissions. > There have been cases where the permission were different. Some of > these shares have existed since NT 3.1 and just migrated with permission > since that time. > >> Now, share-level security is, I think, relatively unusual >> and you might well want to know the file security as well, >> but they're not the same thing. (Just in case). >> >> Another caveat: you almost certainly don't want the group security >> from that share, either. That's a pretty much defunct relic of >> the Windows Posix layer which would mimic the Unix security >> model by giving every file a group and an owner. The owner >> is still used sometimes. The group, probably never. >> >> Have a look at this: >> >> http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html > > This what I used to get as far as I have :) > > But, I think the mistake I making is using the share as you point out. > I should be using the actual folder name, in which case I'd need to > be making a connection to the serve with wmi. Is that what your saying > to me? Let's see. I think where we're at is this: you have a number of shares on server1 (sharea, shareb) which you wish to set up on server2 so that, in effect, the same users can access them in the same way. (And, if you DNS-rename the servers around each other, without realising that anything's changed). Although WMI can help you in doing this, it's a bit of a clumsy tool unless you have no other way of getting there. In particular, if you're in an AD setup (or in an NT domain) and have suitably administrative privs, you should be able to use either AD or the Win32 API NetShare* functions (which are exposed via the win32net module in pywin32). I'm not sure if you can simply disregard the share permissions -- which would certainly be the most common approach -- or whether you want them, but are happy for them to match the NTFS permissions for the underlying path. The former is certainly easier; the latter is certainly possible. Ok; let's keep things simple. Assuming suitable admin privs across all relevant machines, this code will read the shares from one machine and recreate them on another assuming that the corresponding paths are already in place: import win32net def shares (system): share_infos, total, hResume = win32net.NetShareEnum (system, 2, 0) for share_info in share_infos: if share_info['type'] == 0: yield share_info while hResume > 0: share_infos, total, hResume = win32net.NetShareEnum ( system, 2, hResume ) for share_info in share_infos: if share_info['type'] == 0: yield share_info def create_share (system, share_info): win32net.NetShareAdd (system, 2, share_info) for share_info in shares ("server1"): create_share ("server2", share_info) Could you see how far that takes you towards your goal? I'm not clear whether you need help specifying the perms on the underlying paths, since that would normally be done by some kind of backup-restore toolset. But if you need something I can certainly advise. TJG From rodperson at rodperson.com Mon Feb 20 13:11:57 2012 From: rodperson at rodperson.com (Rod Person) Date: Mon, 20 Feb 2012 07:11:57 -0500 Subject: [python-win32] Getting Remote Share User Group Names and Permissions In-Reply-To: <4F42344A.70700@timgolden.me.uk> References: <20120217132644.0000431b@unknown> <4F3EB679.1030402@timgolden.me.uk> <20120218182229.09d9d9ba@ATOMIZER64> <4F42344A.70700@timgolden.me.uk> Message-ID: <20120220071157.00004d1b@unknown> On Mon, 20 Feb 2012 11:53:46 +0000 Tim Golden wrote: > > Let's see. I think where we're at is this: you have a number of shares > on server1 (sharea, shareb) which you wish to set up on server2 so > that, in effect, the same users can access them in the same way. (And, > if you DNS-rename the servers around each other, without realising > that anything's changed). > > Although WMI can help you in doing this, it's a bit of a clumsy tool > unless you have no other way of getting there. In particular, if > you're in an AD setup (or in an NT domain) and have suitably > administrative privs, you should be able to use either AD or the > Win32 API NetShare* functions (which are exposed via the win32net > module in pywin32). > > I'm not sure if you can simply disregard the share permissions -- > which would certainly be the most common approach -- or whether you > want them, but are happy for them to match the NTFS permissions for > the underlying path. The former is certainly easier; the latter is > certainly possible. > > Ok; let's keep things simple. Assuming suitable admin privs across > all relevant machines, this code will read the shares from one > machine and recreate them on another assuming that the corresponding > paths are already in place: > > > import win32net > > def shares (system): > share_infos, total, hResume = win32net.NetShareEnum (system, 2, 0) > for share_info in share_infos: > if share_info['type'] == 0: > yield share_info > while hResume > 0: > share_infos, total, hResume = win32net.NetShareEnum ( > system, 2, hResume > ) > for share_info in share_infos: > if share_info['type'] == 0: > yield share_info > > def create_share (system, share_info): > win32net.NetShareAdd (system, 2, share_info) > > for share_info in shares ("server1"): > create_share ("server2", share_info) > > > > > Could you see how far that takes you towards your goal? I'm > not clear whether you need help specifying the perms on > the underlying paths, since that would normally be done by > some kind of backup-restore toolset. But if you need something > I can certainly advise. > > TJG Thanks you again, Tim. I will look at this later today or tomorrow. Permission in my case aren't any problems I have domain administration rights, but that is a relic of when our IT department was 3 people. But yes, the basic goal here is to duplicate a servers shares, the server in question has 150 or so shares and the person in charge wants to do all that by hand...which is seems ridiculous to, especially since he is a programmer...anyway in this situation the two servers will be on the network and the new server will eventually renamed to what the old server name is. -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From rafyengibaryan at gmail.com Mon Feb 20 14:18:49 2012 From: rafyengibaryan at gmail.com (Rafael Yengibaryan) Date: Mon, 20 Feb 2012 17:18:49 +0400 Subject: [python-win32] COM-interfaces in python Message-ID: Hi all. I need some COM-interfaces for virtual disk service(VDS) that are not supported by standard win32com package. Which are the ways to be able to use these interfaces in python code? -------------- next part -------------- An HTML attachment was scrubbed... URL: From etienne.labaume at free.fr Mon Feb 20 16:02:53 2012 From: etienne.labaume at free.fr (etienne.labaume at free.fr) Date: Mon, 20 Feb 2012 16:02:53 +0100 (CET) Subject: [python-win32] [ANN] pywin32 build 217 released. In-Reply-To: <4F3850B6.7070103@skippinet.com.au> Message-ID: <491d2dd5-e9c7-40d7-b739-526e721d6d7a@zimbra8-e1.priv.proxad.net> > For initial support (eg, to ask questions about the release etc), please > contact this mailing-list (python-win32 at python.org). If you want to > report a bug, please do so at https://sf.net/projects/pywin32. Hello Mark, I don't know if this is the best way to let you know, but I have updated my latest findings on bug 3314345 in build 217 in the comments below: http://sourceforge.net/tracker/?func=detail&aid=3314345&group_id=78018&atid=551954 Regards, -- ?tienne From jens at dataflake.org Mon Feb 20 16:26:05 2012 From: jens at dataflake.org (Jens Vagelpohl) Date: Mon, 20 Feb 2012 16:26:05 +0100 Subject: [python-win32] Python-based Windows service: Subcommand works with "debug", but hangs under "start" Message-ID: <5960B458-1727-47F5-9BF8-6BC30358C53F@dataflake.org> Hi all, I've written a Windows service based on win32serviceutil.ServiceFramework. The service per se is running just fine. I am testing it on Windows Server 2003. When starting, the service uses the win32process.CreateProcess to start a process: win32process.CreateProcess(None, , None, None, 0, 0, None, , win32process.STARTUPINFO()) This process is a new Python interpreter which allows me better control over setting up the the environment (e.g. PYTHONPATH) in order to invoke code outside of the system's PYTHONPATH. The service is using win32event.WaitForMultipleObjects to keep track of this process. That part works fine as well. Where I am failing is an attempt to spawn a subprocess from my service's new Python process. I have tried all kinds of parameter combinations for subprocess.call and subprocess.check_output, and tried win32process.CreateProcess as well. It all works fine when running my service from the command line using the "debug" flag. But when the service is started with the "start" flag (or from the Service Manager), the command line process I am spawning last always hangs. Funny detail: The same code works fine under Windows 7. Can anyone show me how to debug the hanging subprocess? Thanks! jens -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 203 bytes Desc: Message signed with OpenPGP using GPGMail URL: From jens at dataflake.org Mon Feb 20 18:20:12 2012 From: jens at dataflake.org (Jens Vagelpohl) Date: Mon, 20 Feb 2012 18:20:12 +0100 Subject: [python-win32] Python-based Windows service: Subcommand works with "debug", but hangs under "start" In-Reply-To: References: <5960B458-1727-47F5-9BF8-6BC30358C53F@dataflake.org> Message-ID: <9D8C54C8-5AF9-4F69-AF3D-D3E30868D280@dataflake.org> Hi Preston, > Offhand it sounds like a authorization related issue. Have you tried > checking the current user identity / authorization from within the > child processes? Not yet. The service itself is run without specific credentials. > Is there a reason you're calling CreateProcess directly to launch the > initial process instead of using subprocess.Popen? The only reason is the fact that all working code samples I had were using it directly. I'll try switching to subprocess.Popen next. > As far as "showing how to debug" I would think it'd be the same as > debugging any other Python process. You should be able to use a > remote debugging package like in WinPDB or Eclipse+pydev. Ok, thanks, I'll take a look at WinPDB. I'm not a Windows programmer and don't use any IDE normally, so I'm trying to avoid Eclipse. Thanks for the pointers! I'll keep digging. jens -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 203 bytes Desc: Message signed with OpenPGP using GPGMail URL: From rodperson at rodperson.com Mon Feb 20 19:19:43 2012 From: rodperson at rodperson.com (Rod Person) Date: Mon, 20 Feb 2012 13:19:43 -0500 Subject: [python-win32] Getting Remote Share User Group Names and Permissions In-Reply-To: <4F42344A.70700@timgolden.me.uk> References: <20120217132644.0000431b@unknown> <4F3EB679.1030402@timgolden.me.uk> <20120218182229.09d9d9ba@ATOMIZER64> <4F42344A.70700@timgolden.me.uk> Message-ID: <20120220131943.0000310e@unknown> On Mon, 20 Feb 2012 11:53:46 +0000 Tim Golden wrote: > > > import win32net > > def shares (system): > share_infos, total, hResume = win32net.NetShareEnum (system, 2, 0) > for share_info in share_infos: > if share_info['type'] == 0: > yield share_info > while hResume > 0: > share_infos, total, hResume = win32net.NetShareEnum ( > system, 2, hResume > ) > for share_info in share_infos: > if share_info['type'] == 0: > yield share_info > > def create_share (system, share_info): > win32net.NetShareAdd (system, 2, share_info) > > for share_info in shares ("server1"): > create_share ("server2", share_info) > > > > > Could you see how far that takes you towards your goal? I'm > not clear whether you need help specifying the perms on > the underlying paths, since that would normally be done by > some kind of backup-restore toolset. But if you need something > I can certainly advise. Ok, this is what happens. Your code fails for me in create_share, because the folders don't exist. So I changed it to this: def create_share (system, share_info): path = share_info['path'].replace(':','$') r_dir = r'\\{0}\{1}'.format(system, path) if not os.path.exists(r_dir): os.makedirs(r_dir) win32net.NetShareAdd(system, 2, share_info) Now that works, and creates the share. But the permission are totally screwed. Here is an example: On the existing server we have a share named: FINANCE_FSI Groups that are allowed access to this folder are: CCBH_OU_Admins CCBH_Finance Managed_Care There are no other groups, no administrator or users. No standard group name shows in the security tab. Also, the share permissions and the actual folder have the same permissions. Now when recreated on the new server the groups are: Administrator Creator_Owner System Users Not sure if my changes caused the problems with the groups. -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From luc.kesters at hotmail.com Mon Feb 20 23:05:05 2012 From: luc.kesters at hotmail.com (Luc Kesters) Date: Mon, 20 Feb 2012 23:05:05 +0100 Subject: [python-win32] [ANN] pywin32 build 217 released. In-Reply-To: <4F418784.4020603@gmail.com> References: <4F3850B6.7070103@skippinet.com.au> <1329675037155-4485616.post@n6.nabble.com> <4F418784.4020603@gmail.com> Message-ID: Hello Mark, I installed the new pywin32. I don't have a problem with pywin32 itself. But when importing other packages (the ones I mentioned) I still have the problem (see below) When I read the issues (see first message) it seemed to me a python problem and not a pywin32 problem. If I understand your answer correct, this isn't the case? I should go back to the developers of the packages (I must say that the "manifest" issue, is somewhat too technical for me) Luc [Error] Message="Syntax error in script" Number=44804 [Error Context] Error_Description_1="Traceback (most recent call last):" Error_Description_2=" File ""