Beispiel #1
0
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]
    name = ''

    for dataset in datasets:
        arcpy.env.Workspace = gzSupport.workspace
        name = dataset.getAttributeNode("name").nodeValue
        table = gzSupport.getFullName(name, tNames, tFullNames)
        gzSupport.sourceIDField = dataset.getAttributeNode(
            "sourceIDField").nodeValue
        gzSupport.sourceNameField = dataset.getAttributeNode(
            "sourceNameField").nodeValue
        if not arcpy.Exists(table):
            gzSupport.addError("Feature Class " + table +
                               " does not exist, exiting")
            arcpy.SetParameter(SUCCESS, False)
            return
        if not arcpy.TestSchemaLock(table):
            gzSupport.addError("Unable to obtain a schema lock for " + table +
                               ", exiting")
            arcpy.SetParameter(SUCCESS, False)
            return -1
        desc = arcpy.Describe(table)
        fields = dataset.getElementsByTagName("Field")
        try:
            attrs = [f.name for f in arcpy.ListFields(table)]
            for field in fields:
                arcpy.env.Workspace = gzSupport.workspace
                targetName = gzSupport.getNodeValue(field, "TargetName")
                gzSupport.addGizintaField(table, targetName, field, attrs)

            retVal = setFieldValues(table, fields)
            if retVal == False:
                success = False
            gzSupport.logDatasetProcess(name, "Fields", retVal)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
            gzSupport.cleanupGarbage()

        except:
            gzSupport.showTraceback()
            success = False
            gzSupport.logDatasetProcess("fieldCalculator", name, False)
        finally:
            arcpy.RefreshCatalog(table)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    if success == False:
        gzSupport.addError(
            "Errors occurred during process, look in log file tools\\log\\fieldCalculator.log for more information"
        )
    if gzSupport.ignoreErrors == True:
        success = True
    arcpy.SetParameter(SUCCESS, success)
    arcpy.ResetProgressor()
    gzSupport.closeLog()
    return
Beispiel #2
0
def main(argv = None):
    success = True
    gzSupport.compressGDB(gzSupport.workspace)
    tables = gzSupport.listDatasets(gzSupport.workspace)
    tNames = tables[0]
    tFullNames = tables[1]

    if len(datasets) > 0:
        progBar = len(datasets)
        arcpy.SetProgressor("step", "Running QA...", 0,progBar, 1)
    for dataset in datasets:
        arcpy.env.Workspace = gzSupport.workspace
        name = dataset.getAttributeNode("name").nodeValue
        gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue
        table = gzSupport.getFullName(name,tNames, tFullNames)
        #table = os.path.join(gzSupport.workspace,name)
        fields = dataset.getElementsByTagName("Field")
        name = ''
        try:
            # run qa for dataset
            qaRulesDataset = dataset.getAttributeNode("qa").nodeValue
            gzSupport.addMessage("\nRunning QA (" + qaRulesDataset + ") for " + name)
            retVal = runDatasetChecks(dataset,table,qaRulesDataset)
            if retVal == False:
                success = False

            for field in fields:
                sourceQA = False
                targetQA = False
                fieldName = gzSupport.getNodeValue(field,"TargetName")
                if sourceFieldQA.lower() == "true" and qaRulesDataset.find("CheckFields") > -1:
                    sourceQA = True
                    fieldName = gzSupport.getNodeValue(field,"SourceName")
                if targetFieldQA.lower() == "true" and qaRulesDataset.find("CheckFields") > -1:
                    targetQA = True
                    fieldName = gzSupport.getNodeValue(field,"TargetName")
                retVal = runFieldCheck(dataset,table,field,sourceQA,targetQA)
                if retVal == False:
                    success = False
                try:
                    gzSupport.logDatasetProcess(name,fieldName,retVal)
                except:
                    gzSupport.addMessage("Process not logged for field")
            arcpy.SetProgressorPosition()
        except:
            gzSupport.showTraceback()
            gzSupport.addError("Field Check Error")
            success = False
            gzSupport.logDatasetProcess("sourceTargetQA",name,False)
        finally:
            arcpy.ResetProgressor()
            arcpy.RefreshCatalog(table)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    if success == False:
        gzSupport.addError("Errors occurred during process, look in log file tools\\log\\sourceTargetQA.log for more information")
    if gzSupport.ignoreErrors == True:
        success = True
    arcpy.SetParameter(SUCCESS, success)
    gzSupport.closeLog()
    return
