Skip to content

Instantly share code, notes, and snippets.

@PaulTaykalo
Created March 5, 2017 00:26
Show Gist options
  • Save PaulTaykalo/e8062aba508c5ddb73f6b548d2fbe2b3 to your computer and use it in GitHub Desktop.
Save PaulTaykalo/e8062aba508c5ddb73f6b548d2fbe2b3 to your computer and use it in GitHub Desktop.
Xcode Time tracking
# So there should be run script which will pass
#./timecheck.py start
#./timecheck.py stop
#!/usr/bin/python
import json,httplib,sys,time,os
from os.path import expanduser
seconds = int(round(time.time()))
if len(sys.argv) < 2:
print "Please run with start or stop parameter"
exit()
pass
# Just saving start time in the file
if sys.argv[1] == "start":
print "Starting measuring time"
with open (expanduser("~/.timecheck/start_time"), 'w') as f: f.write (str(seconds))
exit
pass
# Writing in end time (for the simplicity)
if sys.argv[1] == "finish":
print "Stopping measuring time"
line = ""
with open (expanduser("~/.timecheck/end_time"), 'w') as f: f.write (str(seconds))
with open (expanduser("~/.timecheck/start_time"), 'r') as f: line = f.readline()
start_time = int(line)
diff = seconds - start_time
# Activity will contain build message like "Build Started", "Build Failed", "Tests Started" etc
activity = os.environ.get("IDEAlertMessage", "No message")
# Workspace name can be got from the environment vars. There are plenty of other variables. Need to check those
project_name = os.environ.get("XcodeWorkspace", "No project")
print "It's took " + str(diff) + " seconds to [" + activity + "] for " + project_name
# Send the result if it's neede to some stats
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment