Re: Print recent CGI error

2010-12-04 Thread Gnarlodious
After many curse words I figured it out. A two-stage filter was
needed. The 5th line solves the problem of colliding domain cookies:

NowCookie=http.cookies.SimpleCookie() # Instantiate a SimpleCookie
object
savedCookie=os.environ.get('HTTP_COOKIE') # get the cookie string
if savedCookie:  # Already is a domain cookie
NowCookie.load(savedCookie)  # Could be any domain cookie
if CookieName in NowCookie:  # Look for a specific cookie
savedCookie=NowCookie[CookieName].value  # Load the cookie
string into a dict
self.List=list(savedCookie.split('~'))  # Parse the payload
string delimited at tilde
return
self.List=[hashlib.sha1(repr(time.time()).encode()).hexdigest(), '',
'']  # Else default payload
self.Write()  # Tell the client to remember

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


Re: Print recent CGI error

2010-12-04 Thread MRAB

On 04/12/2010 21:13, Gnarlodious wrote:

What you posted doesn't work, I don't know why. All I get is a blank
page and no Apache error report.

There are two problems with this. I am really trying to figure out how
to trap an error on the server without exposing my innards to the
world, which import cgitb; cgitb.enable() does. The other problem is
that no traceback seems to play well with a try-except block. I guess
I am forced to use one or the other, but not both.

What I really wanted to do is display any error in a simple error
statement. This is probably a KeyError, but how am I to know? There
must be some way to print a dump of the current thread before it
deallocates.


Double-check what version of Python is on the server.

See if you can write the traceback to a file on the server which you
can then download.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print recent CGI error

2010-12-04 Thread Gnarlodious
What you posted doesn't work, I don't know why. All I get is a blank
page and no Apache error report.

There are two problems with this. I am really trying to figure out how
to trap an error on the server without exposing my innards to the
world, which import cgitb; cgitb.enable() does. The other problem is
that no traceback seems to play well with a try-except block. I guess
I am forced to use one or the other, but not both.

What I really wanted to do is display any error in a simple error
statement. This is probably a KeyError, but how am I to know? There
must be some way to print a dump of the current thread before it
deallocates.

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


Re: Print recent CGI error

2010-12-04 Thread MRAB

On 04/12/2010 18:33, Gnarlodious wrote:

I have a serious error that causes the process to crash. Apache
refuses to log the error and it only happens on the server, not on the
dev machine. Problem is, I can't figure out how to get the most recent
error. I can find all sorts of pages telling how to print a specific
error, but how to get an unknown error:

Here is where I am:

NowCookie.load(savedCookie)
try:
 savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
except:
 print("Content-type:text/html\n\n")
 print("???")  # PRINT WHATEVER ERROR OCCURRED
 quit()

There must be something so simple I am missing...

This is Python 3.


You could try something like:

import traceback

NowCookie.load(savedCookie)
try:
savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
except:
print("Content-type:text/html\n\n")
traceback.print_exception(*sys.exc_info())  # PRINT WHATEVER ERROR 
OCCURRED

quit()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print recent CGI error

2010-12-04 Thread Dan Stromberg
I've sometimes got similar situations in CGI, that turned out to be
because of a syntax error that kept apache from being able to run the
script.  What if you just run the script at the command line?  It
should either error out due to lack of a CGI environment/arguments,
but hopefully it'll give you an error message that'll be useful.
Also, you might be able to get some mileage out of finding out what
env vars and command line options are being passed, and running from
the command line with those.

On Sat, Dec 4, 2010 at 10:33 AM, Gnarlodious  wrote:
> I have a serious error that causes the process to crash. Apache
> refuses to log the error and it only happens on the server, not on the
> dev machine. Problem is, I can't figure out how to get the most recent
> error. I can find all sorts of pages telling how to print a specific
> error, but how to get an unknown error:
>
> Here is where I am:
>
> NowCookie.load(savedCookie)
> try:
>    savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
> except:
>    print("Content-type:text/html\n\n")
>    print("???")  # PRINT WHATEVER ERROR OCCURRED
>    quit()
>
> There must be something so simple I am missing...
>
> This is Python 3.
>
> -- Gnarlie
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Print recent CGI error

