當前位置: 首頁>>代碼示例>>Python>>正文


Python arcpy.ExecuteError方法代碼示例

本文整理匯總了Python中arcpy.ExecuteError方法的典型用法代碼示例。如果您正苦於以下問題:Python arcpy.ExecuteError方法的具體用法?Python arcpy.ExecuteError怎麽用?Python arcpy.ExecuteError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在arcpy的用法示例。


在下文中一共展示了arcpy.ExecuteError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dataValidation

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def dataValidation(self, in_nc, messages):
        """Check the necessary dimensions and variables in the input netcdf data"""
        data_nc = NET.Dataset(in_nc)
        vars = data_nc.variables.keys()
        for each in self.vars_oi:
            if each not in vars:
                messages.addErrorMessage(self.errorMessages[3].format(each))
                raise arcpy.ExecuteError
            else:
                dims = data_nc.variables[each].dimensions
                if self.dims_var != dims:
                    messages.addErrorMessage(self.errorMessages[4].format(each))
                    raise arcpy.ExecuteError

        data_nc.close()

        return 
開發者ID:Esri,項目名稱:python-toolbox-for-rapid,代碼行數:19,代碼來源:CreateInflowFileFromWRFHydroRunoff.py

示例2: dataValidation

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def dataValidation(self, in_nc, messages):
        """Check the necessary dimensions and variables in the input netcdf data"""
        data_nc = NET.Dataset(in_nc)
        dims = data_nc.dimensions.keys()
        globalattrs = data_nc.__dict__.keys()
        for each in self.dimensions:
            if each not in dims:
                messages.addErrorMessage(self.errorMessages[1].format(each))
                raise arcpy.ExecuteError
        for each in self.globalattributes:
            if each not in globalattrs:
                messages.addErrorMessage(self.errorMessages[2].format(each))
                raise arcpy.ExecuteError

        data_nc.close()

        return 
開發者ID:Esri,項目名稱:python-toolbox-for-rapid,代碼行數:19,代碼來源:CreateWeightTableFromWRFGeogrid.py

示例3: login

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def login(email, password, server_url):
    """Authenticate the user."""

    api_key = None
    username = None

    try:
        login_result = urllib2.urlopen(
            '{}/footprint/login/'.format(server_url),
            data=urllib.urlencode({'email': email, 'password': password, 'output': 'json'}),
            **ssl_context_kwarg
        )
    except urllib2.HTTPError, e:
        if e.code != 200:
            raise arcpy.ExecuteError("Incorrect Email/Password combination. Please try again.")
    # raise error to user if url request fails 
開發者ID:CalthorpeAnalytics,項目名稱:urbanfootprint,代碼行數:18,代碼來源:arc_tool.py

示例4: get_config_entity_id

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def get_config_entity_id(username, api_key, config_entity_name, server_url):
    """Make an API query of Projects by name and return the id."""

    config_entity_id = None

    url = '{}/footprint/api/v1/project/?format=json&username={}&api_key={}&name={}'.format(
            server_url, urllib.quote(username), urllib.quote(api_key), urllib.quote(config_entity_name))

    config_entity_result = urllib2.urlopen(
        url,
        **ssl_context_kwarg
    )

    try:
        config_entity_data = json.loads(config_entity_result.read())
    except ValueError:
        raise arcpy.ExecuteError("Project lookup returned invalid response.")

    if config_entity_data and 'objects' in config_entity_data:
        if len(config_entity_data['objects']):
            config_entity_id = config_entity_data['objects'][0]['id']

    return config_entity_id 
開發者ID:CalthorpeAnalytics,項目名稱:urbanfootprint,代碼行數:25,代碼來源:arc_tool.py

示例5: dataValidation

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def dataValidation(self, in_nc, messages):
        """Check the necessary dimensions and variables in the input netcdf data"""
        data_nc = NET.Dataset(in_nc)

        dims = data_nc.dimensions.keys()
        if dims != self.dims_oi:
            messages.addErrorMessage(self.errorMessages[1])
            raise arcpy.ExecuteError

        vars = data_nc.variables.keys()
        if vars != self.vars_oi:
            messages.addErrorMessage(self.errorMessages[2])
            raise arcpy.ExecuteError

        return 
開發者ID:Esri,項目名稱:python-toolbox-for-rapid,代碼行數:17,代碼來源:CreateInflowFileFromECMWFRunoff.py

