SHARE
TWEET

Untitled

a guest Mar 5th, 2015 244 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import sys
  3. import json
  4. import time
  5.  
  6.  
  7. def set_build_status(filename, branch, status, desc):
  8.     f = open(filename, 'r')
  9.     obj = json.loads(f.read())
  10.     f.close()
  11.     branch_status = obj.get(branch)
  12.     if not branch_status:
  13.         branch_status = {}
  14.         obj[branch] = branch_status
  15.     branch_status['status'] = status
  16.     branch_status['desc'] = desc
  17.     branch_status['last_update'] = time.strftime('%Y/%m/%d-%H:%M:%S')
  18.     f = open(filename, 'w')
  19.     f.write(json.dumps(obj))
  20.     f.flush()
  21.     f.close()
  22.  
  23.  
  24. if __name__ == '__main__':
  25.     set_build_status(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top