2010-12-04 Thread Gnarlodious
I have a serious error that causes the process to crash. Apache
refuses to log the error and it only happens on the server, not on the
dev machine. Problem is, I can't figure out how to get the most recent
error. I can find all sorts of pages telling how to print a specific
error, but how to get an unknown error:

Here is where I am:

NowCookie.load(savedCookie)
try:
savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
except:
print("Content-type:text/html\n\n")
print("???")  # PRINT WHATEVER ERROR OCCURRED
quit()

There must be something so simple I am missing...

This is Python 3.

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


Re: Weird cgi error

2008-02-25 Thread gherzig
>
>> This is some kind of crooked game, right? Your code works fine on a
>> local server, and there's no reason why it shouldn't work just fine on
>> yours either. All you are changing is the standard input to the process.
>>
>> Since you claim to have spotted this specific error, perhaps you'd like
>> to explain just exactly how you came across it. I mean that's a pretty
>> specific input to test with ...
>>
>> Frankly I am not sure you are telling the truth about the code behind
>> that page. If you *are* then you'd better provide specifics: Python
>> version, Apache version, httpd.conf file, and so on. April 1 is still
>> over a month away.
>>
>> regards
>>   Steve
>>
>> PS: consider closing the  tag on the same line as the opening
>> tag to avoid spurious spaces in your pristine form.
>> --
>> Steve Holden+1 571 484 6266   +1 800 494 3119
>> Holden Web LLC  http://www.holdenweb.com/
>
> Thanks for the reply.
>
> No, it's not a game, crookedgames.com is a mostly defunct games site
> that I was working on for a while.  I'm just hosting the script
> there.  What I am actually working on is a tool used to compare
> various things.  Check it out here:
> http://crookedgames.com/cgi-bin/Language_Comparison.py
> Here's some input you can use to test with:
>
> Cats
>   +2 Fuzzy
>   -1 Medium Maintenance
>
> Fish
>   +1 Low Maintenance
>   -1 Stupid
>
> Dogs
>   +2 Fuzzy
>   -2 High Maintenance
>
> (note that there's supposed to be two spaces before the +/- symbols --
> in case my formatting doesn't go through)
>
> I originally created that tool because I wanted to compare programming
> languages, python among them, thus leading me discover this issue.
>
> Now, I'm very new to this web development stuff (this is my first real
> app), so it's quite likely that I'm just doing something stupid, but I
> can't figure out what.
>
> I'm using LunarPages.  CPanel reports my Apache version as: 1.3.37
> (Unix)
>
> I added the line "print sys.version" to the test script, and that
> spits out: "2.3.4 (#1, Dec 11 2007, 05:27:57) [GCC 3.4.6 20060404 (Red
> Hat 3.4.6-9)]"
>
> I can't find any file called httpd.conf.  It would be in /etc, right?
> I guess I don't have one.
>
> Still having the same problem.
>
> Here's the new contents of test.py:
>
> #!/usr/bin/python
> import cgitb, sys
> cgitb.enable()
>
> print "Content-Type: text/html\n"
> print sys.version
> print """
> 
> 
>   
>  
> 
>   
> 
> 
> """
>
> It's not a joke, honest :)
> --
It just doesnt make sense to me. I guess we all agree that is not a python
problem, because that code does actually nothing but showing the form.

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


Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge

