Usage errors printed to console

91 views
Skip to first unread message

Ross Peoples

unread,
Jan 28, 2012, 8:31:32 PM1/28/12
to web...@googlegroups.com
I pulled from trunk a week or so ago and ever since, I've been getting this every few minutes printed to the console:

WARNING:web2py.cron:WEB2PY CRON Call returned code 2:
-J is reserved for Jython
usage: /usr/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

I am running web2py using this: python web2py.py -a password -i 0.0.0.0

If I add -N, the error goes away. I'm not using cron or anything. I only have one app in this web2py instance. Anyone else noticing these errors?

Jonathan Lundell

unread,
Jan 30, 2012, 9:52:02 AM1/30/12
to web...@googlegroups.com

The problem seems to be that when we issue a command like this (which the newcron does):

python web2py.py ... -J ...

...the -J is interpreted as an argument to python rather than to web2py.py.

I believe this can be fixed by adding a line in newcron.py. Change:

w2p_path = fileutils.abspath('web2py.py', gluon=True)
if os.path.exists(w2p_path):
commands.append(w2p_path)

to

w2p_path = fileutils.abspath('web2py.py', gluon=True)
if os.path.exists(w2p_path):
commands.append(w2p_path)
commands.append('--')

(BTW, the os.path.exists logic seems broken. If the path doesn't exist, it doesn't make sense to continue at all.)


Massimo Di Pierro

unread,
Jan 30, 2012, 11:05:24 AM1/30/12
to web...@googlegroups.com
what does append('--') do?

Jonathan Lundell

unread,
Jan 30, 2012, 11:27:24 AM1/30/12
to web...@googlegroups.com
On Jan 30, 2012, at 8:05 AM, Massimo Di Pierro wrote:

> what does append('--') do?

It tells the command (python in this case) to stop processing command-line options for itself.

Jonathan Lundell

unread,
Jan 30, 2012, 11:33:00 AM1/30/12
to web...@googlegroups.com

man bash:

-- A -- signals the end of options and disables further option processing. Any arguments
after the -- are treated as filenames and arguments. An argument of - is equivalent to --.

Massimo Di Pierro

unread,
Jan 30, 2012, 12:27:27 PM1/30/12
to web2py-users
ok adding --.

The reason it does not fail when it does not find web2py.py is that
(if I remember) this should work which binary distributions which do
not have a web2py.py.

Jonathan Lundell

unread,
Jan 30, 2012, 12:43:57 PM1/30/12
to web...@googlegroups.com
On Jan 30, 2012, at 9:27 AM, Massimo Di Pierro wrote:

> ok adding --.
>
> The reason it does not fail when it does not find web2py.py is that
> (if I remember) this should work which binary distributions which do
> not have a web2py.py.

I see. In that case, appending -- should be part of the if body (that is, indent it one level from my patch below).

Jonathan Lundell

unread,
Jan 30, 2012, 12:50:32 PM1/30/12
to web...@googlegroups.com
On Jan 30, 2012, at 9:43 AM, Jonathan Lundell wrote:

> On Jan 30, 2012, at 9:27 AM, Massimo Di Pierro wrote:
>
>> ok adding --.
>>
>> The reason it does not fail when it does not find web2py.py is that
>> (if I remember) this should work which binary distributions which do
>> not have a web2py.py.
>
> I see. In that case, appending -- should be part of the if body (that is, indent it one level from my patch below).

This might be a little more complicated. I believe that we want the -- if the command we're running is python, but not if the command we're running is web2py.py or the equivalent.

Reply all
Reply to author
Forward
0 new messages