narsdani

ListVersions: Not a valid SDE workspace.

Discussion created by narsdani on Oct 5, 2011
Latest reply on Oct 10, 2011 by rbrennan-esristaff
I've been beating my head against a wall for a couple days now & it's past time for me to ask for help.  I've got a script that I run from the command prompt that I want (among other things) to get a list of all versions in an SDE instance, loop through that list looking for a version with a particular name, and delete that version if it exists.  The code I wrote is as follows:

ParentConnection = "C:\\temp\\Basemap_Default_DC1.sde\\"  ## Actually set programmatically but this is what's pumped into my function
ParentConnection = ParentConnection.rstrip("\\")
arcpy.env.workspace = ParentConnection
VersionList = arcpy.ListVersions()
## arcpy.ListVersions(ParentConnection) yielded the same results 
for name in VersionList:
       if name.endswith("." + VersionName):    ## If a version with this name already exists then delete it
              arcpy.DeleteVersion_management(ParentConnection, name)
              break



When I call arcpy.ListVersions() (regardless of scope or the two different ways to specify the workspace as noted above), I get the following error:

Traceback (most recent call last):
  File "R:\Addressing\QualityControl\PythonFiles\CountywideNearAnalysis.py", line 121, in <module>
    raise inst
ValueError: ListVersions: Not a valid SDE workspace.


Can anyone shed some light on this?  The sde file exists and works correctly in ArcCatalog, furthermore this same code works in ArcCatalog's Python window.  Thanks.
Dan

Outcomes