setup.py 1.4 KB

123456789101112131415161718192021222324252627282930
  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. os.environ["GOPATH"] = os.path.expanduser('~/FrameworkBenchmarks/go')
  15. subprocess.call("go get ./...", shell=True, cwd="go", stderr=errfile, stdout=logfile)
  16. subprocess.Popen("go run src/hello/hello.go".rsplit(" "), cwd="go", stderr=errfile, stdout=logfile)
  17. return 0
  18. def stop(logfile, errfile):
  19. if os.name == 'nt':
  20. subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  21. subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  22. return 0
  23. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  24. out, err = p.communicate()
  25. for line in out.splitlines():
  26. if 'hello' in line:
  27. pid = int(line.split(None, 2)[1])
  28. os.kill(pid, 15)
  29. return 0