From timr at probo.com Mon Mar 1 03:16:41 2010 From: timr at probo.com (Tim Roberts) Date: Sun, 28 Feb 2010 18:16:41 -0800 Subject: [python-win32] Catch system level events in python Message-ID: <201003010216.o212Gfp31091@probo.probo.com> You wrote: > >i am developing a windows service using python-win32. >Now I am searching for a possibility to get a notification when a user is >trying to shutdown the system. >In certain cases I need to cancel this shutdown, >Does anyone knows how this could be done? This is trickier than you might think. Many shutdowns cannot be blocked. For example, if battery power is critically low, you're going down, like it or not. Further, if someone has their laptop set to hibernate when the close the lid, they're going to be really pissed off if your application blocks that and the battery expires. On Vista and beyond, you can use ShutdownBlockReasonCreate to say "the system should not be shutdown for a while". >Is it possible to catch system level events in python like in other >programming languages as for example C#: Anything that can be done in C# can be done in Python. Do you have a C# example you want to copy? >http://mail.python.org/pipermail/python-win32/2008-January/006645.html Is this code not sufficient for your needs? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mdriscoll at co.marshall.ia.us Mon Mar 1 15:41:38 2010 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 01 Mar 2010 08:41:38 -0600 Subject: [python-win32] How to query the peak commit charge In-Reply-To: <4B8855CF.7000405@gmail.com> References: <4B87E71F.2010007@co.marshall.ia.us> <4B8855CF.7000405@gmail.com> Message-ID: <4B8BD222.40806@co.marshall.ia.us> Hi Mark, On 2/26/2010 5:14 PM, Mark Hammond wrote: > On 27/02/2010 2:22 AM, Mike Driscoll wrote: >> Hi, >> >> I have been tasked with trying to find a way to query the peak commit >> charge of our various workstations. It would be great if I could do it >> remotely, but logging is also a possibility. Unfortunately, my Google >> skills have failed me as I can't find anyone else who is doing this >> publicly. Do you guys have any hints for how best to approach this task? >> >> Here's the use case: We are using Sun Ray virtual desktops and are >> trying to figure out how much RAM each VM is using. We are trying to >> decide if we can shrink the allocated amount of RAM of if we should just >> upgrade the servers. > > Maybe look into the win32pdh/win32pdhutil modules? > > Mark I must be dense, but I'm not seeing how to tell win32pdh which counter I want it to count. I did some research on Google and Windows forums and they seemed to either have nothing on the subject or they would mention the Win32_PerfFormattedData_PerfOS_Memory class. I tried querying that with Tim Golden's WMI, but this class only seems to expose the Total commit charge and the limit commit, but not the peak (see http://msdn.microsoft.com/en-us/library/aa394268%28VS.85%29.aspx). The only other hint I found was this: http://forum.sysinternals.com/forum_posts.asp?TID=15540&PID=75852 where someone says the following: "The only way I'm aware of that one can get this detail is from the uMmPeakCommitLimit member of the SYSTEM_PERFORMANCE_INFORMATION structure one passes to NtQuerySystemInformation when calling it with the SystemPerformanceInformation type." Unfortunately, I don't have a clue as to how to do that in Python. From what I've seen on the list about NtQuerySystemInformation, it doesn't sound like PyWin32 wraps it. Is that correct? Thanks! - Mike From christophedeze at wanadoo.fr Mon Mar 1 18:03:26 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Mon, 01 Mar 2010 18:03:26 +0100 Subject: [python-win32] authentication proxy and download Message-ID: <4B8BF35E.1030500@wanadoo.fr> hello I wrote a windows app that must download file it works fine with urllib.urlretrieve. But I want to download file through a proxy with NTLM (samba)authentication . I want to use windows sessions credential transparently, as IE and Firefox do well... I don't think that urllib(2) can do this. But maybe a win32 API ? http://docs.activestate.com/activepython/2.5/pywin32/win32inet.html http://msdn.microsoft.com/en-us/library/aa384220%28VS.85%29.aspx What do you think of this ? any idea ? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From christophedeze at wanadoo.fr Mon Mar 1 18:59:20 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Mon, 01 Mar 2010 18:59:20 +0100 Subject: [python-win32] authentication proxy and download In-Reply-To: <4B8BF35E.1030500@wanadoo.fr> References: <4B8BF35E.1030500@wanadoo.fr> Message-ID: <4B8C0078.7060007@wanadoo.fr> it should look like that ??? import win32inet hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0) win32inet.InternetSetOption(INTERNET_OPTION_PROXY_PASSWORD,SizeofOtion) win32inet.InternetSetOption(INTERNET_OPTION_PROXY_USERNAME,SizeofOtion) #h = win32inet.InternetConnect(hinternet,'www.google.fr',80,'','',3,0) h = win32inet.InternetOpenUrl(hinternet,'http://downloads.sourceforge.net/sevenzip/7z465.msi') data =win32inet.InternetReadFile(hinternet,sizeOfFile) Le 01/03/2010 18:03, Christophe Deze a ?crit : > hello > > I wrote a windows app that must download file > it works fine with urllib.urlretrieve. > > But I want to download file through a proxy with NTLM > (samba)authentication . > I want to use windows sessions credential transparently, as IE and > Firefox do well... > > I don't think that urllib(2) can do this. > > But maybe a win32 API ? > > http://docs.activestate.com/activepython/2.5/pywin32/win32inet.html > http://msdn.microsoft.com/en-us/library/aa384220%28VS.85%29.aspx > > > What do you think of this ? > any idea ? > > thanks > > > > > > _______________________________________________ > 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 christophedeze at wanadoo.fr Mon Mar 1 19:57:21 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Mon, 01 Mar 2010 19:57:21 +0100 Subject: [python-win32] authentication proxy and download In-Reply-To: <4B8C0078.7060007@wanadoo.fr> References: <4B8BF35E.1030500@wanadoo.fr> <4B8C0078.7060007@wanadoo.fr> Message-ID: <4B8C0E11.7090207@wanadoo.fr> sorry for the monolog .. :D i'm closed to succeed but how to retrieve transparently user and pwd ? import win32inet hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0) h = win32inet.InternetOpenUrl(hinternet,'http://downloads.sourceforge.net/sevenzip/7z465.msi') win32inet.InternetSetOption(h,43,user) win32inet.InternetSetOption(h, 44,pwd) chunks = [] while 1: chunk = win32inet.InternetReadFile(h, 1024) if not chunk: break chunks.append(chunk) data = ''.join(chunks) f = open('test.msi', 'wb') f.write(data) maybe should I use ctype like here : http://stackoverflow.com/questions/1078939/id-like-to-call-the-windows-c-function-winhttpgetproxyforurl-from-python-can thanks for reading Le 01/03/2010 18:59, Christophe Deze a ?crit : > it should look like that ??? > > import win32inet > hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0) > win32inet.InternetSetOption(INTERNET_OPTION_PROXY_PASSWORD,SizeofOtion) > win32inet.InternetSetOption(INTERNET_OPTION_PROXY_USERNAME,SizeofOtion) > #h = win32inet.InternetConnect(hinternet,'www.google.fr',80,'','',3,0) > > h = > win32inet.InternetOpenUrl(hinternet,'http://downloads.sourceforge.net/sevenzip/7z465.msi') > > data =win32inet.InternetReadFile(hinternet,sizeOfFile) > > > Le 01/03/2010 18:03, Christophe Deze a ?crit : >> hello >> >> I wrote a windows app that must download file >> it works fine with urllib.urlretrieve. >> >> But I want to download file through a proxy with NTLM >> (samba)authentication . >> I want to use windows sessions credential transparently, as IE and >> Firefox do well... >> >> I don't think that urllib(2) can do this. >> >> But maybe a win32 API ? >> >> http://docs.activestate.com/activepython/2.5/pywin32/win32inet.html >> http://msdn.microsoft.com/en-us/library/aa384220%28VS.85%29.aspx >> >> >> What do you think of this ? >> any idea ? >> >> thanks >> >> >> >> >> >> _______________________________________________ >> 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 ulrich.mierendorff at gmx.net Mon Mar 1 23:10:42 2010 From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff) Date: Mon, 01 Mar 2010 23:10:42 +0100 Subject: [python-win32] Implementing a python com server that is used by a python client Message-ID: <4B8C3B62.9000807@gmx.net> Hi, I have implemented a simple com server called "TestServer" using the following mail as an example http://markmail.org/message/vheujc2lijgwhhju#query:+page:1+mid:4lgd7lzzokglsckc+state:results (but without multi-threading support) Now I want to write a python client that should be able to connect to "TestServer" via COM and receive events. Connecting to the server and calling methods is easy: I just use win32com.client.Dispatch(..). As far as I know I have to use DispatchWithEvents if I would like to receive events. This requires makepy registration, so I created an idl-file for the server, compiled it with midl to a tlb file and compiled this with makepy to a python file. Now I thought everything should work. But it doesn't: Z:\extension\test>testclient.py Traceback (most recent call last): File "Z:\extension\test\testclient.py", line 28, in server = win32com.client.DispatchWithEvents("testproject.TestServer", TestServerEventHandler) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 256, in DispatchWithEvents raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") TypeError: This COM object can not automate the makepy process - please run makepy manually for this object (I've attached a simple example client and server including the file generated by makepy) Others seem to have similar problems http://www.mail-archive.com/python-win32 at python.org/msg02142.html http://mail.python.org/pipermail/python-win32/2008-November/008384.html but I can't find a solution. Is it impossible? If yes, is there another way to connect a python client to a python com server with events? -Ulrich -------------- next part -------------- A non-text attachment was scrubbed... Name: test.zip Type: application/zip Size: 3231 bytes Desc: not available URL: From skippy.hammond at gmail.com Tue Mar 2 00:59:37 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 02 Mar 2010 10:59:37 +1100 Subject: [python-win32] authentication proxy and download In-Reply-To: <4B8BF35E.1030500@wanadoo.fr> References: <4B8BF35E.1030500@wanadoo.fr> Message-ID: <4B8C54E9.5040303@gmail.com> On 2/03/2010 4:03 AM, Christophe Deze wrote: > hello > > I wrote a windows app that must download file > it works fine with urllib.urlretrieve. > > But I want to download file through a proxy with NTLM > (samba)authentication . > I want to use windows sessions credential transparently, as IE and > Firefox do well... Try looking at the pywin32 sample win32\Demos\security\sspi\fetch_url.py - it uses NTLM to download stuff directly from the destination server, but you may be able to hack it into working with a proxy wanting auth. HTH, Mark From skippy.hammond at gmail.com Tue Mar 2 01:06:41 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 02 Mar 2010 11:06:41 +1100 Subject: [python-win32] Implementing a python com server that is used by a python client In-Reply-To: <4B8C3B62.9000807@gmx.net> References: <4B8C3B62.9000807@gmx.net> Message-ID: <4B8C5691.10005@gmail.com> On 2/03/2010 9:10 AM, Ulrich Mierendorff wrote: > Hi, > > I have implemented a simple com server called "TestServer" using the > following mail as an example > http://markmail.org/message/vheujc2lijgwhhju#query:+page:1+mid:4lgd7lzzokglsckc+state:results > > (but without multi-threading support) > > Now I want to write a python client that should be able to connect to > "TestServer" via COM and receive events. Connecting to the server and > calling methods is easy: I just use win32com.client.Dispatch(..). > > As far as I know I have to use DispatchWithEvents if I would like to > receive events. This requires makepy registration, so I created an > idl-file for the server, compiled it with midl to a tlb file and > compiled this with makepy to a python file. You probably need to tell your server about the typelib being associated with your server - eg, look at the win32com\test\pippo_server.py - it includes the following information in the class: ### Link to typelib _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}' _typelib_version_ = 1, 0 _com_interfaces_ = ['IPippo'] Obviously your ids will be different, but this should be enough to allow your server to provide the typeinfo when requested by Python, and therefore allow clients to use it. HTH, Mark > > Now I thought everything should work. But it doesn't: > > Z:\extension\test>testclient.py > > Traceback (most recent call last): > File "Z:\extension\test\testclient.py", line 28, in > server = win32com.client.DispatchWithEvents("testproject.TestServer", > TestServerEventHandler) > File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line > 256, in DispatchWithEvents > raise TypeError("This COM object can not automate the makepy process - > please run makepy manually for this object") > TypeError: This COM object can not automate the makepy process - please > run makepy manually for this object > > (I've attached a simple example client and server including the file > generated by makepy) > > Others seem to have similar problems > http://www.mail-archive.com/python-win32 at python.org/msg02142.html > http://mail.python.org/pipermail/python-win32/2008-November/008384.html > > but I can't find a solution. Is it impossible? If yes, is there another > way to connect a python client to a python com server with events? > > > -Ulrich > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From Dave.Cross at cdl.co.uk Tue Mar 2 15:41:50 2010 From: Dave.Cross at cdl.co.uk (Dave Cross) Date: Tue, 2 Mar 2010 14:41:50 -0000 Subject: [python-win32] Byte arrays and COM Message-ID: Hi All, I'm tying myself in knots trying to pass a byte array between a C++ DLL and python. The simplified IDl looks like this: HRESULT Test([in,out] int *len, [in,out, size_is(*len)] byte* outp); and the implementation does this: STDMETHODIMP CComTestObj::Test(int *len, unsigned char* outp) { printf("input param is <%d> %s at %lx,\n",*len, outp, outp); strncpy((char*)outp,"TEST",*len); return S_OK; } Makepy generates the following: def Test(self, len=defaultNamedNotOptArg, outp=defaultNamedNotOptArg): """method Test""" return self._ApplyTypes_(6, 1, (24, 0), ((16387, 3), (16401, 3)), u'Test', None,len, outp) I interpret (16387,3) as VT_I4, ByREF, In & Out and (16401,3) as VT_UI1, ByRef In & Out so this looks OK to me. However when I call it like this: object = win32com.client.Dispatch("ComTest.ComTestObj.1") test = create_string_buffer("Hello") print "Test is ", object.Test(6,addressof(test)) Then a) The C++ routine gets an address that doesn't map to the input string and b) the returned value is (3, 84) Any ideas as to where I'm going wrong would be much appreciated. Dave.

**********************************************************************
Please consider the environment - do you really need to print this email?

This email is intended only for the person(s) named above and may contain private and confidential information. If it has come to you in error, please destroy and permanently delete any copy in your possession and contact us on +44 (0) 161 480 4420. The information in this email is copyright © CDL Group Holdings Limited. We cannot accept any liability for any loss or damage sustained as a result of software viruses. It is your responsibility to carry out such virus checking as is necessary before opening any attachment.
Cheshire Datasystems Limited uses software which automatically screens incoming emails for inappropriate content and attachments. If the software identifies such content or attachment, the email will be forwarded to our Technology Department for checking. You should be aware that any email which you send to Cheshire Datasystems Limited is subject to this procedure.
Cheshire Datasystems Limited, Strata House, Kings Reach Road, Stockport SK4 2HD
Registered in England and Wales with Company Number 3991057
VAT registration: 727 1188 33

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Tue Mar  2 19:51:36 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 02 Mar 2010 10:51:36 -0800
Subject: [python-win32] Byte arrays and COM
In-Reply-To: 
References: 
Message-ID: <4B8D5E38.9060904@probo.com>

Dave Cross wrote:
> Hi All,
>  
> I'm tying myself in knots trying to pass a byte array between a
> C++ DLL and python.

More accurately, between a COM server and Python.  The strategies are
somewhat different.


> The simplified IDl looks like this:
>     HRESULT Test([in,out] int *len, [in,out, size_is(*len)] byte* outp);
>  and the implementation does this:
>     STDMETHODIMP CComTestObj::Test(int *len, unsigned char* outp)
>     {
>      printf("input param is <%d>  %s at  %lx,\n",*len, outp, outp);
>      strncpy((char*)outp,"TEST",*len);
>      return S_OK;    
>     }
> Makepy generates the following:
>  
>      def Test(self, len=defaultNamedNotOptArg,
> outp=defaultNamedNotOptArg):
>           """method Test"""
>           return self._ApplyTypes_(6, 1, (24, 0), ((16387, 3), (16401,
> 3)), u'Test', None,len, outp)
>  
> I interpret (16387,3) as VT_I4, ByREF, In & Out and (16401,3) as
> VT_UI1, ByRef In & Out so this looks OK to me.

Well, sort of.  Python reasonably interprets those as being "one
integer, in and out" and "one byte, in and out".  It does not interpret
either one as an array.  "byte *" is not a standard COM type.  You can
pass strings as BSTR, or you can use a VARIANT to pass a SAFEARRAY.

That's especially true if you intend to change the string.  You need to
take extra steps to do that.


> However when I call it like this:
>  
>      object = win32com.client.Dispatch("ComTest.ComTestObj.1")
>      test = create_string_buffer("Hello")
>      print "Test is ", object.Test(6,addressof(test))
> Then
>           a) The C++ routine gets an address that doesn't map to the
> input string
> and     b) the returned value is (3, 84)

Was that the exact code?  84 is correct, because your C code changes the
first byte "T", which is ASCII 84.  I would have expected the first
parameter to be 6, however.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From ulrich.mierendorff at gmx.net  Tue Mar  2 21:39:43 2010
From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff)
Date: Tue, 02 Mar 2010 21:39:43 +0100
Subject: [python-win32] Implementing a python com server that is used by
 a python client
In-Reply-To: <4B8C5691.10005@gmail.com>
References: <4B8C3B62.9000807@gmx.net> <4B8C5691.10005@gmail.com>
Message-ID: <4B8D778F.5030005@gmx.net>

Mark Hammond wrote:
> On 2/03/2010 9:10 AM, Ulrich Mierendorff wrote:
>> Hi,
>>
>> I have implemented a simple com server called "TestServer" using the
>> following mail as an example
>> http://markmail.org/message/vheujc2lijgwhhju#query:+page:1+mid:4lgd7lzzokglsckc+state:results 
>>
>>
>> (but without multi-threading support)
>>
>> Now I want to write a python client that should be able to connect to
>> "TestServer" via COM and receive events. Connecting to the server and
>> calling methods is easy: I just use win32com.client.Dispatch(..).
>>
>> As far as I know I have to use DispatchWithEvents if I would like to
>> receive events. This requires makepy registration, so I created an
>> idl-file for the server, compiled it with midl to a tlb file and
>> compiled this with makepy to a python file.
>
> You probably need to tell your server about the typelib being 
> associated with your server - eg, look at the 
> win32com\test\pippo_server.py - it includes the following information 
> in the class:
>
>     ### Link to typelib
>     _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}'
>     _typelib_version_ = 1, 0
>     _com_interfaces_ = ['IPippo']
>
> Obviously your ids will be different, but this should be enough to 
> allow your server to provide the typeinfo when requested by Python, 
> and therefore allow clients to use it.
Thank you for this excellent help! I used these modifications, changed 
some other parts (to make this work with events), changed my .idl with 
the help of pippo.idl, registered the typelib and simplified the client 
and server code. Now it works!

Here is the output from the client:
Z:\extension\test>testclient.py


client: OnMyEvent received: 123 ; arg type: 
client: OnMyEvent2 received: this is a str ; arg type: 
client: OnMyEvent2 received: this is an unicode string ??? ; arg type: 


And debug output from the server (I don't know why those "None" messages 
appear, but it works...)
in _Invoke_ with 1 0 1 (123,)
server: fire_event called 123 ; arg type: 
server: OnMyEvent fired 123 ; arg type: 
None
in _Invoke_ with 2 0 1 (u'this is a str',)
server: fire_event2 called this is a str ; arg type: 
server: OnMyEvent2 fired this is a str ; arg type: 
None
in _Invoke_ with 2 0 1 (u'this is an unicode string \xe4\xf6\xfc',)
server: fire_event2 called this is an unicode string {characters with 
destroyed encoding}; arg type: 
server: OnMyEvent2 fired this is an unicode string {characters with 
destroyed encoding} ; arg type: 
None


I've attached the testclient.py, testserver.py and testserver.idl. Maybe 
it will help others if they have similar problems..

-Ulrich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/zip
Size: 2374 bytes
Desc: not available
URL: 

From ulrich.mierendorff at gmx.net  Tue Mar  2 22:17:05 2010
From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff)
Date: Tue, 02 Mar 2010 22:17:05 +0100
Subject: [python-win32] Implementing a python com server that is used by
 a python client
In-Reply-To: <4B8D778F.5030005@gmx.net>
References: <4B8C3B62.9000807@gmx.net> <4B8C5691.10005@gmail.com>
	<4B8D778F.5030005@gmx.net>
Message-ID: <4B8D8051.9000006@gmx.net>

Ulrich Mierendorff wrote:
> [...]
> And debug output from the server (I don't know why those "None" 
> messages appear, but it works...)
I figured it out: I was printing the return value of 
self._BroadcastNotify which is None

-Ulrich


From sinan_aksimsek at yahoo.com  Tue Mar  2 17:01:54 2010
From: sinan_aksimsek at yahoo.com (H. Sinan Aksimsek)
Date: Tue, 2 Mar 2010 16:01:54 +0000 (GMT)
Subject: [python-win32] Pyvisa_GPIB problem
Message-ID: <278320.81109.qm@web24406.mail.ird.yahoo.com>

Hi all,

I want to control the HP 438A with python, get power information and plot it over time. This is my first python project and I need just to control power meter and get information as I said before. There is no time to learn step by step the python.

I installed the phton 2.6, PyVISA-1.3.win32 and the software of the GPIB-USB controller. I started the program and wrote this script.

from visa import *

and the response I received is below.

Traceback (most recent call last):
  File "", line 1, in 
    from visa import *
  File "C:\Python25\lib\site-packages\visa.py", line 1, in 
    from pyvisa.visa import *
  File "C:\Python25\Lib\site-packages\pyvisa\visa.py", line 231, in 
    resource_manager = ResourceManager()
  File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 105, in __new__
    it.init(*args, **kwds)
  File "C:\Python25\Lib\site-packages\pyvisa\visa.py", line 227, in init
    self.session = self.vi = vpp43.open_default_resource_manager()
  File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 758, in open_default_resource_manager
    visa_library().viOpenDefaultRM(byref(session))
  File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 175, in __call__
    self.load_library()
  File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 141, in load_library
    self.__lib       = windll.visa32
  File "C:\Python25\lib\ctypes\__init__.py", line 423, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] Das angegebene Modul wurde nicht gefunden


I wasted to much time to reach the answer of this problem over the google, you know. So, what is the problem? What do you suggest me?

Thanks a lot from now on.

Best Regards.
H.Sinan Aksimsek


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verf?gt ?ber einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Wed Mar  3 02:49:41 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 02 Mar 2010 17:49:41 -0800
Subject: [python-win32] Pyvisa_GPIB problem
In-Reply-To: <278320.81109.qm@web24406.mail.ird.yahoo.com>
References: <278320.81109.qm@web24406.mail.ird.yahoo.com>
Message-ID: <4B8DC035.7090909@probo.com>

H. Sinan Aksimsek wrote:
>
> I want to control the HP 438A with python, get power information and
> plot it over time. This is my first python project and I need just to
> control power meter and get information as I said before. There is no
> time to learn step by step the python.
>
> I installed the phton 2.6, PyVISA-1.3.win32 and the software of the
> GPIB-USB controller. I started the program and wrote this script.

Is that a typo, or did you actually install the Python 2.6 version of
PyVISA?  Because:..

> Traceback (most recent call last):
>   File "", line 1, in 
>     from visa import *
>   File "C:\Python25\lib\site-packages\visa.py", line 1, in 
>     from pyvisa.visa import *

...you are running Python 2.5.  You need the Python 2.5 version of PyVISA.


>   File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
>     self._handle = _dlopen(self._name, mode)
> WindowsError: [Error 126] Das angegebene Modul wurde nicht gefunden

Error 126 indicates that a DLL was not found.  If their DLL links to the
Python26.dll runtime, that would cause the problem.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From antonyjoseph89 at gmail.com  Wed Mar  3 07:07:35 2010
From: antonyjoseph89 at gmail.com (Antony Joseph)
Date: Wed, 3 Mar 2010 11:37:35 +0530
Subject: [python-win32] How to get Outlook headers
Message-ID: 

Dear all,

I am trying to read the Message date from Outlook, I get the message date
easily by using  "PR_TRANSPORT_MESSAGE_HEADERS" only for the emails sent
over the Internet. If the email was sent internally using exchange the mail
headers are not  exist on this "PR_TRANSPORT_MESSAGE_HEADERS".

How to get their headers for internal mails?

Then i tried by using other property "PR_MESSAGE_DELIVERY_TIME" to get the
message date for internal mails.

it returns
(805765184, )

The time is different from the original Message date is 2/1/2010 12:00:00 PM


Is there any other property for internal mails which allow me to get the
exact message date


regards
Antony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From chef at ghum.de  Wed Mar  3 08:57:15 2010
From: chef at ghum.de (Massa, Harald Armin)
Date: Wed, 3 Mar 2010 08:57:15 +0100
Subject: [python-win32] How to get Outlook headers
In-Reply-To: 
References: 
Message-ID: 

Antony,

for dealing with Outlook I can really recommend

http://www.dimastr.com/redemption/

it is around 200 Money Units; and it saves you a lot of challenges ...


> I am trying to read the Message date from Outlook, I get the message date
> easily by using  "PR_TRANSPORT_MESSAGE_HEADERS" only for the emails sent
> over the Internet. If the email was sent internally using exchange the mail
> headers are not  exist on this "PR_TRANSPORT_MESSAGE_HEADERS".
>
> for your challenge my solution would be:
- convert to .eml using an RDO object
- parse the .eml with the Python Standard Library email-modules.


disclaimer: Outlook-Redemption just saved my sanity when dealing with .msg;
I am not affiliated with the author in any way.

Harald

-- 
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Stra?e 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
%s is too gigantic of an industry to bend to the whims of reality
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From nihil at blue.dyn-o-saur.com  Wed Mar  3 10:58:41 2010
From: nihil at blue.dyn-o-saur.com (nihil at blue.dyn-o-saur.com)
Date: Wed, 3 Mar 2010 10:58:41 +0100
Subject: [python-win32] cde Outlook 2007 rules and python
Message-ID: <20100303105841.09fb63ea@silvertop>

I try to translate this vbs script to python.
http://www.outlookcode.com/threads.aspx?forumid=2&messageid=29505
The purpose of this script is to automatically create an rule in Outlook to sort incoming messages.
It is possible to do this in Outlook 2007 and the vbs file works. The SPAM folder is writable so thats not the problem.

This code works but only creates an rule that forwards the messages to an another mail address:

#!/bin/env python
# -*- coding: UTF-8 -*-
import codecs
import tempfile
import win32api
import win32com.client
import sys,os
constants = win32com.client.constants
application = win32com.client.Dispatch("Outlook.Application")
rules = application.Session.DefaultStore.GetRules()
_folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
_spamfolder = _folder.Folders["Spam"]
_rule = rules.Create("SPAM",constants.olRuleReceive)
_condition = _rule.Conditions.MessageHeader
_condition.Text = ["X-Spam-Status: Yes"]
_condition.Enabled = True
_action = _rule.Actions.Forward
_action.Recipients.Add("mail at mail.com")
_action.Enabled = True
_rule.Enabled = True
rules.Save()

This is the code i need but it is not working:

#!/bin/env python
# -*- coding: UTF-8 -*-
import codecs
import tempfile
import win32api
import win32com.client
import sys,os

constants = win32com.client.constants
application = win32com.client.Dispatch("Outlook.Application")
rules = application.Session.DefaultStore.GetRules()
_folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
_spamfolder = _folder.Folders["Spam"]
_rule = rules.Create("SPAM",constants.olRuleReceive)
_condition = _rule.Conditions.MessageHeader
_condition.Text = ["X-Spam-Status: Yes"]
_condition.Enabled = True
_action = _rule.Actions.MoveToFolder
_action.Folder = _spamfolder
_spamfolder2 = _spamfolder
print _spamfolder, _spamfolder2, _action.Folder
_action.Enabled = True
_rule.Enabled = True
rules.Save()

The problem is that even after the assignment and in my print _action.Folder contains None but
_spamfolder and _spamfolder2 both contain an reference to the Library.MAPIFolder. 
Could anyone please enlighten me. Why is _action.Folder empty?
It seems the vbs guys have the same problem but they use "Set objActionMoveToFolder.Folder = objFolderJunk"
instead of "objActionMoveToFolder.Folder = objFolderJunk" 







From jan at janschneider.net  Wed Mar  3 19:47:50 2010
From: jan at janschneider.net (Jan Schneider)
Date: Wed, 3 Mar 2010 19:47:50 +0100
Subject: [python-win32] Catch system level events in python
In-Reply-To: <201003010216.o212Gfp31091@probo.probo.com>
References: <201003010216.o212Gfp31091@probo.probo.com>
Message-ID: <201003031947.50487.jan@janschneider.net>

Am Montag, 1. M?rz 2010 03:16:41 schrieb Tim Roberts:
> You wrote:
> >i am developing a windows service using python-win32.
> >Now I am searching for a possibility to get a notification when a user is
> >trying to shutdown the system.
> >In certain cases I need to cancel this shutdown,
> >Does anyone knows how this could be done?
> 
> This is trickier than you might think.  Many shutdowns cannot be blocked. 
> For example, if battery power is critically low, you're going down, like
> it or not.  Further, if someone has their laptop set to hibernate when the
> close the lid, they're going to be really pissed off if your application
> blocks that and the battery expires.
> 
> On Vista and beyond, you can use ShutdownBlockReasonCreate to say "the
> system should not be shutdown for a while".
> 
> >Is it possible to catch system level events in python like in other
> 
> >programming languages as for example C#:
> Anything that can be done in C# can be done in Python.  Do you have a C#
> example you want to copy?
> 
> >http://mail.python.org/pipermail/python-win32/2008-January/006645.html
> 
> Is this code not sufficient for your needs?
Thanks for your answer!

The code is good to get a notification when the system shuts down.
But I can not see a possibility to cancel the shutdown.

I think what i need is something like the code below, but I don't know how to 
implement this in python:

http://blogs.techrepublic.com.com/howdoi/?p=135

SystemEvents.SessionEnding += new 
SessionEndingEventHandler(SystemEvents_SessionEnding);

void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{
        e.Cancel();
}

The e.Cancel() should cancel the shutdown.
My next problem is to tell the difference between a shutdown (poweroff) and a 
reboot.

What I want to do is:
* catch a shutdown
* decide if it is a power off or reboot
* do some tasks
* shut down or restart the machine

