当前位置: 首页>>代码示例>>Python>>正文


Python arcpy.AddError方法代码示例

本文整理汇总了Python中arcpy.AddError方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.AddError方法的具体用法?Python arcpy.AddError怎么用?Python arcpy.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arcpy的用法示例。


在下文中一共展示了arcpy.AddError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CountTripsOnLines

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def CountTripsOnLines(day, start_sec, end_sec, DepOrArr, Specific=False):
    '''Given a time window, return a dictionary of {line_key: [[trip_id, start_time, end_time]]}'''

    triplist, triplist_yest, triplist_tom = GetTripLists(day, start_sec, end_sec, DepOrArr, Specific)

    try:
        frequencies_dict = MakeFrequenciesDict()

        # Get the stop_times that occur during this time window
        linetimedict = GetLineTimesInTimeWindow(start_sec, end_sec, DepOrArr, triplist, "today", frequencies_dict)
        linetimedict_yest = GetLineTimesInTimeWindow(start_sec, end_sec, DepOrArr, triplist_yest, "yesterday", frequencies_dict)
        linetimedict_tom = GetLineTimesInTimeWindow(start_sec, end_sec, DepOrArr, triplist_tom, "tomorrow", frequencies_dict)

        # Combine the three dictionaries into one master
        for line in linetimedict_yest:
            linetimedict[line] = linetimedict.setdefault(line, []) + linetimedict_yest[line]
        for line in linetimedict_tom:
            linetimedict[line] = linetimedict.setdefault(line, []) + linetimedict_tom[line]

    except:
        arcpy.AddError("Error creating dictionary of lines and trips in time window.")
        raise CustomError

    return linetimedict 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:26,代码来源:BBB_SharedFunctions.py

示例2: import_AGOLservice

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def import_AGOLservice(service_name, username="", password="", ags_connection_file="", token="", referer=""):
    '''Imports the AGOL service toolbox based on the specified credentials and returns the toolbox object'''

    #Construct the connection string to import the service toolbox
    if username and password:
        tbx = "http://logistics.arcgis.com/arcgis/services;{0};{1};{2}".format(service_name, username, password)
    elif ags_connection_file:
        tbx = "{0};{1}".format(ags_connection_file, service_name)
    elif token and referer:
        tbx = "http://logistics.arcgis.com/arcgis/services;{0};token={1};{2}".format(service_name, token, referer)
    else:
        arcpy.AddError("No valid option specified to connect to the {0} service".format(service_name))
        raise CustomError

    #Import the service toolbox
    tbx_alias = "agol"
    arcpy.ImportToolbox(tbx, tbx_alias)

    return getattr(arcpy, tbx_alias) 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:21,代码来源:BBB_SharedFunctions.py

示例3: CheckArcVersion

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def CheckArcVersion(min_version_pro=None, min_version_10x=None):
    DetermineArcVersion()
    # Lists must stay in product release order
    # They do not need to have new product numbers added unless a tool requires a higher version
    versions_pro = ["1.0", "1.1", "1.1.1", "1.2"]
    versions_10x = ["10.1", "10.2", "10.2.1", "10.2.2", "10.3", "10.3.1", "10.4"]

    def check_version(min_version, all_versions):
        if min_version not in all_versions:
            arcpy.AddError("Invalid minimum software version number: %s" % str(min_version))
            raise CustomError
        version_idx = all_versions.index(min_version)
        if ArcVersion in all_versions[:version_idx]:
            # Fail out if the current software version is in the list somewhere earlier than the minimum version
            arcpy.AddError("The BetterBusBuffers toolbox does not work in versions of %s prior to %s.  \
You have version %s.  Please check the user's guide for more information on software version compatibility." % (ProductName, min_version, ArcVersion))
            raise CustomError

    if ProductName == "ArcGISPro" and min_version_pro:
        check_version(min_version_pro, versions_pro)
    else:
        if min_version_10x:
            check_version(min_version_10x, versions_10x) 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:25,代码来源:BBB_SharedFunctions.py

