setup.py 1.0 KB

12345678910111213141516171819202122232425
  1. import subprocess
  2. import sys
  3. import os
  4. def start(args, logfile, errfile):
  5. if os.name == 'nt':
  6. subprocess.call("set GOPATH=C:\\FrameworkBenchmarks\\webgo&&go get ./...", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  7. subprocess.Popen("setup.bat", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  8. return 0
  9. subprocess.call("go get ./...", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  10. subprocess.Popen("go run src/hello/hello.go".rsplit(" "), cwd="webgo", stderr=errfile, stdout=logfile)
  11. return 0
  12. def stop(logfile, errfile):
  13. if os.name == 'nt':
  14. subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  15. subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  16. return 0
  17. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  18. out, err = p.communicate()
  19. for line in out.splitlines():
  20. if 'hello' in line:
  21. pid = int(line.split(None, 2)[1])
  22. os.kill(pid, 15)
  23. return 0