import RPLib
if __name__ == '__main__':
# Email variables
RPLib.email_To = ('to@yourorganization.org',)
RPLib.email_From = 'from@organization.org'
RPLib.email_IP = "10.20.2.8"
RPLib.email_Port = 587
RPLib.email_Username = "username"
RPLib.email_Password = "password"
RPLib.email_ON = True
# Logging variables
LogFileLoc = "C:/GIS/Log"
RPLib.Logger(LogFileLoc)
RPLib.verboseLog = False
# Exlude tables that have the below variations in their name from the
# Rebuild indexes and analyze function
excludeList = ['VW_', '_VW', 'V_', '_V',]
# Create version variable
createVersions_List = ['JOHNDOE','JANEDOE','JOHNSMITH','JANESMITH']
# SDE connection files
dataOwner = 'C:/GIS/GIS@GISADMIN.sde'
sdeOwner = 'C:/GIS/GIS@SDE.sde'
# Rebuild indexes and update statistics to maintain optimal geodatabase performance.
RPLib.rebuild_indexes_analyze(dataOwner, excludeList, False, True, False, True, True, True)
## Stop all services in the folder FeatureServices on ArcGIS Server
RPLib.controlservices("FeatureServices","stop","GISAPP","administrator","password")
RPLib.pauseconnections(sdeOwner)
RPLib.killconnections(sdeOwner)
if RPLib.reconcilepost(sdeOwner,"C:/TESTGIS",[],"sde.DEFAULT",True,True,True,True,True,True,True):
RPLib.createversions(sdeOwner,createVersions_List,True,"sde.default")
RPLib.compressgdb(sdeOwner)
RPLib.resumeconnections(sdeOwner)
RPLib.controlservices("FeatureServices","start","GISAPP","administrator","password")
RPLib.rebuild_indexes_analyze(dataOwner, excludeList, False, True, False, True, True, True)
RPLib.deletefilesolderthan(14,LogFileLoc)
RPLib.clearworkspacecache(sdeOwner)
RPLib.clearworkspacecache(dataOwner)
else:
RPLib.resumeconnections(sdeOwner)
RPLib.controlservices("FeatureServices","start","GISAPP","administrator","password")
RPLib.deletefilesolderthan(14,LogFileLoc)
RPLib.clearworkspacecache(sdeOwner)
RPLib.clearworkspacecache(dataOwner)