From timr at probo.com  Wed Mar  3 21:02:00 2010
From: timr at probo.com (Tim Roberts)
Date: Wed, 03 Mar 2010 12:02:00 -0800
Subject: [python-win32] Byte arrays and COM
In-Reply-To: 
References: 
Message-ID: <4B8EC038.6000407@probo.com>

Dave Cross wrote:
> DOH! Should have spotted that 84 was 'T'
> So how do I convince MakePy that I mean an array?
> I thought the [size_is] in the IDL should achieve that?

There's no way to do this with the automatic translation.  You will
either have to dig in to the comtypes module, which works at a lower level:
    http://starship.python.net/crew/theller/comtypes/
or use a separate C routine to bridge between the two.

There's a spec for COM IDispatch objects that allows a rather narrow
subset of the vast range of possible types.  Your object doesn't follow
that spec, so you need to take extraordinary steps.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From python at bdurham.com  Wed Mar  3 22:40:18 2010
From: python at bdurham.com (python at bdurham.com)
Date: Wed, 03 Mar 2010 16:40:18 -0500
Subject: [python-win32] Detect when application is running in a VM
	environment?
Message-ID: <1267652418.18938.1362973075@webmail.messagingengine.com>

Looking for ideas on how to detect when our Windows application
is running in one of the following VM environments. Some starter
ideas for detection are in parentheses. There may be (much)
better detection techniques - the starter ideas I've come up with
are based on my Google research.

- VMWare (looking for the presence of optional VMware Tools is
one way)
- Microsoft Virtual PC (have a device named "Virtual HD" for
their IDE disks, "MS Virtual SCSI Disk Device" for their SCSI
disks)
- Citrix Xen
- Sun Virtual Box

Any suggestions?

Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mvilas at gmail.com  Thu Mar  4 01:06:23 2010
From: mvilas at gmail.com (Mario Vilas)
Date: Wed, 3 Mar 2010 21:06:23 -0300
Subject: [python-win32] Detect when application is running in a VM
	environment?
In-Reply-To: <1267652418.18938.1362973075@webmail.messagingengine.com>
References: <1267652418.18938.1362973075@webmail.messagingengine.com>
Message-ID: <3fbf862f1003031606na126761k293121e0f068b065@mail.gmail.com>

This is a small paper that summarizes a number of more extense papers
describing different methods of VM detection. It may be of help:

http://www.s21sec.com/descargas/vmware-eng.pdf

On Wed, Mar 3, 2010 at 6:40 PM,   wrote:
> Looking for ideas on how to detect when our Windows application is running
> in one of the following VM environments. Some starter ideas for detection
> are in parentheses. There may be (much) better detection techniques - the
> starter ideas I've come up with are based on my Google research.
>
> - VMWare (looking for the presence of optional VMware Tools is one way)
> - Microsoft Virtual PC (have a device named "Virtual HD" for their IDE
> disks, "MS Virtual SCSI Disk Device" for their SCSI disks)
> - Citrix Xen
> - Sun Virtual Box
>
> Any suggestions?
>
> Malcolm
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>



-- 
HONEY: I want to? put some powder on my nose.
GEORGE: Martha, won?t you show her where we keep the euphemism?

From timr at probo.com  Thu Mar  4 01:32:08 2010
From: timr at probo.com (Tim Roberts)
Date: Wed, 03 Mar 2010 16:32:08 -0800
Subject: [python-win32] Detect when application is running in a VM
	environment?
In-Reply-To: <1267652418.18938.1362973075@webmail.messagingengine.com>
References: <1267652418.18938.1362973075@webmail.messagingengine.com>
Message-ID: <4B8EFF88.7070507@probo.com>

python at bdurham.com wrote:
> Looking for ideas on how to detect when our Windows application is
> running in one of the following VM environments.

Why?  Is this for curiousity, or is it a lame-brained security scheme?

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From python at bdurham.com  Thu Mar  4 03:01:19 2010
From: python at bdurham.com (python at bdurham.com)
Date: Wed, 03 Mar 2010 21:01:19 -0500
Subject: [python-win32] WMI script that shows general info about a computer
Message-ID: <1267668079.25493.1363011877@webmail.messagingengine.com>

Apologies for the vague description. I'm looking for tips on a
WMI query that would allow me to show general info about a
computer.

We're going to use this data as part of a workstation inventory
project I'm working on.

I'm sure I've seen this type of query before but my google-mojo
is failing me.

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Thu Mar  4 03:08:07 2010
From: python at bdurham.com (python at bdurham.com)
Date: Wed, 03 Mar 2010 21:08:07 -0500
Subject: [python-win32] Detect when application is running in a VM
 environment?
In-Reply-To: <4B8EFF88.7070507@probo.com>
References: <1267652418.18938.1362973075@webmail.messagingengine.com>
	<4B8EFF88.7070507@probo.com>
Message-ID: <1267668487.26382.1363012977@webmail.messagingengine.com>

Hi Tim,

>> Looking for ideas on how to detect when our Windows application is
>> running in one of the following VM environments.

> Why? Is this for curiousity, or is it a lame-brained security scheme?

LOL! No, I'm working on a script that inventories all the environments
we're running in our development labs. With virtualization, we have lots
of new environments popping up all over the place - most of which are
intended as temporary test environments - that have the unfortunate side
effect of hanging around a lot longer than we had hoped.

Malcolm

From python at bdurham.com  Thu Mar  4 07:30:10 2010
From: python at bdurham.com (python at bdurham.com)
Date: Thu, 04 Mar 2010 01:30:10 -0500
Subject: [python-win32] WMI script that shows general info about a
 computer (SOLVED)
In-Reply-To: <1267668079.25493.1363011877@webmail.messagingengine.com>
References: <1267668079.25493.1363011877@webmail.messagingengine.com>
Message-ID: <1267684210.26901.1363039405@webmail.messagingengine.com>

OP here. When in doubt, read the (very well commented) wmi.py
source code :)

computerSystem = wmi.WMI().Win32_ComputerSystem()[0]

Sorry for the interuption.

Malcolm

----- Original message -----
From: python at bdurham.com
To: python-win32 at python.org
Date: Wed, 03 Mar 2010 21:01:19 -0500
Subject: [python-win32] WMI script that shows general info about
a computer
Apologies for the vague description. I'm looking for tips on a
WMI query that would allow me to show general info about a
computer.

We're going to use this data as part of a workstation inventory
project I'm working on.

I'm sure I've seen this type of query before but my google-mojo
is failing me.

Thank you,
Malcolm
_______________________________________________
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 python at bdurham.com  Thu Mar  4 07:38:21 2010
From: python at bdurham.com (python at bdurham.com)
Date: Thu, 04 Mar 2010 01:38:21 -0500
Subject: [python-win32] How to enumerate a WMI object to discover its
	properties?
Message-ID: <1267684701.27973.1363039525@webmail.messagingengine.com>

Is there a way to enumerate a WMI object's properties to discover
what they are vs. having to explictly reference properties by
name?

>From reading the wmi.py source code I understand that enumerating
Win32_ComputerSystem() is not a good idea. But, using that as an
example anyway, how would I get a list of WMI properties like
.TotalPhysicalMemory without having to know each property ahead
of time.

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Thu Mar  4 09:46:24 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 04 Mar 2010 08:46:24 +0000
Subject: [python-win32] WMI script that shows general info about a
 computer (SOLVED)
In-Reply-To: <1267684210.26901.1363039405@webmail.messagingengine.com>
References: <1267668079.25493.1363011877@webmail.messagingengine.com>
	<1267684210.26901.1363039405@webmail.messagingengine.com>
Message-ID: <4B8F7360.8040905@timgolden.me.uk>

On 04/03/2010 06:30, python at bdurham.com wrote:
> OP here. When in doubt, read the (very well commented) wmi.py
> source code :)
>
> computerSystem = wmi.WMI().Win32_ComputerSystem()[0]

Well I'm always glad to hear a positive comment on the
source code, but there *is* some documentation:

http://timgolden.me.uk/python/wmi/index.html
http://timgolden.me.uk/python/wmi/tutorial.html
http://timgolden.me.uk/python/wmi/cookbook.html

:)

TJG

From mail at timgolden.me.uk  Thu Mar  4 09:49:28 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 04 Mar 2010 08:49:28 +0000
Subject: [python-win32] How to enumerate a WMI object to discover its
 properties?
In-Reply-To: <1267684701.27973.1363039525@webmail.messagingengine.com>
References: <1267684701.27973.1363039525@webmail.messagingengine.com>
Message-ID: <4B8F7418.2070901@timgolden.me.uk>

On 04/03/2010 06:38, python at bdurham.com wrote:
> Is there a way to enumerate a WMI object's properties to discover
> what they are vs. having to explictly reference properties by
> name?

Assuming I understand the question, a quickie shortcut is
just to "print" the object:


import wmi

c = wmi.WMI ()
for s in c.Win32_ComputerSystem ():
   print s



but in fact each object also holds a list of its own properties:


import wmi

c = wmi.WMI ()
print list (c.Win32_ComputerSystem.properties)
print list (c.Win32_ComputerSystem.methods)

or you can do the same with an instance:

for s in c.Win32_ComputerSystem ():
   print list (s.properties)



TJG

From Dave.Cross at cdl.co.uk  Thu Mar  4 13:08:53 2010
From: Dave.Cross at cdl.co.uk (Dave Cross)
Date: Thu, 4 Mar 2010 12:08:53 -0000
Subject: [python-win32] MIDL & MakePy
Message-ID: 

Hi all,

Can anyone explain how MakePy interprets COM IDL?
 
If I define: 
 HRESULT Test([out] byte* outp);
Makepy generates:
 """method Test"""
 return self._ApplyTypes_(3, 1, (24, 0), ((16401, 2),), u'Test',
None,outp)
and I can interpret (16401,2) as VT_UI1, BYREF and OUT.
 
If, however, I define:
 HRESULT Test([in] long len, [in, size_is(len)] byte outp[]); 
MakePy generates:
 """method Test"""
 return self._ApplyTypes_(4, 1, (24, 0), ((16387, 3), (16401, 2)),
u'Test', None,len, outp)
and the marshalling of outp is still a pointer to a single byte, not an
array of bytes.
 
Manually editing the MakePy class to use a value of 16412 (i.e.
VT_CARRAY BYREF) gives me a 
'VARIANT Type is unknown' exception as does 16414 (VT_LPSTR)
Adding in 0x2000 to set VT_ARRAY leads to a 'Type mismatch' error.
 
 
Is there some doccumentation somewhere to tell me which VARIANT types I
can use and how to do arrays?
 
Many thanks,
Dave.

**********************************************************************
Please consider the environment - do you really need to print this email?

This email is intended only for the person(s) named above and may contain private and confidential information. If it has come to you in error, please destroy and permanently delete any copy in your possession and contact us on +44 (0) 161 480 4420. The information in this email is copyright © CDL Group Holdings Limited. We cannot accept any liability for any loss or damage sustained as a result of software viruses. It is your responsibility to carry out such virus checking as is necessary before opening any attachment.
Cheshire Datasystems Limited uses software which automatically screens incoming emails for inappropriate content and attachments. If the software identifies such content or attachment, the email will be forwarded to our Technology Department for checking. You should be aware that any email which you send to Cheshire Datasystems Limited is subject to this procedure.
Cheshire Datasystems Limited, Strata House, Kings Reach Road, Stockport SK4 2HD
Registered in England and Wales with Company Number 3991057
VAT registration: 727 1188 33

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Thu Mar  4 19:06:20 2010
From: timr at probo.com (Tim Roberts)
Date: Thu, 04 Mar 2010 10:06:20 -0800
Subject: [python-win32] MIDL & MakePy
In-Reply-To: 
References: 
Message-ID: <4B8FF69C.7000109@probo.com>

Dave Cross wrote:
>
> Can anyone explain how MakePy interprets COM IDL?

Well, remember that MakePy does not interpret IDL.  MakePy reads the
TLB, which is the compiled version of the IDL.  By the time MakePy sees
it, it's already been through one level of interpretation.


> If I define:
>  HRESULT Test([out] byte* outp);
> Makepy generates:
>  """method Test"""
>  return self._ApplyTypes_(3, 1, (24, 0), ((16401, 2),), u'Test',
> None,outp)
> and I can interpret (16401,2) as VT_UI1, BYREF and OUT.
>  
> If, however, I define:
>  HRESULT Test([in] long len, [in, size_is(len)] byte outp[]); 
> MakePy generates:
>  """method Test"""
>  return self._ApplyTypes_(4, 1, (24, 0), ((16387, 3), (16401, 2)),
> u'Test', None,len, outp)
> and the marshalling of outp is still a pointer to a single byte, not
> an array of bytes.

There is no difference in C (or C++) between "byte* outp" and "byte
outp[]" in a parameter list.  It's just two different ways to spell of
the same thing.
 

> Manually editing the MakePy class to use a value of 16412 (i.e.
> VT_CARRAY BYREF) gives me a
> 'VARIANT Type is unknown' exception as does 16414 (VT_LPSTR)
> Adding in 0x2000 to set VT_ARRAY leads to a 'Type mismatch' error.

Right.  MakePy only understand the types that are COM
dispatch-compliant, and VT_CARRAY is not one of those.  It cannot be
handled safely in all languages.  VT_ARRAY designates that the parameter
is a pointer to a SAFEARRAY structure.

 
> Is there some doccumentation somewhere to tell me which VARIANT types
> I can use and how to do arrays?

You said you couldn't change the server, right?  Unless the COM object
is expecting a pointer to VARIANT, you cannot just pass it one.  As I
said, you're going to need some kind of adapter.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From python at bdurham.com  Thu Mar  4 19:19:57 2010
From: python at bdurham.com (python at bdurham.com)
Date: Thu, 04 Mar 2010 13:19:57 -0500
Subject: [python-win32] How to enumerate a WMI object to discover its
 properties?
In-Reply-To: <4B8F7418.2070901@timgolden.me.uk>
References: <1267684701.27973.1363039525@webmail.messagingengine.com>
	<4B8F7418.2070901@timgolden.me.uk>
Message-ID: <1267726797.1978.1363137925@webmail.messagingengine.com>

Hi Tim,

Thanks to your help, here's what I'm using to record interesting
information about our workstation inventory. It works great!

c = wmi.WMI().Win32_ComputerSystem
computer = c()[0]
for propertyName in sorted( list( c.properties ) ):
	print '%s = %s' % ( propertyName, getattr( computer,
	propertyName, '' ) )

For those searching the archives, the same technique can be used to
capture BIOS info as well using the following replacement line.

c = wmi.WMI().Win32_BIOS

Thank you very much for your help and for all your Win32
contributions!!!

Cheers,
Malcolm


----- Original message -----
From: "Tim Golden" 
To: 
Cc: "zz Python Win32 Newsgroup" 
Date: Thu, 04 Mar 2010 08:49:28 +0000
Subject: Re: [python-win32] How to enumerate a WMI object to discover
its properties?

On 04/03/2010 06:38, python at bdurham.com wrote:
> Is there a way to enumerate a WMI object's properties to discover
> what they are vs. having to explictly reference properties by
> name?

Assuming I understand the question, a quickie shortcut is
just to "print" the object:


import wmi

c = wmi.WMI ()
for s in c.Win32_ComputerSystem ():
   print s



but in fact each object also holds a list of its own properties:


import wmi

c = wmi.WMI ()
print list (c.Win32_ComputerSystem.properties)
print list (c.Win32_ComputerSystem.methods)

or you can do the same with an instance:

for s in c.Win32_ComputerSystem ():
   print list (s.properties)



From python at bdurham.com  Thu Mar  4 19:25:40 2010
From: python at bdurham.com (python at bdurham.com)
Date: Thu, 04 Mar 2010 13:25:40 -0500
Subject: [python-win32] WMI script that shows general info about a
 computer (SOLVED)
In-Reply-To: <4B8F7360.8040905@timgolden.me.uk>
References: <1267668079.25493.1363011877@webmail.messagingengine.com><1267684210.26901.1363039405@webmail.messagingengine.com>
	<4B8F7360.8040905@timgolden.me.uk>
Message-ID: <1267727140.2985.1363139565@webmail.messagingengine.com>

Hi Tim,

> Well I'm always glad to hear a positive comment on the
> source code, but there *is* some documentation:
>
> http://timgolden.me.uk/python/wmi/index.html
> http://timgolden.me.uk/python/wmi/tutorial.html
> http://timgolden.me.uk/python/wmi/cookbook.html

I read and enjoyed all your documentation. The WMI feature I was trying
to find (couldn't remember the name) was Win32_ComputerSystem and I
don't believe that showed up in any of your examples. Not a criticism -
I wasn't expecting you to provide general WMI documentation.

I'm back on track thanks to your help!

Cheers,
Malcolm

From mehgcap at gmail.com  Thu Mar  4 19:42:06 2010
From: mehgcap at gmail.com (Alex Hall)
Date: Thu, 4 Mar 2010 13:42:06 -0500
Subject: [python-win32] wmi: processor class seems slow
Message-ID: 

Hi all,
I have a script that gets the load of a given core, or the average of
all cores, along with other information, like free ram and hard disk
space. The script runs fine, but when I give it processor-related
commands it is sometimes rather fast and sometimes quite slow. Delays
range from one to ten or fifteen seconds, but only on processor
queries, nothing else. I am not sure how this is and would very much
like to correct the problem as I plan to make this script publically
available. I figure it must be possible since system resource
gadgets/widgets can keep a constantly updating graph of processor
performance. How can I get rid of this frustrating delay? Thank you in
advance for any help!

-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap

From mail at timgolden.me.uk  Thu Mar  4 20:23:59 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 04 Mar 2010 19:23:59 +0000
Subject: [python-win32] wmi: processor class seems slow
In-Reply-To: 
References: 
Message-ID: <4B9008CF.6020504@timgolden.me.uk>

On 04/03/2010 18:42, Alex Hall wrote:
> Hi all,
> I have a script that gets the load of a given core, or the average of
> all cores, along with other information, like free ram and hard disk
> space. The script runs fine, but when I give it processor-related
> commands it is sometimes rather fast and sometimes quite slow. Delays
> range from one to ten or fifteen seconds, but only on processor
> queries, nothing else.

Point of information: certain of the attributes exposed on the
Win32_Processor class are calculated at runtime. At this moment
I don't remember which, but if you're not already, specify the
columns you want to retrieve (ie don't use "SELECT *" or, if you're
using my wmi module, pass a list of fields as the first positional
parameter to the WMI () call.

I am not sure how this is and would very much
> like to correct the problem as I plan to make this script publically
> available. I figure it must be possible since system resource
> gadgets/widgets can keep a constantly updating graph of processor
> performance. How can I get rid of this frustrating delay? Thank you in
> advance for any help!

Why not make the code publicly available now (if only on pastebin)
so we can see better.

TJG

From mehgcap at gmail.com  Thu Mar  4 20:38:06 2010
From: mehgcap at gmail.com (Alex Hall)
Date: Thu, 4 Mar 2010 14:38:06 -0500
Subject: [python-win32] wmi: processor class seems slow
In-Reply-To: <4B9008CF.6020504@timgolden.me.uk>
References: 
	<4B9008CF.6020504@timgolden.me.uk>
Message-ID: 

I do specify the field(s) I want, but this has not significant affect
on processor-related information access times. I will upload a zip
file of the entire thing, including dependencies, to my site soon and
will email the list with the above question (for reference) and a link
to the zip file. Thanks.

On 3/4/10, Tim Golden  wrote:
> On 04/03/2010 18:42, Alex Hall wrote:
>> Hi all,
>> I have a script that gets the load of a given core, or the average of
>> all cores, along with other information, like free ram and hard disk
>> space. The script runs fine, but when I give it processor-related
>> commands it is sometimes rather fast and sometimes quite slow. Delays
>> range from one to ten or fifteen seconds, but only on processor
>> queries, nothing else.
>
> Point of information: certain of the attributes exposed on the
> Win32_Processor class are calculated at runtime. At this moment
> I don't remember which, but if you're not already, specify the
> columns you want to retrieve (ie don't use "SELECT *" or, if you're
> using my wmi module, pass a list of fields as the first positional
> parameter to the WMI () call.
>
> I am not sure how this is and would very much
>> like to correct the problem as I plan to make this script publically
>> available. I figure it must be possible since system resource
>> gadgets/widgets can keep a constantly updating graph of processor
>> performance. How can I get rid of this frustrating delay? Thank you in
>> advance for any help!
>
> Why not make the code publicly available now (if only on pastebin)
> so we can see better.
>
> TJG
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap

From mehgcap at gmail.com  Thu Mar  4 21:19:34 2010
From: mehgcap at gmail.com (Alex Hall)
Date: Thu, 4 Mar 2010 15:19:34 -0500
Subject: [python-win32] WMI processor class is very slow?
Message-ID: 

Hi all,
I wrote a couple hours ago asking why wmi information about my
processor (core and overall load) is very slow, delaying up to ten or
fifteen seconds when disk and ram information is immediate. Here is
the link to the zipped project file. I do not have svn or anything
fancy like that. Note that you cannot run the script unless you
install saytools.exe in the dependencies folder and, of course, get
the rest of the dependencies. If anyone can tell me why processor info
is being so slow, I would really appreciate it!
Note that my code is indented by one space for each level; sorry to
those used to tabs. It is a lot easier to administer this way when
using a screen reader.
http://www.gateway2somewhere.com/sw.zip

-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap

From mail at timgolden.me.uk  Fri Mar  5 12:09:35 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Fri, 05 Mar 2010 11:09:35 +0000
Subject: [python-win32] WMI script that shows general info about a
 computer (SOLVED)
In-Reply-To: <1267727140.2985.1363139565@webmail.messagingengine.com>
References: <1267668079.25493.1363011877@webmail.messagingengine.com><1267684210.26901.1363039405@webmail.messagingengine.com>
	<4B8F7360.8040905@timgolden.me.uk>
	<1267727140.2985.1363139565@webmail.messagingengine.com>
Message-ID: <4B90E66F.1040806@timgolden.me.uk>

On 04/03/2010 18:25, python at bdurham.com wrote:
> Hi Tim,
>
>> Well I'm always glad to hear a positive comment on the
>> source code, but there *is* some documentation:
>>
>> http://timgolden.me.uk/python/wmi/index.html
>> http://timgolden.me.uk/python/wmi/tutorial.html
>> http://timgolden.me.uk/python/wmi/cookbook.html
>
> I read and enjoyed all your documentation. The WMI feature I was trying
> to find (couldn't remember the name) was Win32_ComputerSystem and I
> don't believe that showed up in any of your examples. Not a criticism -
> I wasn't expecting you to provide general WMI documentation.

Ah. Slightly misunderstood. Something else which might help, then,
is the wmiweb.py which ships with recent versions of the wmi
module. It installs to c:\pythonxx\scripts or you can just get
it here:

   http://svn.timgolden.me.uk/wmi/trunk/wmiweb.py

It's a standalone web app which lets you browse the wmi
namespaces on local or remote computers. I often use it
when I know there's a WMI class for something but I can't
remember exactly what it's called :)

TJG

From python at bdurham.com  Fri Mar  5 19:50:19 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 05 Mar 2010 13:50:19 -0500
Subject: [python-win32] WMI script that shows general info about a
 computer (SOLVED)
In-Reply-To: <4B90E66F.1040806@timgolden.me.uk>
References: <1267668079.25493.1363011877@webmail.messagingengine.com><1267684210.26901.1363039405@webmail.messagingengine.com><4B8F7360.8040905@timgolden.me.uk><1267727140.2985.1363139565@webmail.messagingengine.com>
	<4B90E66F.1040806@timgolden.me.uk>
Message-ID: <1267815019.24310.1363330017@webmail.messagingengine.com>

Hi Tim,

> Something else which might help, then, is the wmiweb.py which ships with recent versions of the wmi module. It installs to c:\pythonxx\scripts or you can just get it here: http://svn.timgolden.me.uk/wmi/trunk/wmiweb.py

> It's a standalone web app which lets you browse the wmi namespaces on local or remote computers. I often use it when I know there's a WMI class for something but I can't remember exactly what it's called :)

WOW!!! I had that on my workstation and didn't even know about it.

I just took a look and was blown away. Very nicely done. And very, very
helpful!!!

THANK YOU TIM!

Cheers,
Malcolm

From python at bdurham.com  Sat Mar  6 00:20:47 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 05 Mar 2010 18:20:47 -0500
Subject: [python-win32] Detect whether a workstation is a laptop or
	desktop/server?
Message-ID: <1267831247.330.1363365665@webmail.messagingengine.com>

As part of an inventory project I'm working on, I'm trying to
figure out whether a specific computer is a mobile asset (laptop)
or fixed asset (desktop/server).

Is there some feature that I can look that would indicate whether
a computer is a laptop or not? My initial thought was I could
look for battery properties, but I'm not sure that would allow me
to distinguish between a laptop and a server with an attached
UPS.

Any suggestions?

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From skippy.hammond at gmail.com  Sat Mar  6 06:37:49 2010
From: skippy.hammond at gmail.com (Mark Hammond)
Date: Sat, 06 Mar 2010 16:37:49 +1100
Subject: [python-win32] How to get Outlook headers
In-Reply-To: 
References: 
Message-ID: <4B91EA2D.8060109@gmail.com>

On 3/03/2010 5:07 PM, Antony Joseph wrote:
> Dear all,
>
> I am trying to read the Message date from Outlook, I get the message
> date easily by using "PR_TRANSPORT_MESSAGE_HEADERS" only for the emails
> sent over the Internet. If the email was sent internally using exchange
> the mail headers are not  exist on this "PR_TRANSPORT_MESSAGE_HEADERS".
>
> How to get their headers for internal mails?

You can't, as they don't exist.  Only messages sent via the internet 
have such headers.  The SpamBayes project has some code you may find 
interesting in this regard (it even makes some attempt to reconstitute 
the mime stuff which outlook mangles even for internet mail)
>
> Then i tried by using other property "PR_MESSAGE_DELIVERY_TIME" to get
> the message date for internal mails.
>
> it returns
> (805765184, )
>
> The time is different from the original Message date is 2/1/2010
> 12:00:00 PM
>
> Is there any other property for internal mails which allow me to get the
> exact message date

As Harald mentioned, 'redemption' is a nice tool for this kind of 
ad-hock property browsing...

HTH,

Mark

From python at bdurham.com  Sat Mar  6 16:00:28 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sat, 06 Mar 2010 10:00:28 -0500
Subject: [python-win32] Detect whether a workstation is a laptop or
 desktop/server?
In-Reply-To: <11855D58-D6D6-4701-A191-C95D78F2D833@gmail.com>
References: <1267831247.330.1363365665@webmail.messagingengine.com>
	<11855D58-D6D6-4701-A191-C95D78F2D833@gmail.com>
Message-ID: <1267887628.32602.1363432379@webmail.messagingengine.com>

Hi Roberto. 

> I assume you could categorize a computer as a laptop or desktop once you knew the machine's make an model.  

Unfortunately, we're a start-up company with an entirely random mix of
computers from what seems like every vendor possible. I'm not sure where
I would find a database for some of the machines we have.

I'm hoping that there's a WMI property that allows me to distinguish
between a laptop battery and an external UPS. (I've been looking, but my
google-fu is failing me).

Thanks for your help,

Regards,
Malcolm

From steven.james at gmail.com  Sat Mar  6 16:17:43 2010
From: steven.james at gmail.com (Steven James)
Date: Sat, 6 Mar 2010 10:17:43 -0500
Subject: [python-win32] Detect whether a workstation is a laptop or
	desktop/server?
In-Reply-To: <1267887628.32602.1363432379@webmail.messagingengine.com>
References: <1267831247.330.1363365665@webmail.messagingengine.com>
	<11855D58-D6D6-4701-A191-C95D78F2D833@gmail.com>
	<1267887628.32602.1363432379@webmail.messagingengine.com>
Message-ID: 

Not sure exactly, but perhaps you could distinguish whether the battery is
connected via USB or some other transport method? Looking through the device
manager there seem to be some fields that might be relevant. As a network
admin, I've used a free software called Spiceworks in the past that scans
our network and classifies machines. Does a decent job and seems to use the
model-database technique.

Other ways might be...does the machine have a PCMCIA slot? does it have
built-in wifi/bluetooth? A 5400RPM hard drive? These aren't assurances, but
they point to laptops.

Well I think that's every way possible of not answering your question. Sorry
=).

SJ


On Sat, Mar 6, 2010 at 10:00 AM,  wrote:

> Hi Roberto.
>
> > I assume you could categorize a computer as a laptop or desktop once you
> knew the machine's make an model.
>
> Unfortunately, we're a start-up company with an entirely random mix of
> computers from what seems like every vendor possible. I'm not sure where
> I would find a database for some of the machines we have.
>
> I'm hoping that there's a WMI property that allows me to distinguish
> between a laptop battery and an external UPS. (I've been looking, but my
> google-fu is failing me).
>
> Thanks for your help,
>
> Regards,
> Malcolm
> _______________________________________________
> 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 python at bdurham.com  Sat Mar  6 19:59:21 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sat, 06 Mar 2010 13:59:21 -0500
Subject: [python-win32] Detect whether a workstation is a laptop or
 desktop/server?
In-Reply-To: 
References: <1267831247.330.1363365665@webmail.messagingengine.com><11855D58-D6D6-4701-A191-C95D78F2D833@gmail.com><1267887628.32602.1363432379@webmail.messagingengine.com>
	
Message-ID: <1267901961.28519.1363453861@webmail.messagingengine.com>

Steve,

Those are some great ideas! I'll give it a shot and see what
works for us.

Thanks for your help,

Malcolm



----- Original message -----
From: "Steven James" 
To: python-win32 at python.org
Date: Sat, 6 Mar 2010 10:17:43 -0500
Subject: Re: [python-win32] Detect whether a workstation is a
laptop or desktop/server?
Not sure exactly, but perhaps you could distinguish whether the
battery is connected via USB or some other transport method?
Looking through the device manager there seem to be some fields
that might be relevant. As a network admin, I've used a free
software called Spiceworks in the past that scans our network and
classifies machines. Does a decent job and seems to use the
model-database technique.
Other ways might be...does the machine have a PCMCIA slot? does
it have built-in wifi/bluetooth? A 5400RPM hard drive? These
aren't assurances, but they point to laptops.
Well I think that's every way possible of not answering your
question. Sorry =).
SJ
On Sat, Mar 6, 2010 at 10:00 AM, <[1]python at bdurham.com> wrote:

  Hi Roberto.
  > I assume you could categorize a computer as a laptop or
  desktop once you knew the machine's make an model.
  Unfortunately, we're a start-up company with an entirely
  random mix of
  computers from what seems like every vendor possible. I'm not
  sure where
  I would find a database for some of the machines we have.
  I'm hoping that there's a WMI property that allows me to
  distinguish
  between a laptop battery and an external UPS. (I've been
  looking, but my
  google-fu is failing me).
  Thanks for your help,
  Regards,
  Malcolm
  _______________________________________________
  python-win32 mailing list
  [2]python-win32 at python.org
  [3]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

References

1. mailto:python at bdurham.com
2. mailto:python-win32 at python.org
3. http://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulrich.mierendorff at gmx.net  Sat Mar  6 23:41:30 2010
From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff)
Date: Sat, 06 Mar 2010 23:41:30 +0100
Subject: [python-win32] Detect whether a workstation is a laptop or
	desktop/server?