示例4: HandleOIDUniqueID

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def HandleOIDUniqueID(inPointsLayer, inLocUniqueID):
    '''If ObjectID was selected as the unique ID, copy the values to a new field
    so they don't get messed up when copying the table.'''
    pointsOID = arcpy.Describe(inPointsLayer).OIDFieldName
    if inLocUniqueID.lower() == pointsOID.lower():
        try:
            inLocUniqueID = "BBBUID"
            arcpy.AddMessage("You have selected your input features' ObjectID field as the unique ID to use for this analysis. \
In order to use this field, we have to transfer the ObjectID values to a new field in your input data called '%s' because ObjectID values \
may change when the input data is copied to the output. Adding the '%s' field now, and calculating the values to be the same as the current \
ObjectID values..." % (inLocUniqueID, inLocUniqueID))
            arcpy.management.AddField(inPointsLayer, inLocUniqueID, "LONG")
            arcpy.management.CalculateField(inPointsLayer, inLocUniqueID, "!" + pointsOID + "!", "PYTHON_9.3")
        except:
            arcpy.AddError("Unable to add or calculate new unique ID field. Please fix your data or choose a different unique ID field.")
            raise CustomError
    return inLocUniqueID 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:19,代码来源:BBB_SharedFunctions.py

示例5: make_remove_extra_fields

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def make_remove_extra_fields(tablename, columns):
    '''Make a function that removes extraneous columns from the CSV rows.
    E.g.: the CTA dataset has things like stops.wheelchair_boarding and
    trips.direction that aren't in the spec.'''
    orig_num_fields = len(columns)
    # Identify the extraneous columns:
    cols = [ ]
    tbl = sql_schema[tablename]
    for idx,field in enumerate(columns):
        if field not in tbl:
            cols.append(idx)
    cols.reverse()
    # ... and here's the function:
    def drop_fields(in_row):
        out_row = list(in_row)
        # Check that row was the correct length in the first place.
        if len(out_row) != orig_num_fields:
            msg = "GTFS table %s contains at least one row with the wrong number of fields. Fields: %s; Row: %s" % (tablename, columns, str(in_row))
            arcpy.AddError(msg)
            raise BBB_SharedFunctions.CustomError
        # Remove the row entries for the extraneous columns
        for idx in cols:
            out_row.pop(idx)
        return tuple(out_row)
    return drop_fields 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:27,代码来源:sqlize_csv.py

示例6: check_date_fields

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def check_date_fields(rows, col_names, tablename, fname):
    '''Ensure date fields are the in the correct YYYYMMDD format before adding them to the SQL table'''
    def check_date_cols(row):
        if tablename == "calendar":
            date_cols = ["start_date", "end_date"]
        elif tablename == "calendar_dates":
            date_cols = ["date"]
        date_column_idxs = [col_names.index(x) for x in date_cols]
        for idx in date_column_idxs:
            date = row[idx]
            try:
                datetime.datetime.strptime(date, '%Y%m%d')
            except ValueError:
                msg ='Column "' + col_names[idx] + '" in file ' + fname + ' has an invalid value: ' + date + '. \
Date fields must be in YYYYMMDD format. Please check the date field formatting in calendar.txt and calendar_dates.txt.'
                arcpy.AddError(msg)
                raise BBB_SharedFunctions.CustomError
        return row
    if ispy3:
        return map(check_date_cols, rows)
    else:
        return itertools.imap(check_date_cols, rows) 
开发者ID:Esri,项目名称:public-transit-tools,代码行数:24,代码来源:sqlize_csv.py

示例7: featuresToGPX

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def featuresToGPX(inputFC, outGPX, zerodate, pretty):
    ''' This is called by the __main__ if run from a tool or at the command line
    '''

    descInput = arcpy.Describe(inputFC)
    if descInput.spatialReference.factoryCode != 4326:
        arcpy.AddWarning("Input data is not projected in WGS84,"
                         " features were reprojected on the fly to create the GPX.")

    generatePointsFromFeatures(inputFC , descInput, zerodate)

    # Write the output GPX file
    try:
        if pretty:
            gpxFile = open(outGPX, "w")
            gpxFile.write(prettify(gpx))
        else:
            gpxFile = open(outGPX, "wb")
            ET.ElementTree(gpx).write(gpxFile, encoding="UTF-8", xml_declaration=True)
    except TypeError as e:
        arcpy.AddError("Error serializing GPX into the file.")
    finally:
        gpxFile.close() 
开发者ID:arcpy,项目名称:sample-gp-tools,代码行数:25,代码来源:FeaturesToGPX.py

示例8: output_msg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def output_msg(msg, severity=0):
    """ Adds a Message (in case this is run as a tool)
        and also prints the message to the screen (standard output)
        :param msg: text to output
        :param severity: 0 = none, 1 = warning, 2 = error
    """
    print msg
    # Split the message on \n first, so that if it's multiple lines,
    #  a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            # Add appropriate geoprocessing message
            if severity == 0:
                arcpy.AddMessage(string)
            elif severity == 1:
                arcpy.AddWarning(string)
            elif severity == 2:
                arcpy.AddError(string)
    except:
        pass 
