setup.py 825 B

12345678910111213141516171819202122
  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.Popen("make && ./hello", shell=True, cwd="onion", stderr=errfile, stdout=logfile)
  11. return 0
  12. def stop(logfile, errfile):
  13. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  14. out, err = p.communicate()
  15. for line in out.splitlines():
  16. if 'hello' in line:
  17. pid = int(line.split(None, 2)[1])
  18. os.kill(pid, 9)
  19. return 0