submit_awcy.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import requests
  4. import argparse
  5. import os
  6. import subprocess
  7. import sys
  8. if "check_output" not in dir( subprocess ): # duck punch it in!
  9. def f(*popenargs, **kwargs):
  10. if 'stdout' in kwargs:
  11. raise ValueError('stdout argument not allowed, it will be overridden.')
  12. process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
  13. output, unused_err = process.communicate()
  14. retcode = process.poll()
  15. if retcode:
  16. cmd = kwargs.get("args")
  17. if cmd is None:
  18. cmd = popenargs[0]
  19. raise subprocess.CalledProcessError(retcode, cmd)
  20. return output
  21. subprocess.check_output = f
  22. if 'DAALA_ROOT' not in os.environ:
  23. print("Please specify the DAALA_ROOT environment variable to use this tool.")
  24. sys.exit(1)
  25. key = None
  26. with open('secret_key','r') as keyfile:
  27. key = keyfile.read().strip()
  28. if key is None:
  29. print("Could not open secret_key")
  30. sys.exit(1)
  31. daala_root = os.environ['DAALA_ROOT']
  32. os.chdir(daala_root)
  33. branch = subprocess.check_output('git symbolic-ref -q --short HEAD',shell=True).strip()
  34. parser = argparse.ArgumentParser(description='Submit test to arewecompressedyet.com')
  35. parser.add_argument('-prefix',default=branch)
  36. parser.add_argument('-master',action='store_true',default=False)
  37. args = parser.parse_args()
  38. commit = subprocess.check_output('git rev-parse HEAD',shell=True).strip()
  39. short = subprocess.check_output('git rev-parse --short HEAD',shell=True).strip()
  40. date = subprocess.check_output(['git','show','-s','--format=%ci',commit]).strip()
  41. date_short = date.split()[0]
  42. user = args.prefix
  43. is_master = args.master
  44. run_id = user+'-'+date_short+'-'+short
  45. print('Creating run '+run_id)
  46. r = requests.post("https://arewecompressedyet.com/submit/job", {'run_id': run_id, 'commit': commit, 'master': is_master, 'key': key})
  47. print(r)