开发者ID:gdherbert,项目名称:DataPillager,代码行数:22,代码来源:DataServicePillager.py

示例9: release_info

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def release_info():
    """Get latest release version and download URL from
       the GitHub API.

    Returns:
        (download_url, tag_name) tuple.
    """
    download_url = None
    tag = None
    json_r = parse_json_url(latest_url)
    if json_r is not None and 'assets' in json_r:
        assets = json_r['assets'][0]
        if 'browser_download_url' in assets and \
                'tag_name' in json_r:
            download_url = assets['browser_download_url']
            tag = json_r['tag_name']
        if not download_url or not tag:
            arcpy.AddError("Invalid GitHub API response for URL '{}'".format(
                latest_url))

    return (download_url, tag) 
开发者ID:R-ArcGIS,项目名称:r-bridge-install,代码行数:23,代码来源:github_release.py

示例10: update_service_definition

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def update_service_definition(args_parser):
    try:
        gis = GIS(args_parser.url,args_parser.username, args_parser.password)
        featureLayerItem = gis.content.get(args_parser.itemId)

        featureLayerCollection = FeatureLayerCollection.fromitem(featureLayerItem)
        layers = featureLayerCollection.manager.layers
        tables = featureLayerCollection.manager.tables

        arcpy.AddMessage("Updating Service Definition..")        

        for layer in layers:
            layer_index = layers.index(layer)
            update_template(featureLayerCollection,layer,layer_index,False)

        for table in tables:
            table_index = tables.index(table)
            update_template(featureLayerCollection,table,table_index,True)

                
        arcpy.AddMessage("Updated Service Definition..")

    except Exception as e:
        arcpy.AddError(e) 
开发者ID:Esri,项目名称:collector-tools,代码行数:26,代码来源:reset_required_fields_python_api.py

示例11: PrintMsg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def PrintMsg(msg, severity=0):
    # Adds tool message to the geoprocessor
    #
    #Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            #Add a geoprocessing message (in case this is run as a tool)
            if severity == 0:
                arcpy.AddMessage(string)

            elif severity == 1:
                arcpy.AddWarning(string)

            elif severity == 2:
                arcpy.AddMessage("    ")
                arcpy.AddError(string)

    except:
        pass

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:23,代码来源:SSURGO_CheckgSSURGO2.py

示例12: PrintMsg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def PrintMsg(msg, severity=0):
    # prints message to screen if run as a python script
    # Adds tool message to the geoprocessor
    #
    #Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            #Add a geoprocessing message (in case this is run as a tool)
            if severity == 0:
                arcpy.AddMessage(string)

            elif severity == 1:
                arcpy.AddWarning(string)

            elif severity == 2:
                arcpy.AddMessage("    ")
                arcpy.AddError(string)
                #arcpy.AddMessage("    ")

    except:
        pass

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:25,代码来源:GetDominantComponent.py

示例13: PrintMsg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def PrintMsg(msg, severity=0):
    # prints message to screen if run as a python script
    # Adds tool message to the geoprocessor
    #
    # Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            #Add a geoprocessing message (in case this is run as a tool)
            if severity == 0:
                arcpy.AddMessage(string)

            elif severity == 1:
                arcpy.AddWarning(string)

            elif severity == 2:
                arcpy.AddMessage("    ")
                arcpy.AddError(string)

    except:
        pass

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:24,代码来源:SSURGO_gSSURGO_byTile.py

示例14: PrintMsg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def PrintMsg(msg, severity=0):
    # Adds tool message to the geoprocessor
    #
    #Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            #Add a geoprocessing message (in case this is run as a tool)
            if severity == 0:
                arcpy.AddMessage(string)

            elif severity == 1:
                arcpy.AddWarning(string)

            elif severity == 2:
                arcpy.AddError(" \n" + string)

    except:
        pass

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:22,代码来源:SSURGO_BatchDownload.py

示例15: PrintMsg

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddError [as 别名]
def PrintMsg(msg, severity=0):
    # prints message to screen if run as a python script
    # Adds tool message to the geoprocessor
    #
    #Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
    try:
        for string in msg.split('\n'):
            #Add a geoprocessing message (in case this is run as a tool)
            if severity == 0:
                arcpy.AddMessage(string)

            elif severity == 1:
                arcpy.AddWarning(string)

            elif severity == 2:
                arcpy.AddMessage("    ")
                arcpy.AddError(string)

    except:
        pass

## =================================================================================== 
开发者ID:ncss-tech,项目名称:geo-pit,代码行数:24,代码来源:SSURGO_ExportMuRaster.py


注:本文中的arcpy.AddError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。