Is there to test if a mxd has a login to ArcGIS Online in python?

12-31-2015 09:35 AM
MVP Frequent Contributor

Anyone know a way to test to see if a MXD is logged in?  I have a mxd that has a Hosted Feature Service in it.  I then have a python script running on a schedule.  The only way I can have python be logged in is to leave ArcMap open all the time and logged in on the same machine.  Then python sees it.  Problem is ArcMap logs itself out appox every 12 hours.  I have posted and no one seems to know how to change this.  So instead is there a way I can test for a login then exit the script if it is not?

If the script runs interactively it will popup a login to AGO box.  But if the script is scheduled it just sits and waits which locks up my log file until I kill python in task manager.

Just trying anything now since there is strangely no way to login in a mxd in a script.

I am using Data Driven pages off the HFS so it dies here

            mxd = arcpy.mapping.MapDocument(os.path.join(mapsDir, mapToUse))

            ddp = mxd.dataDrivenPages

Oh and no REST does not work.  The MXD can not see REST tokens.


0 Kudos
3 Replies
Esri Regular Contributor

Hi Doug,

Please let me know if the following Stack Exchange details your experience and issue and if the answer addressed the issue or not: arcpy - How can I leverage ArcGIS Online sign in credentials/dialog box in a python add-in for Deskt... 



0 Kudos
MVP Frequent Contributor

Thanks but I have seen that already.  Been searching a lot.  As the post points out the kicker is....

"Again, none of these can be used to sign in (you need to already be signed in), but the functions will hopefully provide some bits you need."

This is a script that runs on a schedule through windows event scheduler.

I have asked about the registry entries I have found also but no one knows anything about them.  Even if I could just extend the login time that would help.

0 Kudos
New Contributor III

Doug, any luck with this? I am running into an identical issue with data driven pages that are exported weekly while  I'm not around.

0 Kudos