示例6: dataValidation

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def dataValidation(self, in_nc, messages):
        """Check the necessary dimensions and variables in the input netcdf data"""
        data_nc = NET.Dataset(in_nc)

        dims = data_nc.dimensions.keys()
        if dims not in self.dims_oi:
            messages.addErrorMessage(self.errorMessages[0])
            raise arcpy.ExecuteError

        vars = data_nc.variables.keys()
        if vars not in self.vars_oi:
            messages.addErrorMessage(self.errorMessages[1])
            raise arcpy.ExecuteError

        return 
開發者ID:Esri,項目名稱:python-toolbox-for-rapid,代碼行數:17,代碼來源:CreateWeightTableFromECMWFRunoff.py

示例7: validateNC

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def validateNC(self, in_nc, messages):
        """Check the necessary variables and dimensions in the input netcdf data"""
        data_nc = NET.Dataset(in_nc)

        vars = data_nc.variables.keys()
        vars_upper = []
        for eachvar in vars:
            vars_upper.append(eachvar.upper())

        counter = 0
        for eachvar_oi in self.vars_oi:
            try:
                ind = vars_upper.index(eachvar_oi.upper())
                # Update the Uppercase/Lowercase of the names of vars of interests
                self.vars_oi[counter] = vars[ind]
                counter += 1
            except RuntimeError:
                messages.addErrorMessage(self.errorMessages[0].format(eachvar_oi))
                raise arcpy.ExecuteError

        dims = data_nc.variables[self.vars_oi[1]].dimensions
        dims_upper = []
        for eachdim in dims:
            dims_upper.append(eachdim.upper())

        counter = 0
        for eachdim_oi in self.dims_oi:
            try:
                ind = dims_upper.index(eachdim_oi.upper())
                # Update the Uppercase/Lowercase of the names of dims of interests
                self.dims_oi[counter] = dims[ind]
                counter += 1
            except RuntimeError:
                messages.addErrorMessage(self.errorMessages[1].format(eachdim_oi, self.vars_oi[1]))
                raise arcpy.ExecuteError

        data_nc.close()

        return 
開發者ID:Esri,項目名稱:python-toolbox-for-rapid,代碼行數:41,代碼來源:CreateDischargeTable.py

示例8: exportPath

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def exportPath(opt, trackname):
    """
    This exports the list of segments into a shapefile, a subset of the loaded segment file, including all attributes
    """
    start_time = time.time()
    opt=getUniqueList(opt)
    qr =  '"OBJECTID" IN ' +str(tuple(opt))
    outname = (os.path.splitext(os.path.basename(trackname))[0][:9])+'_pth'
    arcpy.SelectLayerByAttribute_management('segments_lyr',"NEW_SELECTION", qr)
    try:
        if arcpy.Exists(outname):
            arcpy.Delete_management(outname)
        arcpy.FeatureClassToFeatureClass_conversion('segments_lyr', arcpy.env.workspace, outname)
        print("--- export: %s seconds ---" % (time.time() - start_time))
    except Exception:
        e = sys.exc_info()[1]
        print(e.args[0])

        # If using this code within a script tool, AddError can be used to return messages
        #   back to a script tool.  If not, AddError will have no effect.
        arcpy.AddError(e.args[0])
        arcpy.AddError(arcpy.env.workspace)
        arcpy.AddError(outname)
        #raise arcpy.ExecuteError
    except arcpy.ExecuteError:
        arcpy.AddError(arcpy.GetMessages(2))

    # Return any other type of error
    except:
        # By default any other errors will be caught here
        #
        e = sys.exc_info()[1]
        print(e.args[0])
        arcpy.AddError(e.args[0])
        arcpy.AddError(arcpy.env.workspace)
        arcpy.AddError(outname) 
開發者ID:simonscheider,項目名稱:mapmatching,代碼行數:38,代碼來源:mapmatcher.py

示例9: main

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def main(*argv):
    """ main driver of program """
    try:
        adminUsername = argv[0]
        adminPassword = argv[1]
        siteURL = argv[2]
        deleteUser = argv[3]
        #   Logic
        #
        sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
        admin = arcrest.manageorg.Administration(securityHandler=sh)
        community = admin.community
        user = community.user
        res = user.deleteUser(username=deleteUser)
        if res.has_key('success'):
            arcpy.SetParameterAsText(4, str(res['success']).lower() == "true")
        else:
            arcpy.SetParameterAsText(4, False)
        del sh
        del admin
        del community
        del user
        del res
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
        arcpy.AddError("ArcPy Error Message: %s" % arcpy.GetMessages(2))
    except FunctionError, f_e:
        messages = f_e.args[0]
        arcpy.AddError("error in function: %s" % messages["function"])
        arcpy.AddError("error on line: %s" % messages["line"])
        arcpy.AddError("error in file name: %s" % messages["filename"])
        arcpy.AddError("with error message: %s" % messages["synerror"])
        arcpy.AddError("ArcPy Error Message: %s" % messages["arc"]) 