In-Reply-To: <1267901961.28519.1363453861@webmail.messagingengine.com>
References: <1267831247.330.1363365665@webmail.messagingengine.com><11855D58-D6D6-4701-A191-C95D78F2D833@gmail.com><1267887628.32602.1363432379@webmail.messagingengine.com>	
	<1267901961.28519.1363453861@webmail.messagingengine.com>
Message-ID: <4B92DA1A.5070906@gmx.net>

python at bdurham.com wrote:
> Steve,
>  
> Those are some great ideas! I'll give it a shot and see what works for us.
Detecting the monitor type may also help, because Laptops have built-in 
monitors and PCs not (OK, there are a few cases where PCs also have 
built-in monitor).

-Ulrich
>  
> Thanks for your help,
>  
> Malcolm
>  
>  
>  
> ----- Original message -----
> From: "Steven James" 
> To: python-win32 at python.org
> Date: Sat, 6 Mar 2010 10:17:43 -0500
> Subject: Re: [python-win32] Detect whether a workstation is a laptop 
> or desktop/server?
> Not sure exactly, but perhaps you could distinguish whether the 
> battery is connected via USB or some other transport method? Looking 
> through the device manager there seem to be some fields that might be 
> relevant. As a network admin, I've used a free software called 
> Spiceworks in the past that scans our network and classifies machines. 
> Does a decent job and seems to use the model-database technique.
>
> Other ways might be...does the machine have a PCMCIA slot? does it 
> have built-in wifi/bluetooth? A 5400RPM hard drive? These aren't 
> assurances, but they point to laptops.
>
> Well I think that's every way possible of not answering your question. 
> Sorry =).
>
> SJ
>
>
> On Sat, Mar 6, 2010 at 10:00 AM,  > wrote:
>
>     Hi Roberto.
>
>     > I assume you could categorize a computer as a laptop or desktop
>     once you knew the machine's make an model.
>
>     Unfortunately, we're a start-up company with an entirely random mix of
>     computers from what seems like every vendor possible. I'm not sure
>     where
>     I would find a database for some of the machines we have.
>
>     I'm hoping that there's a WMI property that allows me to distinguish
>     between a laptop battery and an external UPS. (I've been looking,
>     but my
>     google-fu is failing me).
>
>     Thanks for your help,
>
>     Regards,
>     Malcolm
>     _______________________________________________
>     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
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>   


From cappy2112 at gmail.com  Sun Mar  7 06:46:22 2010
From: cappy2112 at gmail.com (Tony Cappellini)
Date: Sat, 6 Mar 2010 21:46:22 -0800
Subject: [python-win32] Detect whether a workstation is a laptop or
	desktop/server?
Message-ID: <8249c4ac1003062146u121a1745rd2c0add06e9fa12f@mail.gmail.com>

Message: 2
Date: Sat, 6 Mar 2010 10:17:43 -0500
From: Steven James 
To: python-win32 at python.org
Subject: Re: [python-win32] Detect whether a workstation is a laptop
       or      desktop/server?
Message-ID:
       
Content-Type: text/plain; charset="iso-8859-1"


>>A 5400RPM hard drive? These aren't assurances, but
>>they point to laptops.
Not at all.
Many laptop vendors are already shipping 7200 RPM drives, and many older
desktops can still use 5400 rpm drives.
There's no easy way to query a drive for this, without using the drive mfg's
internal commands. This information is not typically available to the
public.



Well I think that's every way possible of not answering your question. Sorry
=).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Mon Mar  8 03:22:02 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sun, 07 Mar 2010 21:22:02 -0500
Subject: [python-win32] Detect whether a workstation is a laptop or
 desktop/server?
In-Reply-To: <8249c4ac1003062146u121a1745rd2c0add06e9fa12f@mail.gmail.com>
References: <8249c4ac1003062146u121a1745rd2c0add06e9fa12f@mail.gmail.com>
Message-ID: <1268014922.10971.1363599973@webmail.messagingengine.com>

Preston, Tony, and Steven,

I found the following WMI class which sounds like it might be
useful.

Determine whether a computer is a tower, a mini-tower, a laptop,
and so on by using the Win32_SystemEnclosure class and checking
the value of the ChassisType property.

http://msdn.microsoft.com/en-us/library/aa394587%28VS.85%29.aspx

Oddly enough, this function indicates that my laptop (new Sony
Vaio running Windows 7 Professional (64-bit) has no enclosure. :)

Well, its a start!

Thank you all for your ideas and help!

Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Mon Mar  8 03:38:32 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sun, 07 Mar 2010 21:38:32 -0500
Subject: [python-win32] Trying to get the Win32_PortableBattery and
 Win32_SystemEnclosure classes to work
Message-ID: <1268015912.12804.1363603131@webmail.messagingengine.com>

I'm trying to get the Win32_PortableBattery and
Win32_SystemEnclosure classes to work.

Oddly enough, both classes return empty results on my laptop. I'm
wondering if I'm using the WMI interface correctly or if I need
to be more explict in the arguments I pass to each class's
__init__?

Here are my results from Python 2.6.4 (32-bit) run on a Sony Vaio
laptop with Windows 7 Professional (64-bit):

>>> import wmi
>>> c = wmi.WMI().Win32_SystemEnclosure
>>> c
<_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_SystemEnclosure>

>>> c()
[<_wmi_object:
\\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
Enclosure 0">]

>>> c()[0]
<_wmi_object:
\\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
Enclosure 0">
>>> c()[0].properties
{u'HotSwappable': None, u'SKU': None, u'SerialNumber': None,
u'Width': None, u'SecurityBreach': None, u'Removable': None,
u'PartNumber': None, u'AudibleAlarm': None, u'Status': None,
u'TypeDescriptions': None, u'Description': None,
u'NumberOfPowerCords': None, u'Replaceable': None,
u'LockPresent': None, u'SecurityStatus': None,
u'BreachDescription': None, u'Manufacturer': None,
u'OtherIdentifyingInfo': None, u'Version': None, u'Name': None,
u'InstallDate': None, u'ServiceDescriptions': None,
u'VisibleAlarm': None, u'PoweredOn': None, u'ServicePhilosophy':
None, u'SMBIOSAssetTag': None, u'Caption': None, u'Depth': None,
u'Model': None, u'HeatGeneration': None, u'Weight': None,
u'ChassisTypes': None, u'Height': None, u'Tag': None,
u'CableManagementStrategy': None, u'CreationClassName': None,
u'CurrentRequiredOrProduced': None}

-AND-

>>> c = wmi.WMI().Win32_PortableBattery
>>> c
<_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_PortableBattery>

>>> c()
[]

>>> c.properties
{u'BatteryStatus': None, u'PowerManagementSupported': None,
u'ManufactureDate': None, u'MaxRechargeTime': None,
u'SystemName': None, u'Location': None, u'CapacityMultiplier':
None, u'Status': None, u'TimeToFullCharge': None, u'PNPDeviceID':
None, u'Description': None, u'ConfigManagerUserConfig': None,
u'ErrorCleared': None, u'MaxBatteryError': None, u'Manufacturer':
None, u'Name': None, u'InstallDate': None, u'DesignVoltage':
None, u'EstimatedChargeRemaining': None, u'Caption': None,
u'StatusInfo': None, u'DeviceID': None,
u'ConfigManagerErrorCode': None, u'PowerManagementCapabilities':
None, u'Chemistry': None, u'TimeOnBattery': None,
u'ExpectedLife': None, u'DesignCapacity': None,
u'SmartBatteryVersion': None, u'ErrorDescription': None,
u'Availability': None, u'LastErrorCode': None,
u'CreationClassName': None, u'EstimatedRunTime': None,
u'FullChargeCapacity': None, u'SystemCreationClassName': None}

BTW: I get similar (empty) results when I run the equivalent
non-wmi module code (win32com.client based) for the above WMI
classes from the following script collection:

http://www.thescriptlibrary.com/Default.asp?Action=Browse&Level=C
ategory2&ScriptLanguage=Python&Category1=Scriptomatic&Category2=C
IMV2

Any suggestions appreciated.

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Mon Mar  8 12:01:55 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 08 Mar 2010 11:01:55 +0000
Subject: [python-win32] Trying to get the Win32_PortableBattery and
 Win32_SystemEnclosure classes to work
In-Reply-To: <1268015912.12804.1363603131@webmail.messagingengine.com>
References: <1268015912.12804.1363603131@webmail.messagingengine.com>
Message-ID: <4B94D923.4090709@timgolden.me.uk>

On 08/03/2010 02:38, python at bdurham.com wrote:
> I'm trying to get the Win32_PortableBattery and
> Win32_SystemEnclosure classes to work.
>
> Oddly enough, both classes return empty results on my laptop. I'm
> wondering if I'm using the WMI interface correctly or if I need
> to be more explict in the arguments I pass to each class's
> __init__?

It looks like you're a little bit confused as to what's
going on here. (Or maybe I am :) ).

>>>> import wmi
>>>> c = wmi.WMI().Win32_SystemEnclosure
>>>> c
> <_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_SystemEnclosure>

Although you *can*, you won't normally use the class
as an object in its own right. But maybe you were just
checking that you'd got the right thing.

>
>>>> c()
> [<_wmi_object:
> \\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
> Enclosure 0">]

OK. So you've got a list (of length one) which is a Win32_SystemEnclosure
instance.

>
>>>> c()[0]
> <_wmi_object:
> \\SONYLAPTOP-01\root\cimv2:Win32_SystemEnclosure.Tag="System
> Enclosure 0">

And the first item is indeed the System Enclosure

>>>> c()[0].properties
> {u'HotSwappable': None, u'SKU': None, u'SerialNumber': None,
> u'Width': None, u'SecurityBreach': None, u'Removable': None,
> u'PartNumber': None, u'AudibleAlarm': None, u'Status': None,
> u'TypeDescriptions': None, u'Description': None,
> u'NumberOfPowerCords': None, u'Replaceable': None,
> u'LockPresent': None, u'SecurityStatus': None,
> u'BreachDescription': None, u'Manufacturer': None,
> u'OtherIdentifyingInfo': None, u'Version': None, u'Name': None,
> u'InstallDate': None, u'ServiceDescriptions': None,
> u'VisibleAlarm': None, u'PoweredOn': None, u'ServicePhilosophy':
> None, u'SMBIOSAssetTag': None, u'Caption': None, u'Depth': None,
> u'Model': None, u'HeatGeneration': None, u'Weight': None,
> u'ChassisTypes': None, u'Height': None, u'Tag': None,
> u'CableManagementStrategy': None, u'CreationClassName': None,
> u'CurrentRequiredOrProduced': None}

OK. Now you're looking at the behind-the-scenes properties
cache. Which doesn't have anything in it yet because you
haven't requested any properties. Try this instead:


import wmi

c = wmi.WMI ()
for enclosure in c.Win32_SystemEnclosure ():
   print enclosure

   # or print enclosure.SerialNumber, enclosure.ChassisTypes



Do you still get no values? And likewise for the battery class..

TJG

From python at bdurham.com  Mon Mar  8 19:46:15 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 08 Mar 2010 13:46:15 -0500
Subject: [python-win32] Trying to get the Win32_PortableBattery and
 Win32_SystemEnclosure classes to work
In-Reply-To: <4B94D923.4090709@timgolden.me.uk>
References: <1268015912.12804.1363603131@webmail.messagingengine.com>
	<4B94D923.4090709@timgolden.me.uk>
Message-ID: <1268073975.21998.1363733117@webmail.messagingengine.com>

Hi Tim,

> It looks like you're a little bit confused as to what's going on here. (Or maybe I am :) ).

No, I'm definitely the one that's confused! :)

> Although you *can*, you won't normally use the class as an object in its own right. But maybe you were just checking that you'd got the right thing.

I was checking that I got the right thing - for purposes of documenting
my question on this forum.

>>>> c()[0].properties
> {u'HotSwappable': None, u'SKU': None, u'SerialNumber': None,
> u'Width': None, u'SecurityBreach': None, u'Removable': None,
> u'PartNumber': None, u'AudibleAlarm': None, u'Status': None,
> u'TypeDescriptions': None, u'Description': None,
> u'NumberOfPowerCords': None, u'Replaceable': None,
> u'LockPresent': None, u'SecurityStatus': None,
> u'BreachDescription': None, u'Manufacturer': None,
> u'OtherIdentifyingInfo': None, u'Version': None, u'Name': None,
> u'InstallDate': None, u'ServiceDescriptions': None,
> u'VisibleAlarm': None, u'PoweredOn': None, u'ServicePhilosophy':
> None, u'SMBIOSAssetTag': None, u'Caption': None, u'Depth': None,
> u'Model': None, u'HeatGeneration': None, u'Weight': None,
> u'ChassisTypes': None, u'Height': None, u'Tag': None,
> u'CableManagementStrategy': None, u'CreationClassName': None,
> u'CurrentRequiredOrProduced': None}

> OK. Now you're looking at the behind-the-scenes properties cache. Which doesn't have anything in it yet because you haven't requested any properties. Try this instead:
> Do you still get no values?

Now I see what I was doing wrong. Your code example explains it
perfectly.

Works perfectly for me with the ***c.Win32_SystemEnclosure class***.

> And likewise for the battery class

No. The battery class appears to really return no information.

Here's my updated battery code:

import wmi

c = wmi.WMI()
for battery in c.Win32_PortableBattery():
    print battery

This code doesn't output anything.

Here's a step-by-step from IDLE:

>>> c = wmi.WMI().Win32_PortableBattery
>>> c
<_wmi_class: \\SONYLAPTOP-01\ROOT\cimv2:Win32_PortableBattery>

>>> c()
[] <----- empty list 

I'm testing this on a 2009 Sony Vaio laptop (notebook with a built-in
battery) running Windows 7 Professional (64-bit).

I'm positive I have a battery and that this battery works.

Thanks again for your help on this thread.

Regards,
Malcolm

From python at bdurham.com  Mon Mar  8 20:18:07 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 08 Mar 2010 14:18:07 -0500
Subject: [python-win32] [Correction] Trying to get the
 Win32_PortableBattery and Win32_SystemEnclosure classes to work
In-Reply-To: <1268073975.21998.1363733117@webmail.messagingengine.com>
References: <1268015912.12804.1363603131@webmail.messagingengine.com><4B94D923.4090709@timgolden.me.uk>
	<1268073975.21998.1363733117@webmail.messagingengine.com>
Message-ID: <1268075887.27799.1363740221@webmail.messagingengine.com>

Tim,

The problem with Win32_PortableBattery appears to be that I need to use
Win32_Battery instead.

Using the latter, everything works as expected.

I'm not entirely clear on why there are 2 battery classes and why I
would choose to use vs. the other, but I suspect the
Win32_PortableBattery class is for machines with advanced power supply
management capabilities.

Thank you for your help!

Regards,
Malcolm

From greg.ewing at canterbury.ac.nz  Mon Mar  8 22:54:49 2010
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Tue, 09 Mar 2010 10:54:49 +1300
Subject: [python-win32] [Correction] Trying to get the
 Win32_PortableBattery and Win32_SystemEnclosure classes to work
In-Reply-To: <1268075887.27799.1363740221@webmail.messagingengine.com>
References: <1268015912.12804.1363603131@webmail.messagingengine.com>
	<4B94D923.4090709@timgolden.me.uk>
	<1268073975.21998.1363733117@webmail.messagingengine.com>
	<1268075887.27799.1363740221@webmail.messagingengine.com>
Message-ID: <4B957229.6040507@canterbury.ac.nz>

python at bdurham.com wrote:

> I'm not entirely clear on why there are 2 battery classes and why I
> would choose to use vs. the other, but I suspect the
> Win32_PortableBattery class is for machines with advanced power supply
> management capabilities.

Obviously it's for machines that have a *wireless* battery.

-- 
Greg

From python at bdurham.com  Tue Mar  9 01:28:41 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 08 Mar 2010 19:28:41 -0500
Subject: [python-win32] [Correction] Trying to get the
 Win32_PortableBattery and Win32_SystemEnclosure classes to work
In-Reply-To: <4B957229.6040507@canterbury.ac.nz>
References: <1268015912.12804.1363603131@webmail.messagingengine.com><4B94D923.4090709@timgolden.me.uk><1268073975.21998.1363733117@webmail.messagingengine.com><1268075887.27799.1363740221@webmail.messagingengine.com>
	<4B957229.6040507@canterbury.ac.nz>
Message-ID: <1268094521.15610.1363792457@webmail.messagingengine.com>

>> I suspect the win32_PortableBattery class is for machines with advanced power supply management capabilities.

> Obviously it's for machines that have a *wireless* battery.

:)

Now you tell me!

Malcolm

From python at bdurham.com  Tue Mar  9 14:19:44 2010
From: python at bdurham.com (python at bdurham.com)
Date: Tue, 09 Mar 2010 08:19:44 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
Message-ID: <1268140784.23633.1363880645@webmail.messagingengine.com>

I'm looking for simple ways to monitor and limit the number of
instances of our Python application that gets run on our in-house
Terminal Servers (2003 and 2008).
The purpose of this restriction is to make sure we don't overload
our servers. This is an internal administrative requirement - I
am not looking for a licensing solution.
Background: The application in question is written in Python 2.6
(32-bit). Our Terminal Server environments are used for testing
and it is not uncommon for the test builds of our application to
lock up or abort abnormally. Please consider these non-typical
circumstances when suggesting a solution :)

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Tue Mar  9 15:18:48 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Tue, 09 Mar 2010 14:18:48 +0000
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <1268140784.23633.1363880645@webmail.messagingengine.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
Message-ID: <4B9658C8.4010306@timgolden.me.uk>

On 09/03/2010 13:19, python at bdurham.com wrote:
> I'm looking for simple ways to monitor and limit the number of
> instances of our Python application that gets run on our in-house
> Terminal Servers (2003 and 2008).

It's not quite clear whether you want something which you
can build into the application itself (in which case, the
answer's probably Semaphores:

   http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx

or whether you want something external to the applications which
will watch what's starting up and... shut them down, or log an
alert, or something. In which you can probably use WMI events
or a simple polling loop with something like psutil:

   http://code.google.com/p/psutil/

I'm not quite sure if you need to distinguish the app when running
in a Terminal Server environment or not...

Obviously there are other approaches: you could write transient pid
files in the Unix fashion, you could use Job objects to group your
processes together in one job:

   http://msdn.microsoft.com/en-us/library/ms684161%28VS.85%29.aspx

and limit the number of processes. (I haven't tried this, but in
principle it ought to work).

TJG

From python at bdurham.com  Wed Mar 10 22:16:41 2010
From: python at bdurham.com (python at bdurham.com)
Date: Wed, 10 Mar 2010 16:16:41 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B9658C8.4010306@timgolden.me.uk>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<4B9658C8.4010306@timgolden.me.uk>
Message-ID: <1268255801.4225.1364160081@webmail.messagingengine.com>

Hi Tim,

> It's not quite clear whether you want something which you can build into the application itself 

Yes, since I control the source code, this is a feature I would like to
build into my applications.

> ... in which case, the answer's probably Semaphores:
> http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx

Thanks for that link. My understanding is that semaphores only to apply
to threads within a single running application?

On the other hand, perhaps the term 'threads' applies to applications as
well? I say that because the term thread is used to describe mutex's
which I've used on a program vs. thread basis.

Microsoft's description of Mutex's
http://msdn.microsoft.com/en-us/library/ms684266%28VS.85%29.aspx

My research on semaphors also leads me to believe that if an application
incremented a semaphor and crashed without decrementing the semaphore,
then my semaphore count would be incorrect. Since the code in question
is being run in a test environment, the possibility of abnormal
terminations is higher than one would normally expect. Does this sound
accurate to you?

> Obviously there are other approaches: you could write transient pid files in the Unix fashion, you could use Job objects to group your processes together in one job:
http://msdn.microsoft.com/en-us/library/ms684161%28VS.85%29.aspx

What are your thoughts on using a pre-assigned list of mutexes. An
application would walk a list of named mutex's trying to lock one for
itself. If an application iterated through a list of mutex's without
securing one for itself, it would exit.

The advantage of mutex's over semaphores would be that applications that
terminate abnormally would have their mutex released, while applications
using semaphors that terminated abnormally would leave their semaphore
with an incorrect count?

The disadvantage of using mutex's vs. semaphores is that the time to
find a free mutex might be much slower than the time to simply increment
or decrement a semaphor.

On the other hand, one of my colleagues claims that neither semphores or
mutuxes will be visible to other Terminal Service users. In other words,
all I will be able to do with semaphores and mutex's is to make sure a
SPECIFIC user doesn't run an application more than once.  Put another
way, there may be no such thing as Global (that are visible across user
sessions) semaphores and mutex's.

So I'm back to thinking about your PID file idea :)

Regards,
Malcolm

From skippy.hammond at gmail.com  Thu Mar 11 02:52:43 2010
From: skippy.hammond at gmail.com (Mark Hammond)
Date: Thu, 11 Mar 2010 12:52:43 +1100
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <1268255801.4225.1364160081@webmail.messagingengine.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>	<4B9658C8.4010306@timgolden.me.uk>
	<1268255801.4225.1364160081@webmail.messagingengine.com>
Message-ID: <4B984CEB.2010506@gmail.com>

It sounds like you are after a named semaphore in the "Global\\" 
namespace.  The semaphore count should work fine when your process 
terminates abnormally - but will not if it simply hangs - so something 
will need to terminate a hung process before the semaphore becomes 
available.

HTH,

Mark

On 11/03/2010 8:16 AM, python at bdurham.com wrote:
> Hi Tim,
>
>> It's not quite clear whether you want something which you can build into the application itself
>
> Yes, since I control the source code, this is a feature I would like to
> build into my applications.
>
>> ... in which case, the answer's probably Semaphores:
>> http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx
>
> Thanks for that link. My understanding is that semaphores only to apply
> to threads within a single running application?
>
> On the other hand, perhaps the term 'threads' applies to applications as
> well? I say that because the term thread is used to describe mutex's
> which I've used on a program vs. thread basis.
>
> Microsoft's description of Mutex's
> http://msdn.microsoft.com/en-us/library/ms684266%28VS.85%29.aspx
>
> My research on semaphors also leads me to believe that if an application
> incremented a semaphor and crashed without decrementing the semaphore,
> then my semaphore count would be incorrect. Since the code in question
> is being run in a test environment, the possibility of abnormal
> terminations is higher than one would normally expect. Does this sound
> accurate to you?
>
>> Obviously there are other approaches: you could write transient pid files in the Unix fashion, you could use Job objects to group your processes together in one job:
> http://msdn.microsoft.com/en-us/library/ms684161%28VS.85%29.aspx
>
> What are your thoughts on using a pre-assigned list of mutexes. An
> application would walk a list of named mutex's trying to lock one for
> itself. If an application iterated through a list of mutex's without
> securing one for itself, it would exit.
>
> The advantage of mutex's over semaphores would be that applications that
> terminate abnormally would have their mutex released, while applications
> using semaphors that terminated abnormally would leave their semaphore
> with an incorrect count?
>
> The disadvantage of using mutex's vs. semaphores is that the time to
> find a free mutex might be much slower than the time to simply increment
> or decrement a semaphor.
>
> On the other hand, one of my colleagues claims that neither semphores or
> mutuxes will be visible to other Terminal Service users. In other words,
> all I will be able to do with semaphores and mutex's is to make sure a
> SPECIFIC user doesn't run an application more than once.  Put another
> way, there may be no such thing as Global (that are visible across user
> sessions) semaphores and mutex's.
>
> So I'm back to thinking about your PID file idea :)
>
> Regards,
> Malcolm
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32


From lyeoh at pop.jaring.my  Thu Mar 11 15:04:36 2010
From: lyeoh at pop.jaring.my (Lincoln Yeoh)
Date: Thu, 11 Mar 2010 22:04:36 +0800
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <1268140784.23633.1363880645@webmail.messagingengine.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
Message-ID: <201003111404.o2BE4peQ000167@vsmtp6.jaring.my>

At 09:19 PM 3/9/2010, python at bdurham.com wrote:
>I'm looking for simple ways to monitor and limit the number of 
>instances of our Python application that gets run on our in-house 
>Terminal Servers (2003 and 2008).
>
>The purpose of this restriction is to make sure we don't overload 
>our servers. This is an internal administrative requirement - I am 
>not looking for a licensing solution.
>
>Background: The application in question is written in Python 2.6 
>(32-bit). Our Terminal Server environments are used for testing and 
>it is not uncommon for the test builds of our application to lock up 
>or abort abnormally. Please consider these non-typical circumstances 
>when suggesting a solution :)

If the limit is one, then a lazy and dirty way is to bind to a tcp 
port (just pick a fixed one that's not used by other services- you 
could make it configurable), and exit if the bind fails.

Regards,

Link.



From mike.diehn at ansys.com  Thu Mar 11 15:51:39 2010
From: mike.diehn at ansys.com (Mike Diehn)
Date: Thu, 11 Mar 2010 09:51:39 -0500
Subject: [python-win32] active_directory.py: enumerating membership of
	groups with more than 1500 members.
In-Reply-To: <4B98BC2F.9050600@timgolden.me.uk>
References:  
	<4B98BC2F.9050600@timgolden.me.uk>
Message-ID: 

Thanks, Tim.

I've just subscribed to the python-win32 mailing list and I'll copy this
post to it.

So, my task, in this instance is to retrieve the membership list of a 1650
member AD security group.  That means the group has a 1650 item multi-value
attribute.  It's refusing to send more than 1500, of course. Since this
isn't about objects, page_size and size_limit don't *appear* to help.
 Instead, last night I was working on a technique called "range retrieval."
 Do you suppose I'm missing something?

Range retrieval is documented here:

  http://msdn.microsoft.com/en-us/library/aa367017(VS.85).aspx

and the example that finally helped me get it working is here:

  http://msdn.microsoft.com/en-us/library/aa705933(VS.85).aspx

This is what made it click:

    commandPrefix = ";(objectClass=*);member;range="
    commandSuffix = ";base"

I needed to specify the full ADSPath to the group - the groupDN essentially.
 Until I did that, the query would blow up anytime I put in the bit about
"...;member;range=1500-*;..."

I'll be hacking around on this all morning.

Best,
Mike

On Thu, Mar 11, 2010 at 4:47 AM, Tim Golden  wrote:

> On 10/03/2010 23:29, Mike Diehn wrote:
>
>> Hi again, Tim.
>>
>> I swear I've searched and read and studied trying to solve this.  I hope
>> you
>> won't mind one more question.  Feel free to send me to a more appropriate
>> source, like a mailing list or forum, if you like.
>>
>
> Glad you solved it anyway. FWIW it's always worth posting to the
> python-win32 mailing list where there are many more and better
> informed people than me. I'm usually watching it anyway, so it's
> better than mailing me direct  :)
>
>
>
>> I have a group in our active directory with 1652 members.  I can't get
>> python to show me more than the first 1500.  I understand the 1500 limit -
>> that's the MaxValueLimit imposed by AD 2003.
>>
>> How in the world do I get around it using your active_directory.py
>> modules?
>>
>
> I guess you've found that you need to fiddle around with the
> page_size and/or size_limit flags to the query.
>
> TJG
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email______________________________________________________________________
>



-- 
Mike Diehn
Senior Systems Administrator
ANSYS, Inc - Lebanon, NH Office
mike.diehn at ansys.com, (603) 727-5492
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Thu Mar 11 15:59:31 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 11 Mar 2010 14:59:31 +0000
Subject: [python-win32] active_directory.py: enumerating membership of
 groups with more than 1500 members.
In-Reply-To: 
References: 
	<4B98BC2F.9050600@timgolden.me.uk>
	
Message-ID: <4B990553.4040003@timgolden.me.uk>

On 11/03/2010 14:51, Mike Diehn wrote:
> Thanks, Tim.
>
> I've just subscribed to the python-win32 mailing list and I'll copy this
> post to it.
>
> So, my task, in this instance is to retrieve the membership list of a 1650
> member AD security group.  That means the group has a 1650 item multi-value
> attribute.  It's refusing to send more than 1500, of course. Since this
> isn't about objects, page_size and size_limit don't *appear* to help.
>   Instead, last night I was working on a technique called "range retrieval."

Ah, sorry. I didn't read closely enough. Range retrieval is a pain because
you *have* to be retrieving at least as many items as you're requesting,
so you can't just say "give me 1-20,000", knowing that it'll work every time.

I've been struggling to find a clean way to include this in my slightly
improved AD interface, but haven't found one yet :(. I must confess I
didn't realise it would actually cap the retrieval if you didn't include
a range. I don't think any of our groups have as many as 1500 members.

Didn't know about that -* trick on the last loop, either. You live and learn.

TJG

From mail at timgolden.me.uk  Thu Mar 11 16:31:22 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 11 Mar 2010 15:31:22 +0000
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <1268255801.4225.1364160081@webmail.messagingengine.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<4B9658C8.4010306@timgolden.me.uk>
	<1268255801.4225.1364160081@webmail.messagingengine.com>
Message-ID: <4B990CCA.6070809@timgolden.me.uk>

On 10/03/2010 21:16, python at bdurham.com wrote:
> Hi Tim,
>
>> It's not quite clear whether you want something which you can build into the application itself
>
> Yes, since I control the source code, this is a feature I would like to
> build into my applications.
>
>> ... in which case, the answer's probably Semaphores:
>> http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx
>
> Thanks for that link. My understanding is that semaphores only to apply
> to threads within a single running application?

You can use semaphores (and mutexes, which are basically semaphores with
a count of one) cross-process by naming them:


import time
import win32event

s1 = win32event.CreateSemaphore (None, 4, 4, u"tims-app")
try:
   win32event.WaitForSingleObject (s1, -1)
   time.sleep (10)
finally:
   win32event.ReleaseSemaphore (s1, 1)



