prun.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. '''
  2. Created on 2013-1-25
  3. @author: ZhenQin
  4. '''
  5. import os
  6. import platform
  7. MAIN_CLASS="com.sdyc.clstest.t.HelloWorld"
  8. DEFAULT_LIB="lib"
  9. DEFAULT_CP="classes"
  10. JVM_ARGS="-Xmx128m"
  11. PRO_ARGS=""
  12. SYSTEM="Windows"
  13. FILESEP="\\"
  14. SPLIT=";"
  15. sysstr = platform.system()
  16. if(sysstr =="Windows"):
  17. SYSTEM="Windows"
  18. FILESEP="\\"
  19. SPLIT=";"
  20. elif(sysstr == "Linux"):
  21. SYSTEM="Linux"
  22. FILESEP="/"
  23. SPLIT=":"
  24. else:
  25. SYSTEM="Linux"
  26. FILESEP="/"
  27. SPLIT=":"
  28. def run(mainRun = "java"):
  29. return mainRun
  30. def jvmArgs(vmArgs = ""):
  31. vmArgs += JVM_ARGS
  32. return vmArgs;
  33. def classpath(classpath = ""):
  34. currentDir = os.getcwd()
  35. libdir = currentDir + "/" + DEFAULT_LIB;
  36. libfile = currentDir + FILESEP + DEFAULT_LIB;
  37. clazzdir = currentDir + FILESEP + DEFAULT_CP;
  38. if classpath != "" :
  39. classpath = classpath + SPLIT + clazzdir;
  40. else :
  41. classpath = clazzdir;
  42. for fileordir in os.listdir(libdir):
  43. if os.path.isfile(libdir + "/" + fileordir):
  44. classpath = classpath + SPLIT + libfile + FILESEP + fileordir
  45. return classpath
  46. def mainClass():
  47. return MAIN_CLASS;
  48. def args(args = ""):
  49. return args + PRO_ARGS;
  50. if __name__ == '__main__':
  51. run_arg = run() + " " + jvmArgs();
  52. if classpath() != "" :
  53. run_arg += (" -classpath " + classpath());
  54. run_arg += (" " + mainClass() + " " + args())
  55. print "CONSOLE_EXECUTE: \n" + run_arg
  56. result = os.popen(run_arg).readlines()
  57. print result