On 04/02/2010 10:48, Eli Sandler wrote:
I have a curious problem. I use Tim Golden’s module for WMI, and I use the
‘StdRegProv’ to query a remote registry over WMI. I get an unusual network load
for this procedure.

Using a packet capture, I saw that each new query contains all the previous 
ones.
Do I use the module in a wrong way?
Did anyone else encounter this problem?

Well I can simplify things for you slightly at the beginning:

<code>
import wmi

oReg = wmi.WMI (server, namespace="default", user=user, 
password=password).StdRegProv

</code>

Also you might perhaps simplify your code by using tuple unpacking
and by exploiting the fact that in Python anything empty evaluates
to False including 0, None and "":

<code>
import wmi

server = "BLAH"
user = password = ""

oReg = wmi.WMI (server, namespace="default", user=user, 
password=password).StdRegProv

result, subkeys = oReg.EnumKey( hive, key )
if result:
  print "Couldn't..."
  return

for subkey in subkeys:
  result, name = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayName" )
  if result:
    print "Couldn't get display name..."
    continue
result, ver = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" )
  if result:
    ver = ""

  result, publisher = oReg.GetStringValue( hive, key+'\\'+subkey, 
"DisplayVersion" )
  if result:
    publisher = ""

# ... etc.

</code>

Obviously more refactoring could be done to drop the common code
into functions etc. But I'm sure you knew that.

However I can't see any particular reason why each new query should contain
all the previous ones. Can you show an example of your network trace?

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

Reply via email to