Select to view content in your preferred language

arcpy.mapping.AnalyzeForSD(sddraft) - Missing warnings

4115
7
Jump to solution
01-09-2013 09:42 PM
TonyGegner
New Contributor III
Hi,
I have a problem with the arcpy.mapping.AnalyzeForSD() function.
I'm trying to automate everything and is in need to get all the warnings/messages from the mxd analyze.

Somehow i dont manage to get all the warnings from the analyze. Example:

analysis = arcpy.mapping.AnalyzeForSD(sddraft) print analysis  >> {'errors': {}, 'messages': {(u'Layer draws at all scale ranges', 30003): [<map layer u'Something.sde.Layername'>]}, 'warnings': {(u"Layer's data source doesn't have a spatial index", 10002): [<map layer u'Something.sde.Layername'>]}}


The same thing from ArcMap:

SEVERITY STATUS CODE DESCRIPTION NAME TYPE DATA FRAME
High Unresolved 10002 Layer's data source doesn't have a spatial index u'Something.sde.Layername  Layer Layers
High Unresolved 24011 Layer's data source is not registered with the server and data will be copied to the server Something.sde.Layername Layer Layers
Medium Unresolved 10045 Map is being published with data copied to the server using data frame full extent Layers Data Frame Layers
Low Unresolved 30003 Layer draws at all scale ranges Something.sde.Layername Layer Layers

Warning 24001 and 10045 is missing from the AnalyzeForSD().

Any idea for a solution for this?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Peter_von_Minden
New Contributor III
I couldn't wait for the next release to resolve this bug (NIM08210) so I tried the following workaround to catch when the "Layer's data source is not registered with the server":

import arcpy, re, os

serverRegDBlist = []
lyrDataSourceList = []
continueIfOne = 1
serverFile = r"C:\temp\arcgis on testserver_6080 (admin).ags"
mxdPath = r"C:\temp\test.mxd"
mxd = arcpy.mapping.MapDocument(mxdPath)

# The following loop searches through the server connection file and pulls out the server name and user
for i in arcpy.ListDataStoreItems(serverFile, 'DATABASE'):
[INDENT]    serverDetails = i[1]
    dbDetails = re.split(';', serverDetails)
    serverName = re.split('=', dbDetails[1])[1]
    serverUser = re.split('=', dbDetails[6])[1]
    serverRegDBlist.append(serverUser + "@" + serverName)[/INDENT]

# This loop searches the layers in the mxd to populate a list with connection details for each sde layer
for lyr in arcpy.mapping.ListLayers(mxd):
[INDENT]    # Will only continue if the layer is a feature layer and skip anything else such as groups and rasters
   if lyr.isFeatureLayer == True:
[INDENT]        lyrFullPath = lyr.dataSource
        lyrName = lyr.datasetName
        lyrMxdName = lyr.name
        lyrPath = os.path.dirname(lyrFullPath)
        lyrDirectory = os.path.dirname(lyrPath)[/INDENT]

        # Will continue if the layer supports service properties such as an sde dataset
        if lyr.supports("SERVICEPROPERTIES"):
[INDENT]            # Pulls out properties of the service for each supported layer
            lyrServer =  lyr.serviceProperties.get('Server', 'N/A')
            lyrUser = lyr.serviceProperties.get('UserName', 'N/A')
            lyrServer = lyrServer.strip()
            lyrUser = lyrUser.strip()
            lyrDataSourceList.append(lyrUser + '@' + lyrServer)[/[/INDENT]INDENT]
# This loop compares the lists and, if any individual layer in the mxd is not found in the servers registered databases, the variable
# continueIfOne is assigned a value of 0 which will be used in the proceeding if statement
for layers in lyrDataSourceList:
[INDENT]     if layers not in serverRegDBlist:
         [INDENT]continueIfOne = 0[/INDENT][/INDENT]

if continueIfOne == 0:
     [INDENT]print "Not going to continue"[/INDENT]
else:
    [INDENT]print "Continue ..."[/INDENT]

