setup.py 1.3 KB

1234567891011121314151617181920212223242526272829
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("go/src/hello/hello.go", "tcp\(.*:3306\)", "tcp(" + args.database_host + ":3306)")
  7. if os.name == 'nt':
  8. #subprocess.call("rmdir /s /q pkg\\windows_amd64", shell=True, cwd="go")
  9. #subprocess.call("rmdir /s /q src\\github.com", shell=True, cwd="go")
  10. #subprocess.call("del /s /q /f bin\\hello.exe", shell=True, cwd="go")
  11. subprocess.call("set GOPATH=C:\\FrameworkBenchmarks\\go&& go get ./...", shell=True, cwd="go", stderr=errfile, stdout=logfile)
  12. subprocess.Popen("setup.bat", shell=True, cwd="go", stderr=errfile, stdout=logfile)
  13. return 0
  14. subprocess.call("go get ./...", shell=True, cwd="go", stderr=errfile, stdout=logfile)
  15. subprocess.Popen("go run src/hello/hello.go".rsplit(" "), cwd="go", stderr=errfile, stdout=logfile)
  16. return 0
  17. def stop(logfile, errfile):
  18. if os.name == 'nt':
  19. subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  20. subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  21. return 0
  22. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  23. out, err = p.communicate()
  24. for line in out.splitlines():
  25. if 'hello' in line:
  26. pid = int(line.split(None, 2)[1])
  27. os.kill(pid, 9)
  28. return 0