#!/usr/bin/python # # Add the svn version of the file as an extra entry to the ged game json data before it gets uploaded # # Example usage: # # ./AddSvnVersionToGedData.py gedGameDB.json gedGameDB_to_upload.json # import sys import json import os import subprocess import GetSvnRevision #check the number of arguments if len(sys.argv)<3: print 'Invalid number of arguments - 3 required ' + str(len(sys.argv) - 1) + ' received' exit() # game db json file name gedGameDBJsonFileName = sys.argv[1] # output modified ged json file gedGameDataToUploadFileName = sys.argv[2] # try to open the ged game json file try: gedJson = json.load(open(gedGameDBJsonFileName, 'rb')) except Exception as e: print 'file ' + gedGameDBJsonFileName + ' could not be opened' exit(1) # get the svn version try: svnVersion = GetSvnRevision.get_svn_revision(gedGameDBJsonFileName) except Exception as e: print 'Error while getting svn version of ' + gedGameDBJsonFileName + ' :' + str(e) exit(1) # add the svn version to the ged data gedJson['svnversion'] = svnVersion # save the new json data gedMod = open(gedGameDataToUploadFileName, 'wb') json.dump(gedJson, fp=gedMod, indent=4) gedMod.close()