View solution in original post

7 Replies
JeffMoulds
Esri Contributor
I am aware of an issue with warning #24011 not showing up in arcpy. However, I am not aware of #10045 missing. Can you tell me what version and service pack of ArcGIS you are using, whether you are using Server or Desktop, and details about the layer in your map?

Unfortunately, I cannot think of a reasonable workaround to this issue.
0 Kudos
TonyGegner
New Contributor III
#24011 is the important one.
I'm using 10.1 SP1, Desktop.  Have been testing with all kinds of layers.
This example is a Simple Polygon. Any idea if this issue is being looked at? And if it might be resolved in a near future?
0 Kudos
JeffMoulds
Esri Contributor
The plan (subject to change) is to have this fixed for the next service pack or release. For your records, the tracking number for the issue is NIM088210.
0 Kudos
TonyGegner
New Contributor III
Great, Thanks!
0 Kudos
Peter_von_Minden
New Contributor III
I couldn't wait for the next release to resolve this bug (NIM08210) so I tried the following workaround to catch when the "Layer's data source is not registered with the server":

import arcpy, re, os

serverRegDBlist = []
lyrDataSourceList = []
continueIfOne = 1
serverFile = r"C:\temp\arcgis on testserver_6080 (admin).ags"
mxdPath = r"C:\temp\test.mxd"
mxd = arcpy.mapping.MapDocument(mxdPath)

# The following loop searches through the server connection file and pulls out the server name and user
for i in arcpy.ListDataStoreItems(serverFile, 'DATABASE'):
[INDENT]    serverDetails = i[1]
    dbDetails = re.split(';', serverDetails)
    serverName = re.split('=', dbDetails[1])[1]
    serverUser = re.split('=', dbDetails[6])[1]
    serverRegDBlist.append(serverUser + "@" + serverName)[/INDENT]

# This loop searches the layers in the mxd to populate a list with connection details for each sde layer
for lyr in arcpy.mapping.ListLayers(mxd):
[INDENT]    # Will only continue if the layer is a feature layer and skip anything else such as groups and rasters
   if lyr.isFeatureLayer == True:
[INDENT]        lyrFullPath = lyr.dataSource
        lyrName = lyr.datasetName
        lyrMxdName = lyr.name
        lyrPath = os.path.dirname(lyrFullPath)
        lyrDirectory = os.path.dirname(lyrPath)[/INDENT]

        # Will continue if the layer supports service properties such as an sde dataset
        if lyr.supports("SERVICEPROPERTIES"):
[INDENT]            # Pulls out properties of the service for each supported layer
            lyrServer =  lyr.serviceProperties.get('Server', 'N/A')
            lyrUser = lyr.serviceProperties.get('UserName', 'N/A')
            lyrServer = lyrServer.strip()
            lyrUser = lyrUser.strip()
            lyrDataSourceList.append(lyrUser + '@' + lyrServer)[/[/INDENT]INDENT]
# This loop compares the lists and, if any individual layer in the mxd is not found in the servers registered databases, the variable
# continueIfOne is assigned a value of 0 which will be used in the proceeding if statement
for layers in lyrDataSourceList:
[INDENT]     if layers not in serverRegDBlist:
         [INDENT]continueIfOne = 0[/INDENT][/INDENT]

if continueIfOne == 0:
     [INDENT]print "Not going to continue"[/INDENT]
else:
    [INDENT]print "Continue ..."[/INDENT]
Robertson_Katherine
New Contributor II

NICE!!!!!! Thank you for sharing!

 

0 Kudos
AndrewBrown1
Occasional Contributor II

To bring this back up, warning number 24012, "Standalone table's data source is not registered with the server and data will be copied to the server," is also NOT returned via AnalyzeForMSD. I checked everywhere and couldn't find a bug, so it looks like ESRI missed this one as well.

I know it's different than AnalyzeForSD, but we're utilizing the REST Admin API at 10.1, which only supports MSD.

0 Kudos