RE: WMI - invalid syntax error?

Discussion in 'Python' started by Tim Golden, Jan 3, 2006.

  1. Tim Golden

    Tim Golden Guest

    [py]
    | Sent: 30 December 2005 16:15
    | To:
    | Subject: Re: WMI - invalid syntax error?
    |
    | py wrote:
    | >Something must be happening somewhere causing it
    | > to get fouled up. I'm gonna try on a different PC.
    |
    | I tried on another PC, same problem.
    |
    | Also, I added "reload(wmi)" before I create an instance of
    | wmi.WMI just
    | to see what happens, so I hve...
    |
    | import wmi
    |
    | def ppn(machine=None):
    | try:
    | reload(wmi)
    | wmiObj = wmi.WMI(machine)
    | except Exception, e:
    | print "Error: " + str(e)
    |
    | ...now I get this as the error message..
    | Error: (-2147221020, 'Invalid syntax', None, None)
    |
    | Slightly different than before...but same message.

    Hmmm. I think I'm now in the unusual situation of having
    *too much* information to solve the problem. The thing I'm
    straining for is the minimum reproducible situation. At
    first it looked as though it was down to running the code
    from a file rather than at the interpreter. Is that still
    the case? Your previous post about the monikers suggests
    that running the code twice -- in any way -- triggered
    the problem. Is that true? The code above introduces the
    extra complication of a reload which I'm afraid just muddies
    the waters.

    To confirm, your code above runs from a file any number
    of times without issue on my (WinXP Python 2.4.2) box
    using wmi 0.6b.

    Behind the scenes, the wmi module is doing something
    like this:

    <code>
    import win32com.client
    x = win32com.client.GetObject ("winmgmts:")
    </code>

    Now if I deliberately fudge that moniker, I'll
    get the error message you show above, which is
    what I expected with an ill-formed moniker.

    <code>
    import win32com.client
    x = win32com.client.GetObject ("winmgmtxx:")
    # pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
    </code>

    Googling for your original error code (-0x7ffbfe1c) which
    is 800401E4 in top-bit-set hex, most of the hits suggest
    that WMI is not installed on the box in question (typically
    because it's a Win98 or WinNT install without the WMI download).
    But you're on WinXP, so that can't be it.

    I'm afraid I'm still mystified; it's frustrating because
    I can't even reproduce the situation.

    TJG

    ________________________________________________________________________
    This e-mail has been scanned for all viruses by Star. The
    service is powered by MessageLabs. For more information on a proactive
    anti-virus service working around the clock, around the globe, visit:
    http://www.star.net.uk
    ________________________________________________________________________
     
    Tim Golden, Jan 3, 2006
    #1
    1. Advertising

  2. Tim Golden

    py Guest

    The problem only seems to occur when importing the file and using it
    that way. It works the first time, but not the second, third, etc. If
    I run the same commands via the interpreter I have no problem.

    I may end up looking into some other way of getting the list of
    processes....this is real screwy.

    I am going to try typing up that simple function into a new py file and
    put it on a diff. PC and try it. I tried my current code on another
    computer and had the same issue...but I am wondering if I start anew if
    it will help.
     
    py, Jan 3, 2006
    #2
    1. Advertising

  3. Tim Golden

    py Guest

    py wrote:
    > I am going to try typing up that simple function into a new py file and
    > put it on a diff. PC and try it. I tried my current code on another
    > computer and had the same issue...but I am wondering if I start anew if
    > it will help.


    ok, i am not sure whats going on. I created a simple file with a
    function which creates the WMI object, and I can use it, no problem.
    Must be something weird, non-wmi related happening.

    thanks.
     
    py, Jan 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Winterminute
    Replies:
    0
    Views:
    3,114
    Winterminute
    Dec 4, 2003
  2. Patrick.O.Ige
    Replies:
    1
    Views:
    1,984
    Patrick.O.Ige
    Jul 2, 2006
  3. py
    Replies:
    2
    Views:
    418
  4. Tim Golden

    RE: WMI - invalid syntax error?

    Tim Golden, Dec 30, 2005, in forum: Python
    Replies:
    1
    Views:
    527
  5. Tim Golden

    RE: WMI - invalid syntax error?

    Tim Golden, Dec 30, 2005, in forum: Python
    Replies:
    2
    Views:
    450
Loading...

Share This Page