submit_awcy.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. from datetime import datetime
  9. #our timestamping function, accurate to milliseconds
  10. #(remove [:-3] to display microseconds)
  11. def GetTime():
  12. return datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
  13. if "check_output" not in dir( subprocess ): # duck punch it in!
  14. def f(*popenargs, **kwargs):
  15. if 'stdout' in kwargs:
  16. raise ValueError('stdout argument not allowed, it will be overridden.')
  17. process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
  18. output, unused_err = process.communicate()
  19. retcode = process.poll()
  20. if retcode:
  21. cmd = kwargs.get("args")
  22. if cmd is None:
  23. cmd = popenargs[0]
  24. raise subprocess.CalledProcessError(retcode, cmd)
  25. return output
  26. subprocess.check_output = f
  27. if 'DAALA_ROOT' not in os.environ:
  28. print(GetTime(), "Please specify the DAALA_ROOT environment variable to use this tool.")
  29. sys.exit(1)
  30. key = None
  31. with open('secret_key','r') as keyfile:
  32. key = keyfile.read().strip()
  33. if key is None:
  34. print(GetTime(), "Could not open your secret_key file!")
  35. sys.exit(1)
  36. daala_root = os.environ['DAALA_ROOT']
  37. os.chdir(daala_root)
  38. parser = argparse.ArgumentParser(description='Submit test to arewecompressedyet.com')
  39. parser.add_argument('-branch',default=None)
  40. parser.add_argument('-prefix',default=None)
  41. parser.add_argument('-master',action='store_true',default=False)
  42. parser.add_argument('-set',default='objective-1-fast')
  43. args = parser.parse_args()
  44. if args.branch is None:
  45. args.branch = subprocess.check_output('git symbolic-ref -q --short HEAD',shell=True).strip()
  46. if args.prefix is None:
  47. args.prefix = args.branch
  48. commit = subprocess.check_output('git rev-parse HEAD',shell=True).strip()
  49. short = subprocess.check_output('git rev-parse --short HEAD',shell=True).strip()
  50. date = subprocess.check_output(['git','show','-s','--format=%ci',commit]).strip()
  51. date_short = date.split()[0]
  52. user = args.prefix
  53. is_master = args.master
  54. run_id = user+'-'+date_short+'-'+short
  55. print(GetTime(), 'Creating run '+run_id)
  56. r = requests.post("https://arewecompressedyet.com/submit/job", {'run_id': run_id, 'commit': commit, 'master': is_master, 'key': key, 'task': args.set})
  57. print(GetTime(), r)