本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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"])
示例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"])
示例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"])
示例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"])
示例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,
}
)
示例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,
})
# ----------------------------------------------------------------------
示例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