Python arcpy.GetInstallInfo() Examples

The following are 6 code examples of arcpy.GetInstallInfo(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module arcpy , or try the search function .
Example #1
Source File: Step1_MakeShapesFC.py    From public-transit-tools with Apache License 2.0 5 votes vote down vote up
def check_Arc_version(useAGOL=False, useNA=False):
    '''Check that the user has a version of ArcGIS that can support this tool.'''

    ArcVersionInfo = arcpy.GetInstallInfo("desktop")
    ArcVersion = ArcVersionInfo['Version']
    global ProductName
    ProductName = ArcVersionInfo['ProductName']
    global useBearing
    
    if ProductName == "ArcGISPro":
        if ArcVersion in ["1.0", "1.1", "1.1.1"]:
            arcpy.AddError("You must have ArcGIS Pro 1.2 or higher to run this \
tool. You have ArcGIS Pro version %s." % ArcVersion)
            raise CustomError
        if useNA and ArcVersion in ["1.0", "1.0.1", "1.0.2", "1.1", "1.1.1", "1.2", "1.3", "1.3.1", "1.4", "1.4.1"]:
            # Bearing and BearingTol fields did not work until Pro 2.0.
            arcpy.AddWarning("Warning!  Certain functionality was implemented in ArcGIS Pro 2.0 that \
significantly improves the output of this tool. For better results, upgrade to the latest version of ArcGIS Pro or run \
this tool with ArcMap version 10.3 or higher.")
            useBearing = False
    
    else:
        if ArcVersion == "10.0":
            arcpy.AddError("You must have ArcGIS 10.2.1 or higher (or ArcGIS Pro) to run this \
tool. You have ArcGIS version %s." % ArcVersion)
            raise CustomError
        if ArcVersion in ["10.1", "10.2"]:
            arcpy.AddWarning("Warning!  You can run Step 1 of this tool in \
ArcGIS 10.1 or 10.2, but you will not be able to run Step 2 without ArcGIS \
10.2.1 or higher (or ArcGIS Pro).  You have ArcGIS version %s." % ArcVersion)
            if useNA:
                useBearing = False
        if useAGOL and ArcVersion in ["10.2.1", "10.2.2"]:
            arcpy.AddError("You must have ArcGIS 10.3 (or ArcGIS Pro) to run the ArcGIS Online \
version of this tool. You have ArcGIS version %s." % ArcVersion)
            raise CustomError
        if useNA and ArcVersion in ["10.2.1", "10.2.2"]:
            arcpy.AddWarning("Warning!  This version of Step 1 will produce significantly \
better output using ArcGIS version 10.3 or higher or ArcGIS Pro 2.0 or higher. You have ArcGIS version %s." % ArcVersion)
            useBearing = False 
Example #2
Source File: BBB_SharedFunctions.py    From public-transit-tools with Apache License 2.0 5 votes vote down vote up
def DetermineArcVersion():
    '''Figure out what version of ArcGIS the user is running'''
    ArcVersionInfo = arcpy.GetInstallInfo("desktop")
    global ArcVersion, ProductName
    ProductName = ArcVersionInfo['ProductName']
    ArcVersion = ArcVersionInfo['Version'] 
Example #3
Source File: s57_2_chart.py    From maritime-charting-sample-scripts with Apache License 2.0 5 votes vote down vote up
def getDesktopFolder():
    # Get install info
    install_info = arcpy.GetInstallInfo()
    # Get Version
    version = install_info["Version"]
    folder_version = version.split(".")[0] + "." + version.split(".")[1]
    # Create desktop folder path
    desktop_fldr = os.path.join(os.path.dirname(os.path.dirname(install_info["InstallDir"])), "MaritimeCharting", "Desktop" + folder_version)
    return desktop_fldr 
Example #4
Source File: install_package.py    From r-bridge-install with Apache License 2.0 5 votes vote down vote up
def arcgis_platform():
    """ ArcGIS platform details used internally."""
    info = arcpy.GetInstallInfo()
    install_dir = info['InstallDir']
    arc_version = info['Version']
    if info['ProductName'] == 'ArcGISPro':
        product = 'Pro'
    else:
        # there are other levels, but this is a PYT run from toolbox,
        # so unlikely to be a non-ArcMap context
        product = 'ArcMap'
    return (install_dir, arc_version, product) 
Example #5
Source File: rpath.py    From r-bridge-install with Apache License 2.0 4 votes vote down vote up
def r_pkg_path():
    """
    Package path search. Locations searched:
     - HKCU\\Software\\Esri\\ArcGISPro\\RintegrationProPackagePath
     - [MYDOCUMENTS]/R/win-library/[3-9].[0-9]/ - default for user R packages
     - [ArcGIS]/Resources/Rintegration/arcgisbinding
    """
    package_path = None
    package_name = 'arcgisbinding'

    root_key = winreg.HKEY_CURRENT_USER
    reg_path = "SOFTWARE\\Esri\\ArcGISPro"
    package_key = 'RintegrationProPackagePath'
    pro_reg = None

    try:
        # find the key, 64- or 32-bit we want it all
        pro_reg = winreg.OpenKey(root_key, reg_path, 0, READ_ACCESS)
    except fnf_exception as error:
        handle_fnf(error)

    if pro_reg:
        try:
            # returns a tuple of (value, type)
            package_path_key = winreg.QueryValueEx(pro_reg, package_key)
            package_path_raw = package_path_key[0]
            if os.path.exists(package_path_raw):
                package_path = package_path_raw
        except fnf_exception as error:
            handle_fnf(error)

    # iterate over all known library path locations,
    # and check for our package in each.
    for lib_path in r_all_lib_paths():
        possible_package_path = os.path.join(lib_path, package_name)
        if os.path.exists(possible_package_path):
            package_path = possible_package_path
            # we want the highest-priority library, stop here
            break

    # fallback -- <ArcGIS Install>/Rintegration/arcgisbinding
    if not package_path:
        import arcpy
        arc_install_dir = arcpy.GetInstallInfo()['InstallDir']
        arc_package_dir = os.path.join(
            arc_install_dir, 'Rintegration', package_name)
        if os.path.exists(arc_package_dir):
            package_path = arc_package_dir

    return package_path 
Example #6
Source File: arcapi.py    From arcapi with GNU Lesser General Public License v3.0 4 votes vote down vote up
def concatenate_fields(table, new_field, length, fields=[], delimiter='', number_only=False):
    """Create a new field in a table and concatenate user defined fields.

    This can be used in situations such as creating a Section-Township-Range
    field from 3 different fields.
    Returns the field name that was added.

    Required:
    table -- Input table
    new_field -- new field name
    length -- field length
    fields -- list of fields to concatenate

    Optional:
    delimiter -- join value for concatenated fields
        (example: '-' , all fields will be delimited by dash)
    number_only -- if True, only numeric values from a text field are extracted.
        Default is False.

    Example:
    >>> sec = r'C:\Temp\Sections.shp'
    >>> concatenate_fields(sec, 'SEC_TWP_RNG', 15, ['SECTION', 'TOWNSHIP', 'RANGE'], '-')
    """

    # Add field
    new_field = create_field_name(table, new_field)
    arcpy.AddField_management(table, new_field, 'TEXT', field_length=length)

    # Concatenate fields
    if arcpy.GetInstallInfo()['Version'] != '10.0':
        # da cursor
        with arcpy.da.UpdateCursor(table, fields + [new_field]) as rows:
            for r in rows:
                r[-1] = concatenate(r[:-1], delimiter, number_only)
                rows.updateRow(r)

    else:
        # 10.0 cursor
        rows = arcpy.UpdateCursor(table)
        for r in rows:
            r.setValue(new_field, concatenate([r.getValue(f) for f in fields], delimiter, number_only))
            rows.updateRow(r)
        del r, rows
    return new_field