開發者ID:Esri,項目名稱:ArcREST,代碼行數:38,代碼來源:deleteUser.py

示例10: main

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def main(*argv):
    """ main driver of program """
    try:
        #   Inputs
        #
        adminUsername = argv[0]
        adminPassword = argv[1]
        siteURL = argv[2]
        username = argv[3]
        itemId = argv[4]
        folderId = argv[5]
        #   Logic
        #
        sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
        admin = arcrest.manageorg.Administration(url=siteURL,
                                                 securityHandler=sh)
        content = admin.content
        #if isinstance(content, arcrest.manageorg._content.Content): pass
        usercontent = content.usercontent(username=username)
        if folderId is None or \
           folderId == "":
            res = usercontent.deleteItem(item_id=itemId)
        else:
            res =  usercontent.deleteItem(item_id=itemId, folder=folderId)
        arcpy.SetParameterAsText(6, str(res))
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
        arcpy.AddError("ArcPy Error Message: %s" % arcpy.GetMessages(2))
    except FunctionError, f_e:
        messages = f_e.args[0]
        arcpy.AddError("error in function: %s" % messages["function"])
        arcpy.AddError("error on line: %s" % messages["line"])
        arcpy.AddError("error in file name: %s" % messages["filename"])
        arcpy.AddError("with error message: %s" % messages["synerror"])
        arcpy.AddError("ArcPy Error Message: %s" % messages["arc"]) 
開發者ID:Esri,項目名稱:ArcREST,代碼行數:40,代碼來源:deleteItem.py

示例11: main

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def main(*argv):
    """ main driver of program """
    try:
        #   Inputs
        #
        adminUsername = argv[0]
        adminPassword = argv[1]
        siteURL = argv[2]
        groupName = argv[3]
        #   Logic
        #
        sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
        admin = arcrest.manageorg.Administration(securityHandler=sh)
        community = admin.community
        g = community.getGroupIDs(groupNames=[groupName])
        if len(g) == 0:
            arcpy.AddWarning("No Group Exists with That Name %s" % groupName)
            arcpy.SetParameterAsText(4, False)
        elif len(g) == 1:
            groups = community.groups
            groups.deleteGroup(groupId=g[0])
            arcpy.AddWarning("%s was erased." % groupName)
            arcpy.SetParameterAsText(4, True)
        else:
            arcpy.AddError("Multiple group names found, please manually delete!")
            arcpy.SetParameterAsText(4, False)
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
        arcpy.AddError("ArcPy Error Message: %s" % arcpy.GetMessages(2))
    except FunctionError, f_e:
        messages = f_e.args[0]
        arcpy.AddError("error in function: %s" % messages["function"])
        arcpy.AddError("error on line: %s" % messages["line"])
        arcpy.AddError("error in file name: %s" % messages["filename"])
        arcpy.AddError("with error message: %s" % messages["synerror"])
        arcpy.AddError("ArcPy Error Message: %s" % messages["arc"]) 
開發者ID:Esri,項目名稱:ArcREST,代碼行數:41,代碼來源:deleteGroup.py

示例12: main

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def main(*argv):
    """ main driver of program """
    try:
        url = str(argv[0])

        arcgisSH = ArcGISTokenSecurityHandler()
        if arcgisSH.valid == False:
            arcpy.AddError(arcgisSH.message)
            return
        fl = FeatureLayer(
            url=url,
            securityHandler=arcgisSH,
            initialize=True)

        res = fl.query(where="1=1",out_fields='*',returnGeometry=False)
        arcpy.AddMessage(res)
        arcpy.SetParameterAsText(1, str(res))
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        arcpy.AddError("error on line: %s" % line)
        arcpy.AddError("error in file name: %s" % filename)
        arcpy.AddError("with error message: %s" % synerror)
        arcpy.AddError("ArcPy Error Message: %s" % arcpy.GetMessages(2))
    except FunctionError, f_e:
        messages = f_e.args[0]
        arcpy.AddError("error in function: %s" % messages["function"])
        arcpy.AddError("error on line: %s" % messages["line"])
        arcpy.AddError("error in file name: %s" % messages["filename"])
        arcpy.AddError("with error message: %s" % messages["synerror"])
        arcpy.AddError("ArcPy Error Message: %s" % messages["arc"]) 
