Get sde connections used by mxd files

241
0
04-21-2020 03:35 PM
ChrisHolmes
Occasional Contributor III

Hello everyone,

Is there a way to get from a mxd the sde connections that it uses and then establish those connections? I may not be making a lot of sense.

I have a script that will go through a mxd file and repair broken datasources. If I have the mxd open in arcmap and run the script against the 'current' mxd it works fine because when I open the mxd in arcmap, right off the bat it makes me log into sde:

So under that scenario, it works.

But, the script is written in a way where along with running the script tool against 'current', you can also:

- read the path to the mxd file you want to fix from a .config file

- or, read a path to a folder you want to examine from the .config file (in which case it will loop through all mxd's in the folder)

If I do not have the mxd file open in arcmap and have an untitled blank map open and run the script tool, it will read the mxd file to examine from the .config file but at some point soon after starting execution, the sde login form will display for you to log into sde, but since focus is on the script execution window it is not possible to put focus over to the login form and enter a username/password, so essentially at this point you have to kill the script as it's hung at this point.

Another scenario is to run the python script from outside arcmap (the script is rather time consuming and I thought if it's run from outside arcmap just as a python script, then it wouldn't tie up arcmap for a half hour or so). And while it does work in this scenario, what I find is that when the script loops through the list of broken layers, at each layer it pops up the sde login form for you to log into. So if there's 200 broken layers in a mxd file, it's going to present you with a sde login form 200 times.

My hope with this script was that it would be something where the user could set things up in the .config file, run the script and then not worry about having to do anything else, not sit there and babysit it logging into sde repeatedly.

So, to refresh my question from the beginning. Is it possible to do this sde login behind the scenes in the script so that the user doesn't have to be pulled into it as they are now?

Thanks, and apologies for how long winded this was

Tags (1)
0 Kudos
0 Replies