Overwriting Locator (python) - but it changes permissions to private (portal)

1244
8
Jump to solution
06-24-2022 02:35 PM
ChristenWatts
New Contributor III

Thanks for your potential help!

I'm using the CreateGeocodeSDDraft script to overwrite my Locator on Portal which is working... except -- when it overwrites/publishes  - the permissions are set to Private and I want it to be Public/Everyone.  I can change it to Everyone/Public in Portal, or on the Server Manager - run the script - is published but it private. 

Any ideas?  I've tried everything I can think of (there are some not called variables from all my attempts)

 

here is the script I'm using

import arcpy
import pprint

#sign into portal
arcpy.SignInToPortal(arcpy.GetActivePortalURL(), "####", "####")

# Overwrite any existing outputs
arcpy.env.overwriteOutput = True

locator_path = "C:\\Users\\gisadmin\\Desktop\\Geocoders\\simplicity"
sddraft_file = "C:\\locator_script\\simplicity.sddraft"
sd_file = "C:\\locator_script\\simplicity.sd"
service_name = "simplicity"
#shrOrg = True
#shrEveryone = True
#shrGroups = ""
folderName = "Geocoders"
summary = "Address ans Streets locator for the City of Asheville Simplicity Application!"
tags = "address, locator, geocode"
shared = True
everyone ='true'
orgs = 'true'
groups = None
shrOrg = True
shrEveryone = True
shrGroups = ""

# The URL of the federated server you are publishing to
in_server = "https://gisportal.asheville.gov/server/rest/services/Geocoders/"

# Create the sd draft file
analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sddraft_file, service_name,
copy_data_to_server=True,
summary=summary, tags=tags, max_result_size=20,
max_batch_size=500, suggested_batch_size=150,
overwrite_existing_service=True)

# Stage and upload the service if the sddraft analysis did not contain errors
if analyze_messages['errors'] == {}:
try:
# Execute StageService to convert sddraft file to a service definition
# (sd) file
arcpy.server.StageService(sddraft_file, sd_file)

# Execute UploadServiceDefinition to publish the service definition
# file as a service
arcpy.server.UploadServiceDefinition(sd_file, in_server)
print("The geocode service was successfully published")
except arcpy.ExecuteError:
print("An error occurred")
print(arcpy.GetMessages(2))
else:
# If the sddraft analysis contained errors, display them
print("Error were returned when creating service definition draft")
pprint.pprint(analyze_messages['errors'], indent=2)

1 Solution

Accepted Solutions
ChristenWatts
New Contributor III

I ended up sharing it (in the script) to a folder that was public and now it's public.

View solution in original post

0 Kudos
8 Replies
ChristenWatts
New Contributor III

I am using Enterprise 10.9.1 and ArcGIS Pro 2.9.

 

0 Kudos
ChristenWatts
New Contributor III

I ended up sharing it (in the script) to a folder that was public and now it's public.

0 Kudos
Kayden75
New Contributor III

I am running into the same issue, can you elaborate a little more by what you mean when you say you shared it in the script to a public folder? Like the locator in the C drive in the script?

 

0 Kudos
ChristenWatts
New Contributor III

Hey Kayden,  I meant a folder on portal that was shared publicly. My original was not. Hope you can get it working!

0 Kudos
Kayden75
New Contributor III

Thanks!

0 Kudos
Kayden75
New Contributor III

Sorry to ask you but can you post your code? I'm not sure how to specify the folder.

0 Kudos
ChristenWatts
New Contributor III

import arcpy
import pprint
#from arcgis.gis import GIS

#sign into portal
arcpy.SignInToPortal(arcpy.GetActivePortalURL(), "**user", "**password")

# Overwrite any existing outputs
arcpy.env.overwriteOutput = True

locator_path = "C:\\Users\\gisadmin\\Desktop\\Geocoders\\simplicity"
sddraft_file = "C:\\locator_script\\simplicity.sddraft"
sd_file = "C:\\locator_script\\simplicity.sd"
service_name = "simplicity"
folderName = "Geocoders"
summary = "Address and Streets locator for the City of Asheville Simplicity Application"
tags = "address, locator, geocode"
access = "public"


# The URL of the federated server you are publishing to
in_server = "https://xxxx.ashevillenc.gov/server/rest/services/Geocoders/"

# Create the sd draft file
analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sddraft_file, service_name,
copy_data_to_server=True, folder_name=folderName,
summary=summary, tags=tags, max_result_size=20,
max_batch_size=500, suggested_batch_size=150,
overwrite_existing_service=True)

# Stage and upload the service if the sddraft analysis did not contain errors
if analyze_messages['errors'] == {}:
try:
# Execute StageService to convert sddraft file to a service definition
# (sd) file
arcpy.server.StageService(sddraft_file, sd_file)

# Execute UploadServiceDefinition to publish the service definition
# file as a service
arcpy.server.UploadServiceDefinition(sd_file, in_server)
print("The geocode service was successfully published")


except arcpy.ExecuteError:
print("An error occurred")
print(arcpy.GetMessages(2))
else:
# If the sddraft analysis contained errors, display them
print("Error were returned when creating service definition draft")
pprint.pprint(analyze_messages['errors'], indent=2)

 

0 Kudos
Kayden75
New Contributor III

Thanks!