開發者ID:Esri,項目名稱:ArcREST,代碼行數:32,代碼來源:query_agol_layer_using_ArcMap_Creds.py

示例13: __init__

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def __init__(self, CSVLocation="", layer=None, workspace = None):
        # Gets the values of where the temp feature class resides and
        # the output location of the CSV.
        try:

            self._tempWorkspace = workspace
            self._layer = layer
            self._CSVLocation = CSVLocation

        except arcpy.ExecuteError:
            line, filename, synerror = trace()
            raise ReportToolsError({
                "function": "create_report_layers_using_config",
                "line": line,
                "filename":  filename,
                "synerror": synerror,
                "arcpyError": arcpy.GetMessages(2),
            }
            )
        except:
            line, filename, synerror = trace()
            raise ReportToolsError({
                "function": "create_report_layers_using_config",
                "line": line,
                "filename":  filename,
                "synerror": synerror,
            }
            ) 
開發者ID:Esri,項目名稱:utilities-solution-data-automation,代碼行數:30,代碼來源:csvexport.py

示例14: _CheckCreateGDBProcess

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def _CheckCreateGDBProcess(outputWorkspace):
    try:
        # If user param is to overwrite GDB, then delete it first
        if arcpy.Exists(outputWorkspace) == True:
            arcpy.Delete_management(outputWorkspace)
            print "Deleted previous GDB {0}".format(outputWorkspace)

        # if the local gdb doesn't exist, then create it using the path and name given in the end_db string
        if arcpy.Exists(outputWorkspace) == False:
            if outputWorkspace.rfind("\\") != -1:
                lastSlash = outputWorkspace.rfind("\\")
            else:
                lastSlash = outputWorkspace.rfind("/")
            arcpy.CreateFileGDB_management(outputWorkspace[:lastSlash], outputWorkspace[lastSlash + 1:])

            print "Created geodatabase {0}".format(outputWorkspace[lastSlash + 1:])


    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        raise ReportToolsError({
            "function": "_CheckCreateGDBProcess",
            "line": line,
            "filename": filename,
            "synerror": synerror,
            "arcpyError": arcpy.GetMessages(2),
        })
    except:
        line, filename, synerror = trace()
        raise ReportToolsError({
            "function": "_CheckCreateGDBProcess",
            "line": line,
            "filename": filename,
            "synerror": synerror,
        })


# ---------------------------------------------------------------------- 
開發者ID:Esri,項目名稱:utilities-solution-data-automation,代碼行數:40,代碼來源:reporttools.py

示例15: validate_schema_map

# 需要導入模塊: import arcpy [as 別名]
# 或者: from arcpy import ExecuteError [as 別名]
def validate_schema_map(report_schema, reclass_map, report_date_field, report_ID_field):
    try:
        valid = True
        fieldList = arcpy.ListFields(report_schema)

        layer_fields = []
        for field in fieldList:
            layer_fields.append(field.name)

        for fld in reclass_map:
            if not fld['FieldName'] in layer_fields:
                print "%s does not exist in %s" % (fld['FieldName'], report_schema)
                valid = False
        if report_date_field == '':
            print "Warning: Report Date not set in %s" % (report_schema)
        elif not report_date_field in layer_fields:
            print "%s (Report Date Field) does not exist in %s" % (report_date_field, report_schema)
            valid = False
        if not report_ID_field in layer_fields:
            print "%s (ID Field) does not exist in %s" % (report_ID_field, report_schema)
            valid = False

        if valid == False:
            raise ReportToolsError({
                "function": "validate_schema_map",
                "line": 1454,
                "filename": 'reporttools',
                "synerror": "%s does not contain all the fields contained in the config" % report_schema
            })
    except arcpy.ExecuteError:
        line, filename, synerror = trace()
        raise ReportToolsError({
            "function": "validate_schema_map",
            "line": line,
            "filename": filename,
            "synerror": synerror,
            "arcpyError": arcpy.GetMessages(2),
        })
    except ReportToolsError, e:
        raise e 
開發者ID:Esri,項目名稱:utilities-solution-data-automation,代碼行數:42,代碼來源:reporttools.py


注:本文中的arcpy.ExecuteError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。