Alec Bennett wrote:
I'm trying to get the online/offline status of a printer, and using WMI I'm 
finding it very slow. Here's the code I'm working, maybe there's some way to 
opimize it? Or some other way? I'm able to use win32print to query the status 
of an online printer, but not to find out whether its online or not (its 
pStatus always returns 'Idle').

def check_printer(printer_name):

.....c = wmi.WMI ()

.....for p in c.Win32_Printer():

..........if p.caption == printer_name:

...............if p.WorkOffline:
..................print "its offline"
...............else:
..................print "its online"




Generally, check out the speedup hints here:

http://timgolden.me.uk/python/wmi-tutorial.html#speeding-things-up

but as a rule WMI is not the fastest thing on earth,
so if you really need speed, you'll need to drop
down to the Win32 API and go from there. I can't
remember exactly what you need off-hand, altho'
it's probably in the win32print module.
Perhaps someone else can
fill in for me here...?

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

Reply via email to