Esempio n. 1
0
def main(argv = None):
    success = True
    try:
        if not arcpy.Exists(gzSupport.workspace):
            gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create")
            gzSupport.createGizintaGeodatabase()
        else:
            gzSupport.compressGDB(gzSupport.workspace)
        if len(datasets) > 0:
            progBar = len(datasets) + 1
            arcpy.SetProgressor("step", "Importing Datasets...", 0,progBar, 1) 
            deleteExistingRows(datasets)
            arcpy.SetProgressorPosition()
        for dataset in datasets:
            gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue
            sourceName = dataset.getAttributeNode("sourceName").nodeValue
            targetName = dataset.getAttributeNode("targetName").nodeValue
            arcpy.SetProgressorLabel("Loading " + sourceName + " to " + targetName +"...")
            if not arcpy.Exists(os.path.join(sourceWorkspace,sourceName)):
                gzSupport.addError(os.path.join(sourceWorkspace,sourceName + " does not exist, exiting"))
                return
            if not arcpy.Exists(os.path.join(gzSupport.workspace,targetName)):
                gzSupport.addMessage(os.path.join(gzSupport.workspace,targetName) + " does not exist")
                mode = "export"
            else:
                mode = "import"

            arcpy.env.Workspace = gzSupport.workspace
            try:
                if mode == "import":
                    retVal = gzSupport.importDataset(sourceWorkspace,sourceName,targetName,dataset)
                elif mode == "export":
                    retVal = gzSupport.exportDataset(sourceWorkspace,sourceName,targetName,dataset)
                if retVal == False:
                    success = False
            except:
                gzSupport.showTraceback()
                success = False
                retVal = False
            gzSupport.logDatasetProcess(sourceName,targetName,retVal)
        arcpy.SetProgressorPosition()
    except:
        gzSupport.showTraceback()
        gzSupport.addError("A Fatal Error occurred")
        success = False
        gzSupport.logDatasetProcess("","",False)
    finally:
        arcpy.ResetProgressor()
        arcpy.RefreshCatalog(gzSupport.workspace)
        arcpy.ClearWorkspaceCache_management(sourceWorkspace)
        arcpy.ClearWorkspaceCache_management(gzSupport.workspace)

    if success == False:
        gzSupport.addError("Errors occurred during process, look in log files for more information")        
    if gzSupport.ignoreErrors == True:
        success = True
        
    gzSupport.closeLog()
    arcpy.SetParameter(SUCCESS, success)
Esempio n. 2
0
def main(argv=None):
    success = True
    if not arcpy.Exists(gzSupport.workspace):
        gzSupport.addMessage(gzSupport.workspace +
                             " does not exist, attempting to create")
        gzSupport.createGizintaGeodatabase()
    else:
        gzSupport.compressGDB(gzSupport.workspace)
    arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    try:
        gzSupport.addMessage("Looking for drawings modified since " + since)
        minTime = dt.datetime.strptime(since, "%d/%m/%Y %I:%M:%S %p")
        cadFiles = getFileList(cadFolder, cadExt, minTime)
        if len(cadFiles) > 0:
            progBar = len(cadFiles) + 1
            arcpy.SetProgressor("step", "Importing Drawings...", 0, progBar, 1)
            deleteExistingRows(datasets)
            arcpy.SetProgressorPosition()
        for item in cadFiles:
            cadPath = item[0]
            cadName = item[1]
            gzSupport.addMessage("Importing Drawing " + cadName)

            for dataset in datasets:
                try:
                    name = dataset.getAttributeNode("sourceName").nodeValue
                except:
                    name = dataset.getAttributeNode("name").nodeValue

                gzSupport.sourceIDField = dataset.getAttributeNode(
                    "sourceIDField").nodeValue
                arcpy.SetProgressorLabel("Loading " + name + " for " +
                                         cadName + "...")
                arcpy.env.Workspace = gzSupport.workspace
                targetName = dataset.getAttributeNode("targetName").nodeValue
                sourceWorkspace = os.path.join(cadPath, cadName)
                if not arcpy.Exists(
                        os.path.join(gzSupport.workspace, targetName)):
                    gzSupport.addMessage(
                        os.path.join(gzSupport.workspace, targetName) +
                        " does not exist")
                    mode = "export"
                else:
                    mode = "import"

                try:
                    if mode == "import":
                        retVal = gzSupport.importDataset(
                            sourceWorkspace, name, targetName, dataset)
                    elif mode == "export":
                        retVal = gzSupport.exportDataset(
                            sourceWorkspace, name, targetName, dataset)
                    #retVal = importLayer(cadPath,cadName,dataset)
                    if retVal == False:
                        success = False
                except:
                    gzSupport.showTraceback()
                    success = False
                    retVal = False

                arcpy.env.Workspace = gzSupport.workspace
                gzSupport.logDatasetProcess(cadName, name, retVal)
                gzSupport.cleanupGarbage()
            arcpy.SetProgressorPosition()
    except:
        gzSupport.addError("A Fatal Error occurred")
        gzSupport.showTraceback()
        success = False
        gzSupport.logDatasetProcess("", "", False)
    finally:
        arcpy.ResetProgressor()
        arcpy.RefreshCatalog(gzSupport.workspace)
        arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
        gzSupport.cleanupGarbage()

    if success == False:
        gzSupport.addError(
            "Errors occurred during process, look in log files for more information"
        )
    if gzSupport.ignoreErrors == True:
        success = True
    gzSupport.closeLog()
    arcpy.SetParameter(SUCCESS, success)
Esempio n. 3
0
def main(argv=None):
    success = True
    try:
        if not arcpy.Exists(gzSupport.workspace):
            gzSupport.addMessage(gzSupport.workspace +
                                 " does not exist, attempting to create")
            gzSupport.createGizintaGeodatabase()
        else:
            gzSupport.compressGDB(gzSupport.workspace)
        if len(datasets) > 0:
            progBar = len(datasets) + 1
            arcpy.SetProgressor("step", "Importing Datasets...", 0, progBar, 1)
            deleteExistingRows(datasets)
            arcpy.SetProgressorPosition()
        for dataset in datasets:
            gzSupport.sourceIDField = dataset.getAttributeNode(
                "sourceIDField").nodeValue
            sourceName = dataset.getAttributeNode("sourceName").nodeValue
            targetName = dataset.getAttributeNode("targetName").nodeValue
            arcpy.SetProgressorLabel("Loading " + sourceName + " to " +
                                     targetName + "...")
            if not arcpy.Exists(os.path.join(sourceWorkspace, sourceName)):
                gzSupport.addError(
                    os.path.join(sourceWorkspace,
                                 sourceName + " does not exist, exiting"))
                return
            if not arcpy.Exists(os.path.join(gzSupport.workspace, targetName)):
                gzSupport.addMessage(
                    os.path.join(gzSupport.workspace, targetName) +
                    " does not exist")
                mode = "export"
            else:
                mode = "import"

            arcpy.env.Workspace = gzSupport.workspace
            try:
                if mode == "import":
                    retVal = gzSupport.importDataset(sourceWorkspace,
                                                     sourceName, targetName,
                                                     dataset)
                elif mode == "export":
                    retVal = gzSupport.exportDataset(sourceWorkspace,
                                                     sourceName, targetName,
                                                     dataset)
                if retVal == False:
                    success = False
            except:
                gzSupport.showTraceback()
                success = False
                retVal = False
            gzSupport.logDatasetProcess(sourceName, targetName, retVal)
        arcpy.SetProgressorPosition()
    except:
        gzSupport.showTraceback()
        gzSupport.addError("A Fatal Error occurred")
        success = False
        gzSupport.logDatasetProcess("", "", False)
    finally:
        arcpy.ResetProgressor()
        arcpy.RefreshCatalog(gzSupport.workspace)
        arcpy.ClearWorkspaceCache_management(sourceWorkspace)
        arcpy.ClearWorkspaceCache_management(gzSupport.workspace)

    if success == False:
        gzSupport.addError(
            "Errors occurred during process, look in log files for more information"
        )
    if gzSupport.ignoreErrors == True:
        success = True

    gzSupport.closeLog()
    arcpy.SetParameter(SUCCESS, success)
Esempio n. 4
0
def main(argv = None):
    success = True
    if not arcpy.Exists(gzSupport.workspace):
        gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create")
        gzSupport.createGizintaGeodatabase()
    else:
        gzSupport.compressGDB(gzSupport.workspace)
    arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
    try:
        gzSupport.addMessage("Looking for drawings modified since " + since)
        minTime = dt.datetime.strptime(since,"%d/%m/%Y %I:%M:%S %p")
        cadFiles = getFileList(cadFolder,cadExt,minTime)
        if len(cadFiles) > 0:
            progBar = len(cadFiles) + 1
            arcpy.SetProgressor("step", "Importing Drawings...", 0,progBar, 1) 
            deleteExistingRows(datasets)
            arcpy.SetProgressorPosition()
        for item in cadFiles:
            cadPath = item[0]
            cadName = item[1]
            gzSupport.addMessage("Importing Drawing " + cadName)
            
            for dataset in datasets:
                try:
                    name = dataset.getAttributeNode("sourceName").nodeValue
                except:
                    name = dataset.getAttributeNode("name").nodeValue

                gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue
                arcpy.SetProgressorLabel("Loading " + name + " for " + cadName + "...") 
                arcpy.env.Workspace = gzSupport.workspace
                targetName = dataset.getAttributeNode("targetName").nodeValue
                sourceWorkspace = os.path.join(cadPath,cadName)
                if not arcpy.Exists(os.path.join(gzSupport.workspace,targetName)):
                    gzSupport.addMessage(os.path.join(gzSupport.workspace,targetName) + " does not exist")
                    mode = "export"
                else:
                    mode = "import"

                try:
                    if mode == "import":
                        retVal = gzSupport.importDataset(sourceWorkspace,name,targetName,dataset)
                    elif mode == "export":
                        retVal = gzSupport.exportDataset(sourceWorkspace,name,targetName,dataset)
                    #retVal = importLayer(cadPath,cadName,dataset)
                    if retVal == False:
                        success = False
                except:
                    gzSupport.showTraceback()
                    success = False
                    retVal = False

                arcpy.env.Workspace = gzSupport.workspace
                gzSupport.logDatasetProcess(cadName,name,retVal)
                gzSupport.cleanupGarbage()
            arcpy.SetProgressorPosition()
    except:
        gzSupport.addError("A Fatal Error occurred")
        gzSupport.showTraceback()
        success = False
        gzSupport.logDatasetProcess("","",False)
    finally:
        arcpy.ResetProgressor()
        arcpy.RefreshCatalog(gzSupport.workspace)
        arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
        gzSupport.cleanupGarbage()

    if success == False:
        gzSupport.addError("Errors occurred during process, look in log files for more information")        
    if gzSupport.ignoreErrors == True:
        success = True
    gzSupport.closeLog()
    arcpy.SetParameter(SUCCESS, success)