If you run this micro-app in five separate windows, the fifth
edition will block until one of the others completes. If you're
using terminal services, you'll have to use the "global\" prefix
to the name to allow it to be seen by other TS sessions.

Note that the pywin32 docs for CreateSemaphore are wrong; I think
they're a hybrid of the CreateEvent and CreateSemaphore signature.
Follow the ms docs literally as I do above and you're fine.

> My research on semaphors also leads me to believe that if an application
> incremented a semaphor and crashed without decrementing the semaphore,
> then my semaphore count would be incorrect.

I think you're ok if you crash. Either the finally: clause above
will take care of things or -- I imagine, altho' I don't know
for sure -- the process will release all its handles when it dies,
including its semaphore.

> What are your thoughts on using a pre-assigned list of mutexes. An
> application would walk a list of named mutex's trying to lock one for
> itself. If an application iterated through a list of mutex's without
> securing one for itself, it would exit.

I think this is to some extent re-inventing semaphores with a homebrew
numbering system.

> The advantage of mutex's over semaphores would be that applications that
> terminate abnormally would have their mutex released, while applications
> using semaphors that terminated abnormally would leave their semaphore
> with an incorrect count?

See above; I don't this mutexes and semaphores differ in this respect.


TJG

From mike.diehn at ansys.com  Thu Mar 11 16:44:37 2010
From: mike.diehn at ansys.com (Mike Diehn)
Date: Thu, 11 Mar 2010 10:44:37 -0500
Subject: [python-win32] active_directory.py: enumerating membership of
	groups with more than 1500 members.
In-Reply-To: <4B990553.4040003@timgolden.me.uk>
References:  
	<4B98BC2F.9050600@timgolden.me.uk>
	 
	<4B990553.4040003@timgolden.me.uk>
Message-ID: 

As you probably just read, Microsoft say that if I query for the "member"
attribute in the case of a group with a large membership, say 9000, the
domain controller (DC) will send me back two attributes: an empty "member"
attribute and a 1500 item attribute named "member;range=0-1499".
 Apparently, that's how we're to know we need to use the range retrieval
technique.  Next query would be for member;range=1500-* and they send back
that one empty but with a new one named member;range=1500-2999.  Indicating
need for yet another round.

Well, I did this in a python interactive session:

>>> import active_directory as ad
>>> gau = ad.find_group('google apps users')
>>> len(gau.member)
1500
>>> for p in gau.properties:
...    print p

The resulting list of property names contained "member", but  nothing like
"member;range=0-1499."  And "member" has 1500 items.

I did it in perl (needing *many* more lines :-) ) using the Net::LDAP
modules and got back an empty "member" attribute and a 1500 value
member;range=0-1499" attribute.  So I expect AD is sending what MS says it
is.

Do you suppose something in pywin32 is munging the attributes names?

Thanks,
Mike


On Thu, Mar 11, 2010 at 9:59 AM, Tim Golden  wrote:

> On 11/03/2010 14:51, Mike Diehn wrote:
>
>> Thanks, Tim.
>>
>> I've just subscribed to the python-win32 mailing list and I'll copy this
>> post to it.
>>
>> So, my task, in this instance is to retrieve the membership list of a 1650
>> member AD security group.  That means the group has a 1650 item
>> multi-value
>> attribute.  It's refusing to send more than 1500, of course. Since this
>> isn't about objects, page_size and size_limit don't *appear* to help.
>>  Instead, last night I was working on a technique called "range
>> retrieval."
>>
>
> Ah, sorry. I didn't read closely enough. Range retrieval is a pain because
> you *have* to be retrieving at least as many items as you're requesting,
> so you can't just say "give me 1-20,000", knowing that it'll work every
> time.
>
> I've been struggling to find a clean way to include this in my slightly
> improved AD interface, but haven't found one yet :(. I must confess I
> didn't realise it would actually cap the retrieval if you didn't include
> a range. I don't think any of our groups have as many as 1500 members.
>
> Didn't know about that -* trick on the last loop, either. You live and
> learn.
>
> TJG
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email______________________________________________________________________
>



-- 
Mike Diehn
Senior Systems Administrator
ANSYS, Inc - Lebanon, NH Office
mike.diehn at ansys.com, (603) 727-5492
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From chris at slort.org  Fri Mar 12 02:38:29 2010
From: chris at slort.org (Christopher Nilsson)
Date: Fri, 12 Mar 2010 12:38:29 +1100
Subject: [python-win32] Technique to limit number of instances of our
	application under Terminal Server
In-Reply-To: <4B990CCA.6070809@timgolden.me.uk>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<4B9658C8.4010306@timgolden.me.uk>
	<1268255801.4225.1364160081@webmail.messagingengine.com>
	<4B990CCA.6070809@timgolden.me.uk>
Message-ID: <29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>

Hi all,

On 12 March 2010 02:31, Tim Golden  wrote:

>
>  The advantage of mutex's over semaphores would be that applications that
>> terminate abnormally would have their mutex released, while applications
>> using semaphors that terminated abnormally would leave their semaphore
>> with an incorrect count?
>>
>
> See above; I don't this mutexes and semaphores differ in this respect.
>


Actually, if you take the example of someone calling TerminateProcess()
against the process (or some other equally fatal
do-not-pass-the-finally-block abnormal exits), they will be different.

In this case, a mutex will be unlocked, and another process' waiting thread
will get a WAIT_ABANDONED wake up.

For semaphores, the handles will be mopped up, but the available count on
that semaphore will not be incremented.  So if you've got lots of other
processes coming and being killed in this way, you can easily run out of
slots, even though there is only one handle open on the thing.

It's a pity, since the semaphore way of doing this is much cleaner and
faster than the "bunch of mutexes" method.

If you've got some other way to guarantee that you'll see such processes
vanish (eg. grab a SYNCHRONIZE handle on it via OpenProcess() -- these will
get signalled when the process dies normally or abnormally), then it's still
workable, since you can then call ReleaseSemaphore() yourself -- without
having to wait for the original holder to do it.  But now you've got two
problems (limit instances *and* notice when they die). :)


Or, maybe it's an acceptable risk.  How badly do you want to fight
TerminateProcess / death by Task Manager anyway?  And you could argue that
other kinds of abnormal explosions are bugs that need fixing.  My vote would
definitely be for the semaphore method.


Cheers,
Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Fri Mar 12 09:31:54 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Fri, 12 Mar 2010 08:31:54 +0000
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>	<4B9658C8.4010306@timgolden.me.uk>	<1268255801.4225.1364160081@webmail.messagingengine.com>	<4B990CCA.6070809@timgolden.me.uk>
	<29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>
Message-ID: <4B99FBFA.2000001@timgolden.me.uk>

On 12/03/2010 01:38, Christopher Nilsson wrote:
> Hi all,
>
> On 12 March 2010 02:31, Tim Golden  wrote:
>
>>
>>   The advantage of mutex's over semaphores would be that applications that
>>> terminate abnormally would have their mutex released, while applications
>>> using semaphors that terminated abnormally would leave their semaphore
>>> with an incorrect count?
>>>
>>
>> See above; I don't [think] mutexes and semaphores differ in this respect.

> Actually, if you take the example of someone calling TerminateProcess()
> against the process (or some other equally fatal
> do-not-pass-the-finally-block abnormal exits), they will be different.

> For semaphores, the handles will be mopped up, but the available count on
> that semaphore will not be incremented.

Key information. Thanks.

TJG

From greg.ewing at canterbury.ac.nz  Fri Mar 12 12:15:19 2010
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Sat, 13 Mar 2010 00:15:19 +1300
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B99FBFA.2000001@timgolden.me.uk>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<4B9658C8.4010306@timgolden.me.uk>
	<1268255801.4225.1364160081@webmail.messagingengine.com>
	<4B990CCA.6070809@timgolden.me.uk>
	<29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>
	<4B99FBFA.2000001@timgolden.me.uk>
Message-ID: <4B9A2247.3020400@canterbury.ac.nz>

Here's another possible solution. Each process tries to open a
socket connection to a server process. When the maximum number of
processes are connected, the server stops accepting connections.

The server also selects all of its open connections for reading.
When a process dies, the server will notice because it will
see an EOF condition on its connection.

-- 
Greg


From python at bdurham.com  Fri Mar 12 12:48:52 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 06:48:52 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B9A2247.3020400@canterbury.ac.nz>
References: <1268140784.23633.1363880645@webmail.messagingengine.com><4B9658C8.4010306@timgolden.me.uk><1268255801.4225.1364160081@webmail.messagingengine.com><4B990CCA.6070809@timgolden.me.uk><29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com><4B99FBFA.2000001@timgolden.me.uk>
	<4B9A2247.3020400@canterbury.ac.nz>
Message-ID: <1268394532.8170.1364465805@webmail.messagingengine.com>

Greg,

Very clever! Thank you,

Malcolm


----- Original message -----
From: "Greg Ewing" 
To: "zz Python Win32 Newsgroup" 
Date: Sat, 13 Mar 2010 00:15:19 +1300
Subject: Re: [python-win32] Technique to limit number of instances of
our application under Terminal Server

Here's another possible solution. Each process tries to open a
socket connection to a server process. When the maximum number of
processes are connected, the server stops accepting connections.

The server also selects all of its open connections for reading.
When a process dies, the server will notice because it will
see an EOF condition on its connection.

-- 
Greg

_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


From python at bdurham.com  Fri Mar 12 15:04:52 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 09:04:52 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B984CEB.2010506@gmail.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<4B9658C8.4010306@timgolden.me.uk>
	<1268255801.4225.1364160081@webmail.messagingengine.com>
	<4B984CEB.2010506@gmail.com>
Message-ID: <1268402692.29092.1364482455@webmail.messagingengine.com>

Hi Mark,

> It sounds like you are after a named semaphore in the "Global\\" 
namespace.  The semaphore count should work fine when your process 
terminates abnormally ...

Thanks for your help. I'm experimenting with the semaphore concept
and I think its possible for my semaphore counts to fall out of
sync in certain situations.

In a perfect world, semaphores look like a great solution, but
I may need to fall back to my idea of a collection of mutex's.
Admittedly this is an awkward solution, but mutex's seem to be a 
very reliable way to determine whether a process is holding a 
resource or not, eg. they consistently get released when a 
process terminates abnormally.


----- Original message -----
From: "Mark Hammond" 
To: python at bdurham.com
Cc: "Tim Golden" , "zz Python Win32 Newsgroup"

Date: Thu, 11 Mar 2010 12:52:43 +1100
Subject: Re: [python-win32] Technique to limit number of instances of
our application under Terminal Server

It sounds like you are after a named semaphore in the "Global\\" 
namespace.  The semaphore count should work fine when your process 
terminates abnormally - but will not if it simply hangs - so something 
will need to terminate a hung process before the semaphore becomes 
available.

HTH,

Mark

On 11/03/2010 8:16 AM, python at bdurham.com wrote:
> Hi Tim,
>
>> It's not quite clear whether you want something which you can build into the application itself
>
> Yes, since I control the source code, this is a feature I would like to
> build into my applications.
>
>> ... in which case, the answer's probably Semaphores:
>> http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx
>
> Thanks for that link. My understanding is that semaphores only to apply
> to threads within a single running application?
>
> On the other hand, perhaps the term 'threads' applies to applications as
> well? I say that because the term thread is used to describe mutex's
> which I've used on a program vs. thread basis.
>
> Microsoft's description of Mutex's
> http://msdn.microsoft.com/en-us/library/ms684266%28VS.85%29.aspx
>
> My research on semaphors also leads me to believe that if an application
> incremented a semaphor and crashed without decrementing the semaphore,
> then my semaphore count would be incorrect. Since the code in question
> is being run in a test environment, the possibility of abnormal
> terminations is higher than one would normally expect. Does this sound
> accurate to you?
>
>> Obviously there are other approaches: you could write transient pid files in the Unix fashion, you could use Job objects to group your processes together in one job:
> http://msdn.microsoft.com/en-us/library/ms684161%28VS.85%29.aspx
>
> What are your thoughts on using a pre-assigned list of mutexes. An
> application would walk a list of named mutex's trying to lock one for
> itself. If an application iterated through a list of mutex's without
> securing one for itself, it would exit.
>
> The advantage of mutex's over semaphores would be that applications that
> terminate abnormally would have their mutex released, while applications
> using semaphors that terminated abnormally would leave their semaphore
> with an incorrect count?
>
> The disadvantage of using mutex's vs. semaphores is that the time to
> find a free mutex might be much slower than the time to simply increment
> or decrement a semaphor.
>
> On the other hand, one of my colleagues claims that neither semphores or
> mutuxes will be visible to other Terminal Service users. In other words,
> all I will be able to do with semaphores and mutex's is to make sure a
> SPECIFIC user doesn't run an application more than once.  Put another
> way, there may be no such thing as Global (that are visible across user
> sessions) semaphores and mutex's.
>
> So I'm back to thinking about your PID file idea :)
>
> Regards,
> Malcolm
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



From python at bdurham.com  Fri Mar 12 15:08:28 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 09:08:28 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <201003111404.o2BE4peQ000167@vsmtp6.jaring.my>
References: <1268140784.23633.1363880645@webmail.messagingengine.com>
	<201003111404.o2BE4peQ000167@vsmtp6.jaring.my>
Message-ID: <1268402908.29670.1364483687@webmail.messagingengine.com>

Hi Link,

> If the limit is one, then a lazy and dirty way is to bind to a tcp 
port (just pick a fixed one that's not used by other services - you 
could make it configurable), and exit if the bind fails.

An excellent idea. I'm leaning towards either this idea or a
collection of mutexes.

Thanks for your feedback,

Mal


From python at bdurham.com  Fri Mar 12 15:21:52 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 09:21:52 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B990CCA.6070809@timgolden.me.uk>
References: <1268140784.23633.1363880645@webmail.messagingengine.com><4B9658C8.4010306@timgolden.me.uk><1268255801.4225.1364160081@webmail.messagingengine.com>
	<4B990CCA.6070809@timgolden.me.uk>
Message-ID: <1268403712.31604.1364484583@webmail.messagingengine.com>

Tim,

Thank you for your example code and ideas!!

I think my earlier experiments with semaphores may be the result of my
poor code vs. your approach :)

I'm going to put aside my pool of mutex's idea and experiment with your
sample code.

Regards,
Malcolm


----- Original message -----
From: "Tim Golden" 
To: 
Cc: "zz Python Win32 Newsgroup" 
Date: Thu, 11 Mar 2010 15:31:22 +0000
Subject: Re: [python-win32] Technique to limit number of instances of
our application under Terminal Server

On 10/03/2010 21:16, python at bdurham.com wrote:
> Hi Tim,
>
>> It's not quite clear whether you want something which you can build into the application itself
>
> Yes, since I control the source code, this is a feature I would like to
> build into my applications.
>
>> ... in which case, the answer's probably Semaphores:
>> http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx
>
> Thanks for that link. My understanding is that semaphores only to apply
> to threads within a single running application?

You can use semaphores (and mutexes, which are basically semaphores with
a count of one) cross-process by naming them:


import time
import win32event

s1 = win32event.CreateSemaphore (None, 4, 4, u"tims-app")
try:
   win32event.WaitForSingleObject (s1, -1)
   time.sleep (10)
finally:
   win32event.ReleaseSemaphore (s1, 1)



If you run this micro-app in five separate windows, the fifth
edition will block until one of the others completes. If you're
using terminal services, you'll have to use the "global\" prefix
to the name to allow it to be seen by other TS sessions.

Note that the pywin32 docs for CreateSemaphore are wrong; I think
they're a hybrid of the CreateEvent and CreateSemaphore signature.
Follow the ms docs literally as I do above and you're fine.

> My research on semaphors also leads me to believe that if an application
> incremented a semaphor and crashed without decrementing the semaphore,
> then my semaphore count would be incorrect.

I think you're ok if you crash. Either the finally: clause above
will take care of things or -- I imagine, altho' I don't know
for sure -- the process will release all its handles when it dies,
including its semaphore.

> What are your thoughts on using a pre-assigned list of mutexes. An
> application would walk a list of named mutex's trying to lock one for
> itself. If an application iterated through a list of mutex's without
> securing one for itself, it would exit.

I think this is to some extent re-inventing semaphores with a homebrew
numbering system.

> The advantage of mutex's over semaphores would be that applications that
> terminate abnormally would have their mutex released, while applications
> using semaphors that terminated abnormally would leave their semaphore
> with an incorrect count?

See above; I don't this mutexes and semaphores differ in this respect.


TJG
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


From mail at timgolden.me.uk  Fri Mar 12 15:31:54 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Fri, 12 Mar 2010 14:31:54 +0000
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <1268403712.31604.1364484583@webmail.messagingengine.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com><4B9658C8.4010306@timgolden.me.uk><1268255801.4225.1364160081@webmail.messagingengine.com>
	<4B990CCA.6070809@timgolden.me.uk>
	<1268403712.31604.1364484583@webmail.messagingengine.com>
Message-ID: <4B9A505A.3050202@timgolden.me.uk>

On 12/03/2010 14:21, python at bdurham.com wrote:
> Tim,
>
> Thank you for your example code and ideas!!
>
> I think my earlier experiments with semaphores may be the result of my
> poor code vs. your approach :)
>
> I'm going to put aside my pool of mutex's idea and experiment with your
> sample code.

Good luck. Be aware of Christopher Nilsson's point that while
the Mutex will be released if the holding process crashes hard,
the Semaphore will not release its token. (Haven't tried this
myself; I'm assuming he's had experience or has read the docs
more carefully than me).

The bind-to-a-socket approach is a good general-purpose solution.
(It can be used on any socket-based system where binding semantics
disallow simultaneous connections).

Greg Ewing's "control server" is the kind of thing you'd be doing
for license control, eg, and has the advantage he points out about
detecting dead session. But it has the overhead of a control process.
Which may or may not be an issue for you.

TJG

From python at bdurham.com  Fri Mar 12 15:33:51 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 09:33:51 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>
References: <1268140784.23633.1363880645@webmail.messagingengine.com><4B9658C8.4010306@timgolden.me.uk><1268255801.4225.1364160081@webmail.messagingengine.com><4B990CCA.6070809@timgolden.me.uk>
	<29a42921003111738i3ed2edc4r3c11649595553851@mail.gmail.com>
Message-ID: <1268404431.882.1364487199@webmail.messagingengine.com>

Hi Christopher,

Thanks for your thoughts. I'm going to go back and re-test the
semaphor strategy using Tim's sample code.

My situation is very unusual in that the apps being run are often
buggy because they are early releases of software being tested by
a small team of testers. Our test team seems to test on a random
schedule (of course they would argue otherwise!) which means
there are spikes in demand on our server. The code I'm trying to
write doesn't need to be perfect - it just needs to be good
enough to protect us from ourselves :)

On the other hand, you might be suprised how many times our apps
get abnormally terminated so we do need a fairly accurate way to
track running instances or the entire process is not worth
pursuing.

Regards,
Malcolm


----- Original message -----
From: "Christopher Nilsson" 
To: "Tim Golden" 
Cc: "zz Python Win32 Newsgroup" 
Date: Fri, 12 Mar 2010 12:38:29 +1100
Subject: Re: [python-win32] Technique to limit number of
instances of our application under Terminal Server
Hi all,
On 12 March 2010 02:31, Tim Golden <[1]mail at timgolden.me.uk>
wrote:

  The advantage of mutex's over semaphores would be that
  applications that
  terminate abnormally would have their mutex released, while
  applications
  using semaphors that terminated abnormally would leave their
  semaphore
  with an incorrect count?

  See above; I don't this mutexes and semaphores differ in this
  respect.

Actually, if you take the example of someone calling
TerminateProcess() against the process (or some other equally
fatal do-not-pass-the-finally-block abnormal exits), they will be
different.
In this case, a mutex will be unlocked, and another process'
waiting thread will get a WAIT_ABANDONED wake up.
For semaphores, the handles will be mopped up, but the available
count on that semaphore will not be incremented.  So if you've
got lots of other processes coming and being killed in this way,
you can easily run out of slots, even though there is only one
handle open on the thing.
It's a pity, since the semaphore way of doing this is much
cleaner and faster than the "bunch of mutexes" method.
If you've got some other way to guarantee that you'll see such
processes vanish (eg. grab a SYNCHRONIZE handle on it via
OpenProcess() -- these will get signalled when the process dies
normally or abnormally), then it's still workable, since you can
then call ReleaseSemaphore() yourself -- without having to wait
for the original holder to do it.  But now you've got two
problems (limit instances *and* notice when they die). :)
Or, maybe it's an acceptable risk.  How badly do you want to
fight TerminateProcess / death by Task Manager anyway?  And you
could argue that other kinds of abnormal explosions are bugs that
need fixing.  My vote would definitely be for the semaphore
method.
Cheers,
Chris.
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32

References

1. mailto:mail at timgolden.me.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Fri Mar 12 15:41:19 2010
From: python at bdurham.com (python at bdurham.com)
Date: Fri, 12 Mar 2010 09:41:19 -0500
Subject: [python-win32] Technique to limit number of instances of our
 application under Terminal Server
In-Reply-To: <4B9A505A.3050202@timgolden.me.uk>
References: <1268140784.23633.1363880645@webmail.messagingengine.com><4B9658C8.4010306@timgolden.me.uk><1268255801.4225.1364160081@webmail.messagingengine.com><4B990CCA.6070809@timgolden.me.uk><1268403712.31604.1364484583@webmail.messagingengine.com>
	<4B9A505A.3050202@timgolden.me.uk>
Message-ID: <1268404879.2057.1364488333@webmail.messagingengine.com>

Hi Tim,

Before continuing I want to express how grateful I am to you and all the
others that have joined this thread. THANK-YOU, THANK-YOU, THANK-YOU!

> Be aware of Christopher Nilsson's point that while the Mutex will be released if the holding process crashes hard, the Semaphore will not release its token. (Haven't tried this myself; I'm assuming he's had experience or has read the docs more carefully than me).

This is actually what I saw, too, but thought it was a subtle problem
with how I coded my tests.

> The bind-to-a-socket approach is a good general-purpose solution. (It can be used on any socket-based system where binding semantics disallow simultaneous connections).

I like this idea (and Windows seems to disallow simultaneous
connections), but at a high level, I'm not sure how managing a pool of
sockets is any different than managing a pool of mutex's? I haven't
tried it yet, but intuitively I would think that a pool of mutex's would
be faster to iterate through and more resource efficient?

Regards,
Malcolm

----- Original message -----
From: "Tim Golden" 
To: 
Cc: "zz Python Win32 Newsgroup" 
Date: Fri, 12 Mar 2010 14:31:54 +0000
Subject: Re: [python-win32] Technique to limit number of instances of
our application under Terminal Server

On 12/03/2010 14:21, python at bdurham.com wrote:
> Tim,
>
> Thank you for your example code and ideas!!
>
> I think my earlier experiments with semaphores may be the result of my
> poor code vs. your approach :)
>
> I'm going to put aside my pool of mutex's idea and experiment with your
> sample code.

Good luck. Be aware of Christopher Nilsson's point that while
the Mutex will be released if the holding process crashes hard,
the Semaphore will not release its token. (Haven't tried this
myself; I'm assuming he's had experience or has read the docs
more carefully than me).

The bind-to-a-socket approach is a good general-purpose solution.
(It can be used on any socket-based system where binding semantics
disallow simultaneous connections).

Greg Ewing's "control server" is the kind of thing you'd be doing
for license control, eg, and has the advantage he points out about
detecting dead session. But it has the overhead of a control process.
Which may or may not be an issue for you.

TJG
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


From mike.diehn at ansys.com  Fri Mar 12 23:58:39 2010
From: mike.diehn at ansys.com (Mike Diehn)
Date: Fri, 12 Mar 2010 17:58:39 -0500
Subject: [python-win32] Ranged retrieval of large group membership lists
Message-ID: 

Hey folks,

I can't be the only person dealing with this, right?

I have an AD group of 1650 members.  The find_group() function in
active_directory.py can't return more than 1500 members.  I've coded a
generator that gets around it by using the query() method in a sort of brute
force method.  But I'd really like to know what everyone else is doing
instead.

In other words, what did I miss?

Thanks,
Mike

-- 
Mike Diehn
Senior Systems Administrator
ANSYS, Inc - Lebanon, NH Office
mike.diehn at ansys.com, (603) 727-5492
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Sat Mar 13 11:17:38 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Sat, 13 Mar 2010 10:17:38 +0000
Subject: [python-win32] Ranged retrieval of large group membership lists
In-Reply-To: 
References: 
Message-ID: <4B9B6642.5080104@timgolden.me.uk>

On 12/03/2010 22:58, Mike Diehn wrote:
> Hey folks,
>
> I can't be the only person dealing with this, right?
>
> I have an AD group of 1650 members.  The find_group() function in
> active_directory.py can't return more than 1500 members.  I've coded a
> generator that gets around it by using the query() method in a sort of brute
> force method.  But I'd really like to know what everyone else is doing
> instead.
>
> In other words, what did I miss?


Hi, Mike. As far as I can see you haven't missed anything. I've been
playing around a little as far as my time has permitted and I imagine
the following are true. (Obviously "most people" here refers to "most
people who use Python on Windows and want to access AD...")

* Most people don't use my active_directory module for accessing AD
   but write the code themselves or use one of the python-ldap modules.

* Most people don't have member lists of > 1500. We certainly don't. In
   order to test this I'm going to have to sweet-talk my admins into
   letting me use on our test-harness AD where I can generate several
   thousand random users.

* This is more of an issue if you're accessing members by means of the
   IADsGroup object (which you are if you're looking at the .members
   attribute). AFAICT There is no way to specify anything like the
   ranging attributes there. Could be wrong. Haven't yet tried something
   like GetInfoEx to see if you can specify a range there. I'm trying to
   build something pretty much automatic into the underlying .query
   mechanism in my module but I'm hampered by the fact that we don't need
   it at my work, and they're the ones paying for the time I spend on
   developing this.

I need to spend more time looking into this in the coming week but I'm
not sure how much time will be available to me...

TJG

From andrews at korbitec.com  Sat Mar 13 16:39:48 2010
From: andrews at korbitec.com (Andrew Spagnoletti)
Date: Sat, 13 Mar 2010 17:39:48 +0200
Subject: [python-win32] Python Windows Socket problem after Py2exe and
	install
Message-ID: 

Hi,

 

Hope this is the correct forum .

 

I have a Windows Python 2.5 (using wxPython) application, which works
fine until I 'compile' with py2exe (i.e. the installed program does not
work - although the 'test' in py2exe does).

 

I use urllib to add functionality to send an SMS from my program (via
www.bulksms.co.za) and it works great, but after running py2exe and
creating an install using Windows Advanced Installer, the installation
completes but when I run the program I get this error traceback in the
Program Files log file (changed the file names): -

 

Traceback (most recent call last):

  File "xxxStart.py", line 9, in 

  File "xxxMain.pyo", line 17, in 

  File "xxxRecordActivity.pyo", line 18, in 

  File "xxxSMS.pyo", line 4, in 

  File "urllib.pyo", line 26, in 

  File "socket.pyo", line 45, in 

  File "_socket.pyo", line 12, in 

    

  File "_socket.pyo", line 10, in __load

    

ImportError: DLL load failed: The specified module could not be found.

 

Any ideas?

 

 

 

Andrew Spagnoletti

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From aahz at pythoncraft.com  Sat Mar 13 21:22:51 2010
From: aahz at pythoncraft.com (Aahz)
Date: Sat, 13 Mar 2010 12:22:51 -0800
Subject: [python-win32] Python Windows Socket problem after Py2exe
	and	install
In-Reply-To: 
References: 
Message-ID: <20100313202251.GB2693@panix.com>

On Sat, Mar 13, 2010, Andrew Spagnoletti wrote:
>
> Hope this is the correct forum .

It's an acceptable one, but you probably should subscribe to
py2exe-users.

> ImportError: DLL load failed: The specified module could not be found.

Here's what I just posted to py2exe-users in response to a similar
question:

Are any of your imports buried inside "if" or "def" statements?  py2exe
uses a module-finding technique that doesn't work with those, and you'll
either need to change your code or list the modules in setup.py
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer

From python at bdurham.com  Sun Mar 14 00:42:22 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sat, 13 Mar 2010 18:42:22 -0500
Subject: [python-win32] Python Windows Socket problem after Py2exe and
 install
In-Reply-To: <20100313202251.GB2693@panix.com>
References: 
	<20100313202251.GB2693@panix.com>
Message-ID: <1268523742.22700.1364679785@webmail.messagingengine.com>

> Are any of your imports buried inside "if" or "def" statements? py2exe uses a module-finding technique that doesn't work with those, and you'll either need to change your code or list the modules in setup.py

We have import's embedded in 'if' blocks and py2exe seems to be picking
these up fine.

We also have some applications that were making some dynamic imports
that py2exe naturally wouldn't know about. We solved this problem by
making sure we included almost all the modules's in python's standard
library ('the kitchen sink strategy'). We did this by placing a huge
list of imports inside a 'if False:' block.

Our strategy for deciding what modules to include (import) in our py2exe
project is detailed in my Mar 9 post to this forum titled 'Choosing a
collection of common modules/packages for a general purpose reusable
PY2EXE runtime'. This post got zero feedback so our idea is either too
stupid or too obvious to warrant further conversation :)

Malcolm

From python at bdurham.com  Sun Mar 14 01:49:55 2010
From: python at bdurham.com (python at bdurham.com)
Date: Sat, 13 Mar 2010 19:49:55 -0500
Subject: [python-win32] Python Windows Socket problem after Py2exe and
 install
In-Reply-To: 
References: 
	<20100313202251.GB2693@panix.com>
	<1268523742.22700.1364679785@webmail.messagingengine.com>
	
Message-ID: <1268527795.29636.1364684909@webmail.messagingengine.com>

Tom,

> You don't need to add a whole load of imports inside a "if
False" block to make py2exe add them. If I recall correctly there
is a option in py2exe to force exclude and include modules when
compiling.

 DOH! You're right! 

I've been doing a lot of work with our automated build cycle and
I must have looked at 100 different setup.py's. We do use these
features to fine tune our py2exe setup scripts for each
application. We just missed using these features for forcing our
large 'standard library (kitchen sink)' collection of modules.

Good catch!

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From andrews at korbitec.com  Sun Mar 14 09:10:38 2010
From: andrews at korbitec.com (Andrew Spagnoletti)
Date: Sun, 14 Mar 2010 10:10:38 +0200
Subject: [python-win32] Python Windows Socket problem after Py2exe and
	install