Beispiel #3
0
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]
    name = ''
    
    for dataset in datasets:
        arcpy.env.Workspace = gzSupport.workspace
        name = dataset.getAttributeNode("name").nodeValue
        table = gzSupport.getFullName(name,tNames,tFullNames)
        gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue
        gzSupport.sourceNameField = dataset.getAttributeNode("sourceNameField").nodeValue
        if not arcpy.Exists(table):
            gzSupport.addError("Feature Class " + table + " does not exist, exiting")
            arcpy.SetParameter(SUCCESS, False)
            return
        if not arcpy.TestSchemaLock(table):
            gzSupport.addError("Unable to obtain a schema lock for " + table + ", exiting")
            arcpy.SetParameter(SUCCESS, False)
            return -1
        desc = arcpy.Describe(table)
        fields = dataset.getElementsByTagName("Field")
        try:
            attrs = [f.name for f in arcpy.ListFields(table)]
            for field in fields:
                arcpy.env.Workspace = gzSupport.workspace
                targetName = gzSupport.getNodeValue(field,"TargetName")
                gzSupport.addGizintaField(table,targetName,field,attrs)

            retVal = setFieldValues(table,fields)
            if retVal == False:
                success = False
            gzSupport.logDatasetProcess(name,"Fields",retVal)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
            gzSupport.cleanupGarbage()

        except:
            gzSupport.showTraceback()
            success = False
            gzSupport.logDatasetProcess("fieldCalculator",name,False)
        finally:
            arcpy.RefreshCatalog(table)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    if success == False:
        gzSupport.addError("Errors occurred during process, look in log file tools\\log\\fieldCalculator.log for more information")
    if gzSupport.ignoreErrors == True:
        success = True
    arcpy.SetParameter(SUCCESS, success)
    arcpy.ResetProgressor()
    gzSupport.closeLog()
    return
def analyze(workspace, datasets, tNames, tFullNames):
    retVal = True
    for dataset in datasets:
        name = dataset.getAttributeNode("name").nodeValue
        targetTable = gzSupport.getFullName(name, tNames, tFullNames)
        arcpy.SetProgressorLabel("Analyzing " + name)
        try:
            arcpy.Analyze_management(targetTable, "BUSINESS")
            arcpy.Analyze_management(targetTable, "ADDS")
            arcpy.Analyze_management(targetTable, "DELETES")
            arcpy.Analyze_management(targetTable, "FEATURE")
        except:
            retVal = False

    return retVal
Beispiel #5
0
def analyze(workspace,datasets,tNames,tFullNames):
    retVal = True
    for dataset in datasets:
        name = dataset.getAttributeNode("name").nodeValue
        targetTable = gzSupport.getFullName(name,tNames,tFullNames)
        arcpy.SetProgressorLabel("Analyzing " + name)
        try:
            arcpy.Analyze_management(targetTable,"BUSINESS")
            arcpy.Analyze_management(targetTable,"ADDS")
            arcpy.Analyze_management(targetTable,"DELETES")
            arcpy.Analyze_management(targetTable,"FEATURE")
        except:
            retVal = False

    return retVal
