# --------------------------------------------------------------------------- # addMissingFields.py # Created on: 2014-08-14 SG # Description: Add missing fields to a target Geodatabase using the provided field name, type, etc. using the Gizinta.xml # --------------------------------------------------------------------------- # Copyright 2012-2014 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport, myGizinta gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText(2)) # boolean indicates whether to return False if errors encountered SUCCESS = 3 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue valueMappings = gzSupport.getXmlElements(gzSupport.xmlFileName,"ValueMaps") def main(argv = None): success = True gzSupport.compressGDB(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) tables = gzSupport.listDatasets(gzSupport.workspace) tNames = tables[0] tFullNames = tables[1]
# Description: Import a set of .lyr files to Geodatabase. # --------------------------------------------------------------------------- # Copyright 2012-2014 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText( 0) # xml file name as a parameter sourceLayer = arcpy.GetParameterAsText(1) # Source Layer File to load from gzSupport.workspace = arcpy.GetParameterAsText(2) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText( 3)) # boolean indicates whether to return False if errors encountered SUCCESS = 4 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getDatasets(gzSupport.xmlFileName) rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode( "errorTableName").nodeValue def main(argv=None): success = True name = '' try: if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace +
def main(argv=None): global sourceDataset, targetDataset, xmlFileName # os.path.realpath( __file__).replace('.py','.log') gzSupport.startLog() createGzFile(sourceDataset, targetDataset, xmlFileName) gzSupport.closeLog()
def main(argv=None): # main function - list the source and target datasets, then delete rows/append where there is a match on non-prefixed name dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) logname = os.path.join(outputFolder, 'gzCreateProjectFiles.log') gzSupport.startLog() success = True try: gzSupport.addMessage("Getting list of datasets for Target " + targetGDB) targets = gzSupport.listDatasets(targetGDB) tNames = targets[0] tFullNames = targets[1] gzSupport.addMessage("Getting list of datasets for Source " + sourceGDB) sources = gzSupport.listDatasets(sourceGDB) sNames = sources[0] sFullNames = sources[1] t = 0 arcpy.SetProgressor("Step", "Creating Files...", 0, len(tNames), 1) for name in tNames: arcpy.SetProgressorPosition(t) arcpy.SetProgressorLabel("Creating file for " + name + "...") # for each source name if debug: gzSupport.addMessage(name) try: # look for the matching name in target names s = sNames.index(name) except: # will get here if no match s = -1 if s > -1: # create file if there is a match fileName = outputFolder + os.sep + prefixStr + name.title( ) + ".xml" if os.path.exists(fileName): os.remove(fileName) try: #arcpy.AddToolbox(os.path.join(dir,"Gizinta.tbx")) #arcpy.gzCreateProject_gizinta(sFullNames[s],tFullNames[t],fileName) # this doesn't always work... gzCreateProject.createGzFile(sFullNames[s], tFullNames[t], fileName) retVal = True gzSupport.addMessage("Created " + fileName) except: retVal = False if retVal == False: gzSupport.addMessage("Failed to create file for " + name) gzSupport.showTraceback() success = False else: gzSupport.addMessage("Skipping " + name) t = t + 1 except: gzSupport.showTraceback() arcpy.AddError("Error creating project files") success = False finally: arcpy.ResetProgressor() arcpy.SetParameter(gzSupport.successParameterNumber, success) arcpy.env.workspace = targetGDB arcpy.RefreshCatalog(outputFolder) gzSupport.closeLog()
def main(argv = None): # main function - list the source and target datasets, then delete rows/append where there is a match on non-prefixed name dir = os.path.dirname(os.path.dirname( os.path.realpath( __file__) )) logname = os.path.join(outputFolder,'gzCreateProjectFiles.log') gzSupport.startLog() success = True try: gzSupport.addMessage("Getting list of datasets for Target " + targetGDB) targets = gzSupport.listDatasets(targetGDB) tNames = targets[0] tFullNames = targets[1] gzSupport.addMessage("Getting list of datasets for Source " + sourceGDB) sources = gzSupport.listDatasets(sourceGDB) sNames = sources[0] sFullNames = sources[1] t = 0 arcpy.SetProgressor("Step","Creating Files...",0,len(tNames),1) for name in tNames: arcpy.SetProgressorPosition(t) arcpy.SetProgressorLabel("Creating file for " + name + "...") # for each source name if debug: gzSupport.addMessage(name) try: # look for the matching name in target names s = sNames.index(name) except: # will get here if no match s = -1 if s > -1: # create file if there is a match fileName = outputFolder + os.sep + prefixStr + name.title() + ".xml" if os.path.exists(fileName): os.remove(fileName) try: #arcpy.AddToolbox(os.path.join(dir,"Gizinta.tbx")) #arcpy.gzCreateProject_gizinta(sFullNames[s],tFullNames[t],fileName) # this doesn't always work... gzCreateProject.createGzFile(sFullNames[s],tFullNames[t],fileName) retVal = True gzSupport.addMessage("Created " + fileName) except: retVal = False if retVal == False: gzSupport.addMessage("Failed to create file for " + name) gzSupport.showTraceback() success = False else: gzSupport.addMessage("Skipping " + name) t = t + 1 except: gzSupport.showTraceback() arcpy.AddError("Error creating project files") success = False finally: arcpy.ResetProgressor() arcpy.SetParameter(gzSupport.successParameterNumber, success) arcpy.env.workspace = targetGDB arcpy.RefreshCatalog(outputFolder) gzSupport.closeLog()