about invalid syntax

2005-11-14 Thread Ben Bush
When I run scripts in PythonWin,
sometimes will get the message of invalid syntax error.
How can I check which error I made?
For example, in VB, you might got the wrong place highlighted and help message too.-- Thanks!Ben Bush
-- 
http://mail.python.org/mailman/listinfo/python-list

SyntaxError: invalid syntax

2005-12-26 Thread DIBS
I'm new to Python and I don't understand what I'm doing wrong.

I'm running windows xp.

In the command line window, I type:
Python Sudoku.py

and I get the response"

SyntaxError: invalid syntax

If anyone cane help me I'd be very grateful. 


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


SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
no matter where I place this imported file,the statement after it in
the main program gets a syntax error, regardless of the syntax.

I think I may have changed something in this file, but I'm stuck.  Can
anyone help?

#!/usr/local/bin/python
# Copyright 2004 by Stephen Masterman

#Change the db connection details here.


import MySQLdb




def connect():


   return =  MySQLdb.connect (host = "db91x..com",
   user = "",
passwd = "x",
db = "homebase_zingers"
   );

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


Re: about invalid syntax

2005-11-14 Thread adDoc's networker Phil
. maybe you could separate your code into parts { python std, pythonwin-specific},
and then use a debugger to know most of the problem sources?
(I'm not familiar with pythonwin, I assume it's a superset of python std) .On 11/14/05, Ben Bush <[EMAIL PROTECTED]
> wrote:When I run scripts in PythonWin,
sometimes will get the message of invalid syntax error.
How can I check which error I made?
For example, in VB, you might got the wrong place highlighted and help message too.-- Thanks!Ben Bush

--http://mail.python.org/mailman/listinfo/python-list
-- American Dream Documentshttp://www.geocities.com/amerdreamdocs/home/"(real opportunity starts with real documentation)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: about invalid syntax

2005-11-14 Thread Ben Bush

On 11/14/05, adDoc's networker Phil <[EMAIL PROTECTED]> wrote:
. maybe you could separate your code into parts { python std, pythonwin-specific},and then use a debugger to know most of the problem sources?
(I'm not familiar with pythonwin, I assume it's a superset of python std) .

On 11/14/05, Ben Bush <
[EMAIL PROTECTED] > wrote:


When I run scripts in PythonWin,
sometimes will get the message of invalid syntax error.
How can I check which error I made?
For example, in VB, you might got the wrong place highlighted and help message too.
-- 
which IDE do you use to run Python?Thanks!Ben Bush 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: about invalid syntax

2005-11-15 Thread adDoc's networker Phil

. I've been schooled with various versions of several languages,
but I'm just now learning python:
I've not yet personally experienced any python debugger .

. I understand the python`IDLE (integrated DeveL Envir)
 comes with the std distro, and here is the part in the doc's 
that you might find encouraging:

google( python idle debugger faq)
[EMAIL PROTECTED] http://www.python.org/doc/faq/programming.html#is-there-a-source-code-level-debugger-with-breakpoints-single-stepping-etc

"(

General Questions
1.1.1   Is there a source code level debugger with breakpoints, single-stepping, etc.? Yes.

The IDLE -- includes a graphical debugger. 
(see folder path: Tools/scripts/idle),
 
There is documentation for the IDLE debugger 
at http://www.python.org/idle/doc/idle2.html#Debugger

PythonWin 
includes a GUI debugger
 based on pdb (python`s std command-line debug)
. The Pythonwin debugger colors breakpoints 
and has quite a few cool features such as debugging non-Pythonwin
programs. A reference can be found at
http://www.python.org/windows/pythonwin/
. Recent versions of PythonWin are available as a part of
 the 
ActivePython distribution 
(see http://www.activestate.com/Products/ActivePython/index.html).
)-python.org

. another thing I plan to get into
 since I'm interested in taming xp,
is 
    iPython, [EMAIL PROTECTED] http://ipython.scipy.org/

