def runScript(log,config): try: # Config File username = config.get( 'AGOL', 'USER') password = config.get('AGOL', 'PASS') joinData = config.get('LOCAL_DATA', 'JOINDATA') joinDataJoinField = config.get('LOCAL_DATA', 'JOINDATAJOINFIELD') inputData = config.get('LOCAL_DATA', 'INPUTDATA') inputJoinField = config.get('LOCAL_DATA', 'INPUTJOINFIELD') copyFields = eval(config.get('LOCAL_DATA', 'COPYFIELDS')) prevFields =eval(config.get('LOCAL_DATA', 'PREVIOUSFIELDS')) createCurrent = config.get('LOCAL_DATA', 'CREATECURRENT') reportArchiveURL = config.get('FS_INFO', 'REPORTARCHIVEURL') reportCurrentURL = config.get('FS_INFO', 'REPORTCURRENTURL') deleteSQL = config.get('FS_INFO', 'DELETESQL') print "Config file loaded" if arcpy.Exists(joinData) == False: print "Join Data Does Not Exist, exiting" sys.exit() if arcpy.Exists(inputData) == False: print "Input Data Does Not Exist, exiting" sys.exit() fs = services.FeatureService(url=reportArchiveURL,username=username,password=password) if fs == None: print "Cannot find Archive Service, exiting" sys.exit() Utilities.currentToPrevious(inputData,prevFields) print "Existing data moved to previous fields" Utilities.JoinAndCalc(inputData,inputJoinField,joinData,joinDataJoinField,copyFields) print "Data joined and calculated" #Save results to historical service fs.addFeatures(inputData) print "Historical data updated" #Update Current service if used if createCurrent == "True": fs.url = reportCurrentURL fs.deleteFeatures(deleteSQL) print "Current service reset" fs.addFeatures(inputData) print "Current service updated" except FeatureServiceError,e: line, filename, synerror = Utilities.trace() print "error on line: %s" % line print "error in file name: %s" % filename print "with error message: %s" % synerror print "Add. Error Message: %s" % e print datetime.datetime.now().strftime("%Y-%m-%d %H:%M")