| #!/usr/bin/python |
| |
| from mixpanel import Mixpanel |
| |
| import sys |
| import getpass |
| import socket |
| import subprocess |
| import os |
| |
| from os.path import expanduser |
| home = expanduser("~") |
| |
| try: |
| mp = Mixpanel("7d5ca3b3ff870dbeda89c9d5af59e9e9") |
| hostname = socket.gethostname() |
| |
| context = {} |
| context['debian-version'] = open('/etc/debian_version').read().strip() |
| |
| |
| os.chdir(home+'/cord/orchestration/xos') |
| p = subprocess.Popen(['git','rev-parse','HEAD'], stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=subprocess.PIPE) |
| |
| git_hash,err = p.communicate() |
| |
| context['last-commit'] = git_hash |
| |
| config = open(home + '/cord/build/config/cord_in_a_box.yml').read().splitlines() |
| for l in config: |
| if 'cord_profile:' in l: |
| context['profile'] = l.rstrip().rsplit(' ')[-1].replace("'","") |
| |
| context['user'] = getpass.getuser() |
| |
| name = '' |
| idx=0 |
| lst = hostname.split('.') |
| lst.reverse() |
| for i in lst: |
| name='.'.join([name,i]).lstrip('.') |
| |
| context['level-%d'%idx] = name |
| idx+=1 |
| |
| if (len(sys.argv)>2 and 'finish' in sys.argv[2]): |
| logfile = open(home + '/cord/install.out').read().splitlines() |
| snapshot = logfile[-20:] |
| snapshot = filter(lambda x:x, snapshot) |
| context['snapshot'] = snapshot |
| |
| try: |
| build_id = open('/tmp/cord-build').read().rstrip() |
| except: |
| build_id = context['user'] + name |
| mp.track(build_id, sys.argv[1], context) |
| except Exception,e: |
| print str(e) |
| pass |