. there are many reasons for this,
but the one most relevant to your needs at the moment
(avoiding mysterious error msg's)
is this:
"(
# Automatic indentation of code as you type 
-- (merely having inconsistent spaces or a tab-space mixture can cause unexpected syntax msg's, I'm told)

# Verbose and colored exception traceback printouts
. Easier to parse visually, and in verbose mode they produce a lot of useful debugging information

# Easy debugger access
to rapidly isolate the source of a bug:

. You can set IPython to call up the Python debugger (pdb) every time there is an uncaught exception
. This drops you inside the code which triggered the exception 
with all the data live and it is possible to navigate the stack 
. The %run magic command -with the -d option- 
can run any script under pdb's control,
 automatically setting initial breakpoints for you.

[. other features that interest me include: ]

# Offers a flexible framework inspired by the likes of Mathematica, IDL and Mathcad 
# Session logging (you can then later use these logs as code in your programs).
# Session restoring: logs can be replayed to restore a previous session to the state where you left it.
# Filesystem navigation, via a magic %cd command, 
along with a persistent bookmark system (using %bookmark) 
for fast access to frequently visited directories.
# The ability to expand python variables when calling the system shell
. In a shell command, any python variable prefixed with $ is expanded
. A double $$ allows passing a literal $ to the shell (for access to shell and environment variables like $PATH).
)-scipy.org

On 11/14/05, Ben Bush <[EMAIL PROTECTED]> wrote:

On 11/14/05, adDoc's networker Phil <[EMAIL PROTECTED]
> wrote:
. maybe you could separate your code into parts { python std, pythonwin-specific},and then use a debugger to know most of the problem sources?
(I'm not familiar with pythonwin, I assume it's a superset of python std) .

On 11/14/05, Ben Bush <
[EMAIL PROTECTED] > wrote:


When I run scripts in PythonWin,
sometimes will get the message of invalid syntax error.
How can I check which error I made?
For example, in VB, you might got the wrong place highlighted and help message too.
-- 
which IDE do you use to run Python?Thanks!Ben Bush 

-- American Dream Documentshttp://www.geocities.com/amerdreamdocs/home/"(real opportunity starts with real documentation)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: invalid syntax

2005-12-27 Thread Steven D'Aprano
On Tue, 27 Dec 2005 07:40:12 +, DIBS wrote:

> I'm new to Python and I don't understand what I'm doing wrong.
> 
> I'm running windows xp.
> 
> In the command line window, I type:
> Python Sudoku.py
> 
> and I get the response"
> 
> SyntaxError: invalid syntax
> 
> If anyone cane help me I'd be very grateful.

Please post the *full* traceback of the error, not just the last
description.

For example, something like this:

>>> x = x+*9
  File "", line 1
x = x+*9
  ^
SyntaxError: invalid syntax


Just "SyntaxError" on its own is not enough to tell what is going on,
except to say that it sounds like a bug in the program you are trying to
run.


-- 
Steven.

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


Re: SyntaxError: invalid syntax

2005-12-27 Thread Fredrik Lundh
Steven D'Aprano wrote:

> Please post the *full* traceback of the error, not just the last
> description.
>
> For example, something like this:
>
> >>> x = x+*9
>   File "", line 1
>     x = x+*9
>   ^
> SyntaxError: invalid syntax
>
> Just "SyntaxError" on its own is not enough to tell what is going on,
> except to say that it sounds like a bug in the program you are trying to
> run.

or that he's using a program written for a newer version of Python than
the one he has on his machine...





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


Re: SyntaxError: invalid syntax

2005-12-27 Thread DIBS
>>> python sudoku.py
File "", line 1
   python sudoku.py
^

>>>SyntaxError: invalid syntax




Thanks for your help.
The above is the extact message.

DIBS




"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Tue, 27 Dec 2005 07:40:12 +, DIBS wrote:
>
>> I'm new to Python and I don't understand what I'm doing wrong.
>>
>> I'm running windows xp.
>>
>> In the command line window, I type:
>> Python Sudoku.py
>>
>> and I get the response"
>>
>> SyntaxError: invalid syntax
>>
>> If anyone cane help me I'd be very grateful.
>
> Please post the *full* traceback of the error, not just the last
> description.
>
> For example, something like this:
>
>>>> x = x+*9
>  File "", line 1
>x = x+*9
>  ^
> SyntaxError: invalid syntax
>
>
> Just "SyntaxError" on its own is not enough to tell what is going on,
> except to say that it sounds like a bug in the program you are trying to
> run.
>
>
> -- 
> Steven.
> 


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


Re: SyntaxError: invalid syntax

2005-12-27 Thread Fredrik Lundh
"DIBS" <[EMAIL PROTECTED]> wrote:

> >>> python sudoku.py
> File "", line 1
>python sudoku.py
>         ^
>
> >>>SyntaxError: invalid syntax

> Thanks for your help.
> The above is the extact message.

that looks like the Python interpreter window, not the Windows command-
line window.

To run complete Python programs, type "python filename" in the Windows
command-line window (or double-click on filename from the explorer).

the FAQ has more information:

http://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-under-windows





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


Re: SyntaxError: invalid syntax