In-Reply-To: <1268527795.29636.1364684909@webmail.messagingengine.com>
References: <20100313202251.GB2693@panix.com><1268523742.22700.1364679785@webmail.messagingengine.com>
	<1268527795.29636.1364684909@webmail.messagingengine.com>
Message-ID: 

Hi Malcolm,

 

Problem solved! For some reason _socket.pyd was not added to the
install; I manually included it with Advanced Installer and now it
works.

 

I can only presume that with my other application (the one that included
CherryPy and simplejson) I have some 'include' that causes _socket.pyd
to be included in my Windows install, but this application did not.

 

Sorry if I wasted your time. I would just like to say that I have been
programming for the past 40 years (but only the last 3 in Python with
wxPython) and what a pleasure Python and all its associated programs
have been, with unbelievable support. I am sure that many others, like
me, appreciate the time and expertise that people like you and your
colleagues  give so generously to this community.

 

Thanks again,

 

Andrew

 

Tom,

 

> You don't need to add a whole load of imports inside a "if False"
block to make py2exe add them. If I recall correctly there is a option
in py2exe to force exclude and include modules when compiling.

 

 DOH! You're right! 

 

I've been doing a lot of work with our automated build cycle and I must
have looked at 100 different setup.py's. We do use these features to
fine tune our py2exe setup scripts for each application. We just missed
using these features for forcing our large 'standard library (kitchen
sink)' collection of modules.

 

Good catch!

 

Thank you,

Malcolm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From greg.ewing at canterbury.ac.nz  Sun Mar 14 23:35:19 2010
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Mon, 15 Mar 2010 11:35:19 +1300
Subject: [python-win32] Python Windows Socket problem after Py2exe and
 install
In-Reply-To: <1268523742.22700.1364679785@webmail.messagingengine.com>
References: 
	<20100313202251.GB2693@panix.com>
	<1268523742.22700.1364679785@webmail.messagingengine.com>
Message-ID: <4B9D64A7.3080308@canterbury.ac.nz>

python at bdurham.com wrote:

> ...'Choosing a
> collection of common modules/packages for a general purpose reusable
> PY2EXE runtime'. This post got zero feedback so our idea is either too
> stupid or too obvious to warrant further conversation :)

I think the problem is that in the rare cases when you need
a kitchen-sink approach, the set of appropriate modules to
include isn't going to be covered by a single project-independent
choice. Different kitchens need different-sized sinks. :-)

-- 
Greg

From mail at timgolden.me.uk  Mon Mar 15 11:06:48 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 15 Mar 2010 10:06:48 +0000
Subject: [python-win32] Ranged retrieval of large group membership lists
In-Reply-To: <4B9B6642.5080104@timgolden.me.uk>
References: 
	<4B9B6642.5080104@timgolden.me.uk>
Message-ID: <4B9E06B8.4000302@timgolden.me.uk>

On 13/03/2010 10:17, Tim Golden wrote:
> * Most people don't have member lists of>  1500. We certainly don't. In
>     order to test this I'm going to have to sweet-talk my admins into
>     letting me use on our test-harness AD where I can generate several
>     thousand random users.

OK; I've got the ok to use our AD test rig to generate a whole bunch
of users into a big group. I've got a reasonable idea how I can build
the ranging functionality into the (in-development version of the)
ad module relatively smoothly. What I don't have a clear idea of is
how it will affect performance. I'll try to get to this in the next
day or two.

TJG

From info at apli-agipa.com  Mon Mar 15 11:51:20 2010
From: info at apli-agipa.com (Sylvain Fauveau (apli-agipa))
Date: Mon, 15 Mar 2010 11:51:20 +0100
Subject: [python-win32] Pywin32-Excel Range/Cells problems
Message-ID: <4B9E1128.30306@apli-agipa.com>

Hello everybody.

I have detected a problem with a cell with loooong text in it but I'm 
not sure of his source.

To reproduce it :
from win32com.client import Dispatch
excel = Dispatch('Excel.Application')
sheet = excel.ActiveSheet

sheet.Range('A1:C1').Value = ['test','test'*400,'test']
doesn't work :
pywintypes.com_error(-2147352567,"Une exception s'est produite.", (0, 
None, None, None, 0, -2416827284), None)

But :
sheet.Cells('A1').Value = 'test'*400
work

I have searching on google to see if I found an excel problem, but 
doesn't find. If I make copy/paste from Excel, it's ok.
Python 2.5
Pywin32-211
Office 2003 SP3

If someone has an idee...

Best regards

-- 

*Sylvain Fauveau*
Apli-Agipa
T?l: 03-26-58-18-28
Logo d'APLI-AGIPA
--Pensez ? la nature et n'imprimez cet email que si n?cessaire--

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature_agipa-apli.JPG
Type: image/jpeg
Size: 12696 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: info.vcf
Type: text/x-vcard
Size: 176 bytes
Desc: not available
URL: 

From mike.diehn at ansys.com  Mon Mar 15 17:04:13 2010
From: mike.diehn at ansys.com (Mike Diehn)
Date: Mon, 15 Mar 2010 12:04:13 -0400
Subject: [python-win32] Ranged retrieval of large group membership lists
In-Reply-To: <4B9E06B8.4000302@timgolden.me.uk>
References:  
	<4B9B6642.5080104@timgolden.me.uk> <4B9E06B8.4000302@timgolden.me.uk>
Message-ID: 

Do you want me to ship you the code I wrote to do it?

M

On Mon, Mar 15, 2010 at 6:06 AM, Tim Golden  wrote:

> On 13/03/2010 10:17, Tim Golden wrote:
>
>> * Most people don't have member lists of>  1500. We certainly don't. In
>>    order to test this I'm going to have to sweet-talk my admins into
>>    letting me use on our test-harness AD where I can generate several
>>    thousand random users.
>>
>
> OK; I've got the ok to use our AD test rig to generate a whole bunch
> of users into a big group. I've got a reasonable idea how I can build
> the ranging functionality into the (in-development version of the)
> ad module relatively smoothly. What I don't have a clear idea of is
> how it will affect performance. I'll try to get to this in the next
> day or two.
>
>
> TJG
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email______________________________________________________________________
>



-- 
Mike Diehn
Senior Systems Administrator
ANSYS, Inc - Lebanon, NH Office
mike.diehn at ansys.com, (603) 727-5492
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mail at timgolden.me.uk  Mon Mar 15 17:05:25 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 15 Mar 2010 16:05:25 +0000
Subject: [python-win32] Ranged retrieval of large group membership lists
In-Reply-To: 
References: 
	<4B9B6642.5080104@timgolden.me.uk>
	<4B9E06B8.4000302@timgolden.me.uk>
	
Message-ID: <4B9E5AC5.6060204@timgolden.me.uk>

On 15/03/2010 16:04, Mike Diehn wrote:
> Do you want me to ship you the code I wrote to do it?

Wouldn't do any harm :) Thanks

TJG

From timr at probo.com  Mon Mar 15 18:03:31 2010
From: timr at probo.com (Tim Roberts)
Date: Mon, 15 Mar 2010 10:03:31 -0700
Subject: [python-win32] Pywin32-Excel Range/Cells problems
In-Reply-To: <4B9E1128.30306@apli-agipa.com>
References: <4B9E1128.30306@apli-agipa.com>
Message-ID: <4B9E6863.8050404@probo.com>

Sylvain Fauveau (apli-agipa) wrote:
> Hello everybody.
>
> I have detected a problem with a cell with loooong text in it but I'm
> not sure of his source.
>
> To reproduce it :
> from win32com.client import Dispatch
> excel = Dispatch('Excel.Application')
> sheet = excel.ActiveSheet
>
> sheet.Range('A1:C1').Value = ['test','test'*400,'test']
> doesn't work :
> pywintypes.com_error(-2147352567,"Une exception s'est produite.", (0,
> None, None, None, 0, -2416827284), None)

It's always dangerous to retype lines like these instead of cutting and
pasting, because it's so easy to mistype the error number.  In this
case, the error is actually -2146827284, which would be 800A03EC
(ERROR_INVALID_FLAGS), but that isn't a typical Excel error code.

For what it's worth, it works up through 911 characters and fails on
912.  That's odd.  I wonder if this is a request-length restriction in
the marshalling code.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From kxroberto at googlemail.com  Mon Mar 15 20:01:22 2010
From: kxroberto at googlemail.com (Robert)
Date: Mon, 15 Mar 2010 20:01:22 +0100
Subject: [python-win32] COM:  Volume Shadow Service through Python?
Message-ID: 

is there a way to use the VSS (as requester) from Python rather 
simple way - with COM functions or so (win32com or cytpes)?  or 
only through a compiled SWIG extension or so?

CreateVssBackupComponents / vssapi.dll
http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx
seems to be a C++ only interface.

There is a "VSS.VSSCoordinator" in the COM browser. does it have 
to do anything with that...


Robert


From kevin.horn at gmail.com  Mon Mar 15 21:47:00 2010
From: kevin.horn at gmail.com (Kevin Horn)
Date: Mon, 15 Mar 2010 14:47:00 -0600
Subject: [python-win32] COM: Volume Shadow Service through Python?
In-Reply-To: 
References: 
Message-ID: <562bcc11003151347q329bef2l689919135aa1dd69@mail.gmail.com>

On Mon, Mar 15, 2010 at 1:01 PM, Robert  wrote:

> is there a way to use the VSS (as requester) from Python rather simple way
> - with COM functions or so (win32com or cytpes)?  or only through a compiled
> SWIG extension or so?
>
> CreateVssBackupComponents / vssapi.dll
> http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx
> seems to be a C++ only interface.
>
> There is a "VSS.VSSCoordinator" in the COM browser. does it have to do
> anything with that...
>
>
> Robert
>
>
Search the list archives..there was something on this a while ago, but I
can't find it just now...

Kevin Horn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From davea at ieee.org  Tue Mar 16 02:42:23 2010
From: davea at ieee.org (Dave Angel)
Date: Mon, 15 Mar 2010 20:42:23 -0500
Subject: [python-win32] ImportError on win32api
Message-ID: <4B9EE1FF.1000409@ieee.org>

Starting yesterday, one of my programs gets an import error trying to 
import win32api.  The last time I ran the program was probably a month 
ago, and in the meantime I had updated the Python version, as follows:

2.6.4 (r264:75706, Jan 22 2010, 16:41:54) [MSC v.1500 32 bit (Intel)]

This was installed from ActiveState's distro, which includes the Win32 
stuff.

The error happens on the following, regardless of whether other imports 
happen first.


Traceback (most recent call last):
  File 
"M:\Programming\Python\sources\diskutils\testwin32api\testwin32.py", 
line 23, in 
    import win32api
ImportError: DLL load failed: The specified procedure could not be found.


I added in logic to search the sys.path, and it found that:
  C:\PrgFiles\APython26\lib\site-packages\win32

contained file win32api.pyd

I examined python26.dll with Dependency Walker 2.2, and it showed a 
missing delay-load:  MSJAVA.DLL (imported by MSHTML.DLL).  But that 
shouldn't be a problem, unless one of the MSJAVA entry points is 
actually used.

Any suggestions?
Thanks,
DaveA


From info at apli-agipa.com  Tue Mar 16 09:10:05 2010
From: info at apli-agipa.com (Sylvain Fauveau (apli-agipa))
Date: Tue, 16 Mar 2010 09:10:05 +0100
Subject: [python-win32] Pywin32-Excel Range/Cells problems
In-Reply-To: <4B9E6863.8050404@probo.com>
References: <4B9E1128.30306@apli-agipa.com> <4B9E6863.8050404@probo.com>
Message-ID: <4B9F3CDD.4080603@apli-agipa.com>

Tim Roberts a ?crit :
> Sylvain Fauveau (apli-agipa) wrote:
>   
>> sheet.Range('A1:C1').Value = ['test','test'*400,'test']
>> doesn't work :
>> pywintypes.com_error(-2147352567,"Une exception s'est produite.", (0,
>> None, None, None, 0, -2416827284), None)
>>     
>
> It's always dangerous to retype lines like these instead of cutting and
> pasting, because it's so easy to mistype the error number.  In this
> case, the error is actually -2146827284, which would be 800A03EC
> (ERROR_INVALID_FLAGS), but that isn't a typical Excel error code.
>   
Hello Tim. Thanks for your answer.

You're right. Copy and paste error message :
 >>> sheet.Range('A1:C1').Value = ['test','test'*400,'test']
Traceback (most recent call last):
File "", line 1, in 
File "C:\usr\Python25\lib\site-packages\win32com\client\__init__.py", 
line 463, in __setattr__
self._oleobj_.Invoke(*(args + (value,) + defArgs))
com_error: (-2147352567, "Une exception s'est produite.", (0, None, 
None, None, 0, -2146827284), None)
 >>>
> For what it's worth, it works up through 911 characters and fails on
> 912.  That's odd.  I wonder if this is a request-length restriction in
> the marshalling code.
>   
So you can reproduce it, but with which version of python/pywin32 ?

Best regards
-- 

*Sylvain Fauveau*
Apli-Agipa
T?l: 03-26-58-18-28
Logo d'APLI-AGIPA
--Pensez ? la nature et n?imprimez cet email que si n?cessaire--

-------------- next part --------------
A non-text attachment was scrubbed...
Name: info.vcf
Type: text/x-vcard
Size: 176 bytes
Desc: not available
URL: 

From timr at probo.com  Tue Mar 16 18:01:38 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 16 Mar 2010 10:01:38 -0700
Subject: [python-win32] Pywin32-Excel Range/Cells problems
In-Reply-To: <4B9F3CDD.4080603@apli-agipa.com>
References: <4B9E1128.30306@apli-agipa.com> <4B9E6863.8050404@probo.com>
	<4B9F3CDD.4080603@apli-agipa.com>
Message-ID: <4B9FB972.2000107@probo.com>

Sylvain Fauveau (apli-agipa) wrote:
> Tim Roberts a ?crit :
>> For what it's worth, it works up through 911 characters and fails on
>> 912.  That's odd.  I wonder if this is a request-length restriction in
>> the marshalling code.
>>   
> So you can reproduce it, but with which version of python/pywin32 ?

I can reproduce it with Python 2.6.2 and pyWin32 214.  However, this is
not a problem in pyWin32.  I tried the exact same thing with a VBScript
script, and got the exact same error.  It's some kind of generic
restriction in the Excel COM marshalling code.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From info at apli-agipa.com  Tue Mar 16 18:27:57 2010
From: info at apli-agipa.com (Sylvain Fauveau (apli-agipa))
Date: Tue, 16 Mar 2010 18:27:57 +0100
Subject: [python-win32] Pywin32-Excel Range/Cells problems
In-Reply-To: <4B9FB972.2000107@probo.com>
References: <4B9E1128.30306@apli-agipa.com>
	<4B9E6863.8050404@probo.com>	<4B9F3CDD.4080603@apli-agipa.com>
	<4B9FB972.2000107@probo.com>
Message-ID: <4B9FBF9D.7010606@apli-agipa.com>

Tim Roberts a ?crit :
> Sylvain Fauveau (apli-agipa) wrote:
>   
>> Tim Roberts a ?crit :
>>     
>>> For what it's worth, it works up through 911 characters and fails on
>>> 912.  That's odd.  I wonder if this is a request-length restriction in
>>> the marshalling code.
>>>   
>>>       
>> So you can reproduce it, but with which version of python/pywin32 ?
>>     
>
> I can reproduce it with Python 2.6.2 and pyWin32 214.  However, this is
> not a problem in pyWin32.  I tried the exact same thing with a VBScript
> script, and got the exact same error.  It's some kind of generic
> restriction in the Excel COM marshalling code.
>   
Ok.
I will make a try/except per line and retry with Cell.Value when I get a 
problem.

Thank you very much Tim, for your answer.

Best regards.

-- 

*Sylvain Fauveau*
Apli-Agipa
T?l: 03-26-58-18-28
Logo d'APLI-AGIPA
--Pensez ? la nature et n?imprimez cet email que si n?cessaire--

-------------- next part --------------
A non-text attachment was scrubbed...
Name: info.vcf
Type: text/x-vcard
Size: 176 bytes
Desc: not available
URL: 

From kxroberto at googlemail.com  Tue Mar 16 18:48:52 2010
From: kxroberto at googlemail.com (Robert)
Date: Tue, 16 Mar 2010 18:48:52 +0100
Subject: [python-win32] COM: Volume Shadow Service through Python?
In-Reply-To: <562bcc11003151347q329bef2l689919135aa1dd69@mail.gmail.com>
References: 
	<562bcc11003151347q329bef2l689919135aa1dd69@mail.gmail.com>
Message-ID: 

Kevin Horn wrote:
> On Mon, Mar 15, 2010 at 1:01 PM, Robert  > wrote:
>
>     is there a way to use the VSS (as requester) from Python rather
>     simple way - with COM functions or so (win32com or cytpes)?  or only
>     through a compiled SWIG extension or so?
>
>     CreateVssBackupComponents / vssapi.dll
>     http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx
>     
>     seems to be a C++ only interface.
>
>     There is a "VSS.VSSCoordinator" in the COM browser. does it have to
>     do anything with that...
>
>
>     Robert
>
>
> Search the list archives..there was something on this a while ago, but I
> can't find it just now...
>

hmm
"volume shadow" site:mail.python.org
etc tells nothing. (Somebody just suggested to switch to VSS for 
some task).
any other search terms associated with those posts?

Robert




From mail at timgolden.me.uk  Tue Mar 16 19:16:04 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Tue, 16 Mar 2010 18:16:04 +0000
Subject: [python-win32] COM: Volume Shadow Service through Python?
In-Reply-To: 
References: 	<562bcc11003151347q329bef2l689919135aa1dd69@mail.gmail.com>
	
Message-ID: <4B9FCAE4.4000406@timgolden.me.uk>

On 16/03/2010 17:48, Robert wrote:
> Kevin Horn wrote:
>> On Mon, Mar 15, 2010 at 1:01 PM, Robert> >  wrote:
>>
>>      is there a way to use the VSS (as requester) from Python rather
>>      simple way - with COM functions or so (win32com or cytpes)?  or only
>>      through a compiled SWIG extension or so?
>>
>>      CreateVssBackupComponents / vssapi.dll
>>      http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx
>>      
>>      seems to be a C++ only interface.
>>
>>      There is a "VSS.VSSCoordinator" in the COM browser. does it have to
>>      do anything with that...
>>
>>
>>      Robert
>>
>>
>> Search the list archives..there was something on this a while ago, but I
>> can't find it just now...
>>
>
> hmm
> "volume shadow" site:mail.python.org
> etc tells nothing. (Somebody just suggested to switch to VSS for
> some task).
> any other search terms associated with those posts?

http://markmail.org/thread/bmyioexeuvnwlmho

TJG

From fuzzyman at gmail.com  Tue Mar 16 20:11:43 2010
From: fuzzyman at gmail.com (Michael Foord)
Date: Tue, 16 Mar 2010 19:11:43 +0000
Subject: [python-win32] EuroPython 2010 - Open for registration and reminder
	of participation
Message-ID: <6f4025011003161211r4c78da92q6d02f4ee676e7879@mail.gmail.com>

EuroPython 2010 - 17th to 24th July 2010
----------------------------------------
EuroPython is a conference for the Python programming language
community, including the Django, Zope and Plone communities. It is
aimed at everyone in the Python community, of all skill levels, both
users and programmers.

Last year's conference was the largest open source conference in the
UK and one of the largest community organised software conferences in
Europe.

This year EuroPython will be held from the 17th to 24th July in
Birmingham, UK. It will include over 100 talks, tutorials, sprints and
social events.

Registration
------------
Registration is open now at: http://www.europython.eu/registration/

For the best registration rates, book as soon as you can! Extra Early
Bird closes soon, after which normal Early Bird rate will apply until
10th May

 Talks, Activities and Events
----------------------------
Do you have something you wish to present at EuroPython? You want to
give a talk, run a tutorial or sprint?
Go to http://www.europython.eu/talks/cfp/ for information and advice!
Go to http://wiki.europython.eu/Sprints to plan a sprint!

Help Us Out
-----------
EuroPython is run by volunteers, like you! We could use a hand, and
any contribution is welcome.
Go to http://wiki.europython.eu/Helping to join us!
Go to http://www.europython.eu/contact/ to contact us directly!

Sponsors
--------
Sponsoring EuroPython is a unique opportunity to affiliate with this
prestigious conference and to reach a large number of Python users
from computing professionals to academics, from entrepreneurs to
motivated and well-educated job seekers.
http://www.europython.eu/sponsors/

Spread the Word
---------------
We are a community-run not-for-profit conference. Please help to
spread the word by distributing this announcement to colleagues,
project mailing lists, friends, your blog, Web site, and through your
social networking connections. Take a look at our publicity resources:
http://wiki.europython.eu/Publicity

 General Information
-------------------
For more information about the conference, please visit the official
site: http://www.europython.eu/

Looking forward to see you!
The EuroPython Team

-- 
http://www.ironpythoninaction.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From chris.jesse at flightdataservices.com  Fri Mar 19 11:30:42 2010
From: chris.jesse at flightdataservices.com (Chris Jesse)
Date: Fri, 19 Mar 2010 10:30:42 +0000 (GMT)
Subject: [python-win32] Finding the physical USBSTOR disk size
In-Reply-To: <8796244.121268994343473.JavaMail.chris@jesse1c-laptop>
Message-ID: <5804327.141268994638188.JavaMail.chris@jesse1c-laptop>

Hello, 

I am trying to use WMI in order to get information about drives so that we can read and write bytes to raw Compact Flash cards, among other devices. The problem that we are having is that we can't seem to get an accurate size for the disks. We need to be able to get a full dump of the cards and write 0x00 to the cards in order to zero them completely but cannot do so without having an accurate size, in bytes, for the devices. 

I know that in the past we were able to do so, using the Win32_Diskpartition Size property but have recently found that this is no longer the case as it is inaccurate. We believe this is because we may not have tested it with a FAT formatted media before. 

These are the results of using a 512MB CF card with Fat16 formatting: 
-------- Correct sizes reported by Linux and Winhex -------- 
>>> 512483328 # HAL, FDISK and WinHex on Ubuntu Linux both report this size (real size) 
512483328 
>>> 512483328 # WinHex Total capacity of Physical media (real size) 
512483328 
-------- Wrong sizes reported -------- 
>>> int(partition.Size) # Win32_DiskDriveToDiskPartition - works when there are NO partitions (i.e. already initialised with \x00 throughout) 
509935104 
>>> int(drive.Size) # Win32_DiskDrive - always wrong, it's a "best guess" given info the disk provides 
509967360 
>>> 509665280 # Windows Right Click > Properties on drive 
509665280 
>>> 509665280 # WinHex Free Space of Logical media (f:) -- same as Properties (as it has fat formatting) 
509665280 
>>> 509934592 # WinHex Total capacity of Logical media (f:) 
509934592 

Do you have any ideas on how we might be able to get this size information? 

Below is some of the code that we have been using to try and get all of the disk information that we require. 

Thanks in advance, Chris. 
--- 
for drive in c.Win32_DiskDrive(): 
# Add device and its size to medias found dictionary 
# Use the MediaLoaded to add to the dictionary that it's loaded 
pnp_dev_id = drive.PNPDeviceID.split('\\') 

if pnp_dev_id[0] == 'USBSTOR': 
usb_dev = flightdataretrieval.device.GenericDevice() 
for partition in drive.associators("Win32_DiskDriveToDiskPartition"): 
for logical_disk in partition.associators("Win32_LogicalDiskToPartition"): 
usb_vol_dict = {} 
if str(logical_disk.FileSystem) != "None": 
usb_vol_dict[str(logical_disk.Caption)] = str(logical_disk.FileSystem) 
logging.debug("Drive %s size %s",str(logical_disk.FileSystem),str(drive.Size)) 
if drive.Size != None: 
# Determine the path to use for removable disk access 
logical_address = '\\\\.\\' + logical_disk.Caption 
usb_dev.location = logical_address # r'\\.\f:' 
usb_dev.physical_location = drive.DeviceID # r'\\.\PHYSICALDRIVE1' 
usb_dev.dev_type = 'USB' 
usb_dev.media_loaded = drive.MediaLoaded 
# fix 02.12.09 - use physical disk drive size, not that of the partition. 
# counter fix 18.02.10 - no, use the partition! it has the larger size reported. 
usb_dev.size = int(partition.Size) # e.g. 521773056 (512MB) 
##usb_dev.size = int(drive.Size) # e.g. 518192640 (512MB) 
usb_dev.volumes = usb_vol_dict 
usb_dev_list.append(usb_dev) 
else: pass 

-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From clintonlee.taylor at gmail.com  Fri Mar 19 20:56:00 2010
From: clintonlee.taylor at gmail.com (Clinton Lee Taylor)
Date: Fri, 19 Mar 2010 21:56:00 +0200
Subject: [python-win32] OT: Syncing routes ...
Message-ID: 

Greetings ...

I'm still very new to Python, so please excuss my request ... I have
written some very basic Python utils and slowly get my head around
Python and com objects in Windows ...

 I was hoping that I might be able to bug the list for any pointers on
syncing routes, that I could use to sync records from one DB to
another ... Basically looking to sync Outlook Contacts into and from a
MySQL DB.  Later, would like to extend this to include Windows Address
Book, Thunderbird Contacts and maybe any other DateBase.

 Also looking for a good place to host this project, any suggests
would be welcome.

Thanks
Mailed
LeeT

From mail at timgolden.me.uk  Mon Mar 22 11:05:13 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 10:05:13 +0000
Subject: [python-win32] OT: Syncing routes ...
In-Reply-To: 
References: 
Message-ID: <4BA740D9.4080809@timgolden.me.uk>

On 19/03/2010 19:56, Clinton Lee Taylor wrote:
> Greetings ...
>
> I'm still very new to Python, so please excuss my request ... I have
> written some very basic Python utils and slowly get my head around
> Python and com objects in Windows ...
>
>   I was hoping that I might be able to bug the list for any pointers on
> syncing routes, that I could use to sync records from one DB to
> another ... Basically looking to sync Outlook Contacts into and from a
> MySQL DB.  Later, would like to extend this to include Windows Address
> Book, Thunderbird Contacts and maybe any other DateBase.

Well I'm no expert in this area, but since I've not seen any other
replies I'll have a stab. Your question is quite wide-ranging,
taking in several major software packages, all of which have
quite different access methods. You say you're new to Python
(and presumably to Windows development, if you're coming to terms
with COM). Do you have any other development experience?

Outlook contacts can be read via the so-called CDO libraries.
This is the definitive starting point:

   http://msdn.microsoft.com/en-us/library/ms988614%28EXCHG.65%29.aspx

and there's some good resources here:

   http://www.cdolive.com/default.htm

For the most part, CDO is easy enough to translate into Python.
I have some examples here (altho' not contact-related):

   http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html
   http://timgolden.me.uk/python/win32_how_do_i/replace-outlook-attachments-with-links.html
   http://timgolden.me.uk/python/win32_how_do_i/create-an-mhtml-archive.html

and once you've got hold of the terms you need, you can easily
Google around for more.

Then you have the database side. You mention MySQL but you might be better off
using sqlite, an interface to which is included with Python in recent versions.
This is, of course, unless you have a truly huge list of contacts, or an
existing investment in MySQL.

   http://sqlite.org/
   http://docs.python.org/library/sqlite3.html

There certainly are Python bindings to MySQL altho' I'm not a user myself
so I'm not sure which ones favoured at the moment. Worth asking on the
main Python lists.

Hopefully that's enough to get you started. Feel free to post back with
more questions or info. If your questions aren't win32 specific you
might get more answers on the main Python mailing list:

   http://mail.python.org/mailman/listinfo/python-list

TJG

From mail at timgolden.me.uk  Mon Mar 22 11:09:49 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 10:09:49 +0000
Subject: [python-win32] Finding the physical USBSTOR disk size
In-Reply-To: <5804327.141268994638188.JavaMail.chris@jesse1c-laptop>
References: <5804327.141268994638188.JavaMail.chris@jesse1c-laptop>
Message-ID: <4BA741ED.2000600@timgolden.me.uk>

On 19/03/2010 10:30, Chris Jesse wrote:
> I am trying to use WMI in order to get information about drives so
>The problem that we are having is that we can't seem to get an accurate
>size for the disks.

> I know that in the past we were able to do so, using the Win32_Diskpartition
> Size property but have recently found that this is no longer the case as it is
> inaccurate. We believe this is because we may not have tested it with a FAT
> formatted media before.

I'm not going to be much help here, I'm afraid, except to suggest that
the likely API for this is going to be one of the DeviceIOControl
functions:

   http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx

   http://timgolden.me.uk/pywin32-docs/win32file__DeviceIoControl_meth.html

In principle, the parents of the Win32_LogicalDisk clsas (CIM_LogicalDisk,
CIM_StorageExtent) should offer access to the lower-level data which
makes up the Size attributes. But it doesn't seem to be implemented that
way; they simply return None.

TJG

From werner.bruhin at free.fr  Mon Mar 22 12:06:16 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 12:06:16 +0100
Subject: [python-win32] MAPI with win32com
Message-ID: 

I am trying to use MAPI to send an email using win32com, but I get the 
following exception.

from win32com.client import Dispatch
s = Dispatch("Mapi.Session")
Traceback (most recent call last):
   File "", line 1, in 
   File "C:\Python25\lib\site-packages\win32com\client\__init__.py", 
line 95, in Dispatch
     dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
   File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 
98, in _GetGoodDispatchAndUserName
     return (_GetGoodDispatch(IDispatch, clsctx), userName)
   File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 
78, in _GetGoodDispatch
     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)

I first tried this having Thunderbird as my MAPI client, then installed 
Windows Live Email (I want to test MAPI with one of the "newer" MS Mail 
clients) and defined it as the MAPI client (Default Programs - MAPI), 
still same result.

Any hints on what I am doing wrong here would be very much welcomed.

I am on Windows 7, Python 2.5.4, py2in32 build 210.

Werner


From werner.bruhin at free.fr  Mon Mar 22 12:22:29 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 12:22:29 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References: 
Message-ID: 

On 22/03/2010 12:06, Werner F. Bruhin wrote:
> I am trying to use MAPI to send an email using win32com, but I get the
> following exception.
>
> from win32com.client import Dispatch
> s = Dispatch("Mapi.Session")
> Traceback (most recent call last):
> File "", line 1, in 
> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
> dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
> 98, in _GetGoodDispatchAndUserName
> return (_GetGoodDispatch(IDispatch, clsctx), userName)
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
> 78, in _GetGoodDispatch
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>
> I first tried this having Thunderbird as my MAPI client, then installed
> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
> clients) and defined it as the MAPI client (Default Programs - MAPI),
> still same result.
>
> Any hints on what I am doing wrong here would be very much welcomed.
>
> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>
> Werner
Just came accross Tim Golden's site 
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html) and 
tried this:

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.

