try: gis = GIS("Pro") except: logger.error()
I would like to get notified (except) when Pro fails to log in because no user is currently logged in or return the user that is logged in.
Hi
I'm not sure if you found a solution to your original post? If not then you you might find the following code snippet useful:
from arcgis.gis import GIS try: myGIS = GIS(url = 'pro') print(myGIS.users.me) # This will display the # user who accessed ArcGIS Pro and is used to # then authenticate the connection to your portal except ValueError as e: # if nobody has authenticated using ArcGIS # Pro then a ValueError is generated..... print("There was an error\n") print(f"The error is:\n\t{e}")
Hopefully this will do the trick and identify who has authenticated using ArcGIS Pro and a suitable error message displayed if nobody has authenticated.
If you have already authenticated using ArcGIS Pro; then run the above code and THEN sign out of ArcGIS Pro and re-run the code again, then the myGIS.users.me returns a None object. You might want to code for that outcome...?
I hope this helps you out - Let me know how you get on?
many thanks
ed
if not arcpy.GetSigninToken(): fail() portal = arcgis.GIS("Pro")
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.