2005-12-27 Thread Terry Hancock
On Tue, 27 Dec 2005 09:32:18 GMT
"DIBS" <[EMAIL PROTECTED]> wrote:
> >>> python sudoku.py
> File "", line 1
>python sudoku.py
>     ^
> 
> >>>SyntaxError: invalid syntax
> 
> Thanks for your help.
> The above is the extact message.

Based on the ">>>" prompt, I'd say you tried to type this
into the python interactive interpreter. It's supposed to be
a shell command -- i.e. you *invoke* the python interpreter
to run the file from the command line.

If you are already running python, then you might get what
you want by importing the module:

>>> import sudoku

but whether that's what you really want or not depends on
how the module is meant to be used (is it a "module" or a
"script"?).

Cheers,
Terry

-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

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


WMI - invalid syntax error?

2005-12-30 Thread py
Hi,
  I am running python 2.4.2 on win xp pro.  I have the WMI module from
Tim Golden (http://tgolden.sc.sabren.com/python/wmi.html).

I have some code which does this...

MyScript.py
--
import wmi
# the ip of my own local desktop
machine = "1.2.3.4"
try:
w = wmi.WMI(machine)  # also tried, wmi.WMI(computer=machine)
except Exception, e:
print "ERROR:", e

c:>python
>> from MyScript import *
>>> ERROR: -0x7ffbfe1c - Invalid syntax

>> import wmi
>> w = wmi.WMI("1.2.3.4")
>>

So when I import the script I get the "invalid syntax" error (which
comes from the line, w = wmi.WMI())

but in the same window if I just type it in manually I get no error.

Any ideas???

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Roberto Bonvallet
ronrsr wrote:
>   return =  MySQLdb.connect (host = "db91x..com",
>   user = "",
>passwd = "x",
>db = "homebase_zingers"
>   );

return is a reserved keyword.  You cannot have a variable with that name.

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
here's some of the surrounding code from the main program:



querystring = querystring + " ORDER BY keywords ";
#SQL
import zsql





zc = zsql.connect()

print("return from open")



zq = zc.query(querystring).dictresult()

ronrsr wrote:
> no matter where I place this imported file,the statement after it in
> the main program gets a syntax error, regardless of the syntax.
>
> I think I may have changed something in this file, but I'm stuck.  Can
> anyone help?
>
> #!/usr/local/bin/python
> # Copyright 2004 by Stephen Masterman
>
> #Change the db connection details here.
>
>
> import MySQLdb
>
>
>
>
> def connect():
>
>
>return =  MySQLdb.connect (host = "db91x..com",
>user = "",
> passwd = "x",
>   db = "homebase_zingers"
>);

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, ronrsr wrote:

> def connect():
> 
> 
>return =  MySQLdb.connect (host = "db91x..com",
^

You can't assign to a keyword.  Just leave this ``=`` out.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
thanks for the speedy answer.  what i meant was:

 return   MySQLdb.connect (host = "db91b.pair.com",
   user = "homebase",
passwd = "Newspaper2",
db = "homebase_zingers"
   );


but even when I have that, I still get the same error.

bests, 

-rsr-

ronrsr wrote:
> here's some of t

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Roberto Bonvallet
ronrsr wrote:
> thanks for the speedy answer.  what i meant was:
> 
> return   MySQLdb.connect (host = "db91b.pair.com",
>   user = "homebase",
>passwd = "Newspaper2",
>db = "homebase_zingers"
>   );
> 
> 
> but even when I have that, I still get the same error.

Could you please copy and paste the exact code that is triggering the
error, and the exact error message?

(BTW, in Python you don't need to end your statements with a semi-colon)
-- 
Roberto Bonvallet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
the exact code that is triggering the error message is:

zc = zsql.connect()


exact error message:  SyntaxError:  Invalid Syntax


but any statement that follows the import statement will trigger it.

bests,

r-sr-




Roberto Bonvallet wrote:
> ronrsr wrote:
> > thanks for the speedy answer.  what i meant was:
> >

> Could you please copy and paste the exact code that is triggering the
> error, and the exact error message?
>
> (BTW, in Python you don't need to end your statements with a semi-colon)
> -- 
> Roberto Bonvallet

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
the syntax error comes in the main program, in any line that follows
the import statement.


ronrsr wrote:
> the exact code that is triggering the error message is:
>
> zc = zsql.connect()
>
>
> exact error message:  SyntaxError:  Invalid Syntax
>
>
> but any statement that follows the import statement will trigger it.
>
> bests,
>
> r-sr-
>
>
>
>
> Roberto Bonvallet wrote:
> > ronrsr wrote:
> > > thanks for the speedy answer.  what i meant was:
> > >
>
> > Could you please copy and paste the exact code that is triggering the
> > error, and the exact error message?
> >
> > (BTW, in Python you don't need to end your statements with a semi-colon)
> > -- 
> > Roberto Bonvallet

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Fredrik Lundh
"ronrsr" <[EMAIL PROTECTED]> wrote:

> the exact code that is triggering the error message is:
>
> zc = zsql.connect()

individual statements don't "trigger" syntax errors; they're compiler 
errors, and only
appear when do something that causes code to be compiled.

> exact error message:  SyntaxError:  Invalid Syntax

a complete syntax error usually includes a traceback:

Traceback (most recent call last):
  File "program.py", line 1, in 
import module
  File "module.py", line 25
if 1
   ^
SyntaxError: invalid syntax

what does the traceback look like in your case?

 



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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Steve Holden
ronrsr wrote:
> the syntax error comes in the main program, in any line that follows
> the import statement.
> 
in which case, don't you think it might be the "import" statement that's 
causing the problem. What is stopping you from showing us the whole 
source? Or at least the import statement as well as the statement that 
causes the syntax error to be reported. Maybe your module has an odd 
name like "from", for example.

We aren't psychic, you know (though some on this list come close).

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread John Machin

ronrsr wrote:
> the exact code that is triggering the error message is:
>
> zc = zsql.connect()

Don't give us one line; give us the whole of the imported module plus
the calling script (at least up to the place where it gets the error).
That way we can see what is really going on, and someone with mysqldb
installed could try to reproduce your problem.

>
> exact error message:  SyntaxError:  Invalid Syntax

Inexact! The message would have been
SyntaxError: invalid syntax

Please *DON'T* type in what you think you remember you think you saw on
the screen; *COPY/PASTE* the traceback and the error message.

>
>
> but any statement that follows the import statement will trigger it.
>
> bests,
>
> r-sr-
>
>
>
>
> Roberto Bonvallet wrote:
> > ronrsr wrote:
> > > thanks for the speedy answer.  what i meant was:
> > >
>
> > Could you please copy and paste the exact code that is triggering the
> > error, and the exact error message?
> >
> > (BTW, in Python you don't need to end your statements with a semi-colon)
> > --

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


Re: WMI - invalid syntax error?

2005-12-30 Thread py
here's the trace...

  File "MyScript.py", line 10,
wmiObj = wmi.WMI(machine)
  File "wmi.py", line 519, in __init__
handle_com_error (error_info)
  File "wmi.py", line 131, in handle_com_error
raise x_wmi, "\n".join (exception_string)
x_wmi: -0x7ffbfe1c - Invalid syntax

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


Re: WMI - invalid syntax error?

2005-12-30 Thread py
one more note, I am using WMI v0.6 however, I also tried it with
the latest version 1.0 rc2.

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


RE: WMI - invalid syntax error?

2005-12-30 Thread Tim Golden
[py]

> import wmi
> # the ip of my own local desktop
> machine = "1.2.3.4"
> try:
> w = wmi.WMI(machine)  # also tried, wmi.WMI(computer=machine)
> except Exception, e:
> print "ERROR:", e
.
.
> c:>python
> >>> from MyScript import *
> >>> ERROR: -0x7ffbfe1c - Invalid syntax
.
.
> here's the trace...
>
>  File "MyScript.py", line 10,
>wmiObj = wmi.WMI(machine)
>  File "wmi.py", line 519, in __init__
>handle_com_error (error_info)
>  File "wmi.py", line 131, in handle_com_error
>raise x_wmi, "\n".join (exception_string)
> x_wmi: -0x7ffbfe1c - Invalid syntax
.
.
> one more note, I am using WMI v0.6 however, I also tried it with
> the latest version 1.0 rc2.

OK, so if I understand you: at the interpreter you can do this:


import wmi
w = wmi.WMI ("1.2.3.4")
# no problem


but if you put it into a file and then import * from
that file, it fails with a wmi exception:


import wmi
w = wmi.WMI ("1.2.3.4")



from blah import *
## some kind of x_wmi exception happens here


And this happens on wmi 0.6 and 1.0rc2.

Is this correct? 

It's just that you've got several things which could
to be blurring the issue - the fact that you're using 
an explicit IP address rather than passing no params, 
which will then use the local machine automatically; 
you've added an exception handler which doesn't do much; 
your traceback in the second email doesn't (quite) match 
the  MyScript in the first. It's not that these are wrong - 
I'm just trying to eliminate non-essentials to get to the 
core of the thing.

In short, what I wrote above works for me on 0.6 and 1.0rc2.
A syntax error usually means that the moniker's got problems -
that's the string which the wmi module builds up on your
behalf to get something to pass to MS COM.

Could you just post (or send by private email if you prefer)
the exact script you're running? If you want to send it
privately, please us mail  timgolden.me.uk.

Thanks
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

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


Re: WMI - invalid syntax error?

2005-12-30 Thread py
Tim Golden wrote:
> Could you just post (or send by private email if you prefer)
> the exact script you're running? If you want to send it
> privately, please us mail  timgolden.me.uk.

I am truly unsure what the problem could be, and the fact that the
error says "invalid syntax" ...just doesn't make much sense to me.
Perhaps I could print out the moniker and see if that looks right...any
suggestion on how to do that?

Anyway I have this:
import wmi

def ppn(machine=None):
try:
wmiObj = wmi.WMI(machine)
print "Got it:", wmiObj
except Exception, e:
print "Error:", e


This is the same code, line for line, as i am using in a bigger script.
 It's got to be something stupid...just doesn't make any sense.  Wish
the error was more specific.

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


RE: WMI - invalid syntax error?

2005-12-30 Thread Tim Golden
[py]
| Tim Golden wrote:
| > Could you just post (or send by private email if you prefer)
| > the exact script you're running? If you want to send it
| > privately, please us mail  timgolden.me.uk.
| 
| I am truly unsure what the problem could be, and the fact that the
| error says "invalid syntax" ...just doesn't make much sense to me.
| Perhaps I could print out the moniker and see if that looks 
| right...any
| suggestion on how to do that?
| 
| Anyway I have this:

[.. snipped code ..]

OK, well just to confirm, I saved your code
as blah3.py, started an interpreter 
(Python 2.4.2 on XP Pro) and did:


from blah3 import *
blah3.ppn ()


and all was well.

Which obviously doesn't help you at all.

Get version 0.6b for the moment (if you don't have
it - http://tgolden.sc.sabren.com/python/downloads/wmi-0.6b.py).
Then set the _DEBUG flag to True. (v0.6 doesn't have this flag).


import wmi
wmi._DEBUG = True

c = wmi.WMI ()
# This will print a moniker looking something like this:
#
winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/ro
ot/cimv2


and let me know what comes out.

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

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


Re: WMI - invalid syntax error?

2005-12-30 Thread py
Tim Golden wrote:
> 
> import wmi
> wmi._DEBUG = True
>
> c = wmi.WMI ()
> # This will print a moniker looking something like this:
> #
> winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/ro
> ot/cimv2
> 
>
> and let me know what comes out.

I ran it twice, first it worked, second time it didnt...
winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/root/cimv2
winmgmts:{impersonationLevel=Impersonate,authenticationLevel=Default}/root/cimv2

..but same moniker.  Something must be happening somewhere causing it
to get fouled up.  I'm gonna try on a different PC.

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


Re: WMI - invalid syntax error?

2005-12-30 Thread py
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.

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


RE: WMI - invalid syntax error?

2006-01-03 Thread Tim Golden
[py]
| Sent: 30 December 2005 16:15
| To: python-list@python.org
| 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:


import win32com.client
x = win32com.client.GetObject ("winmgmts:")


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.


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


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

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


Re: WMI - invalid syntax error?

2006-01-03 Thread py
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
processesthis 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.

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


Re: WMI - invalid syntax error?

2006-01-03 Thread py
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.

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


RE: WMI - invalid syntax error?

2006-01-03 Thread Tim Golden
[py]
| I may end up looking into some other way of getting the list of
| processesthis is real screwy.

Just in case you hadn't found it under your own
steam, this link may help:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442477 


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

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


invalid syntax - problems with CR (0x0a)

2006-03-31 Thread cesare
hi,
i'm very new to python and am experiencing the following problem:

an identical program that runs on certain computers crashes on other 
machines due to Carriage Returns (CR; 0x0a) that
now appear in the source code. I guess it's some kind of character encoding 
issue, i.e. ways of saving the source files...
I spent a lot of time trying to fix the problem but wasn't successful until 
now.

Can somebody help me?

Cheers,
Cesare


error message inside the log file:

Traceback (most recent call last):
  File 
"S:\P037_Gewerbeverband\Programm\Testumgebung\meta_search_download_scheduler.py",
 
line 132, in instanceMP
exec 'import %s' % mp
  File "", line 1, in ?
  File "S:\P037_Gewerbeverband\Programm\Testumgebung\weisseseiten.py", line 
87
 s = s.replace('.-', ' CHF')
    s = s.replace(';', ' ')
^
 SyntaxError: invalid syntax 



== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list