> This is some kind of crooked game, right? Your code works fine on a
> local server, and there's no reason why it shouldn't work just fine on
> yours either. All you are changing is the standard input to the process.
>
> Since you claim to have spotted this specific error, perhaps you'd like
> to explain just exactly how you came across it. I mean that's a pretty
> specific input to test with ...
>
> Frankly I am not sure you are telling the truth about the code behind
> that page. If you *are* then you'd better provide specifics: Python
> version, Apache version, httpd.conf file, and so on. April 1 is still
> over a month away.
>
> regards
>   Steve
>
> PS: consider closing the  tag on the same line as the opening
> tag to avoid spurious spaces in your pristine form.
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.com/

Thanks for the reply.

No, it's not a game, crookedgames.com is a mostly defunct games site
that I was working on for a while.  I'm just hosting the script
there.  What I am actually working on is a tool used to compare
various things.  Check it out here: 
http://crookedgames.com/cgi-bin/Language_Comparison.py
Here's some input you can use to test with:

Cats
  +2 Fuzzy
  -1 Medium Maintenance

Fish
  +1 Low Maintenance
  -1 Stupid

Dogs
  +2 Fuzzy
  -2 High Maintenance

(note that there's supposed to be two spaces before the +/- symbols --
in case my formatting doesn't go through)

I originally created that tool because I wanted to compare programming
languages, python among them, thus leading me discover this issue.

Now, I'm very new to this web development stuff (this is my first real
app), so it's quite likely that I'm just doing something stupid, but I
can't figure out what.

I'm using LunarPages.  CPanel reports my Apache version as: 1.3.37
(Unix)

I added the line "print sys.version" to the test script, and that
spits out: "2.3.4 (#1, Dec 11 2007, 05:27:57) [GCC 3.4.6 20060404 (Red
Hat 3.4.6-9)]"

I can't find any file called httpd.conf.  It would be in /etc, right?
I guess I don't have one.

Still having the same problem.

Here's the new contents of test.py:

#!/usr/bin/python
import cgitb, sys
cgitb.enable()

print "Content-Type: text/html\n"
print sys.version
print """


  
 

  


"""

It's not a joke, honest :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weird cgi error

2008-02-25 Thread Steve Holden
Jesse Aldridge wrote:
> I uploaded the following script, called "test.py", to my webhost.
> It works find except when I input the string "python ".  Note that's
> the word "python" followed by a space.  If I submit that I get a 403
> error.  It seems to work fine with any other string.
> What's going on here?
> 
> Here's the script in action: http://crookedgames.com/cgi-bin/test.py
> 
> Here's the code:
> 
> #!/usr/bin/python
> print "Content-Type: text/html\n"
> print """
> 
> 
>   
> 
> 
>   
>   
> 
> 
> """

This is some kind of crooked game, right? Your code works fine on a 
local server, and there's no reason why it shouldn't work just fine on 
yours either. All you are changing is the standard input to the process.

Since you claim to have spotted this specific error, perhaps you'd like 
to explain just exactly how you came across it. I mean that's a pretty 
specific input to test with ...

Frankly I am not sure you are telling the truth about the code behind 
that page. If you *are* then you'd better provide specifics: Python 
version, Apache version, httpd.conf file, and so on. April 1 is still 
over a month away.

regards
  Steve

PS: consider closing the  tag on the same line as the opening 
tag to avoid spurious spaces in your pristine form.
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge
On Feb 25, 11:42 am, Jesse Aldridge <[EMAIL PROTECTED]> wrote:
> > If you cant have access to the apache (?) error_log, you can put this in
> > your code:
> > import cgitb
> > cgitb.enable()
>
> > Which should trap what is being writed on the error stream and put it on
> > the cgi output.
>
> > Gerardo
>
> I added that.  I get no errors.  It still doesn't work.  Well, I do
> get several errors about the missing favicon, but I'm pretty sure
> that's unrelated.

Oh, and yeah, the server's running Apache.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge

> If you cant have access to the apache (?) error_log, you can put this in
> your code:
> import cgitb
> cgitb.enable()
>
> Which should trap what is being writed on the error stream and put it on
> the cgi output.
>
> Gerardo

