本文整理汇总了Python中arcpy.GetMessages方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.GetMessages方法的具体用法?Python arcpy.GetMessages怎么用?Python arcpy.GetMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.GetMessages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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"])
示例2: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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"])
示例3: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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"])
示例4: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def main(*argv):
""" main driver of program """
try:
adminUsername = argv[0]
adminPassword = argv[1]
siteURL = argv[2]
username = argv[3]
groupName = argv[4]
# Logic
#
# Connect to AGOL
#
sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
admin = arcrest.manageorg.Administration(securityHandler=sh)
# Get the group ID
#
community = admin.community
groupId = community.getGroupIDs(groupNames=[groupName])[0]
# Add the User to the Group
#
groups = community.groups
res = groups.group(groupId=groupId).addUsersToGroups(users=username)
if len(res['notAdded'] ) == 0:
arcpy.SetParameterAsText(5, True)
else:
arcpy.SetParameterAsText(5, 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"])
示例5: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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"])
示例6: __init__
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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,
}
)
示例7: _CheckCreateGDBProcess
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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,
})
# ----------------------------------------------------------------------
示例8: validate_schema_map
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [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
示例9: _executePostProcess
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def _executePostProcess(self):
try:
print "Running post process GP"
for process in self.postExtractGP:
if process["ToolType"].upper() == "MODEL":
arcpy.ImportToolbox(process["ToolPath"])
arcpy.gp.toolbox = process["ToolPath"]
tools = arcpy.ListTools()
for tool in process["Tools"]:
if tool in tools:
customCode = "arcpy." + tool + "()"
print eval(customCode)
print "Finished executing model {0}".format(tool)
elif process["ToolType"].upper() == "SCRIPT":
for tool in process["Tools"]:
scriptPath = process["ToolPath"] + "/" + tool
subprocess.call([sys.executable, os.path.join(scriptPath)])
print "Finished executing script {0}".format(tool)
else:
print "Sorry, not a valid tool"
return True
except arcpy.ExecuteError:
line, filename, synerror = trace()
raise DataPrepError({
"function": "CopyData",
"line": line,
"filename": filename,
"synerror": synerror,
"arcpyError": arcpy.GetMessages(2),
})
except:
line, filename, synerror = trace()
raise DataPrepError({
"function": "CopyData",
"line": line,
"filename": filename,
"synerror": synerror,
})
示例10: compareDatum
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def compareDatum(fc):
# Return True if fc datum is either WGS84 or NAD83
try:
# Create Spatial Reference of the input fc. It must first be converted in to string in ArcGIS10
# otherwise .find will not work.
fcSpatialRef = str(arcpy.CreateSpatialReference_management("#",fc,"#","#","#","#"))
FCdatum_start = fcSpatialRef.find("DATUM") + 7
FCdatum_stop = fcSpatialRef.find(",", FCdatum_start) - 1
fc_datum = fcSpatialRef[FCdatum_start:FCdatum_stop]
# Create the GCS WGS84 spatial reference and datum name using the factory code
WGS84_sr = arcpy.SpatialReference(4326)
WGS84_datum = WGS84_sr.datumName
NAD83_datum = "D_North_American_1983"
# Input datum is either WGS84 or NAD83; return true
if fc_datum == WGS84_datum or fc_datum == NAD83_datum:
del fcSpatialRef, FCdatum_start, FCdatum_stop,fc_datum,WGS84_sr,WGS84_datum,NAD83_datum
return True
# Input Datum is some other Datum; return false
else:
del fcSpatialRef, FCdatum_start, FCdatum_stop,fc_datum,WGS84_sr,WGS84_datum,NAD83_datum
return False
except arcpy.ExecuteError:
AddMsgAndPrint(arcpy.GetMessages(2),2)
return False
except:
print_exception()
return False
## ===============================================================================================================
示例11: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def main(*argv):
""" main driver of program """
try:
# Inputs
#
adminUsername = argv[0]
adminPassword = argv[1]
siteURL = argv[2]
groupTitle = argv[3]
groupTags = argv[4]
description = argv[5]
access = argv[6]
# Logic
#
# Connect to the site
#
sh = arcrest.AGOLTokenSecurityHandler(adminUsername, adminPassword)
admin = arcrest.manageorg.Administration(url=siteURL,
securityHandler=sh,
initialize=True)
community = admin.community
# Create Group
#
res = community.createGroup(title=groupTitle,
tags=groupTags,
description=description,
snippet="",
phone="",
access=access,
sortField="title",
sortOrder="asc",
isViewOnly=False,
isInvitationOnly=False,
thumbnail=None)
arcpy.SetParameterAsText(7, 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"])
示例12: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def main(*argv):
""" main driver of program """
try:
# Inputs
#
adminUsername = argv[0]
adminPassword = argv[1]
siteURL = argv[2]
username = argv[3]
subFolders = argv[4].lower() == "true"
# 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)
res = usercontent.listUserContent(username=adminUsername)
# Delete Root Items
#
eItems = ""
itemsToErase = ",".join([item['id'] for item in res['items']])
usercontent.deleteItems(items=itemsToErase)
# Walk Each Folder and erase items if subfolder == True
#
if subFolders:
for folder in res['folders']:
c = usercontent.listUserContent(username=username, folderId=folder['id'])
itemsToErase = ",".join([item['id'] for item in c['items']])
if len(itemsToErase.split(',')) > 0:
usercontent.deleteItems(items=itemsToErase)
del c
usercontent.deleteFolder(folderId=folder['id'])
del folder
arcpy.AddMessage("User %s content has been deleted." % username)
arcpy.SetParameterAsText(4, True)
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: WriteCSV
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def WriteCSV(self):
# This function writes the CSV. It writes the header then the rows. This script omits the SHAPE fields.
try:
env.workspace = self._tempWorkspace
#fc = arcpy.ListFeatureClasses(self._layers)
# for fcs in self._layer:
fcs = self._layer
if arcpy.Exists(fcs):
with open(self._CSVLocation, 'wb') as outFile:
print "%s create" % self._CSVLocation
linewriter = csv.writer(outFile, delimiter = ',')
fcdescribe = arcpy.Describe(fcs)
flds = fcdescribe.Fields
# skip shape fields and derivatives
attrs = ("areaFieldName", "lengthFieldName", "shapeFieldName")
resFields = [getattr(fcdescribe, attr) for attr in attrs
if hasattr(fcdescribe, attr)]
header,fldLst = zip(*((fld.AliasName, fld.name) for fld in flds
if fld.name not in resFields))
linewriter.writerow([h.encode('utf8') if isinstance(h, unicode) else h for h in header])
linewriter.writerows([[r.encode('utf8') if isinstance(r, unicode) else r for r in row]
for row in arcpy.da.SearchCursor(fcs, fldLst)])
print "CSV file complete"
return True
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: classified_pivot
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def classified_pivot(classified_layer, classified_layer_field_name, reporting_areas_ID_field, count_field,
summary_fields=''):
_tempWorkspace = None
_freq = None
_pivot = None
try:
_tempWorkspace = env.scratchGDB
_freq = os.path.join(_tempWorkspace, Common.random_string_generator())
_pivot = os.path.join(_tempWorkspace, Common.random_string_generator())
if not count_field in summary_fields and count_field != 'FREQUENCY':
summary_fields = count_field if summary_fields == '' else summary_fields + ";" + count_field
arcpy.Frequency_analysis(in_table=classified_layer, out_table=_freq,
frequency_fields=reporting_areas_ID_field + ';' + classified_layer_field_name,
summary_fields=summary_fields)
arcpy.PivotTable_management(_freq, reporting_areas_ID_field, classified_layer_field_name, count_field, _pivot)
deleteFC([_freq])
return _pivot
except arcpy.ExecuteError:
line, filename, synerror = trace()
raise ReportToolsError({
"function": "classified_pivot",
"line": line,
"filename": filename,
"synerror": synerror,
"arcpyError": arcpy.GetMessages(2),
}
)
except:
line, filename, synerror = trace()
raise ReportToolsError({
"function": "classified_pivot",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
_tempWorkspace = None
_freq = None
del _tempWorkspace
del _freq
gc.collect()
# ----------------------------------------------------------------------
示例15: CopyData
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetMessages [as 别名]
def CopyData(self):
try:
print "************ BEGIN Data Copy****************"
# Read the config values and store in local variables then start extraction
# It all depends on if it can create a GDB, if not, all other processes are bypassed.
for database in self.databases:
self.overWrite = None
self.databases = None
self.start_db = None
self.end_db = None
self.datasetsToInclude = None
self.standaloneFeatures = None
self.postExtractGP = None
retVal = True
if "GDBPath" in database and "SDEPath" in database:
#workspaceProp = arcpy.Describe(database["GDBPath"])
if (database["GDBPath"].lower()).find(".sde") == -1:
#if (workspaceProp.workspaceType == "LocalDatabase"):
self.start_db = database["SDEPath"]
self.end_db = database["GDBPath"]
self.overWrite = database["Overwrite"]
if self._CheckCreateGDBProcess():
if "DataSets" in database:
if database["DataSets"]:
self.datasetsToInclude = database["DataSets"]
retVal = self._CopyDatasetsProcess()
if "FeatureClasses" in database:
if database["FeatureClasses"]:
self.standaloneFeatures = database["FeatureClasses"]
retVal = self._CopyDataTypeProcess(type="FeatureClasses")
if "Tables" in database:
if database["Tables"]:
self.standaloneFeatures = database["Tables"]
retVal = self._CopyDataTypeProcess(type="Tables")
else:
print "The output geodatabase must be a file geodatabase"
retVal = False
if "PostProcesses" in database:
if database["PostProcesses"]:
self.postExtractGP = database["PostProcesses"]
retVal = self._executePostProcess()
print "************ END Data Copy ****************"
return retVal
except arcpy.ExecuteError:
line, filename, synerror = trace()
raise DataPrepError({
"function": "CopyData",
"line": line,
"filename": filename,
"synerror": synerror,
"arcpyError": arcpy.GetMessages(2),
})
except (DataPrepError),e:
raise e