checking for availablity of dataset based on SDE permissions

2726
1
07-01-2015 01:47 PM
TrevorWeiland
New Contributor III

I am writing a python script that checks for a dataset before deleting the previous output.  I have found that arcpy.Exists returns true if a dataset exists regardless of whether the user has permissions to that dataset.

Is there a way to check that the dataset exists AND that the specific user established in the sde connection file actually has permission to that dataset in python?


Trevor

Tags (1)
0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

I can't think of anything simple right off the top, but there is nearly always a way to do what you want if you want to do it bad enough.  Some ideas are thrown around over in a StackExchange post:  Checking current user privileges for an SDE dataset with Python/arcpy.

Regardless of the specific approach, verifying permissions before trying to delete a dataset will be an expensive operation, or expensive enough that I might just go with a try/except block instead.  Whereas some or most languages are LBYL, Python works pretty well with EAFP.

Do you expect the attempt to fail or succeed most of the time?  If it fails or the user doesn't have permissions, what will you do then?