I added that.  I get no errors.  It still doesn't work.  Well, I do
get several errors about the missing favicon, but I'm pretty sure
that's unrelated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weird cgi error

2008-02-25 Thread Gerardo Herzig
Jesse Aldridge wrote:

>I uploaded the following script, called "test.py", to my webhost.
>It works find except when I input the string "python ".  Note that's
>the word "python" followed by a space.  If I submit that I get a 403
>error.  It seems to work fine with any other string.
>What's going on here?
>
>Here's the script in action: http://crookedgames.com/cgi-bin/test.py
>
>Here's the code:
>
>#!/usr/bin/python
>print "Content-Type: text/html\n"
>print """
>
>
>  
>
>
>  
>  
>
>
>"""
>  
>
If you cant have access to the apache (?) error_log, you can put this in 
your code:
import cgitb
cgitb.enable()

Which should trap what is being writed on the error stream and put it on 
the cgi output.

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


Re: Weird cgi error

2008-02-25 Thread marti john
 GET YOUR  SITE LISTET AT GOOGLE & YAHOO "NR.1" SEARCH RESULT for FREE Now BEST 
CHANCE EVER 2 GET TONZ OF SIGN UPS IN UR DOWNLINE !!!  CLICK IT DON'T MISS



MAKE 16.000 Dollars Every Fcuckng Month !
Click  Don't Miss it !!

Jesse Aldridge <[EMAIL PROTECTED]> wrote: I uploaded the following script, 
called "test.py", to my webhost.
It works find except when I input the string "python ".  Note that's
the word "python" followed by a space.  If I submit that I get a 403
error.  It seems to work fine with any other string.
What's going on here?

Here's the script in action: http://crookedgames.com/cgi-bin/test.py

Here's the code:

#!/usr/bin/python
print "Content-Type: text/html\n"
print """


  

   [input] 
  






MAKE 16.000 Dollars Every Fcuckng Month !
Click  Don't Miss it !!

   
-
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.-- 
http://mail.python.org/mailman/listinfo/python-list

Weird cgi error

2008-02-24 Thread Jesse Aldridge
I uploaded the following script, called "test.py", to my webhost.
It works find except when I input the string "python ".  Note that's
the word "python" followed by a space.  If I submit that I get a 403
error.  It seems to work fine with any other string.
What's going on here?

Here's the script in action: http://crookedgames.com/cgi-bin/test.py

Here's the code:

#!/usr/bin/python
print "Content-Type: text/html\n"
print """


  


  
  


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


Re: cgi error

2006-03-31 Thread Richard Brodie

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> It works fine when i run it in python , but it won't run when i run my
> cgi script.
>
> It says AttributeError: 'module' object has no attribute 'FTPHost'
> what could be a possible cause? thanks.

Perhaps you called your script 'ftputil'. If so, 'import ftputil' won't
import the standard library version. 


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


Re: cgi error

2006-03-31 Thread v0id
I'm not sure, but in your CGI script, where you have
import cgi
or
import cgi
import cgitb; cgitb.enable()
there sometimes come error if place any other modules over it.
I don't now if it is that, 'cus i don't have seen more of your code.
so if your code is:
importFTPHost
import cgi
import cgitb; cgitb.enable()
#Some code here
# and here
.. then prove this:
import cgi
import cgitb; cgitb.enable()
import FTPHost
#Some code here
# and here

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


cgi error

2006-03-31 Thread s99999999s2003
hi
I have a little function to use ftputil module to get a file from a
server

def getfile(filename):
import ftputil
host = ftputil.FTPHost(svr, usr,pswd)
host.chdir("/somewhere")
try:
host.download(filename,filename,"a")
except ftputil.FTPError,v:
print v

It works fine when i run it in python , but it won't run when i run my
cgi script
It says AttributeError: 'module' object has no attribute 'FTPHost'
what could be a possible cause? thanks.

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