Hi -
Does anyone know why Pro 2.0.1 would drop my signed-in status to our AGOL org? Is there a time-out setting somewhere? The way I am staging and uploading hosted content relies on my being signed into our AGOL account:
arcpy.mp.CreateWebLayerSDDraft(lyr, "V:/ArcProProjets/AgolUpdates/Cadastral/" + lyr.name + ".sddraft", lyr.name, "MY_HOSTED_SERVICES", "FEATURE_ACCESS",
"OpenData", True, False, False, True, False, "", 'Cadastral')
arcpy.StageService_server('V:/ArcProProjets/AgolUpdates/Cadastral/' + lyr.name + '.sddraft', 'V:/ArcProProjets/AgolUpdates/Cadastral/' + lyr.name + '.sd')I'm running this once a week on Saturdays. I should note that we are using our concurrent license manager and not named user accounts.
Thanks,
David
Solved! Go to Solution.
So interesting note on this with the 2.1 update. The new arcpy.SignInToPortal arcpy function does work, but if you want to upload the service definition it looks like you need to do so in the same try block that you create the sddraft and stage the service. I have tried using the sign-in with just the UploadServiceDefinition function in a stand alone bloc and it does not work, returns an 'not signed in error'. But if you run everything together seems to work ok:
try:
# Sign-in to ArcGIS Online
arcpy.SignInToPortal("https://yourorg.maps.arcgis.com/", "your_username", "your_password")
print ("I'm signed in")
portal = arcpy.GetActivePortalURL()
print (portal)
aprx = arcpy.mp.ArcGISProject(r'V:\ArcProProjets\AgolUpdates\AgolUpdates.aprx')
for m in aprx.listMaps("HostedAppLayers"):
message = message + "\n\n" "Map: " + m.name + "\n\n"
print("Map: " + m.name)
for lyr in m.listLayers():
if lyr.name == 'ParcelsHosted':# or lyr.name == 'ElevationCertificate':
print(" " + lyr.name)
arcpy.mp.CreateWebLayerSDDraft(lyr, "V:/ArcProProjets/AgolUpdates/HostedAppLayers/" + lyr.name + ".sddraft", lyr.name, "MY_HOSTED_SERVICES", "FEATURE_ACCESS",
"HostedAppLayers", True, False, False, True, False, "", 'HostedAppLayer')
arcpy.StageService_server('V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sddraft', 'V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sd')
message = message + "\n" "Layer: " + lyr.name
arcpy.UploadServiceDefinition_server('V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sd','My Hosted Services', "","","","","",
"OVERRIDE_DEFINITION","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION","")
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
#print(e.args[0])
#print "Line %i" % tb.tb_lineno
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + e.message
I had the same issue happen to me last week, where my Pro sign-in settings seem to have reset and my script for overwriting a web layer stopped working (since I wasn't signed in anymore).
I suspect it was an automatic update that caused it to sign out, so I've unchecked "Check for updates on startup" in the About ArcGIS Pro section. If this works, I'll just update Pro and log back in on my schedule.
We'll see if it happens again.
Thanks Eric, I'll give that a shot as well. Feels buggy. It'd be nice when ESRI adds the Sign In To Portal Sign Out From Portal tools to the 3.x python . . .
Actually, scratch my last. I did not and do not have the 'Check for updates on start up' option selected, so I don't know . . . seems that there is something that checks for inactivity or something in AGOL
There goes my theory... Thanks for letting me know.
sure if I find out anything I'll post back
Still no update on this. Does anyone know if Sign In To Portal / Sign Out From Portal will be included in the next or future release of ArcGIS Pro?
So interesting note on this with the 2.1 update. The new arcpy.SignInToPortal arcpy function does work, but if you want to upload the service definition it looks like you need to do so in the same try block that you create the sddraft and stage the service. I have tried using the sign-in with just the UploadServiceDefinition function in a stand alone bloc and it does not work, returns an 'not signed in error'. But if you run everything together seems to work ok:
try:
# Sign-in to ArcGIS Online
arcpy.SignInToPortal("https://yourorg.maps.arcgis.com/", "your_username", "your_password")
print ("I'm signed in")
portal = arcpy.GetActivePortalURL()
print (portal)
aprx = arcpy.mp.ArcGISProject(r'V:\ArcProProjets\AgolUpdates\AgolUpdates.aprx')
for m in aprx.listMaps("HostedAppLayers"):
message = message + "\n\n" "Map: " + m.name + "\n\n"
print("Map: " + m.name)
for lyr in m.listLayers():
if lyr.name == 'ParcelsHosted':# or lyr.name == 'ElevationCertificate':
print(" " + lyr.name)
arcpy.mp.CreateWebLayerSDDraft(lyr, "V:/ArcProProjets/AgolUpdates/HostedAppLayers/" + lyr.name + ".sddraft", lyr.name, "MY_HOSTED_SERVICES", "FEATURE_ACCESS",
"HostedAppLayers", True, False, False, True, False, "", 'HostedAppLayer')
arcpy.StageService_server('V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sddraft', 'V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sd')
message = message + "\n" "Layer: " + lyr.name
arcpy.UploadServiceDefinition_server('V:/ArcProProjets/AgolUpdates/HostedAppLayers/' + lyr.name + '.sd','My Hosted Services', "","","","","",
"OVERRIDE_DEFINITION","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION","")
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
#print(e.args[0])
#print "Line %i" % tb.tb_lineno
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + e.message