AnsweredAssumed Answered

MXD Layers Assigned To Temp SDE Files When Using ArcPy & ArcCatalog

Question asked by clintglover15 on Jul 23, 2019
Latest reply on Apr 30, 2020 by cschieffer_newcom

I am currently responsible for updating layer data sources within mxds after an Oracle password change takes place.  To do this I have put together a Python script that goes through a folder (designated by the user), finds all of the .mxd files, and one by one reads in the layers of each mxd (arcpy.mapping.ListLayers), checks the workspacePath of each layer to determine which Oracle account is used for the layer, and then uses the replaceDataSource method to set it to the updated sde connection file.  After it finishes, it saves the mxd and then goes on to the next mxd file.  

 

I've recently discovered that when running the Python script, the data source information of some of the layers will occasionally be assigned to a temporary sde connection file that is being generated by some part of the ESRI software.  This assignment is being done BEFORE my Python checks the workspacePath and attempts to use the replaceDataSource method.  The temporary sde files are being generated in the following location on my local machine: C:\Users\John Doe\AppData\Local\Temp.  Within the Temp folder, a folder titled "arc66D2" was generated, which contained the temporary sde file that was named 131dcb16a392ebc818a09874d51fce89.sde.  When I looked at the connection properties of this temp sde file (from ArcCatalog), it contained the old connection information from one of the layers within a mxd I ran my Python script on.  This behavior has happened on multiple occasions, each of which involves a different temporary sde file that were generated.

 

I have also discovered that this behavior occurs some times when I open ArcCatalog, right click on a mxd file, and select the "Set Data Source(s)..." option, which allows you to manually update the data source information for an mxd.  The tricky part is that there doesn't appear to be any pattern with this occurrence.  Has anyone ever had this same issue and/or know why this is occurring and how to prevent it?  From my tests, this has occurred when working with mxds on my local machine as well as mxds located on various servers.

 

After a password change, I have to run this Python script on thousands of mxds that have been created over the past 5 to 10 years by our end users to fix the data source information of all the layers, and when this temporary sde file is thrown in there "randomly", I can't trust my script to work 100% of the time and it causes additional work for me.  

 

For reference, I am using ArcMap/ArcCatalog 10.6.1 and Oracle 12c.  In the past, our Oracle account passwords have never changed, thus this wasn't a problem.  Recently, my organization started forcing us to update our Oracle passwords every 90 days, so this is becoming a huge ordeal for our GIS group to support and manage.

Outcomes