Hello to the Jmol mailing list,
this is my first post.

I wrote a CGI python script that I will carry over for clarity:

=======================================































*#!/usr/bin/python# -*- coding: utf-8 -*-import cgiimport cgitb;
cgitb.enable()  # abilitare solo per il debugprint "Content-Type:
text/html;charset=utf-8\n\n"import sys, osimport os.pathimport shlex,
subprocessfrom subprocess import Popen, PIPEfrom os.path import dirname,
split, isdirparent_dir = lambda x: split(x)[0] if isdir(x) else
split(dirname(x))[0]my_launcher =
os.path.dirname(os.path.abspath(__file__))print "<p>The value of <b><font
color='green'>my_launcher</font></b> is:<br><font color='red'>" +
my_launcher + "</font></p>"jmol_dir = parent_dir(parent_dir(my_launcher)) +
"/db/jmol"print "<p>The value of <b><font color='green'>jmol_dir</font></b>
is:<br><font color='red'>" + jmol_dir +
"</font></p>"os.chdir(jmol_dir)os.environ['JAVA_PATH'] =
parent_dir(parent_dir(my_launcher)) + '/db/java/jre1.6.0_21/bin/'print
"<p>The value of <b><font color='green'>os.environ['JAVA_PATH']</font></b>
is:<br><font color='red'>" + os.environ['JAVA_PATH'] +
"</font></p>"jmol_cmd = os.environ['JAVA_PATH'] + '/java -jar ' + jmol_dir
+ '/Jmol.jar -o -s ' + my_launcher + '/jmol.spt -n'print "<p>The value of
<b><font color='green'>jmol_cmd</font></b> is:<br><font color='red'>" +
jmol_cmd + "</font></p>"idtf = shlex.split(jmol_cmd)subprocess1 =
subprocess.Popen(idtf)subprocess1.wait()exit()*

=======================================

I want to use this script as CGI, which runs in background to perform that
jmol elaboration on a downloaded file. I used "print" commands only to test
the script in the browser, in a local apache webserver under Linux 64bit.

This is the first part of the python script, which generates an IDTF file,
successively processed by the remaining parts of the script (here not
reported); the problem is, in fact, at this first level.

When I launch this script (which has 755 as permissions) in a Linux shell,
everything goes well, and the idtf file is generated (in a folder with 777
as permissions).

The problem starts when I want to run everything on a webserver (for now
I'm testing it in local): using "import cgitb; cgitb.enable()" for
debugging, there are no alerts in the browser, and so I can't understand
what is wrong; it is the only hitch. If I create the IDTF file with the
same script above launched in a linux shell, running then the other parts
of the python script as CGI, all is fine. So, I understood that the problem
is here, in the Jmol output generation via CGI (not via shell).

I have thought to use a portable version of java on the server, according
to what I read here (this is my first experience with a web application):
http://stackoverflow.com/questions/3764168/portable-jre-on-linux-possible

which is why I have used that version of java. After the installation of
the bin file, I have tested java giving the command:

java -version

and I saw that it works (the same thing for javaws, which gives me the list
of its options).

For the python script, as you can see, I have used absolute paths.
Consequently, to start Jmol, I have used the portable java:

cd jmol_dir
<absolute path>/java -jar ./Jmol.jar -o -s <absolute path>/jmol.spt -n

The jmol output has been saved in a folder with 777 permissions.

The java executable has 755 permissions, as well as the CGI script in
python.

Searching on the web I found this page on your Wiki:
http://wiki.jmol.org/index.php/Java_Web_Start

My folders are organized in this way:


   - *python_scripts/*  <= [permissions : *755* ]
   - *other_folder/*
      - *Jmol/  *<= [permissions : *755* ]
         - *output_jmol/  *<= [permissions : *777* ]
      - *java/*  <= [permissions : *755 ]*


What is the right way to perform what I want: how to launch a Jmol script
in background (without GUI) on a webserver (local/remote), to export the
output in a folder? I tried to change the owner user of "/var/www" folder,
from my username to *www-data* user, but without success, too.

I hope somebody know how to solve this question.

Thanks a lot for your support,

Riccardo Volpe

(I attach the script for you)





 *ChemBioScripting | X3D PyMOL Molecule Viewer
<http://chembioscripting.hol.es> *|* Gioacchino Riccardo Volpe*
#!/usr/bin/python
# -*- coding: utf-8 -*-

import cgi
import cgitb; cgitb.enable()  # abilitare solo per il debug

print "Content-Type: text/html;charset=utf-8\n\n"

import sys, os
import os.path
import shlex, subprocess
from subprocess import Popen, PIPE

from os.path import dirname, split, isdir
parent_dir = lambda x: split(x)[0] if isdir(x) else split(dirname(x))[0]

my_launcher = os.path.dirname(os.path.abspath(__file__))
print "<p>The value of <b><font color='green'>my_launcher</font></b> is:<br><font color='red'>" + my_launcher + "</font></p>"

jmol_dir = parent_dir(parent_dir(my_launcher)) + "/db/jmol"
print "<p>The value of <b><font color='green'>jmol_dir</font></b> is:<br><font color='red'>" + jmol_dir + "</font></p>"
os.chdir(jmol_dir)

os.environ['JAVA_PATH'] = parent_dir(parent_dir(my_launcher)) + '/db/java/jre1.6.0_21/bin/'
print "<p>The value of <b><font color='green'>os.environ['JAVA_PATH']</font></b> is:<br><font color='red'>" + os.environ['JAVA_PATH'] + "</font></p>"
jmol_cmd = os.environ['JAVA_PATH'] + '/java -jar ' + jmol_dir + '/Jmol.jar -o -s ' + my_launcher + '/jmol.spt -n'
print "<p>The value of <b><font color='green'>jmol_cmd</font></b> is:<br><font color='red'>" + jmol_cmd + "</font></p>"
idtf = shlex.split(jmol_cmd)
subprocess1 = subprocess.Popen(idtf)
subprocess1.wait()
exit()
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to