changeset 7:733fa93086c5

Adding the Xena port to the environment variables. Adding an output file
author melissacline
date Tue, 23 Sep 2014 20:08:36 -0700
parents 75c7d80df9c1
children c1388ebe8662
files startXena.py tool_dependencies.xml xena.xml
diffstat 3 files changed, 18 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/startXena.py	Tue Sep 09 18:48:53 2014 -0700
+++ b/startXena.py	Tue Sep 23 20:08:36 2014 -0700
@@ -8,15 +8,10 @@
 def stop_err(msg, error_level=1):
    """Print error message to stdout and quit with given error level."""
    sys.stderr.write("%s\n" % msg)
-   #fp.write("%s\n" % msg)
-   #fp.write("error code %d\n" % error_level)
    sys.exit(error_level)
 
     
 def run(cmd):
-    #Avoid using shell=True when we call subprocess to ensure if the Python
-    #script is killed, so too is the child process.
-   print cmd
    try:
       child = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
                                stderr=subprocess.PIPE, shell=True)
@@ -29,26 +24,24 @@
       if stderr and stdout:
          stop_err("Return code %i from command:\n%s\n\n%s\n\n%s" % (return_code, err, stdout, stderr))
       else:
-         stop_err("Return code %i from command:\n%s\n%s" % (return_code, err, stderr))
+         stop_err("Return code %i from command:\n%s" % (return_code, stderr))
 
 
 
 def main():
-   #parser = argparse.ArgumentParser()
-   #parser.add_argument("-H", "--host", type=str)
-   #parser.add_argument("-p", "--port", type=str)
-   #args = parser.parse_args()
 
-   jarPath = os.getenv("JAVA_JAR_PATH", "~")
+   jarPath = os.getenv("XENA_JAR_PATH", "~")
    xenaJarPath = os.path.join(jarPath, "xena.jar")
    xenaBaseDir = os.getenv("XENA_BASE_DIR", "~")
-   cmdline = "java -jar %s -r %s/files -d %s/db -t %s/tmp >& /inside/home/cline/tmp/xena.errout" % (xenaJarPath, xenaBaseDir, xenaBaseDir, xenaBaseDir)
+   xenaPort = os.getenv("XENA_PORT", 1236)
+   cmdline = "java -jar %s -r %s/files -d %s/db -t %s/tmp -p %d" % (xenaJarPath, xenaBaseDir, 
+                                                                    xenaBaseDir, xenaBaseDir,
+                                                                    xenaPort)
    for ii in range(1,len(sys.argv)):
        cmdline = "%s %s" % (cmdline, sys.argv[ii])
-   #fp = open("/inside/home/cline/tmp/xena.out", "w")
-   #fp.write("cmdline %s\n" % cmdline)
-   #fp.close()
-   run(cmdline)
+   cmd += " &"
+   print "Xena VM invoked with command", cmdline
+   subprocess.call(cmd, shell=True)
 
 if __name__ == '__main__':
     main( )
--- a/tool_dependencies.xml	Tue Sep 09 18:48:53 2014 -0700
+++ b/tool_dependencies.xml	Tue Sep 23 20:08:36 2014 -0700
@@ -4,7 +4,7 @@
     <install version="1.0">
       <actions>
 	<action type="set_environment">
-          <environment_variable name="JAVA_JAR_PATH" action="set_to">$INSTALL_DIR</environment_variable>
+          <environment_variable name="XENA_JAR_PATH" action="set_to">$INSTALL_DIR</environment_variable>
         </action>  
 	<action type="set_environment">
           <environment_variable name="XENA_BASE_DIR" action="set_to">$INSTALL_DIR/xena</environment_variable>
@@ -12,6 +12,9 @@
 	<action type="set_environment">
 	  <environment_variable name="PYTHONPATH" action="prepend_to">$INSTALL_DIR</environment_variable>
 	</action>
+	<action type="set_environment">
+	  <environment_variable name="XENA_PORT" action="set_to">1236</environment_variable>
+	</action>
 	<action type="move_file">
 	  <source>${REPOSITORY_INSTALL_DIR}/xena.jar</source>
 	  <destination>${INSTALL_DIR}</destination>
--- a/xena.xml	Tue Sep 09 18:48:53 2014 -0700
+++ b/xena.xml	Tue Sep 23 20:08:36 2014 -0700
@@ -4,10 +4,13 @@
    <requirement type="package" version="1.0">installXena</requirement>
  </requirements>
   <command interpreter="python">
-    startXena.py   -H 0.0.0.0 -p 1236 &amp;
+    startXena.py   -H 0.0.0.0 &amp >&amp $outfile;
   </command>
+  <outputs>
+    <data format="txt" name="outfile"/>
+  </outputs>
  <help>
-    Press the Execute button to start the Xena VM.
+    Press the Execute button to start the Xena VM.  An output log will indicate if the VM was started successfully.
   </help>
 </tool>