Werner



From mail at timgolden.me.uk  Mon Mar 22 12:26:11 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 11:26:11 +0000
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References:  
Message-ID: <4BA753D3.4020407@timgolden.me.uk>

On 22/03/2010 11:22, Werner F. Bruhin wrote:
> On 22/03/2010 12:06, Werner F. Bruhin wrote:
>> I am trying to use MAPI to send an email using win32com, but I get the
>> following exception.
>>
>> from win32com.client import Dispatch
>> s = Dispatch("Mapi.Session")
>> Traceback (most recent call last):
>> File "", line 1, in
>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
>> 95, in Dispatch
>> dispatch, userName =
>> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>> 98, in _GetGoodDispatchAndUserName
>> return (_GetGoodDispatch(IDispatch, clsctx), userName)
>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>> 78, in _GetGoodDispatch
>> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
>> pythoncom.IID_IDispatch)
>> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>>
>> I first tried this having Thunderbird as my MAPI client, then installed
>> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
>> clients) and defined it as the MAPI client (Default Programs - MAPI),
>> still same result.
>>
>> Any hints on what I am doing wrong here would be very much welcomed.
>>
>> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>>
>> Werner
> Just came accross Tim Golden's site
> (http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html) and
> tried this:
>
> session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")
>
> But I do get the same exception.

Have a look at:

   http://kb.mozillazine.org/MAPI_Support

which explains that TB (like OE) only supports "Simple MAPI". There's
a whole confusion of terminology around this area, but I'm afraid that
the bottom line is: the only client which really supports CDO, ie MAPI.Session
is the full Outlook client. It's just about possible to use CDO without
installing Outlook (by installing some standalone package whose name
escapes me) but that still only gives you access to Exchange, not to
whatever interface TB exposes.

TJG

From chris.jesse at flightdataservices.com  Mon Mar 22 12:41:23 2010
From: chris.jesse at flightdataservices.com (Chris Jesse)
Date: Mon, 22 Mar 2010 11:41:23 +0000 (GMT)
Subject: [python-win32] Finding the physical USBSTOR disk size
In-Reply-To: <4BA741ED.2000600@timgolden.me.uk>
Message-ID: <14268785.71269258081593.JavaMail.chris@jesse1c-laptop>

Thanks Tim, 

Shame about the None returns; I keep on bumping up against these! 

I'm currently going for the over-read exception - a bit like over-kill, we read beyond the size reported in the smallest block size chunks (512 bytes) until an exception is raised. It does mean we will get 101% read progress reports and a slight delay at the end of our progress bar, but much like progress reported by Microsoft Minutes, it's an inaccuracy we can live with. 

Thanks for help, Chris. 

----- Original Message ----- 
From: "Tim Golden"  
Cc: "Python win32 User List"  
Sent: Monday, 22 March, 2010 10:09:49 GMT +00:00 GMT Britain, Ireland, Portugal 
Subject: Re: [python-win32] Finding the physical USBSTOR disk size 

On 19/03/2010 10:30, Chris Jesse wrote: 
> I am trying to use WMI in order to get information about drives so 
>The problem that we are having is that we can't seem to get an accurate 
>size for the disks. 

> I know that in the past we were able to do so, using the Win32_Diskpartition 
> Size property but have recently found that this is no longer the case as it is 
> inaccurate. We believe this is because we may not have tested it with a FAT 
> formatted media before. 

I'm not going to be much help here, I'm afraid, except to suggest that 
the likely API for this is going to be one of the DeviceIOControl 
functions: 

http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx 

http://timgolden.me.uk/pywin32-docs/win32file__DeviceIoControl_meth.html 

In principle, the parents of the Win32_LogicalDisk clsas (CIM_LogicalDisk, 
CIM_StorageExtent) should offer access to the lower-level data which 
makes up the Size attributes. But it doesn't seem to be implemented that 
way; they simply return None. 

TJG 
_______________________________________________ 
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 mail at timgolden.me.uk  Mon Mar 22 12:44:31 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 11:44:31 +0000
Subject: [python-win32] Finding the physical USBSTOR disk size
In-Reply-To: <14268785.71269258081593.JavaMail.chris@jesse1c-laptop>
References: <14268785.71269258081593.JavaMail.chris@jesse1c-laptop>
Message-ID: <4BA7581F.9070001@timgolden.me.uk>

On 22/03/2010 11:41, Chris Jesse wrote:
> Shame about the None returns; I keep on bumping up against these!


> I'm currently going for the over-read exception - a bit like over-kill,
> we read beyond the size reported in the smallest block size chunks (512 bytes)
> until an exception is raised. It does mean we will get 101% read progress reports
> and a slight delay at the end of our progress bar, but much like progress reported
> by Microsoft Minutes, it's an inaccuracy we can live with.

Heh. http://xkcd.com/612/   :)

Glad you've got something of a solution anyway

TJG

From werner.bruhin at free.fr  Mon Mar 22 13:40:52 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 13:40:52 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: <4BA753D3.4020407@timgolden.me.uk>
References:  
	<4BA753D3.4020407@timgolden.me.uk>
