Re: [python-win32] wmi query error

2009-10-21 Thread Nick Moszer
To make talking about it easier, I've slightly reworked your code to make it run completely (ie I've added imports and the initialisation of the data structures) and to take advantage of the wmi module's built-in features. Hopefully it's perfectly clear what's going on; I've just avoided some

Re: [python-win32] wmi query error

2009-10-21 Thread Tim Golden
Nick Moszer wrote: Hello, I'm occasionally receiving the following error when doing a set of queries: Traceback (most recent call last): File "psg5220_demo.py", line 236, in find_hdd_drives partitions = services.query(query) File "...path..\wmi.py", line 889, in query return [ _wmi

Re: [python-win32] wmi query.

2008-03-26 Thread mark.a.brand
lovely, thanks again. On 26/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote: > > mark.a.brand wrote: > > what about events, > > > > for example i only want to return error and warning events for the last > 4 > > days from all logs. getting all the events and then filtering them will > be > > terrri

Re: [python-win32] wmi query.

2008-03-26 Thread Tim Golden
mark.a.brand wrote: > what about events, > > for example i only want to return error and warning events for the last 4 > days from all logs. getting all the events and then filtering them will be > terrribly slow. You let WMI do the filtering. For this, since it's a non-equi filter (you want the

Re: [python-win32] wmi query.

2008-03-26 Thread mark.a.brand
hi tim: what about events, for example i only want to return error and warning events for the last 4 days from all logs. getting all the events and then filtering them will be terrribly slow. cheers mark On 26/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote: > > mark.a.brand wrote: > > thanks t

Re: [python-win32] wmi query.

2008-03-25 Thread Tim Golden
Tim Golden wrote: [... snip other examples ...] > Even that is a slight optimisation. It usually costs little > to pull back all the fields, so I generally write: > > > import wmi > > c = wmi.WMI () > for service in c.Win32_Service (state="Stopped"): >print c.Caption, c.Status > > Sorr

Re: [python-win32] wmi query.

2008-03-24 Thread Tim Golden
mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stop

Re: [python-win32] wmi query.

2008-03-24 Thread Tim Golden
mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stop

Re: [python-win32] wmi query.

2008-03-24 Thread Tim Golden
mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stop

Re: [python-win32] wmi query.

2008-03-24 Thread Marcus Low
Hi, > c = wmi.WMI() > for service in c.Win32_Service ('State == 'Stopped') I would think that using c.Win32_Service() and iterating would get you anything you want. In ur case of using ('State == 'Stopped') ... (if this ever works) c.Caption would have given you the caption Marcus. -