Mercurial > repos > melissacline > start_xena
view startXena.py @ 10:1374011ce9bc default tip
Updating the xena jar to version 0.3
author | melissacline |
---|---|
date | Tue, 23 Sep 2014 21:42:44 -0700 (2014-09-24) |
parents | ed83452c5f8e |
children |
line wrap: on
line source
#!/usr/bin/env python import argparse import os import subprocess import sys def stop_err(msg, error_level=1): """Print error message to stdout and quit with given error level.""" sys.stderr.write("%s\n" % msg) sys.exit(error_level) def run(cmd): 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)) else: stop_err("Return code %i from command:\n%s" % (return_code, stderr)) def main(): jarPath = os.getenv("XENA_JAR_PATH", "~") xenaJarPath = os.path.join(jarPath, "xena.jar") xenaBaseDir = os.getenv("XENA_BASE_DIR", "~") xenaPort = os.getenv("XENA_PORT", 1236) cmdline = "java -jar %s -r %s/files -d %s/db -t %s/tmp -p %s -H 0.0.0.0" % (xenaJarPath, xenaBaseDir, xenaBaseDir, xenaBaseDir, xenaPort) for ii in range(1,len(sys.argv)): cmdline = "%s %s" % (cmdline, sys.argv[ii]) cmdline += " &" subprocess.call(cmdline, shell=True) print "Xena VM invoked with command", cmdline if __name__ == '__main__': main( )