Message-ID: 

Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:
> On 22/03/2010 11:22, Werner F. Bruhin wrote:
>> On 22/03/2010 12:06, Werner F. Bruhin wrote:
>>> I am trying to use MAPI to send an email using win32com, but I get the
>>> following exception.
>>>
>>> from win32com.client import Dispatch
>>> s = Dispatch("Mapi.Session")
>>> Traceback (most recent call last):
>>> File "", line 1, in
>>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
>>> 95, in Dispatch
>>> dispatch, userName =
>>> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 98, in _GetGoodDispatchAndUserName
>>> return (_GetGoodDispatch(IDispatch, clsctx), userName)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 78, in _GetGoodDispatch
>>> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
>>> pythoncom.IID_IDispatch)
>>> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>>>
>>> I first tried this having Thunderbird as my MAPI client, then installed
>>> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
>>> clients) and defined it as the MAPI client (Default Programs - MAPI),
>>> still same result.
>>>
>>> Any hints on what I am doing wrong here would be very much welcomed.
>>>
>>> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>>>
>>> Werner
>> Just came accross Tim Golden's site
>> (http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
>> and
>> tried this:
>>
>> session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")
>>
>> But I do get the same exception.
>
> Have a look at:
>
> http://kb.mozillazine.org/MAPI_Support
>
> which explains that TB (like OE) only supports "Simple MAPI". There's
> a whole confusion of terminology around this area, but I'm afraid that
> the bottom line is: the only client which really supports CDO, ie
> MAPI.Session
> is the full Outlook client. It's just about possible to use CDO without
> installing Outlook (by installing some standalone package whose name
> escapes me)
I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
  but that still only gives you access to Exchange, not to
> whatever interface TB exposes.
Clients and me using TB are fine, I support that with the simplemapi.py 
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works 
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2 
(failure).
>
> TJG

I don't want to use Outlook, but I like to provide an additional way of 
sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.


Werner


From mail at timgolden.me.uk  Mon Mar 22 13:58:16 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 12:58:16 +0000
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References: 
		<4BA753D3.4020407@timgolden.me.uk>
	
Message-ID: <4BA76968.1060609@timgolden.me.uk>

[Tim Golden]
the only client which really supports CDO, ie
>> MAPI.Session
>> is the full Outlook client. It's just about possible to use CDO without
>> installing Outlook (by installing some standalone package whose name
>> escapes me)

[Werner Bruhin]
> I found this:
> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

Yep. Think that's the one.

> At least I get past the above error, will see how far I get with this.
>    but that still only gives you access to Exchange, not to
>> whatever interface TB exposes.

That's really the problem. AFAICT, CDO is *basically* an interface to
Exchange via Outlook. You can just about get away without the Outlook
bit by installing the download you mention (which presumably includes
the necessary bits of Outlook without the front-end). But I don't
honestly think you can get away without Exchange. I suspect the idea
is that you should be able to. But I'm not aware that anyone's
implemented it to the extent that you could. Happy to be wrong.

> I don't want to use Outlook, but I like to provide an additional way of
> sending problem reports from within my application to me (MAPI,
> smtplib), so hoped that I could use extended MAPI stuff.

Hmmm. Good luck and keep us posted. For my understanding, is there
some reason you can't simply send via SMTP directly? Do you need
the intervening client?

TJG

From python at bdurham.com  Mon Mar 22 14:10:46 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 22 Mar 2010 09:10:46 -0400
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References: 
	<4BA753D3.4020407@timgolden.me.uk>
	
Message-ID: <1269263446.440.1366064119@webmail.messagingengine.com>

Werner,

I'm not sure I understand the benefit of being locked into the
proprietary and awkward MAPI protocol?

Why can't you use industry standard SMTP to send your messages? Simpler
and more portable.

Malcolm


----- Original message -----
From: "Werner F. Bruhin" 
To: python-win32 at python.org
Date: Mon, 22 Mar 2010 13:40:52 +0100
Subject: Re: [python-win32] MAPI with win32com

Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:
> On 22/03/2010 11:22, Werner F. Bruhin wrote:
>> On 22/03/2010 12:06, Werner F. Bruhin wrote:
>>> I am trying to use MAPI to send an email using win32com, but I get the
>>> following exception.
>>>
>>> from win32com.client import Dispatch
>>> s = Dispatch("Mapi.Session")
>>> Traceback (most recent call last):
>>> File "", line 1, in
>>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
>>> 95, in Dispatch
>>> dispatch, userName =
>>> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 98, in _GetGoodDispatchAndUserName
>>> return (_GetGoodDispatch(IDispatch, clsctx), userName)
>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>> 78, in _GetGoodDispatch
>>> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
>>> pythoncom.IID_IDispatch)
>>> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>>>
>>> I first tried this having Thunderbird as my MAPI client, then installed
>>> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
>>> clients) and defined it as the MAPI client (Default Programs - MAPI),
>>> still same result.
>>>
>>> Any hints on what I am doing wrong here would be very much welcomed.
>>>
>>> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>>>
>>> Werner
>> Just came accross Tim Golden's site
>> (http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
>> and
>> tried this:
>>
>> session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")
>>
>> But I do get the same exception.
>
> Have a look at:
>
> http://kb.mozillazine.org/MAPI_Support
>
> which explains that TB (like OE) only supports "Simple MAPI". There's
> a whole confusion of terminology around this area, but I'm afraid that
> the bottom line is: the only client which really supports CDO, ie
> MAPI.Session
> is the full Outlook client. It's just about possible to use CDO without
> installing Outlook (by installing some standalone package whose name
> escapes me)
I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
  but that still only gives you access to Exchange, not to
> whatever interface TB exposes.
Clients and me using TB are fine, I support that with the simplemapi.py 
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works 
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2 
(failure).
>
> TJG

I don't want to use Outlook, but I like to provide an additional way of 
sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.


Werner

_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


From simon.king at motorola.com  Mon Mar 22 14:28:43 2010
From: simon.king at motorola.com (King Simon-NFHD78)
Date: Mon, 22 Mar 2010 13:28:43 -0000
Subject: [python-win32] MAPI with win32com
In-Reply-To: <1269263446.440.1366064119@webmail.messagingengine.com>
References: <4BA753D3.4020407@timgolden.me.uk>
	<1269263446.440.1366064119@webmail.messagingengine.com>
Message-ID: <8D20BBB55F590E42AADF592A815E861704D36448@zuk35exm65.ds.mot.com>

> -----Original Message-----
> From: python-win32-bounces+simon.king=motorola.com at python.org 
> [mailto:python-win32-bounces+simon.king=motorola.com at python.or
> g] On Behalf Of python at bdurham.com
> Sent: 22 March 2010 13:11
> To: Werner F. Bruhin; zz Python Win32 Newsgroup
> Subject: Re: [python-win32] MAPI with win32com
> 
> Werner,
> 
> I'm not sure I understand the benefit of being locked into the
> proprietary and awkward MAPI protocol?
> 
> Why can't you use industry standard SMTP to send your 
> messages? Simpler
> and more portable.
> 
> Malcolm
> 

I can't speak for Werner, but I recently had a request from a user of my
application for an 'email this project' button on the toolbar, which
would create an email message, attach the current project to it, and
then allow the user to edit the message body itself.

If I use SMTP, I need the user to enter all the SMTP configuration
details (host, username, password, TLS etc). The email won't end up in
his "Sent Items" folder. He probably won't be able to use Rich Text or
HTML in the email (of course, you could argue that that is a good thing
:-)

Unfortunately, popping up an Outlook window with the file already
attached is just a better user experience.

I would love it if there were a way to do this that worked in the user's
preferred mail client. If it were cross-platform, that would be even
better. At the moment I use 'mailto:' URLs with os.startfile on Windows,
and /usr/bin/open on the Mac. These work for opening an email with the
To, Subject and message body already filled in, but I don't think
there's any way I can attach a file like that. It also doesn't work if
the message body is too long, presumably because of command-line length
restrictions :-(

Simon

From mail at timgolden.me.uk  Mon Mar 22 14:36:52 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Mon, 22 Mar 2010 13:36:52 +0000
Subject: [python-win32] MAPI with win32com
In-Reply-To: <8D20BBB55F590E42AADF592A815E861704D36448@zuk35exm65.ds.mot.com>
References: <4BA753D3.4020407@timgolden.me.uk>	<1269263446.440.1366064119@webmail.messagingengine.com>
	<8D20BBB55F590E42AADF592A815E861704D36448@zuk35exm65.ds.mot.com>
Message-ID: <4BA77274.5010008@timgolden.me.uk>

On 22/03/2010 13:28, King Simon-NFHD78 wrote:
> I can't speak for Werner, but I recently had a request from a user of my
> application for an 'email this project' button on the toolbar, which
> would create an email message, attach the current project to it, and
> then allow the user to edit the message body itself.

That would be the kind of scenario I had envisaged. Of course, you
could run up a suitable window yourself before handing off to SMTP etc.
but then you're presenting your user with a different interface
than the one he/she is used to and/or you have to re-implement all
the different buttons (address book, spell check etc.) which is
doubtless more trouble than it's worth.

> Unfortunately, popping up an Outlook window with the file already
> attached is just a better user experience.

Agreed. (If they normally use Outlook :) )

> I would love it if there were a way to do this that worked in the user's
> preferred mail client.

There just isn't, and there isn't really the incentive, I believe
from any of the email client providers to do that. As you point out, you
can use a mailto: link with a certain amount of flexibility. You
could, I imagine [WARNING: unconsidered idea ahead] pre-drop the attachment
to dropbox or sendfile or one of these online services and then the
body of the email could just include the link to the online file.

TJG

From mdriscoll at co.marshall.ia.us  Mon Mar 22 14:48:49 2010
From: mdriscoll at co.marshall.ia.us (Mike Driscoll)
Date: Mon, 22 Mar 2010 08:48:49 -0500
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References: 
		<4BA753D3.4020407@timgolden.me.uk>
	
Message-ID: <4BA77541.3060503@co.marshall.ia.us>

Hi Werner,


> I found this:
> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en 
>
>
> At least I get past the above error, will see how far I get with this.
>  but that still only gives you access to Exchange, not to
>> whatever interface TB exposes.
> Clients and me using TB are fine, I support that with the 
> simplemapi.py (http://www.johnnypops.demon.co.uk/python/simplemapi.py) 
> and it works fine, but clients who use Outlook (e.g. Office 11) get a 
> MAPI error 2 (failure).
>>
>> TJG
>
> I don't want to use Outlook, but I like to provide an additional way 
> of sending problem reports from within my application to me (MAPI, 
> smtplib), so hoped that I could use extended MAPI stuff.
>
> I guess I just have to get my hands onto an Outlook to be able to test 
> this stuff.
>
>
> Werner
>
>

I found this recipe: http://code.activestate.com/recipes/149461-mapi-send/

Since we dropped Exchange in favor of Zimbra, I cannot test this 
solution, but maybe it will help you. By the way, is smtplib not working 
for you?

-- 
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From werner.bruhin at free.fr  Mon Mar 22 14:53:29 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 14:53:29 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: <1269263446.440.1366064119@webmail.messagingengine.com>
References: 	<4BA753D3.4020407@timgolden.me.uk>	
	<1269263446.440.1366064119@webmail.messagingengine.com>
Message-ID: 

Hi Malcolm,

On 22/03/2010 14:10, python at bdurham.com wrote:
> Werner,
>
> I'm not sure I understand the benefit of being locked into the
> proprietary and awkward MAPI protocol?
>
> Why can't you use industry standard SMTP to send your messages? Simpler
> and more portable.
I already offer the SMTP option, i.e. there are two buttons, one is 
using smtplib and the other uses MAPI.

As Simon pointed out some users don't like that a message is sent where 
they don't see what is being sent (they actually do in my case as I show 
the details of the error and on that dialog they click one of the two 
buttons).

Werner
>
> Malcolm
>
>
> ----- Original message -----
> From: "Werner F. Bruhin"
> To: python-win32 at python.org
> Date: Mon, 22 Mar 2010 13:40:52 +0100
> Subject: Re: [python-win32] MAPI with win32com
>
> Tim,
>
> Thanks for the quick response.
>
> On 22/03/2010 12:26, Tim Golden wrote:
>> On 22/03/2010 11:22, Werner F. Bruhin wrote:
>>> On 22/03/2010 12:06, Werner F. Bruhin wrote:
>>>> I am trying to use MAPI to send an email using win32com, but I get the
>>>> following exception.
>>>>
>>>> from win32com.client import Dispatch
>>>> s = Dispatch("Mapi.Session")
>>>> Traceback (most recent call last):
>>>> File "", line 1, in
>>>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
>>>> 95, in Dispatch
>>>> dispatch, userName =
>>>> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>>> 98, in _GetGoodDispatchAndUserName
>>>> return (_GetGoodDispatch(IDispatch, clsctx), userName)
>>>> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
>>>> 78, in _GetGoodDispatch
>>>> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
>>>> pythoncom.IID_IDispatch)
>>>> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>>>>
>>>> I first tried this having Thunderbird as my MAPI client, then installed
>>>> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
>>>> clients) and defined it as the MAPI client (Default Programs - MAPI),
>>>> still same result.
>>>>
>>>> Any hints on what I am doing wrong here would be very much welcomed.
>>>>
>>>> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>>>>
>>>> Werner
>>> Just came accross Tim Golden's site
>>> (http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html)
>>> and
>>> tried this:
>>>
>>> session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")
>>>
>>> But I do get the same exception.
>>
>> Have a look at:
>>
>> http://kb.mozillazine.org/MAPI_Support
>>
>> which explains that TB (like OE) only supports "Simple MAPI". There's
>> a whole confusion of terminology around this area, but I'm afraid that
>> the bottom line is: the only client which really supports CDO, ie
>> MAPI.Session
>> is the full Outlook client. It's just about possible to use CDO without
>> installing Outlook (by installing some standalone package whose name
>> escapes me)
> I found this:
> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en
>
> At least I get past the above error, will see how far I get with this.
>    but that still only gives you access to Exchange, not to
>> whatever interface TB exposes.
> Clients and me using TB are fine, I support that with the simplemapi.py
> (http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works
> fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2
> (failure).
>>
>> TJG
>
> I don't want to use Outlook, but I like to provide an additional way of
> sending problem reports from within my application to me (MAPI,
> smtplib), so hoped that I could use extended MAPI stuff.
>
> I guess I just have to get my hands onto an Outlook to be able to test
> this stuff.
>
>
> Werner
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



From werner.bruhin at free.fr  Mon Mar 22 14:58:43 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 14:58:43 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: <4BA76968.1060609@timgolden.me.uk>
References: 		<4BA753D3.4020407@timgolden.me.uk>	
	<4BA76968.1060609@timgolden.me.uk>
Message-ID: 

On 22/03/2010 13:58, Tim Golden wrote:
> [Tim Golden]
> the only client which really supports CDO, ie
>>> MAPI.Session
>>> is the full Outlook client. It's just about possible to use CDO without
>>> installing Outlook (by installing some standalone package whose name
>>> escapes me)
>
> [Werner Bruhin]
>> I found this:
>> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en
>>
>
> Yep. Think that's the one.
>
>> At least I get past the above error, will see how far I get with this.
>> but that still only gives you access to Exchange, not to
>>> whatever interface TB exposes.
>
> That's really the problem. AFAICT, CDO is *basically* an interface to
> Exchange via Outlook. You can just about get away without the Outlook
> bit by installing the download you mention (which presumably includes
> the necessary bits of Outlook without the front-end). But I don't
> honestly think you can get away without Exchange. I suspect the idea
> is that you should be able to. But I'm not aware that anyone's
> implemented it to the extent that you could. Happy to be wrong.
>
>> I don't want to use Outlook, but I like to provide an additional way of
>> sending problem reports from within my application to me (MAPI,
>> smtplib), so hoped that I could use extended MAPI stuff.
>
> Hmmm. Good luck and keep us posted.
The luck run out pretty quickly - get to the logon but then it seems to 
want an existing profile.  So, back on having to get myself a copy of 
outlook to be able to test this stuff:(.
  For my understanding, is there
> some reason you can't simply send via SMTP directly? Do you need
> the intervening client?
I do offer the SMTP option using smtplib which works great, but some 
clients don't know/like to fill in the configuration stuff needed and 
others really want to see in their email client of choice the email to 
go out and it also gives them the record/archive of what has been sent.

Werner


From werner.bruhin at free.fr  Mon Mar 22 14:55:19 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 14:55:19 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: <8D20BBB55F590E42AADF592A815E861704D36448@zuk35exm65.ds.mot.com>
References: <4BA753D3.4020407@timgolden.me.uk>	<1269263446.440.1366064119@webmail.messagingengine.com>
	<8D20BBB55F590E42AADF592A815E861704D36448@zuk35exm65.ds.mot.com>
Message-ID: 

On 22/03/2010 14:28, King Simon-NFHD78 wrote:
>> -----Original Message-----
>> From: python-win32-bounces+simon.king=motorola.com at python.org
>> [mailto:python-win32-bounces+simon.king=motorola.com at python.or
>> g] On Behalf Of python at bdurham.com
>> Sent: 22 March 2010 13:11
>> To: Werner F. Bruhin; zz Python Win32 Newsgroup
>> Subject: Re: [python-win32] MAPI with win32com
>>
>> Werner,
>>
>> I'm not sure I understand the benefit of being locked into the
>> proprietary and awkward MAPI protocol?
>>
>> Why can't you use industry standard SMTP to send your
>> messages? Simpler
>> and more portable.
>>
>> Malcolm
>>
>
> I can't speak for Werner, but I recently had a request from a user of my
> application for an 'email this project' button on the toolbar, which
> would create an email message, attach the current project to it, and
> then allow the user to edit the message body itself.
>
> If I use SMTP, I need the user to enter all the SMTP configuration
> details (host, username, password, TLS etc). The email won't end up in
> his "Sent Items" folder. He probably won't be able to use Rich Text or
> HTML in the email (of course, you could argue that that is a good thing
> :-)
>
> Unfortunately, popping up an Outlook window with the file already
> attached is just a better user experience.
>
> I would love it if there were a way to do this that worked in the user's
> preferred mail client. If it were cross-platform, that would be even
> better. At the moment I use 'mailto:' URLs with os.startfile on Windows,
> and /usr/bin/open on the Mac. These work for opening an email with the
> To, Subject and message body already filled in, but I don't think
> there's any way I can attach a file like that. It also doesn't work if
> the message body is too long, presumably because of command-line length
> restrictions :-(
I used "mailto" in the past, but I need to attach log files, therefore I 
switched to using simplemapi.py which works fine except with the newer 
versions of Outlook (I know that Outlook included with Office 11 has a 
problem, not sure about others).

Werner


From werner.bruhin at free.fr  Mon Mar 22 15:11:45 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Mon, 22 Mar 2010 15:11:45 +0100
Subject: [python-win32] MAPI with win32com
In-Reply-To: <4BA77541.3060503@co.marshall.ia.us>
References: 		<4BA753D3.4020407@timgolden.me.uk>	
	<4BA77541.3060503@co.marshall.ia.us>
Message-ID: 

Hi Mike,

On 22/03/2010 14:48, Mike Driscoll wrote:
> Hi Werner,
>
> 
>> I found this:
>> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en
>>
>>
>> At least I get past the above error, will see how far I get with this.
>>  but that still only gives you access to Exchange, not to
>>> whatever interface TB exposes.
>> Clients and me using TB are fine, I support that with the
>> simplemapi.py (http://www.johnnypops.demon.co.uk/python/simplemapi.py)
>> and it works fine, but clients who use Outlook (e.g. Office 11) get a
>> MAPI error 2 (failure).
>>>
>>> TJG
>>
>> I don't want to use Outlook, but I like to provide an additional way
>> of sending problem reports from within my application to me (MAPI,
>> smtplib), so hoped that I could use extended MAPI stuff.
>>
>> I guess I just have to get my hands onto an Outlook to be able to test
>> this stuff.
>>
>>
>> Werner
>>
>>
>
> I found this recipe: http://code.activestate.com/recipes/149461-mapi-send/
That is basically the same thing as I tried, it needs more then the 
download I mentioned in the other post.
>
> Since we dropped Exchange in favor of Zimbra, I cannot test this
> solution, but maybe it will help you. By the way, is smtplib not working
> for you?
smtplib is working great, but as mentioned before some users prefer 
using their email client (i.e. see what is going out, have an 
archive/copy of it ....) and MAPI solution if it works (which it does 
with all kind of software (Thunderbird, older outlook version ....) it 
requires no setup at all in my software.

Werner


From niki at vintech.bg  Mon Mar 22 15:10:24 2010
From: niki at vintech.bg (niki)
Date: Mon, 22 Mar 2010 16:10:24 +0200
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References: 
Message-ID: <4BA77A50.2010308@vintech.bg>

try this (simple mapi with ctypes):

http://aspn.activestate.com/ASPN/Mail/Message/ctypes-users/2095322

HTH
Niki

From nihil at blue.dyn-o-saur.com  Mon Mar 22 15:43:11 2010
From: nihil at blue.dyn-o-saur.com (nihil at blue.dyn-o-saur.com)
Date: Mon, 22 Mar 2010 15:43:11 +0100
Subject: [python-win32] cde Outlook 2007 rules and python
In-Reply-To: <20100303105841.09fb63ea@silvertop>
References: <20100303105841.09fb63ea@silvertop>
Message-ID: <20100322154311.7a8048a0@silvertop>

Is really no one out there who could point me in the right direction?


On Wed, 3 Mar 2010 10:58:41 +0100
 wrote:

> I try to translate this vbs script to python.
> http://www.outlookcode.com/threads.aspx?forumid=2&messageid=29505
> The purpose of this script is to automatically create an rule in Outlook to sort incoming messages.
> It is possible to do this in Outlook 2007 and the vbs file works. The SPAM folder is writable so thats not the problem.
> 
> This code works but only creates an rule that forwards the messages to an another mail address:
> 
> #!/bin/env python
> # -*- coding: UTF-8 -*-
> import codecs
> import tempfile
> import win32api
> import win32com.client
> import sys,os
> constants = win32com.client.constants
> application = win32com.client.Dispatch("Outlook.Application")
> rules = application.Session.DefaultStore.GetRules()
> _folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
> _spamfolder = _folder.Folders["Spam"]
> _rule = rules.Create("SPAM",constants.olRuleReceive)
> _condition = _rule.Conditions.MessageHeader
> _condition.Text = ["X-Spam-Status: Yes"]
> _condition.Enabled = True
> _action = _rule.Actions.Forward
> _action.Recipients.Add("mail at mail.com")
> _action.Enabled = True
> _rule.Enabled = True
> rules.Save()
> 
> This is the code i need but it is not working:
> 
> #!/bin/env python
> # -*- coding: UTF-8 -*-
> import codecs
> import tempfile
> import win32api
> import win32com.client
> import sys,os
> 
> constants = win32com.client.constants
> application = win32com.client.Dispatch("Outlook.Application")
> rules = application.Session.DefaultStore.GetRules()
> _folder = application.Session.GetDefaultFolder(constants.olFolderInbox)
> _spamfolder = _folder.Folders["Spam"]
> _rule = rules.Create("SPAM",constants.olRuleReceive)
> _condition = _rule.Conditions.MessageHeader
> _condition.Text = ["X-Spam-Status: Yes"]
> _condition.Enabled = True
> _action = _rule.Actions.MoveToFolder
> _action.Folder = _spamfolder
> _spamfolder2 = _spamfolder
> print _spamfolder, _spamfolder2, _action.Folder
> _action.Enabled = True
> _rule.Enabled = True
> rules.Save()
> 
> The problem is that even after the assignment and in my print _action.Folder contains None but
> _spamfolder and _spamfolder2 both contain an reference to the Library.MAPIFolder. 
> Could anyone please enlighten me. Why is _action.Folder empty?
> It seems the vbs guys have the same problem but they use "Set objActionMoveToFolder.Folder = objFolderJunk"
> instead of "objActionMoveToFolder.Folder = objFolderJunk" 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32

From python at bdurham.com  Mon Mar 22 16:48:50 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 22 Mar 2010 11:48:50 -0400
Subject: [python-win32] MAPI with win32com
In-Reply-To: 
References:  
	<4BA753D3.4020407@timgolden.me.uk>
	<4BA76968.1060609@timgolden.me.uk>
	
Message-ID: <1269272930.28616.1366083387@webmail.messagingengine.com>

Werner,

> I do offer the SMTP option using smtplib which works great, but some 
clients don't know/like to fill in the configuration stuff needed and 
others really want to see in their email client of choice the email to 
go out and it also gives them the record/archive of what has been sent.

We solved the configuration issues by posting to a PHP form that in turn
sends out our emails.

We solved the record/archive concern by bcc-ing the customer's email
with a copy of what was being sent.

Malcolm

From europe_travel at hotmail.com  Mon Mar 22 22:22:40 2010
From: europe_travel at hotmail.com (travel europe)
Date: Mon, 22 Mar 2010 17:22:40 -0400
Subject: [python-win32] I/O error
Message-ID: 


Hello,

 

I am getting the following error "ValueError: I/O operation on closed file" when running a module to pull data from the Windows registry.

 

The code is as follows: 

 



import csv
from winsys import registry

 

key = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
fields = ["DisplayName", "Comments", "InstallDate"] # add to as required

 

uninstall = registry.registry (key)
with open ("installed.txt", "wb") as f:
 writer = csv.writer (f)
 writer.writerow (fields)
for subkey in uninstall:
 info = dict (subkey.values ())
 writer.writerow ([info.get (field) for field in fields])


 



The error message is as follows:

Traceback (most recent call last):
  File "C:\Python26\tim.py", line 13, in 
    writer.writerow ([info.get (field) for field in fields])
ValueError: I/O operation on closed file



 

Any ideas on how to rectify this problem? Thanks!
 		 	   		  
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From planders at gmail.com  Mon Mar 22 22:48:21 2010
From: planders at gmail.com (Preston Landers)
Date: Mon, 22 Mar 2010 16:48:21 -0500
Subject: [python-win32] I/O error
In-Reply-To: 
References: 
Message-ID: <796c415c1003221448n3bb2eb15odc41af99123f46a1@mail.gmail.com>

Your indentation is a bit hard to read in this format, but it looks like the
"for subkey in uninstall" block needs to be inside the "with open" block.
When the "with open" block exits, the file is no longer open.  Thus writing
to a closed file will fail.


On Mon, Mar 22, 2010 at 4:22 PM, travel europe wrote:

>  Hello,
>
> I am getting the following error "ValueError: I/O operation on closed file"
> when running a module to pull data from the Windows registry.
>
> The code is as follows:
>
> 
> import csv
> from winsys import registry
>
> key =
> r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
> fields = ["DisplayName", "Comments", "InstallDate"] # add to as required
>
> uninstall = registry.registry (key)
> with open ("installed.txt", "wb") as f:
>  writer = csv.writer (f)
>  writer.writerow (fields)
> for subkey in uninstall:
>  info = dict (subkey.values ())
>  writer.writerow ([info.get (field) for field in fields])
> 
>
> 
> The error message is as follows:
> Traceback (most recent call last):
>   File "C:\Python26\tim.py", line 13, in 
>     writer.writerow ([info.get (field) for field in fields])
> ValueError: I/O operation on closed file
> 
>
> Any ideas on how to rectify this problem? Thanks!
>
> ------------------------------
> Hotmail is redefining busy with tools for the New Busy. Get more from your
> inbox. Sign up now.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Mon Mar 22 23:08:23 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 22 Mar 2010 18:08:23 -0400
Subject: [python-win32] Win API call to display a BMP/PNG file as a splash
 screen for a console app?
Message-ID: <1269295703.32357.1366163877@webmail.messagingengine.com>

Is there a Windows API call I can use to display a BMP or a PNG
file in a window centered on a user's display? This function
would be called from a console app to display a splash screen.

Motivation: I would like some of our customer facing Python
console utilities to display a splash screen. I don't need the
complexity of a full GUI framework like wxPython or pyQT and
hopefully I can avoid the need to use a full library like PIL.

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From cappy2112 at gmail.com  Mon Mar 22 23:47:47 2010
From: cappy2112 at gmail.com (Tony Cappellini)
Date: Mon, 22 Mar 2010 15:47:47 -0700
Subject: [python-win32] Win API call to display a BMP/PNG file as a
	splash screen for a console app?
Message-ID: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com>

From: python at bdurham.com
To: "zz Python Win32 Newsgroup" 
Subject: [python-win32] Win API call to display a BMP/PNG file as a
       splash screen for a console app?
Message-ID: <1269295703.32357.1366163877 at webmail.messagingengine.com>
Content-Type: text/plain; charset="us-ascii"

>>Is there a Windows API call I can use to display a BMP or a PNG
>>file in a window centered on a user's display? This function
>>would be called from a console app to display a splash screen.

I don't know, but I suspect not.
>>complexity of a full GUI framework like wxPython or pyQT and
To do this in wxPython is approximately 10 lines of code, maybe 20 at the
most.
Actually- the # of lines to do this in wxPython is less than your original
email.


class SketchApp(wx.App):

    def OnInit(self):
        bmp = wx.Image("splash.png").ConvertToBitmap()
        wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
                1000, None, -1)
        wx.Yield()

        frame = SketchFrame(None)
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

if __name__ == '__main__':
    app = SketchApp(False)
    app.MainLoop()


This is barebones, taken from wxPython In Action- ideally you should have
some minimal exception handling
to make your app more robust.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at bdurham.com  Tue Mar 23 00:02:57 2010
From: python at bdurham.com (python at bdurham.com)
Date: Mon, 22 Mar 2010 19:02:57 -0400
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app?
In-Reply-To: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com>
References: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com>
Message-ID: <1269298977.8572.1366172451@webmail.messagingengine.com>

Hi Tony,

Thanks for the wxPython code. My reason for wanting to avoid
wxPython (and pyQt) is that I don't want to ship the wxPython
framework just to display a splash screen. I believe this might
triple the size of my PY2EXE generated executables - not a
worthwhile tradeoff for a cosmetic feature like a splash screen.

Regards,
Malcolm

----- Original message -----
From: "Tony Cappellini" 
To: python-win32 at python.org
Cc: python at bdurham.com
Date: Mon, 22 Mar 2010 15:47:47 -0700
Subject: Re:Win API call to display a BMP/PNG file as a splash
screen for a console app?
From: [1]python at bdurham.com
To: "zz Python Win32 Newsgroup" <[2]python-win32 at python.org>
Subject: [python-win32] Win API call to display a BMP/PNG file as
a
       splash screen for a console app?
Message-ID:
<[3]1269295703.32357.1366163877 at webmail.messagingengine.com>
Content-Type: text/plain; charset="us-ascii"
>>Is there a Windows API call I can use to display a BMP or a PNG
>>file in a window centered on a user's display? This function
>>would be called from a console app to display a splash screen.
I don't know, but I suspect not.
>>complexity of a full GUI framework like wxPython or pyQT and
To do this in wxPython is approximately 10 lines of code, maybe
20 at the most.
Actually- the # of lines to do this in wxPython is less than your
original email.
class SketchApp(wx.App):
    def OnInit(self):
        bmp = wx.Image("splash.png").ConvertToBitmap()
        wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN |
wx.SPLASH_TIMEOUT,
                1000, None, -1)
        wx.Yield()
        frame = SketchFrame(None)
        frame.Show(True)
        self.SetTopWindow(frame)
        return True
if __name__ == '__main__':
    app = SketchApp(False)
    app.MainLoop()
This is barebones, taken from wxPython In Action- ideally you
should have some minimal exception handling
to make your app more robust.

References

1. mailto:python at bdurham.com
2. mailto:python-win32 at python.org
3. mailto:1269295703.32357.1366163877 at webmail.messagingengine.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Tue Mar 23 00:49:50 2010
From: timr at probo.com (Tim Roberts)
Date: Mon, 22 Mar 2010 16:49:50 -0700
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app?
In-Reply-To: <1269298977.8572.1366172451@webmail.messagingengine.com>
References: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com>
	<1269298977.8572.1366172451@webmail.messagingengine.com>
Message-ID: <4BA8021E.4000808@probo.com>

python at bdurham.com wrote:
>  
> Thanks for the wxPython code. My reason for wanting to avoid wxPython
> (and pyQt) is that I don't want to ship the wxPython framework just to
> display a splash screen. I believe this might triple the size of my
> PY2EXE generated executables - not a worthwhile tradeoff for a
> cosmetic feature like a splash screen.

Well, you're going to need a framework of some kind.  It's possible you
could make it smaller by using Tkinter, but displaying a bitmap requires
creating a window, and creating a window means you have to have a
message dispatch loop and window procedure, just like a full GUI
application.

There's really no other way.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From Andrew.MacIntyre at acma.gov.au  Tue Mar 23 01:36:19 2010
From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre)
Date: Tue, 23 Mar 2010 11:36:19 +1100
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app? [SEC=PERSONAL]
In-Reply-To: <4BA8021E.4000808@probo.com>
References: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com><1269298977.8572.1366172451@webmail.messagingengine.com>
	<4BA8021E.4000808@probo.com>
Message-ID: <7B01D7143C4AD54899EA079D4557562AFEF9A2@ACT01EXC02.internal.govt>

Is it possible to draw directly to the desktop?  I vaguely recall reading somewhere that that is how some splash screens are done to avoid the overhead of a window...

-------------------------> "These thoughts are mine alone!" <---------
Andrew MacIntyre?????????? Operations Branch
tel:?? +61 2 6219 5356???? Communications Infrastructure Division
fax:?? +61 2 6253 3277???? Australian Communications & Media Authority
email: andrew.macintyre at acma.gov.au??????????? http://www.acma.gov.au/


> -----Original Message-----
> From: python-win32-bounces+andrew.macintyre=acma.gov.au at python.org
> [mailto:python-win32-
> bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Tim
> Roberts
> Sent: Tuesday, 23 March 2010 10:50 AM
> To: Python Win32 Newsgroup
> Subject: Re: [python-win32] Win API call to display a BMP/PNG file as a splash
> screen for a console app?
> 
> python at bdurham.com wrote:
> >
> > Thanks for the wxPython code. My reason for wanting to avoid wxPython
> > (and pyQt) is that I don't want to ship the wxPython framework just to
> > display a splash screen. I believe this might triple the size of my
> > PY2EXE generated executables - not a worthwhile tradeoff for a
> > cosmetic feature like a splash screen.
> 
> Well, you're going to need a framework of some kind.  It's possible you
> could make it smaller by using Tkinter, but displaying a bitmap requires
> creating a window, and creating a window means you have to have a
> message dispatch loop and window procedure, just like a full GUI
> application.
> 
> There's really no other way.
> 
> --
> 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

If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents.
 
Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA.

From timr at probo.com  Tue Mar 23 02:09:11 2010
From: timr at probo.com (Tim Roberts)
Date: Mon, 22 Mar 2010 18:09:11 -0700
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app?
In-Reply-To: <7B01D7143C4AD54899EA079D4557562AFEF9A2@ACT01EXC02.internal.govt>
References: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com><1269298977.8572.1366172451@webmail.messagingengine.com>	<4BA8021E.4000808@probo.com>
	<7B01D7143C4AD54899EA079D4557562AFEF9A2@ACT01EXC02.internal.govt>
Message-ID: <4BA814B7.9000602@probo.com>

Andrew MacIntyre wrote:
> Is it possible to draw directly to the desktop?  I vaguely recall reading somewhere that that is how some splash screens are done to avoid the overhead of a window...
>   

Yes, it's possible, but that's not the right way to do a splash screen,
because there's no good way to force the regions you overwrite to
refresh themselves.

It IS possible to do a simple GUI window using pywin32 directly.  It
isn't pretty (it's like coding to the SDK directly), but I suspect it
would do what you need.  Check in your win32\Demos directory for
win32gui_demo.py and see where that gets you.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From mail at timgolden.me.uk  Tue Mar 23 10:45:56 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Tue, 23 Mar 2010 09:45:56 +0000
Subject: [python-win32] I/O error
In-Reply-To: 
References: 
Message-ID: <4BA88DD4.2090604@timgolden.me.uk>

On 22/03/2010 21:22, travel europe wrote:
>
> I am getting the following error "ValueError: I/O operation on closed file"
>when running a module to pull data from the Windows registry.
> 
>
> import csv
> from winsys import registry
>
>
>
> key = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
> fields = ["DisplayName", "Comments", "InstallDate"] # add to as required
>
> uninstall = registry.registry (key)
> with open ("installed.txt", "wb") as f:
>   writer = csv.writer (f)
>   writer.writerow (fields)
> for subkey in uninstall:
>   info = dict (subkey.values ())
>   writer.writerow ([info.get (field) for field in fields])
> 

The indentation's wrong. The line starting "for subkey in..."
should be indented to the same level as the line above, placing
it within context of the "with open (...):" from a few lines
above. I've just checked the email I sent with that in, and it
looks ok (on my email client) so I can only imagine that
one of the various email clients / servers between us has
munged the indentation.

TJG

From mdriscoll at co.marshall.ia.us  Tue Mar 23 14:29:55 2010
From: mdriscoll at co.marshall.ia.us (Mike Driscoll)
Date: Tue, 23 Mar 2010 08:29:55 -0500
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app?
In-Reply-To: <1269295703.32357.1366163877@webmail.messagingengine.com>
References: <1269295703.32357.1366163877@webmail.messagingengine.com>
Message-ID: <4BA8C253.3040901@co.marshall.ia.us>

Hi Malcolm

On 1:59 PM, python at bdurham.com wrote:
> Is there a Windows API call I can use to display a BMP or a PNG file 
> in a window centered on a user's display? This function would be 
> called from a console app to display a splash screen.
> Motivation: I would like some of our customer facing Python console 
> utilities to display a splash screen. I don't need the complexity of a 
> full GUI framework like wxPython or pyQT and hopefully I can avoid the 
> need to use a full library like PIL.
> Thank you,
> Malcolm

There are ways to significantly reduce the wxPython footprint in your 
py2exe binary. Ask on the mailing list. Steven Sproat was talking about 
some methods last month and I think he said he had an exe that was 5 or 
7 MB when he was done.



-- 
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From phungtvuong at hotmail.com  Tue Mar 23 15:52:48 2010
From: phungtvuong at hotmail.com (Phung Thuy Vuong)
Date: Tue, 23 Mar 2010 14:52:48 +0000
Subject: [python-win32] (no subject)
Message-ID: 


Hello!

  Can anyone give me some hint please? I'm trying to make a log file which keep track of a specific application. For example, I need to punch the time et date where an application, such as Firefox, is opened and when it's closed. I also need to detect when the application goes to idle and when it's re-activate again. (I hope my question it's clear enough.) Thank you!




(\ (\ 

(?-?) 

(")(") P

 		 	   		  
_________________________________________________________________
Live connected with Messenger on your phone
http://go.microsoft.com/?linkid=9712958
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From leahy_rich at hotmail.com  Tue Mar 23 17:01:31 2010
From: leahy_rich at hotmail.com (Richard Leahy)
Date: Tue, 23 Mar 2010 18:01:31 +0200
Subject: [python-win32] Help calling a windows function in user32
Message-ID: 


Hey guys im having a little difficulty sending data to my C application through python. I have my test.exe that has a input box in a window. I am trying to populate the edit box with input i send to it through python. This is a far as I have been able to get so far. any help would be much appreciated. 

import os,sys,subprocess,win32con

from subprocess import *
from os import *
from ctypes import *
from ctypes.wintypes import *

appPath=r'"C:\Dev-Cpp\windowsapp.exe"'

p = subprocess.Popen(appPath)

user32 = windll.user32

user32.SetDlgItemTextA(need to put the hwnd handle here i think??? not sure how this is done, 1, "some text") // this is a user32 function that sends text to my inputbox. 

C code below for reference

 CreateWindow( "edit", "",
          WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
          0, 0, 300, 20, hwnd, (HMENU)1, hThisInstance, NULL);

SetDlgItemTextA(hwnd, 1, "some text")


 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vernondcole at gmail.com  Tue Mar 23 17:06:21 2010
From: vernondcole at gmail.com (Vernon Cole)
Date: Tue, 23 Mar 2010 10:06:21 -0600
Subject: [python-win32] Win API call to display a BMP/PNG file as a
	splash screen for a console app?
In-Reply-To: <4BA8C253.3040901@co.marshall.ia.us>
References: <1269295703.32357.1366163877@webmail.messagingengine.com> 
	<4BA8C253.3040901@co.marshall.ia.us>
Message-ID: 

Malcolm:

   I used to have exactly what you need.  Unfortunately,  when I checked
just now, I find that I failed to "lift" a copy of the source code when I
left the place where I wrote it. "It" was a command line utility which
accepted as arguments the name of a .jpg file and the number of seconds to
display it before exiting. As it happens, mine was written in wxPython.  Any
of the previous suggestions would be a good start.  The point is that you
have your console program run the  splash as a separate (non-console)
program -- using a "Run and don't wait" OS call -- so that the GUI stuff is
not complicating your console code.
  My application displayed a cartoon of a human skeleton looking at a
computer display which said "Please Wait." It was placed at the beginning of
a long and complicated automatic login script for a dedicated workstation
and displayed for 20 seconds.  It completely eliminated anxious users trying
to poke at the workstation before it was ready.
  Yes, the extra .exe and the .jpg will add a little weight to your
distribution, but storage is cheap these days, and user satisfaction is
worth it, IMHO.
--
Vernon

>
> On 1:59 PM, python at bdurham.com wrote:
>
>  Is there a Windows API call I can use to display a BMP or a PNG file in a
> window centered on a user's display? This function would be called from a
> console app to display a splash screen.
>
> Motivation: I would like some of our customer facing Python console
> utilities to display a splash screen. I don't need the complexity of a full
> GUI framework like wxPython or pyQT and hopefully I can avoid the need to
> use a full library like PIL.
>
> Thank you,
> Malcolm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Tue Mar 23 21:54:24 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 23 Mar 2010 12:54:24 -0800
Subject: [python-win32] Help calling a windows function in user32
Message-ID: <201003232054.o2NKsOp03569@probo.probo.com>

You wrote:
>
>Hey guys im having a little difficulty sending data to my C application
>through python. I have my test.exe that has a input box in a window. I 
>am trying to populate the edit box with input i send to it through
>python. This is a far as I have been able to get so far. any help 
>would be much appreciated. 
>
>import os,sys,subprocess,win32con
>
>from subprocess import *
>from os import *

You don't need those two lines.  In fact, they are a bad idea.  Just say "subprocess.Popen" (which is what you are actually doing).

>from ctypes import *
>from ctypes.wintypes import *
>
>appPath=r'"C:\Dev-Cpp\windowsapp.exe"'

You don't need two sets of quotes here.  The file name does not actually have quotes.

>p = subprocess.Popen(appPath)
>
>user32 = windll.user32
>
>user32.SetDlgItemTextA(need to put the hwnd handle here i think??? not sure how this is done, 1, "some text") // this is a user32 function that sends text to my inputbox. 

Yes, you need to find the window handle of your dialog.  You can use the FindWindow API to do that.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

From greg.ewing at canterbury.ac.nz  Tue Mar 23 22:55:13 2010
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Wed, 24 Mar 2010 09:55:13 +1200
Subject: [python-win32] Win API call to display a BMP/PNG file as a
 splash screen for a console app?
In-Reply-To: <4BA814B7.9000602@probo.com>
References: <8249c4ac1003221547i7308dc4cx8b8866e56e559a81@mail.gmail.com>
	<1269298977.8572.1366172451@webmail.messagingengine.com>
	<4BA8021E.4000808@probo.com>
	<7B01D7143C4AD54899EA079D4557562AFEF9A2@ACT01EXC02.internal.govt>
	<4BA814B7.9000602@probo.com>
Message-ID: <4BA938C1.2050700@canterbury.ac.nz>

>Andrew MacIntyre wrote:
>>Is it possible to draw directly to the desktop?  I vaguely recall reading somewhere that that is how some splash screens are done to avoid the overhead of a window...

Somehow I doubt that. I have a hard time imagining that
displaying a splash screen could be a serious performance
bottleneck! Not the window-creation part of it, anyway.

Although if by "overhead" you mean that some programmer
was too lazy to write the necessary code, I could
probably believe that...

-- 
Greg

From timr at probo.com  Tue Mar 23 22:57:36 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 23 Mar 2010 14:57:36 -0700
Subject: [python-win32] Help calling a windows function in user32
In-Reply-To: 
References: <201003232054.o2NKsOp03569@probo.probo.com>
	
Message-ID: <4BA93950.2050306@probo.com>

Richard Leahy wrote:
> Hi, thank you for your reply. I have tried the FindWindow which works
> great how ever It cant find the window i am after.
> ...
> test = windll.user32.FindWindowA(None, "Windows App") // find the
> first window perfectly
>
> if not test:
>     print "[*] cant find window"
>
> test = windll.user32.FindWindowA("edit", None) // cant find the edit
> box window. any ideas?

You don't NEED this second call.  The number you get from the first call
is the handle to the dialog.  Just pass that to SetDlgItemText along
with the control ID (1).

The reason is fails is that FindWindow only returns top-level windows,
not child windows.  It IS possible to use FindWindowEx to search child
windows, but you don't want that.  What you NEED is the top-level dialog
(which you have) and the control ID (which you also have).

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From timr at probo.com  Tue Mar 23 23:11:36 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 23 Mar 2010 15:11:36 -0700
Subject: [python-win32] (no subject)
In-Reply-To: 
References: 
Message-ID: <4BA93C98.1050907@probo.com>

Phung Thuy Vuong wrote:
>
>   Can anyone give me some hint please? I'm trying to make a log file
> which keep track of a specific application. For example, I need to
> punch the time et date where an application, such as Firefox, is
> opened and when it's closed. I also need to detect when the
> application goes to idle and when it's re-activate again. (I hope my
> question it's clear enough.) Thank you!

What you ask is complicated.  You need to install a "window hook" to
intercept the activate and deactivate messages going to all of the
top-level windows in the system.

The reason it's complicated is because of the way window hooks work. 
Your code must live in a DLL, and that DLL is injected into every
process in the system.  Thus, such a thing cannot be written in Python.

You could certainly have a simple hook DLL that reports statistics back
to some Python server "mother ship".  There are several web articles on
writing window hooks.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From timr at probo.com  Wed Mar 24 00:02:44 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 23 Mar 2010 16:02:44 -0700
Subject: [python-win32] (no subject)
In-Reply-To: <2d00d7fe1003231530q19c23dc8n655322f62be9b34e@mail.gmail.com>
References: 	
	<4BA93C98.1050907@probo.com>
	<2d00d7fe1003231530q19c23dc8n655322f62be9b34e@mail.gmail.com>
Message-ID: <4BA94894.7030608@probo.com>

David Hutto wrote:
> On Tue, Mar 23, 2010 at 6:11 PM, Tim Roberts  wrote:
>   
>> Phung Thuy Vuong wrote:
>>     
>>>   Can anyone give me some hint please? I'm trying to make a log file
>>> which keep track of a specific application. For example, I need to
>>> punch the time et date where an application, such as Firefox, is
>>> opened and when it's closed. I also need to detect when the
>>> application goes to idle and when it's re-activate again. (I hope my
>>> question it's clear enough.) Thank you!
>>>       
>> What you ask is complicated.  You need to install a "window hook" to
>> intercept the activate and deactivate messages going to all of the
>> top-level windows in the system. ...
>>     
>
> I'm new so excuse the ignorance, and the simplicity of the idea, if
> it is, but couldn't you just monitor the process id's and then match
> the running/sleep/active usage instead of the dll's. You would only
> have to monitor the single system monitor. If I'm thinking about this
> correctly.
>   

Perhaps so -- the original poster will have to judge whether that's
sufficient.  On Linux, I think you could do that rather easily.  On
Windows, the sentence "just monitor the process ids" is not as trivial
as it sounds.  It's possible to use ToolHelp to run through the list of
processes, and the list of threads for those processes, then use
GetThreadTimes to get the CPU time.  That doesn't necessarily tell you
when an application gains and loses focus.  It all depends on what the
OP really needs to know.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From timr at probo.com  Wed Mar 24 00:08:14 2010
From: timr at probo.com (Tim Roberts)
Date: Tue, 23 Mar 2010 16:08:14 -0700
Subject: [python-win32] Help calling a windows function in user32
In-Reply-To: 
References: <201003232054.o2NKsOp03569@probo.probo.com>,
	,
	<4BA93950.2050306@probo.com>
	
Message-ID: <4BA949DE.1080604@probo.com>

Richard Leahy wrote:
> So basically your saying that if i just use this
>
> test = windll.user32.FindWindowA(None, "Windows App")
>
> if not test:
>     print "[*] cant find window"
>
> print test // which returns 7471154 the handle
>
> windll.user32.SetDlgItemTextA(test,1,"test")
>
> this doesn't seem to set my edit box with the value of test sorry if i
> am not making sense and thank you for your help.

It shouldn't be any more complicated than that.  I was under the
impression that SetDlgItemText marshaled the string pointer so it would
work between processes, but perhaps I am mistaken.  SetDlgItemInt should
CERTAINLY work -- perhaps you should try that first.

BTW, you don't need to use ctypes for this.  FindWindow, SetDlgItemText
and SetDlgItemInt are all exported from win32gui.

    import win32gui
    t = win32gui.FindWindow( None, "Windows App" )
    win32gui.SetDlgItemInt( t, 1, 37 )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From info at apli-agipa.com  Wed Mar 24 08:41:16 2010
From: info at apli-agipa.com (Sylvain Fauveau (apli-agipa))
Date: Wed, 24 Mar 2010 08:41:16 +0100
Subject: [python-win32] Win API call to display a BMP/PNG file as
 a	splash screen for a console app?
In-Reply-To: 
References: <1269295703.32357.1366163877@webmail.messagingengine.com>
	<4BA8C253.3040901@co.marshall.ia.us>
	
Message-ID: <4BA9C21C.8030405@apli-agipa.com>

Not tested, but :

Google: splash screen tkinter

=> http://code.activestate.com/recipes/534124-elegant-tkinter-splash-screen/

tkinter is included with python.

Vernon Cole a ?crit :
> Malcolm:
>
> I used to have exactly what you need. Unfortunately, when I checked 
> just now, I find that I failed to "lift" a copy of the source code 
> when I left the place where I wrote it. "It" was a command line 
> utility which accepted as arguments the name of a .jpg file and the 
> number of seconds to display it before exiting. As it happens, mine 
> was written in wxPython. Any of the previous suggestions would be a 
> good start. The point is that you have your console program run the 
> splash as a separate (non-console) program -- using a "Run and don't 
> wait" OS call -- so that the GUI stuff is not complicating your 
> console code.
> My application displayed a cartoon of a human skeleton looking at a 
> computer display which said "Please Wait." It was placed at the 
> beginning of a long and complicated automatic login script for a 
> dedicated workstation and displayed for 20 seconds. It completely 
> eliminated anxious users trying to poke at the workstation before it 
> was ready.
> Yes, the extra .exe and the .jpg will add a little weight to your 
> distribution, but storage is cheap these days, and user satisfaction 
> is worth it, IMHO.
> --
> Vernon
>
>
>     On 1:59 PM, python at bdurham.com  wrote:
>>     Is there a Windows API call I can use to display a BMP or a PNG
>>     file in a window centered on a user's display? This function
>>     would be called from a console app to display a splash screen.
>>     Motivation: I would like some of our customer facing Python
>>     console utilities to display a splash screen. I don't need the
>>     complexity of a full GUI framework like wxPython or pyQT and
>>     hopefully I can avoid the need to use a full library like PIL.
>>     Thank you,
>>     Malcolm
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>   


-- 

*Sylvain Fauveau*
Apli-Agipa
T?l: 03-26-58-18-28
Logo d'APLI-AGIPA
--Pensez ? la nature et n?imprimez cet email que si n?cessaire--

-------------- next part --------------
A non-text attachment was scrubbed...
Name: info.vcf
Type: text/x-vcard
Size: 176 bytes
Desc: not available
URL: 

From leahy_rich at hotmail.com  Wed Mar 24 14:45:19 2010
From: leahy_rich at hotmail.com (Richard Leahy)
Date: Wed, 24 Mar 2010 15:45:19 +0200
Subject: [python-win32] help writing text to a windows edit control
Message-ID: 


Hi guys. I have been struggling with writing a string into an edit control using the windows api calls. What I have noticed is that if i write text to a different control like a button control for example it works. Is there something in place like a security thing that prevents writing to an edit control? code below. thanks. I have put my C code at the very bottom for reference. 

import os,sys,subprocess,time
from subprocess import *
from os import *
from ctypes import *
from ctypes.wintypes import *

PROCESS_ALL_ACCESS =     ( 0x000F0000 | 0x00100000 | 0xFFF )
kernel32 = windll.kernel32
pid      = sys.argv[1]

h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) )

if not h_process:
    print "[*] Couldn't acquire a handle to PID: %s" % pid
    sys.exit(0)

# parent window
window_handle = windll.user32.FindWindowA(None, "Windows App")

if not window_handle:
    print "[*] cant find window"
    sys.exit(0)

my_string = "testing"

windll.user32.SetDlgItemTextA(window_handle,1, my_string)



C CODE

    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
           


 CreateWindow( "EDIT", "",
          WS_VISIBLE|WS_CHILD,
          0, 0, 300, 50, hwnd, (HMENU)1, hThisInstance, NULL);

    

CreateWindow( "BUTTON", "",
 WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
 0, 50, 100, 30, hwnd, (HMENU)2, hThisInstance, NULL);
 		 	   		  
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bob at bobcowdery.plus.com  Mon Mar 22 16:32:22 2010
From: bob at bobcowdery.plus.com (Bob Cowdery)
Date: Mon, 22 Mar 2010 15:32:22 +0000
Subject: [python-win32] Installer crashes on embedded system.
Message-ID: <4BA78D86.9010406@bobcowdery.plus.com>

Hi

I've been using the extensions on many machines with no issues. I am now
trying to install on an XP embedded touch screen machine and the
installer crashes. I know it's virtually no information, but thats all I
get. The system is Windows Embedded Standard with Service Pack 3 and
made by Sansung. I'm installing pywin32-214.win32-py2.6.exe and it just
throws up the standard 'has encountered a problem' dialog. Python 2.6.4
installed without problems. Does anyone have any ideas?

Regards
Bob

From timr at probo.com  Wed Mar 24 23:43:03 2010
From: timr at probo.com (Tim Roberts)
Date: Wed, 24 Mar 2010 15:43:03 -0700
Subject: [python-win32] help writing text to a windows edit control
In-Reply-To: 
References: 
Message-ID: <4BAA9577.6040803@probo.com>

Richard Leahy wrote:
> Hi guys. I have been struggling with writing a string into an edit
> control using the windows api calls. What I have noticed is that if i
> write text to a different control like a button control for example it
> works. Is there something in place like a security thing that prevents
> writing to an edit control? code below. thanks. I have put my C code
> at the very bottom for reference.

There should be no difference.  If you can change the label on a button,
you should be able to change the text in an edit control, even if it is
read only.  It's the same window message (WM_SETTEXT).  You should not
need to open the process handle; Windows IPC should handle that.

Do you have the Windows SDK or Visual Studio?  The "spyxx" tool should
let you look at the window tree structure of the application, to make
sure the edit control is really where you think it is.

Is this a simple test application you could send me?


> import os,sys,subprocess,time
> from subprocess import *
> from os import *

You really need to get out of that habit.  What "from os import *" does
is this:
    import os
    abort = os.abort
    access = os.access
    chdir = os.chdir
    chmod = os.chmod
    ...
and so on, until every name from "os" is copied into your module.  You
EITHER do
    import os
OR you do
    from os import *
and the latter is virtually always a bad idea, because it fills your
namespace with all those foreign names, most of which you will never use.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From pacopyc at gmail.com  Thu Mar 25 00:29:16 2010
From: pacopyc at gmail.com (pacopyc pacopyc)
Date: Thu, 25 Mar 2010 00:29:16 +0100
Subject: [python-win32] administration script
Message-ID: 

Hello, I'm a NT domain system administrator and I'd like develop simple
administration scripts with Python. I'm not expert and then I need some
examples to understand. Initially I must listing all LAN's PC, for each PC
get users and password, change password local administrator, run shutdown
machines after 21:00 (also printer), get listing installed software, change
PC's name. Can you help me?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Thu Mar 25 00:58:21 2010
From: timr at probo.com (Tim Roberts)
Date: Wed, 24 Mar 2010 16:58:21 -0700
Subject: [python-win32] administration script
In-Reply-To: 
References: 
Message-ID: <4BAAA71D.7090407@probo.com>

pacopyc pacopyc wrote:
> Hello, I'm a NT domain system administrator and I'd like develop
> simple administration scripts with Python. I'm not expert and then I
> need some examples to understand. Initially I must listing all LAN's
> PC, for each PC get users and password, change password local
> administrator, run shutdown machines after 21:00 (also printer), get
> listing installed software, change PC's name.

Although much of what you ask can be done, you cannot get user
passwords.  The unencrypted passwords are simply not stored anywhere. 
As soon as you enter a password, it is encrypted.  If a password is
forgotten, you have no choice but to change it to something else.

There are many, many web sites devoted to scripts for Windows system
administration.  Many of them are VBScript, but it's not too hard to
convert those to Python.  You would do much better to search through
those resources first.  Here are two good examples:

http://gallery.technet.microsoft.com/scriptcenter/en-us/
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/AdminTips/Administrator/ActiveDirectoryRemoteAdminScripts.html

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From clintonlee.taylor at gmail.com  Thu Mar 25 10:18:22 2010
From: clintonlee.taylor at gmail.com (Clinton Lee Taylor)
Date: Thu, 25 Mar 2010 11:18:22 +0200
Subject: [python-win32] OT: Syncing routes ...
Message-ID: 

Greetings ...

 Thanks Tim for your reply ...

>> I'm still very new to Python, so please excuss my request ... I have
>> written some very basic Python utils and slowly get my head around
>> Python and com objects in Windows ...
>>
>> ? I was hoping that I might be able to bug the list for any pointers on
>> syncing routes, that I could use to sync records from one DB to
>> another ... Basically looking to sync Outlook Contacts into and from a
>> MySQL DB. ?Later, would like to extend this to include Windows Address
>> Book, Thunderbird Contacts and maybe any other DateBase.
>
> Well I'm no expert in this area, but since I've not seen any other
> replies I'll have a stab. Your question is quite wide-ranging,
> taking in several major software packages, all of which have
> quite different access methods. You say you're new to Python
> (and presumably to Windows development, if you're coming to terms
> with COM). Do you have any other development experience?
I was hoping somebody had already done some sort of syncing procedures
or functions that other might have tried or worked with ...

> Outlook contacts can be read via the so-called CDO libraries.
> This is the definitive starting point:
>
> ? http://msdn.microsoft.com/en-us/library/ms988614%28EXCHG.65%29.aspx
>
> and there's some good resources here:
>
> ? http://www.cdolive.com/default.htm
>
> For the most part, CDO is easy enough to translate into Python.
> I have some examples here (altho' not contact-related):
>
> ? http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html
> ? http://timgolden.me.uk/python/win32_how_do_i/replace-outlook-attachments-with-links.html
> ? http://timgolden.me.uk/python/win32_how_do_i/create-an-mhtml-archive.html
>
> and once you've got hold of the terms you need, you can easily
> Google around for more.
 I have got most of the Outlook contacts interface working, reading
and writing contacts.  The same with the MySQL interface, reading an
writing ...

 I am now working on the syncing side of things ... Getting a new
contact, adding into DB, syncing back to client with extra syncing
attributes.  Conflict resolution?  Stuff like that ... Was more a call
for ideas on my part, hoping somebody else might have run into this
before ...

> Then you have the database side. You mention MySQL but you might be better off
> using sqlite, an interface to which is included with Python in recent versions.
> This is, of course, unless you have a truly huge list of contacts, or an
> existing investment in MySQL.
 The reason I am looking at MySQL, is that it would need remote client
access ... I'm not sure that sqlite3 would have that without having to
install a services of some sort ... So I think I will stick with MySQL
for now ...


> There certainly are Python bindings to MySQL altho' I'm not a user myself
> so I'm not sure which ones favoured at the moment. Worth asking on the
> main Python lists.
I already have MySQL read and writes working, so not a problem ...
MySQL been the easiest of all the DB's I have tried, was hoping I
could develop local and then code MySQL last, but it does not seem to
be working that way ...

> Hopefully that's enough to get you started. Feel free to post back with
> more questions or info. If your questions aren't win32 specific you
> might get more answers on the main Python mailing list:
>
> ? http://mail.python.org/mailman/listinfo/python-list
 Mmm, another list to subscribe to ... Let's see how far I get by
myself ... Thanks.

Thanks
Mailed
LeeT

From mail at timgolden.me.uk  Thu Mar 25 10:29:26 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Thu, 25 Mar 2010 09:29:26 +0000
Subject: [python-win32] OT: Syncing routes ...
In-Reply-To: 
References: 
Message-ID: <4BAB2CF6.20900@timgolden.me.uk>

On 25/03/2010 09:18, Clinton Lee Taylor wrote:
>   I have got most of the Outlook contacts interface working, reading
> and writing contacts.  The same with the MySQL interface, reading an
> writing ...
>
>   I am now working on the syncing side of things ... Getting a new
> contact, adding into DB, syncing back to client with extra syncing
> attributes.  Conflict resolution?  Stuff like that ... Was more a call
> for ideas on my part, hoping somebody else might have run into this
> before ...

OK, that's a bit clearer. It wasn't quite clear (to me, at least)
from your original email whether you were starting from scratch
and had no real idea where to turn, or were part way in and were
looking for others' experience. The latter, it seems.

I'm afraid I've no particular experience in this area myself.
I'd be keen to see how you go, as this is an interesting area
so even if you carry on by yourself, do post back with interesting
or semi-completed stuff if you feel like it.

TJG

From mdriscoll at co.marshall.ia.us  Thu Mar 25 15:01:12 2010
From: mdriscoll at co.marshall.ia.us (Mike Driscoll)
Date: Thu, 25 Mar 2010 09:01:12 -0500
Subject: [python-win32] administration script
In-Reply-To: 
References: 
Message-ID: <4BAB6CA8.8080505@co.marshall.ia.us>

On 1:59 PM, pacopyc pacopyc wrote:
> Hello, I'm a NT domain system administrator and I'd like develop 
> simple administration scripts with Python. I'm not expert and then I 
> need some examples to understand. Initially I must listing all LAN's 
> PC, for each PC get users and password, change password local 
> administrator, run shutdown machines after 21:00 (also printer), get 
> listing installed software, change PC's name. Can you help me?
>
> Thanks
Here's a few links on the subject, however Tim is correct. Checking out 
VBScript examples is a good was too learn too.

http://timgolden.me.uk/python/wmi/
http://timgolden.me.uk/python-on-windows/
http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[0].Type=ScriptLanguage&f[0].Value=Python&f[0].Text=Python
http://www.blog.pythonlibrary.org/tag/windows/


-- 
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From cappy2112 at gmail.com  Thu Mar 25 15:32:34 2010
From: cappy2112 at gmail.com (Tony Cappellini)
Date: Thu, 25 Mar 2010 07:32:34 -0700
Subject: [python-win32] Win API call to display a BMP/PNG file as a
	splash screen for a console app?
Message-ID: <8249c4ac1003250732j2d51c5b8m659627136daddd3b@mail.gmail.com>

Date: Wed, 24 Mar 2010 08:41:16 +0100
> From: "Sylvain Fauveau (apli-agipa)" 
> Cc: Python-Win32 List 
> Subject: Re: [python-win32] Win API call to display a BMP/PNG file as
>        a       splash screen for a console app?
> Message-ID: <4BA9C21C.8030405 at apli-agipa.com>
> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>
> Not tested, but :
>
> Google: splash screen tkinter
>
> =>
> http://code.activestate.com/recipes/534124-elegant-tkinter-splash-screen/
>
> >>tkinter is included with python.
>
Tkinter is include with Python, but I don't believe Tix is included, unless
it was added to a later distribution than I have.
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Thu Mar 25 20:29:12 2010
From: timr at probo.com (Tim Roberts)
Date: Thu, 25 Mar 2010 12:29:12 -0700
Subject: [python-win32] help writing text to a windows edit control
In-Reply-To: 
References: ,
	<4BAA9577.6040803@probo.com>
	
Message-ID: <4BABB988.10009@probo.com>

Richard Leahy wrote:
> Hi  Tim its just a C windows gui application that consists of a edit
> control and a button. I am just trying to write my text string to the
> edit control i can write to the button and i know i have found the
> right control id for the edit control to but for some reason it just
> does not want to work. thanks for your help.

Well, I'm not sure I understand why, but "SetDlgItemA" does not work
with your edit control and "SendMessage" does:

import win32gui
WM_SETTEXT = 0x0c
t = win32gui.FindWindow( None, "Windows App" )
t1 = win32gui.GetDlgItem( t, 1 )
print win32gui.SendMessage( t1, WM_SETTEXT, 0, "444")

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From mc at mclaveau.com  Sat Mar 27 21:57:44 2010
From: mc at mclaveau.com (Michel Claveau)
Date: Sat, 27 Mar 2010 21:57:44 +0100
Subject: [python-win32] Pywin32+MFC Ok on 7 & Vista, bad on XP
Message-ID: <40B61BF7B96A414C9B81E305AABF4D63@MCI1330>

Hi, all !

I write several scripts with Pywin32, for work with MFC's windows & some 
controls.
All scripts run good on Windows-7 (32 & 64) and Vista.

But, on XP, all windows are white.
Labels, fields, treeviews, listviews, images, buttons, etc. are present, but 
not visible.
If I click on buttons ("blind mode"), it run. But everything is hidden by 
the white.

Any idea?

Thanks.
-- 
Michel Claveau


From roberto.c.aguilar at gmail.com  Wed Mar 24 22:17:22 2010
From: roberto.c.aguilar at gmail.com (Roberto Aguilar)
Date: Wed, 24 Mar 2010 14:17:22 -0700
Subject: [python-win32] Installer crashes on embedded system.
In-Reply-To: <4BA78D86.9010406@bobcowdery.plus.com>
References: <4BA78D86.9010406@bobcowdery.plus.com>
Message-ID: <1550CF05-D969-4147-8D3D-562B9C118399@gmail.com>

On Mar 22, 2010, at 8:32 AM, Bob Cowdery wrote:
> Hi
> 
> I've been using the extensions on many machines with no issues. I am now
> trying to install on an XP embedded touch screen machine and the
> installer crashes. I know it's virtually no information, but thats all I
> get. The system is Windows Embedded Standard with Service Pack 3 and
> made by Sansung. I'm installing pywin32-214.win32-py2.6.exe and it just
> throws up the standard 'has encountered a problem' dialog. Python 2.6.4
> installed without problems. Does anyone have any ideas?

Hi Bob,

It's possible that your system does not have the Visual C runtime that pywin32 was compiled with, though that is a wild guess.  I take from your email that it's the installer that's crashing and not using pywin32.  I'm also assuming python runs fine on that system, which further eliminates the runtime being an issue.

I created a pywin32 MSI for my day job a while back and it has been working well for us.  It runs successfully on win2k, winxp, wepos and Windows Embedded.  Maybe it will work for you.

http://stuff.nutricateonline.com/python/pywin32-2.1.2.win32-py2.6.msi

$ md5sum pywin32-2.1.2.win32-py2.6.msi 
2685633b80fa03286da08965dd91cb5a  pywin32-2.1.2.win32-py2.6.msi

$ sha1sum pywin32-2.1.2.win32-py2.6.msi 
e7a3950c1a0f588bae777e605494276bff5a0452 pywin32-2.1.2.win32-py2.6.msi

Apologies, but I cannot guarantee the long-term existence of the URL above.

-Roberto.


From timr at probo.com  Mon Mar 29 03:28:41 2010
From: timr at probo.com (Tim Roberts)
Date: Sun, 28 Mar 2010 17:28:41 -0800
Subject: [python-win32] Pywin32+MFC Ok on 7 & Vista, bad on XP
Message-ID: <201003290128.o2T1Sfp16394@probo.probo.com>

You wrote:
>
>Hi, all !
>
>I write several scripts with Pywin32, for work with MFC's windows & some 
>controls.
>All scripts run good on Windows-7 (32 & 64) and Vista.
>
>But, on XP, all windows are white.
>Labels, fields, treeviews, listviews, images, buttons, etc. are present,
>but not visible.
>If I click on buttons ("blind mode"), it run. But everything is hidden by 
>the white.
>
>Any idea?

I would hope it was obvious that we can't possibly diagnose anything from this sketchy message  How are you creating windows?  wxPython?  Tkinter?  win32ui?  Direct calls to the API?  Show us your code, and we'll help you find the problem.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

From mc at mclaveau.com  Mon Mar 29 08:16:21 2010
From: mc at mclaveau.com (Michel Claveau)
Date: Mon, 29 Mar 2010 08:16:21 +0200
Subject: [python-win32] Pywin32+MFC Ok on 7 & Vista, bad on XP
In-Reply-To: <201003290128.o2T1Sfp16394@probo.probo.com>
References: <201003290128.o2T1Sfp16394@probo.probo.com>
Message-ID: 

Hi!

Sorry for the lack of information.

I use win32gui + directAPI (SendMessage).
With differents tests, I found:
  - No problem, if I use dialog (CreateDialogIndirect instead 
CreateWindowEx). But dialog is limited (no NM_CUSTOMDRAW...)
  - No problem, if I do not use any: SetGraphicsMode or SelectObject...DC or 
DrawText ; but I use them almost everywhere.

I can show my code, but it is >100 kB, too big for message.

@-salutations
-- 
Michel Claveau



>>I write several scripts with Pywin32, for work with MFC's windows & some
>>controls.
>>All scripts run good on Windows-7 (32 & 64) and Vista.
>>
>>But, on XP, all windows are white.
>>Labels, fields, treeviews, listviews, images, buttons, etc. are present,
>>but not visible.
>>If I click on buttons ("blind mode"), it run. But everything is hidden by
>the white.
>>
>>Any idea?

>I would hope it was obvious that we can't possibly diagnose anything from 
>this sketchy message  How are you creating windows?  wxPython?  >Tkinter? 
>win32ui?  Direct calls to the API?  Show us your code, and we'll help you 
>find the problem.


From timr at probo.com  Mon Mar 29 19:46:20 2010
From: timr at probo.com (Tim Roberts)
Date: Mon, 29 Mar 2010 10:46:20 -0700
Subject: [python-win32] Pywin32+MFC Ok on 7 & Vista, bad on XP
In-Reply-To: 
References: <201003290128.o2T1Sfp16394@probo.probo.com>
	
Message-ID: <4BB0E76C.1030905@probo.com>

Michel Claveau wrote:
>
> Sorry for the lack of information.
>
> I use win32gui + directAPI (SendMessage).
> With differents tests, I found:
>  - No problem, if I use dialog (CreateDialogIndirect instead
> CreateWindowEx). But dialog is limited (no NM_CUSTOMDRAW...)

I don't know what that means.  NM_CUSTOMDRAW is certainly available to
dialog windows.


>  - No problem, if I do not use any: SetGraphicsMode or
> SelectObject...DC or DrawText ; but I use them almost everywhere.

That might imply that you're not restoring the original DC fields
properly.  When you change the graphics mode or select a brush or a pen,
you are always supposed to put the original brush or pen back.


> I can show my code, but it is >100 kB, too big for message.

Not really, but if you want to send it to me in private email, that's fine.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


From europe_travel at hotmail.com  Tue Mar 30 07:39:34 2010
From: europe_travel at hotmail.com (travel europe)
Date: Tue, 30 Mar 2010 01:39:34 -0400
Subject: [python-win32] Attempt to make executable from Python script
Message-ID: 


Hello,

 

I am attempting to make an executable from a working Python script per the instructions from the following website:

 

  http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html

 

Everything seems to go as planned, except when I run the resulting executable I get the following message:

 

Traceback (most recent call last):
  File "tim.py", line 2, in 
  File "winsys\registry.pyc", line 39, in 
  File "winsys\security.pyc", line 42, in 
  File "winsys\_security\_tokens.pyc", line 10, in 
  File "winsys\accounts.pyc", line 31, in 
  File "winsys\dialogs.pyc", line 45, in 
ImportError: No module named shell

 

 

Any suggestions? Thanks!
 		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From werner.bruhin at free.fr  Tue Mar 30 11:44:39 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Tue, 30 Mar 2010 11:44:39 +0200
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: 
Message-ID: 

Hi,

On 30/03/2010 07:39, travel europe wrote:
> Hello,
>
> I am attempting to make an executable from a working Python script per
> the instructions from the following website:
>
> http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html
>
> Everything seems to go as planned, except when I run the resulting
> executable I get the following message:
>
> Traceback (most recent call last):
> File "tim.py", line 2, in 
> File "winsys\registry.pyc", line 39, in 
> File "winsys\security.pyc", line 42, in 
> File "winsys\_security\_tokens.pyc", line 10, in 
> File "winsys\accounts.pyc", line 31, in 
> File "winsys\dialogs.pyc", line 45, in 
> *ImportError: No module named shell*
Is winsys\dialogs your stuff?

What is your setup.py and can you successfully build a small exe?  E.g. 
the one shown on this wiki http://wiki.wxpython.org/Deployment (needs 
wxPython) or the one here http://www.py2exe.org/index.cgi/Tutorial ?

You might want to post to : Py2exe-users at lists.sourceforge.net

Werner


From mail at timgolden.me.uk  Tue Mar 30 16:38:35 2010
From: mail at timgolden.me.uk (Tim Golden)
Date: Tue, 30 Mar 2010 15:38:35 +0100
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: 
	
Message-ID: <4BB20CEB.8030408@timgolden.me.uk>

On 30/03/2010 10:44, Werner F. Bruhin wrote:
> Hi,
>
> On 30/03/2010 07:39, travel europe wrote:
>> Hello,
>>
>> I am attempting to make an executable from a working Python script per
>> the instructions from the following website:
>>
>> http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html
>>
>> Everything seems to go as planned, except when I run the resulting
>> executable I get the following message:
>>
>> Traceback (most recent call last):
>> File "tim.py", line 2, in
>> File "winsys\registry.pyc", line 39, in
>> File "winsys\security.pyc", line 42, in
>> File "winsys\_security\_tokens.pyc", line 10, in
>> File "winsys\accounts.pyc", line 31, in
>> File "winsys\dialogs.pyc", line 45, in
>> *ImportError: No module named shell*
> Is winsys\dialogs your stuff?

No; it's mine. And it is (unfortunately) not a great starting
point for a novice building .exes as it imports things from
the win32com.shell module which does some shuffling of namespaces
behind the scenes.

> What is your setup.py and can you successfully build a small exe?  E.g.
> the one shown on this wiki http://wiki.wxpython.org/Deployment (needs
> wxPython) or the one here http://www.py2exe.org/index.cgi/Tutorial ?

> You might want to post to : Py2exe-users at lists.sourceforge.net

Agree with all this; let's see what the OP can come back with...

TJG

From chef at ghum.de  Tue Mar 30 17:22:28 2010
From: chef at ghum.de (Massa, Harald Armin)
Date: Tue, 30 Mar 2010 17:22:28 +0200
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: 
Message-ID: 

Hello Travel Europe,

that is a documented challenge with the excellent WinShell module from Tim
Golden.

I described in detail how to solve it at:

http://www.py2exe.org/index.cgi/WinShell

best wishes,

Harald

On Tue, Mar 30, 2010 at 07:39, travel europe wrote:

>  Hello,
>
> I am attempting to make an executable from a working Python script per the
> instructions from the following website:
>
>
> http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html
>
> Everything seems to go as planned, except when I run the resulting
> executable I get the following message:
>
> Traceback (most recent call last):
>   File "tim.py", line 2, in 
>   File "winsys\registry.pyc", line 39, in 
>   File "winsys\security.pyc", line 42, in 
>   File "winsys\_security\_tokens.pyc", line 10, in 
>   File "winsys\accounts.pyc", line 31, in 
>   File "winsys\dialogs.pyc", line 45, in 
> *ImportError: No module named shell*
>
>
> Any suggestions? Thanks!
>
> ------------------------------
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox. Learn More.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>


-- 
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Stra?e 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
%s is too gigantic of an industry to bend to the whims of reality
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From europe_travel at hotmail.com  Wed Mar 31 10:59:03 2010
From: europe_travel at hotmail.com (travel europe)
Date: Wed, 31 Mar 2010 04:59:03 -0400
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: ,
	
Message-ID: 


Harald,

 

I followed the recommendation in your link and got the following result:

 

C:\Python26\dist>golden.exe
Traceback (most recent call last):
  File "golden.py", line 2, in 
  File "winsys\registry.pyc", line 39, in 
  File "winsys\security.pyc", line 42, in 
  File "winsys\_security\_tokens.pyc", line 10, in 
  File "winsys\accounts.pyc", line 31, in 
  File "winsys\dialogs.pyc", line 46, in 
  File "win32ui.pyc", line 12, in 
  File "win32ui.pyc", line 10, in __load
ImportError: DLL load failed: This application has failed to start because the a
pplication configuration is incorrect. Reinstalling the application may fix this
 problem.

 

Can you think of anything else to try? Thanks!

 

 

Ron
 


Date: Tue, 30 Mar 2010 17:22:28 +0200
Subject: Re: [python-win32] Attempt to make executable from Python script
From: chef at ghum.de
To: europe_travel at hotmail.com
CC: python-win32 at python.org

Hello Travel Europe,


that is a documented challenge with the excellent WinShell module from Tim Golden.


I described in detail how to solve it at:


http://www.py2exe.org/index.cgi/WinShell



best wishes,


Harald


On Tue, Mar 30, 2010 at 07:39, travel europe  wrote:


Hello,
 
I am attempting to make an executable from a working Python script per the instructions from the following website:
 
  http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html
 
Everything seems to go as planned, except when I run the resulting executable I get the following message:
 
Traceback (most recent call last):
  File "tim.py", line 2, in 
  File "winsys\registry.pyc", line 39, in 
  File "winsys\security.pyc", line 42, in 
  File "winsys\_security\_tokens.pyc", line 10, in 
  File "winsys\accounts.pyc", line 31, in 
  File "winsys\dialogs.pyc", line 45, in 
ImportError: No module named shell
 
 
Any suggestions? Thanks!




Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn More.
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32



-- 
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Stra?e 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon 
-
%s is too gigantic of an industry to bend to the whims of reality
 		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From chef at ghum.de  Wed Mar 31 11:06:43 2010
From: chef at ghum.de (Massa, Harald Armin)
Date: Wed, 31 Mar 2010 11:06:43 +0200
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: 
	
	
Message-ID: 

Ron,


> I followed the recommendation in your link and got the following result:
>
> C:\Python26\dist>golden.exe
>
> Traceback (most recent call last):
>   File "golden.py", line 2, in 
>
>   File "winsys\registry.pyc", line 39, in 
>   File "winsys\security.pyc", line 42, in 
>   File "winsys\_security\_tokens.pyc", line 10, in 
>   File "winsys\accounts.pyc", line 31, in 
>   File "winsys\dialogs.pyc", line 46, in 
>   File "win32ui.pyc", line 12, in 
>   File "win32ui.pyc", line 10, in __load
> ImportError: DLL load failed: This application has failed to start because
> the a
> pplication configuration is incorrect. Reinstalling the application may fix
> this
>  problem.
>
> Can you think of anything else to try? Thanks!
>
>
yes. This is a totally different kind of problem. Two likely reasons:

a) the DLLs from Microsoft Visual C are missing.
b) the manifest included in your .exe is not working with the visual-C DLLs
of Python 2.6

Correct and offical solution for a): get vcredist from Microsoft, and run
it.

Solution I usually use:

- copy msvcp90.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest into the
directory of your .exe


Solution for b)
use this manifest in your setup.py:

manifest_template = '''

  
  MyCare Card Browser Program
  
    
      
        
      
    
  
  
    
      
    
  
  
    
      
    
  

'''

RT_MANIFEST = 24

and within the setup-dictionary ...

wxreport = dict(
    script = "yourscript.py",
    other_resources = [
                (RT_MANIFEST, 1, manifest_template % dict(prog="your
Progname")),
    ],
    dest_base = r"yourdestination",
<--other options-->
    )

best wishes,

Harald




>
> Ron
>
> ------------------------------
> Date: Tue, 30 Mar 2010 17:22:28 +0200
> Subject: Re: [python-win32] Attempt to make executable from Python script
> From: chef at ghum.de
> To: europe_travel at hotmail.com
> CC: python-win32 at python.org
>
>
> Hello Travel Europe,
>
> that is a documented challenge with the excellent WinShell module from Tim
> Golden.
>
> I described in detail how to solve it at:
>
> http://www.py2exe.org/index.cgi/WinShell
>
> best wishes,
>
> Harald
>
> On Tue, Mar 30, 2010 at 07:39, travel europe wrote:
>
> Hello,
>
> I am attempting to make an executable from a working Python script per the
> instructions from the following website:
>
>
> http://logix4u.net/Python/Tutorials/How_to_create_Windows_executable_exe_from_Python_script.html
>
> Everything seems to go as planned, except when I run the resulting
> executable I get the following message:
>
> Traceback (most recent call last):
>   File "tim.py", line 2, in 
>   File "winsys\registry.pyc", line 39, in 
>   File "winsys\security.pyc", line 42, in 
>   File "winsys\_security\_tokens.pyc", line 10, in 
>   File "winsys\accounts.pyc", line 31, in 
>   File "winsys\dialogs.pyc", line 45, in 
> *ImportError: No module named shell*
>
>
> Any suggestions? Thanks!
>
> ------------------------------
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox. Learn More.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
>
>
> --
> GHUM Harald Massa
> persuadere et programmare
> Harald Armin Massa
> Spielberger Stra?e 49
> 70435 Stuttgart
> 0173/9409607
> no fx, no carrier pigeon
> -
> %s is too gigantic of an industry to bend to the whims of reality
>
> ------------------------------
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox. Learn More.
>



-- 
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Stra?e 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
%s is too gigantic of an industry to bend to the whims of reality
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From werner.bruhin at free.fr  Wed Mar 31 11:48:19 2010
From: werner.bruhin at free.fr (Werner F. Bruhin)
Date: Wed, 31 Mar 2010 11:48:19 +0200
Subject: [python-win32] Attempt to make executable from Python script
In-Reply-To: 
References: ,
	
	
Message-ID: 

On 31/03/2010 10:59, travel europe wrote:
> Harald,
>
> I followed the recommendation in your link and got the following result:
>
> C:\Python26\dist>golden.exe
> Traceback (most recent call last):
> File "golden.py", line 2, in 
> File "winsys\registry.pyc", line 39, in 
> File "winsys\security.pyc", line 42, in 
> File "winsys\_security\_tokens.pyc", line 10, in 
> File "winsys\accounts.pyc", line 31, in 
> File "winsys\dialogs.pyc", line 46, in 
> File "win32ui.pyc", line 12, in 
> File "win32ui.pyc", line 10, in __load
> ImportError: DLL load failed: This application has failed to start
> because the a
> pplication configuration is incorrect. Reinstalling the application may
> fix this
> problem.
>
This is due to Python 2.6 and the new SxS MS Runtime .......!

See here for a solution which works for me when using wxPython and Py 2.6.

http://wiki.wxpython.org/py2exe


Werner


From mc at mclaveau.com  Wed Mar 31 12:00:48 2010
From: mc at mclaveau.com (Michel Claveau)
Date: Wed, 31 Mar 2010 12:00:48 +0200
Subject: [python-win32] Pywin32+MFC Ok on 7 & Vista, bad on XP ; solved/résolu
In-Reply-To: <4BB0E76C.1030905@probo.com>
References: <201003290128.o2T1Sfp16394@probo.probo.com>
	<4BB0E76C.1030905@probo.com>
Message-ID: <894D0BBF8C454C5D848D982D25EF3511@MCI1330>

Re!


Sorry for late, but I have work for 35 hours, each day...

The problem was WS_EX_LAYERED.
I used that:

    s=win32gui.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE, s | 
win32con.WS_EX_LAYERED)

but WS_EX_LAYERED must not used alone.
The solution is to add a line like:

    win32gui.SetLayeredWindowAttributes(self.hwnd, 0, 255, 
win32con.LWA_ALPHA)
(or another usage of  LayeredWindow)


For the size of the script, in few days, I will send the result on the web. 
That will interest for some persons, if they can read my bad english (sorry) 
or they can read few my french comments...


@-salutations
-- 
Michel Claveau




From hitman_876 at hotmail.com  Wed Mar 31 19:33:35 2010
From: hitman_876 at hotmail.com (hitheam mohamed)
Date: Wed, 31 Mar 2010 17:33:35 +0000
Subject: [python-win32] (no subject)
Message-ID: 


Hi, 

 

I have a script that runs smoothly on a local copy of an excel workbook. I want to implement this so that it can access a shared version of the workbook but I would like to kick out any users that currently have the shared version open. Is it possibly to kick out any users with an open copy of the shared workbook and keep all users out of the workbook as the script runs and re-enable their access after the script is done compiling?

 

Thanks, 

 

      Hitheam Mohamed (hitman_876 at hotmail.com)
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From timr at probo.com  Wed Mar 31 20:03:16 2010
From: timr at probo.com (Tim Roberts)
Date: Wed, 31 Mar 2010 11:03:16 -0700
Subject: [python-win32] (no subject)
In-Reply-To: 
References: 
Message-ID: <4BB38E64.20308@probo.com>

hitheam mohamed wrote:
>
> I have a script that runs smoothly on a local copy of an excel
> workbook. I want to implement this so that it can access a shared
> version of the workbook but I would like to kick out any users that
> currently have the shared version open. Is it possibly to kick out any
> users with an open copy of the shared workbook and keep all users out
> of the workbook as the script runs and re-enable their access after
> the script is done compiling?

No, Excel doesn't have any way to "kick out" folks that already have a
shared spreadsheet open.  If you really need this kind of shared access,
Excel is the wrong application.  You should use something like Access
with a real database backend, where you can manage concurrent access
more intelligently.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.