def main(argv=None):
    global targetWorkspace
    hasVersion = False
    desc = arcpy.Describe(gzSupport.workspace)
    if desc.workspaceType != "RemoteDatabase" and versionName == None:
        targetWorkspace = defaultWorkspace
    success = True
    arcpy.ResetProgressor()
    arcpy.env.Workspace = gzSupport.workspace
    uniqueValues = gzSupport.getFieldValues("Unique", fieldNames, datasets)[0]
    sources = gzSupport.listDatasets(gzSupport.workspace)
    sNames = sources[0]
    sFullNames = sources[1]
    arcpy.SetProgressor("Step", "Load by " + str(fieldNames) + "...", 0, len(uniqueValues) * len(datasets), 1)
    for value in uniqueValues:
        try:
            hasVersion = False
            gzSupport.addMessage(value)
            if desc.workspaceType == "RemoteDatabase" and versionName != None:
                arcpy.SetProgressorLabel("Creating Version " + versionName)
                hasVersion = gzSupport.createVersion(defaultWorkspace, defaultVersionName, versionName)
            if hasVersion == True or versionName == None or desc.workspaceType == "LocalDatabase":
                arcpy.env.Workspace = targetWorkspace
                targets = gzSupport.listDatasets(targetWorkspace)
                tNames = targets[0]
                tFullNames = targets[1]
                for dataset in datasets:
                    name = dataset.getAttributeNode("name").nodeValue
                    arcpy.SetProgressorLabel("Loading Dataset " + name)
                    targetTable = gzSupport.getFullName(name, tNames, tFullNames)
                    sourceTable = gzSupport.getFullName(name, sNames, sFullNames)
                    attrs = [f.name for f in arcpy.ListFields(targetTable)]
                    expr = getExpression(attrs, fieldNames, value)
                    arcpy.SetProgressorLabel("Loading Dataset " + name + " Where " + expr)
                    tName = targetTable[targetTable.rfind("\\") + 1 :]
                    tLocation = targetTable[0 : targetTable.rfind("\\")]
                    if gzSupport.deleteRows(tLocation, tName, expr) == True:
                        retVal = gzSupport.appendRows(sourceTable, targetTable, expr)
                        if retVal == False:
                            success == False
                    else:
                        success == False
                    arcpy.SetProgressorPosition()
                if success == True:
                    if desc.workspaceType == "RemoteDatabase":
                        arcpy.SetProgressorLabel("Reconcile and Post")
                        retVal = gzSupport.reconcilePost(defaultWorkspace, versionName, defaultVersionName)
                        if retVal == False:
                            success = False
                            gzSupport.deleteVersion(defaultWorkspace, versionName)
                    elif desc.workspaceType == "LocalDatabase":
                        arcpy.SetProgressorLabel("Completed Update for " + str(value))
                    gzSupport.logDatasetProcess(targetTable, sys.argv[0], retVal)
                else:
                    gzSupport.logDatasetProcess(targetTable, sys.argv[0], retVal)
                gzSupport.cleanupGarbage()

        except:
            gzSupport.showTraceback()
            success = False
            gzSupport.logDatasetProcess("Serious error", sys.argv[0], False)
        finally:
            arcpy.SetProgressorPosition()
            arcpy.ClearWorkspaceCache_management(defaultWorkspace)
    if success == False:
        gzSupport.addError("Errors occurred during process, look in log files for more information")
    if gzSupport.ignoreErrors == True:
        success = True
    if desc.workspaceType == "RemoteDatabase" and success == True:
        analyze(defaultWorkspace, datasets, tNames, tFullNames)
    arcpy.SetParameter(SUCCESS, success)

    arcpy.ClearWorkspaceCache_management(defaultWorkspace)
    gzSupport.compressGDB(gzSupport.workspace)
    gzSupport.compressGDB(defaultWorkspace)
    gzSupport.closeLog()
    return
Beispiel #7
0
def main(argv=None):
    success = True
    gzSupport.compressGDB(gzSupport.workspace)
    tables = gzSupport.listDatasets(gzSupport.workspace)
    tNames = tables[0]
    tFullNames = tables[1]

    if len(datasets) > 0:
        progBar = len(datasets)
        arcpy.SetProgressor("step", "Running QA...", 0, progBar, 1)
    for dataset in datasets:
        arcpy.env.Workspace = gzSupport.workspace
        name = dataset.getAttributeNode("name").nodeValue
        gzSupport.sourceIDField = dataset.getAttributeNode(
            "sourceIDField").nodeValue
        table = gzSupport.getFullName(name, tNames, tFullNames)
        #table = os.path.join(gzSupport.workspace,name)
        fields = dataset.getElementsByTagName("Field")
        name = ''
        try:
            # run qa for dataset
            qaRulesDataset = dataset.getAttributeNode("qa").nodeValue
            gzSupport.addMessage("\nRunning QA (" + qaRulesDataset + ") for " +
                                 name)
            retVal = runDatasetChecks(dataset, table, qaRulesDataset)
            if retVal == False:
                success = False

            for field in fields:
                sourceQA = False
                targetQA = False
                fieldName = gzSupport.getNodeValue(field, "TargetName")
                if sourceFieldQA.lower(
                ) == "true" and qaRulesDataset.find("CheckFields") > -1:
                    sourceQA = True
                    fieldName = gzSupport.getNodeValue(field, "SourceName")
                if targetFieldQA.lower(
                ) == "true" and qaRulesDataset.find("CheckFields") > -1:
                    targetQA = True
                    fieldName = gzSupport.getNodeValue(field, "TargetName")
                retVal = runFieldCheck(dataset, table, field, sourceQA,
                                       targetQA)
                if retVal == False:
                    success = False
                try:
                    gzSupport.logDatasetProcess(name, fieldName, retVal)
                except:
                    gzSupport.addMessage("Process not logged for field")
            arcpy.SetProgressorPosition()
        except:
            gzSupport.showTraceback()
            gzSupport.addError("Field Check Error")
            success = False
            gzSupport.logDatasetProcess("sourceTargetQA", name, False)
        finally:
            arcpy.ResetProgressor()
            arcpy.RefreshCatalog(table)
            arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    if success == False:
        gzSupport.addError(
            "Errors occurred during process, look in log file tools\\log\\sourceTargetQA.log for more information"
        )
    if gzSupport.ignoreErrors == True:
        success = True
    arcpy.SetParameter(SUCCESS, success)
    gzSupport.closeLog()
    return
