Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Error when python script run as cgi script (http://www.velocityreviews.com/forums/t545882-error-when-python-script-run-as-cgi-script.html)

sophie_newbie 10-21-2007 04:50 PM

Error when python script run as cgi script
 
Hi, I'm running a python script which if I run from the command line
as root runs fine. But if I run it through the web-browser as a cgi
script gives the following error "Error in X11: unable to start device
PNG".

Now I should say that this python script is calling fucntions in R (a
scripting languange used in statistics) using the python module RPy,
so this I dunno if this is entirely a Python question, because as far
as I can see the error is being thrown by R. But then as I say, when
the script is run by the root user from the command line everything
goes off without a hitch.

So I dunno is there some way to run a CGI script as root, maybe thats
a bad idea because of security? But any ideas would be welcome.

-Thanks.


Dennis Lee Bieber 10-21-2007 06:28 PM

Re: Error when python script run as cgi script
 
On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
<paulgeeleher@gmail.com> declaimed the following in comp.lang.python:

> Hi, I'm running a python script which if I run from the command line
> as root runs fine. But if I run it through the web-browser as a cgi
> script gives the following error "Error in X11: unable to start device
> PNG".
>
> Now I should say that this python script is calling fucntions in R (a
> scripting languange used in statistics) using the python module RPy,
> so this I dunno if this is entirely a Python question, because as far
> as I can see the error is being thrown by R. But then as I say, when
> the script is run by the root user from the command line everything
> goes off without a hitch.
>

Ah, but does it run if you boot into a NON-graphical command shell
mode...

That error message looks suspiciously like something is trying to
open a graphical display window... A web-server likely does not have any
graphical environment.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

sophie_newbie 10-22-2007 11:09 AM

Re: Error when python script run as cgi script
 
On Oct 21, 7:28 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
> <paulgeele...@gmail.com> declaimed the following in comp.lang.python:
>
> > Hi, I'm running a python script which if I run from the command line
> > as root runs fine. But if I run it through the web-browser as a cgi
> > script gives the following error "Error in X11: unable to start device
> > PNG".

>
> > Now I should say that this python script is calling fucntions in R (a
> > scripting languange used in statistics) using the python module RPy,
> > so this I dunno if this is entirely a Python question, because as far
> > as I can see the error is being thrown by R. But then as I say, when
> > the script is run by the root user from the command line everything
> > goes off without a hitch.

>
> Ah, but does it run if you boot into a NON-graphical command shell
> mode...
>
> That error message looks suspiciously like something is trying to
> open a graphical display window... A web-server likely does not have any
> graphical environment.
> --
> Wulfraed Dennis Lee Bieber KD6MOG
> wlfr...@ix.netcom.com wulfr...@bestiaria.com
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff: web-a...@bestiaria.com)
> HTTP://www.bestiaria.com/


Ya thanks looks like you're actually right. The strange thing is that
the program, when run from a graphical command line, doesn't actually
open any display window. Although the code doesn't run when executed
as a webserver, most likely, as you pointed out, because there is no
graphical environment. I wonder if there any way I can somehow enable
a graphical environment for the webserver, or do I have to re-write
the underlying code?


Dennis Lee Bieber 10-22-2007 05:39 PM

Re: Error when python script run as cgi script
 
On Mon, 22 Oct 2007 04:09:31 -0700, sophie_newbie
<paulgeeleher@gmail.com> declaimed the following in comp.lang.python:

> Ya thanks looks like you're actually right. The strange thing is that
> the program, when run from a graphical command line, doesn't actually
> open any display window. Although the code doesn't run when executed


I probably shouldn't have used the word "display"; what I meant to
imply was that the low-level is trying to use a graphical environment to
render something (a PNG image?) using a non-displayed/off-screen memory
block... The main factor being that it isn't drawing the image file
itself, but expecting to create the bitmap using the OS (in this case,
X-window) calls, and probably then doing a "screen grab" to get the
result into a file.

All this is hypothesis based upon the reported message. And it is
likely down in the level of the R source code, not at the Python level
(other than, perhaps, replacing R with something like NumPy/SciPy and
PIL).
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/


All times are GMT. The time now is 05:02 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.