# Import system modules
import sys, string, os, win32com.client,win32api
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
gp.SetProduct("ArcEditor")
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
# Local variables...
PGDBLocation = "C:\\FieldPortal\\Backdrops\\DW_Backdrop1.mdb"
#PGDBLocation = "C:\\Temp.mdb\\"
SDELocation = "Database Connections\Connection to GISPROD as pwpviewer.sde\\"
#Views to be copied
ViewList=[
"WATER.MV_WATERQUALITY",
"WATER.MV_W_VSERVP",
"WATER.MV_W_USAGE6MONTH",
"WATER.MV_W_PREMACCTMETERSERVAC",
"WATER.MV_W_ALLPREMISES",
"WATER.MV_INSTALLS",
"POWER.MV_VAULTLISTLASTINSPECTION",
"POWER.MV_VAULTLASTWOCOMPLETED",
"POWER.MV_VAULTINSPECTIONLIST",
"POWER.MV_UGWORKORDER",
"POWER.MV_TRANSFORMERTESTLIST",
"POWER.MV_TRANSFORMERNAMEPLATE",
"POWER.MV_SWITCHTEST",
"POWER.MV_SWITCHESLISTBYVAULT",
"POWER.MV_POLELASTWOCOMPLETED",
"POWER.MV_POLELASTINSPECTION",
"POWER.MV_POLEALLINSPECTIONS",
"POWER.MV_OHWORKORDER",
"POWER.MV_E_USAGE6MONTH",
"POWER.MV_E_PREMACCTMETERAC",
"POWER.MV_E_ALLPREMISES"]
gp.workspace=PGDBLocation[0:PGDBLocation.rfind("\\")]
try:
win32api.DeleteFile(PGDBLocation)
except:
errNum=win32api.GetLastError()
#print errNum
if(errNum==5): #if file is flag as read only, exit program
print "file is locked for read only, no updates"
sys.exit()
gp.CreatePersonalGDB_management(gp.workspace, "DW_Backdrop1.mdb")
for view in ViewList:
target=PGDBLocation+"\\"+view[view.find(".")+1:]
print "Copy "+ target + " ..."
gp.CopyRows_management(SDELocation+view, target, "")
Sunday, February 1, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment