changeset 0:0676a227dbc6

Uploaded
author melissacline
date Wed, 03 Sep 2014 15:37:49 -0400
parents
children 00ea1bdc1aed
files startXena.py tool_dependencies.xml xena.xml
diffstat 3 files changed, 87 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/startXena.py	Wed Sep 03 15:37:49 2014 -0400
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+import argparse
+import os
+import subprocess
+import sys
+
+def stop_err(msg, fp, 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, fp):
+    #Avoid using shell=True when we call subprocess to ensure if the Python
+    #script is killed, so too is the child process.
+    try:
+        child = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
+                                 stderr=subprocess.PIPE, shell=True)
+    except Exception, err:
+        stop_err("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err))
+    #Use .communicate as can get deadlocks with .wait(),
+    stdout, stderr = child.communicate()
+    return_code = child.returncode
+    if return_code:
+        if stderr and stdout:
+            stop_err("Return code %i from command:\n%s\n\n%s\n\n%s" % (return_code, err, stdout, stderr), fp)
+        else:
+            stop_err("Return code %i from command:\n%s\n%s" % (return_code, err, stderr), fp)
+
+
+
+def main():
+    jarPath = os.getenv("JAVA_JAR_PATH", "~")
+    xenaBaseDir = os.getenv("XENA_BASE_DIR", "~")
+    xenaJarPath = os.path.join(jarPath, "xena.jar")
+    xenaBaseDir = os.getenv("XENA_BASE_DIR", "~")
+    cmdline = "java -jar %s -r %s/xena/files -d %s/xena/db -t %s/xena/tmp" % (xenaJarPath, xenaBaseDir, xenaBaseDir, xenaBaseDir)
+    for ii in range(1,len(sys.argv)):
+        cmdline = "%s %s" % (cmdline, sys.argv[ii])
+    print "executing", cmdline
+    fp = open("/inside/home/cline/tmp/xena.out", "w")
+    fp.write("jar path (not paht) %s\n" % (jarPath))
+    fp.write("xena base dir %s\n" % (xenaBaseDir))
+    fp.write(cmdline)
+    run(cmdline, fp)
+    fp.close()
+
+if __name__ == '__main__':
+    main( )
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Wed Sep 03 15:37:49 2014 -0400
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<tool_dependency>
+  <package name="installXena" version="1.0">
+    <install version="1.0">
+      <actions>
+	<action type="move_file">
+	  <source>${REPOSITORY_INSTALL_DIR}/xena/xena.jar</source>
+	  <destination>${INSTALL_DIR}</destination>
+	</action>
+	<action type="set_environment">
+          <environment_variable name="JAVA_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>
+        </action>
+      </actions>
+    </install>
+  </package>
+</tool_dependency>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xena.xml	Wed Sep 03 15:37:49 2014 -0400
@@ -0,0 +1,15 @@
+<tool id="startXena" description="Start XENA" name="Start XENA" version="0.0.2">
+  <description>XENA VM</description>
+ <requirements>
+   <requirement type="package" version="1.0">installXena</requirement>
+ </requirements>
+  <command interpreter="python">
+    startXena.py  -H 0.0.0.0 -p 1236 &amp;
+  </command>
+ <help>
+    Press the Execute button to start the Xena VM.
+  </help>
+</tool>
+
+
+