Select to view content in your preferred language

Service Properties Layer and Table

866
1
02-21-2019 03:44 PM
forestknutsen1
MVP Regular Contributor

I am making a script that will find, primarily, database (sde) connection information for each layer and table view within each mxd that has been published as a service across a number of ArcGIS servers. Then it inserts the info back into an Oracle table. This is to help with administration. So, I have it working for layers via the service properties attribute. But I don't see a service properties like attribute for a table view object? How can I get database user name (for DBA connections) and the database server for tables in an mxd? The only thing I see like this is the table data source. 

TableView—Help | ArcGIS for Desktop 

Layer—Help | ArcGIS for Desktop 

Please see my two functions below. The working layers one and the table view outline...

Thanks for the help!!

def find_conn_prop_tbl(mxd_source):
    ags = mxd_source[1].split(os.path.sep)[2]
    ags_service = os.path.basename(mxd_source[1])[:-4]
    ags_service_path = mxd_source[1]
    toc_type = 'table_view'
    mxd = arcpy.mapping.MapDocument(mxd_source[0])
    for df in arcpy.mapping.ListDataFrames(mxd):
        if df is not None:
            data_frame_name = df.name
            table_list = arcpy.mapping.ListTableViews(mxd, "", df)
            if table_list is not None:
                for table in table_list:
                    # ?????????
                    del table
            del table_list
    del mxd, df


def find_conn_prop_fc(mxd_source):
    ags = mxd_source[1].split(os.path.sep)[2]
    ags_service = os.path.basename(mxd_source[1])[:-4]
    ags_service_path = mxd_source[1]
    toc_type = 'layer'
    mxd = arcpy.mapping.MapDocument(mxd_source[0])
    for df in arcpy.mapping.ListDataFrames(mxd):
        if df is not None:
            data_frame_name = df.name
            layer_list = arcpy.mapping.ListLayers(mxd, "", df)
            if layer_list is not None:
                for layer in layer_list:
                    if layer.supports('SERVICEPROPERTIES'):
                        toc_path = layer.longName
                        prop_dict = layer.serviceProperties
                        prop_dict['AGS'] = ags
                        prop_dict['AGS_Service'] = ags_service
                        prop_dict['AGS_Service_Path'] = ags_service_path
                        prop_dict['TOC_Path'] = toc_path
                        prop_dict['TOC_Type'] = toc_type
                        prop_dict['Data_Frame'] = data_frame_name
                        oracle_injector.inject(prop_dict)
                    del layer
            del layer_list
    del mxd, df
0 Kudos
1 Reply
forestknutsen1
MVP Regular Contributor

Any thoughts on this one?

0 Kudos