setup.py 934 B

1234567891011121314151617181920212223
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("onion/hello.c", "mysql_real_connect\(data.db\[i\], \".*\",", "mysql_real_connect(data.db[i], \"" + args.database_host + "\",")
  7. os.putenv("ONION_LOG","noinfo")
  8. subprocess.call("rm *.o", cwd="onion", shell=True, stderr=errfile, stdout=logfile)
  9. subprocess.call("cp -R installs/onion/* onion/onion", shell=True, stderr=errfile, stdout=logfile)
  10. subprocess.call("rm CMakeCache.txt", shell=True, cwd="onion/onion/build", stderr=errfile, stdout=logfile)
  11. subprocess.Popen("make && ./hello", shell=True, cwd="onion", stderr=errfile, stdout=logfile)
  12. return 0
  13. def stop(logfile, errfile):
  14. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  15. out, err = p.communicate()
  16. for line in out.splitlines():
  17. if 'hello' in line:
  18. pid = int(line.split(None, 2)[1])
  19. os.kill(pid, 15)
  20. return 0