Beispiel #8
0
def main(argv = None):
    global targetWorkspace
    hasVersion = False
    desc = arcpy.Describe(gzSupport.workspace)
    if desc.workspaceType != "RemoteDatabase" and versionName == None:
        targetWorkspace = defaultWorkspace
    success = True
    arcpy.ResetProgressor()
    arcpy.env.Workspace = gzSupport.workspace
    uniqueValues = gzSupport.getFieldValues("Unique",fieldNames,datasets)[0]
    sources = gzSupport.listDatasets(gzSupport.workspace)
    sNames = sources[0]
    sFullNames = sources[1]
    arcpy.SetProgressor("Step","Load by " + str(fieldNames) + "...",0,len(uniqueValues)*len(datasets),1)
    for value in uniqueValues:
        try:
            hasVersion = False
            gzSupport.addMessage(value)
            if desc.workspaceType == "RemoteDatabase" and versionName != None:
                arcpy.SetProgressorLabel("Creating Version " + versionName)
                hasVersion = gzSupport.createVersion(defaultWorkspace,defaultVersionName,versionName)
            if hasVersion == True  or versionName == None or desc.workspaceType == "LocalDatabase":
                arcpy.env.Workspace = targetWorkspace
                targets = gzSupport.listDatasets(targetWorkspace)
                tNames = targets[0]
                tFullNames = targets[1]
                for dataset in datasets:
                    name = dataset.getAttributeNode("name").nodeValue
                    arcpy.SetProgressorLabel("Loading Dataset " + name)
                    targetTable = gzSupport.getFullName(name,tNames,tFullNames)
                    sourceTable = gzSupport.getFullName(name,sNames,sFullNames)
                    attrs = [f.name for f in arcpy.ListFields(targetTable)]
                    expr = getExpression(attrs,fieldNames,value)
                    arcpy.SetProgressorLabel("Loading Dataset " + name + " Where " + expr)
                    tName = targetTable[targetTable.rfind("\\")+1:]
                    tLocation = targetTable[0:targetTable.rfind("\\")]
                    if gzSupport.deleteRows(tLocation,tName,expr) == True:
                        retVal = gzSupport.appendRows(sourceTable,targetTable,expr)
                        if retVal == False:
                            success == False
                    else:
                        success == False
                    arcpy.SetProgressorPosition()
                if success == True:
                    if desc.workspaceType == "RemoteDatabase":
                        arcpy.SetProgressorLabel("Reconcile and Post")
                        retVal = gzSupport.reconcilePost(defaultWorkspace,versionName,defaultVersionName)
                        if retVal == False:
                            success = False
                            gzSupport.deleteVersion(defaultWorkspace,versionName)
                    elif desc.workspaceType == "LocalDatabase":
                        arcpy.SetProgressorLabel("Completed Update for " + str(value))
                    gzSupport.logDatasetProcess(targetTable,sys.argv[0],retVal)
                else:
                    gzSupport.logDatasetProcess(targetTable,sys.argv[0],retVal)

        except:
            gzSupport.showTraceback()
            success = False
            gzSupport.logDatasetProcess("Serious error",sys.argv[0],False)
        finally:
            arcpy.SetProgressorPosition()
            arcpy.ClearWorkspaceCache_management(defaultWorkspace)
    if success == False:
        gzSupport.addError("Errors occurred during process, look in log files for more information")        
    if gzSupport.ignoreErrors == True:
        success = True
    if desc.workspaceType == "RemoteDatabase" and success == True:
        analyze(defaultWorkspace,datasets,tNames,tFullNames)
    arcpy.SetParameter(SUCCESS, success)

    arcpy.ClearWorkspaceCache_management(defaultWorkspace)
    gzSupport.compressGDB(gzSupport.workspace)
    gzSupport.compressGDB(defaultWorkspace)
    gzSupport.closeLog()
    return