POST
|
Okay. So after overwriting, the service will need to be started using an administrator connection in order for the service to begin to function?
... View more
08-24-2016
08:22 AM
|
0
|
4
|
629
|
POST
|
Hello, I am currently attempting to automate the process of overwriting an existing map service using Arcpy. I was wondering if, before overwriting the map service, there was a need to stop the service? If not, will a publisher connection to ArcGIS Server work for what I am trying to do? Thank you for your time. -Jacob
... View more
08-24-2016
07:59 AM
|
0
|
8
|
1575
|
POST
|
To provide a more specific question about the code, in the 'CreateSDDraft' tool parameters, can the connection file path parameter be specified with the following variable if this connection to the server has already been established in the 'GIS Servers' node in ArcCatalog prior to running the script tool?: server = r"GIS Servers\arcgis on gis.spotsylvania.va.us (publisher)" Thanks again, Jacob
... View more
08-19-2016
11:41 AM
|
0
|
0
|
494
|
POST
|
Dan, I apologize for the earlier post. I had actually been wondering how to format the code properly for this thread...so thank you. The code seems to be in the proper format now. Thanks so much for your time. -Jacob
... View more
08-19-2016
08:19 AM
|
0
|
0
|
494
|
POST
|
Hello, I have written a script that should take a 'Table View' from an SDE Geodatabase, and export it to Shapefile format for use as source data for a layer in a specific MXD file. The script should then take this MXD file and upload it to ArcGIS Server as a map service. This map service must overwrite an existing service (this is a weekly process). I was wondering if anyone could take a look at my code, before I actually run it, to see if there is anything in there that could be a potential issue. I really appreciate any help whatsoever. Code is posted below. Thanks so much. -Jacob --------------------------------------------------------------------------------------------------------------------------------------------------------------- import arcpy
import xml.dom.minidom as DOM
import os
import sys
import traceback
arcpy.AddMessage("Setting the workspace to your Vector.sde connection...")
arcpy.env.workspace = arcpy.GetParameterAsText(0) # User must enter connection to 'Vector' SDE geodatabase ##"C:\Users\jsnyder\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\Vector.sde"
try:
# Specify the folder in which the shapefiles that are necessary will be created, set other variables
wrkspc = arcpy.GetParameterAsText(1) # Navigate to the workspace that contains or should contain parcels shapefile ##r"F:\ETL\04_Exports\Output\CRW"
parcel_shp = str(wrkspc) + "\parcels.shp" ##"F:\ETL\04_Exports\Output\CRW\parcels.shp"
parcel_view = "vector.dbo.PARCEL_VIEW"
tags = 'Spotsylvania, Virginia, VA, CRW'
summary = "Map Service is to be used within Spotsylvania County's CRW application"
service = 'CRW'
server = r"GIS Servers\arcgis on gis.spotsylvania.va.us (publisher)"
mapDoc = arcpy.GetParameterAsText(2) # Navigate to the location of the CRW MXD file that will be used to publish the map service ##arcpy.mapping.MapDocument(r"F:\MXDs\CRW_MapService\CRW_MapService.mxd")
sddraft = str(wrkspc) + "\CRW_MapService.sddraft" ##r"X:\ETL\04_Exports\Output\CRW\CRW_MapService.sddraft"
sd = str(wrkspc) + "\CRW_MapService.sd" ##r"X:\ETL\04_Exports\Output\CRW\CRW_MapService.sd"
# If any shapefiles exist in the folder currently, delete them.
if os.path.exists(parcel_shp):
arcpy.AddMessage("Renaming the old 'parcels' shapefile to 'parcels_old'")
arcpy.Rename_management(parcel_shp, str(wrkspc) + "\parcels_old")
arcpy.AddMessage("Creating new 'parcels' shapefile...")
arcpy.FeatureClassToFeatureClass_conversion(parcel_view, wrkspc, "parcels")
else:
arcpy.FeatureClassToFeatureClass_conversion(parcel_view, wrkspc, "parcels")
arcpy.AddMessage("Dropping 'OID' field from new shapefile...")
# Delete 'ESRI_OID' field from new shapefile
dropField = ["ESRI_OID"]
arcpy.DeleteField_management(parcel_shp, dropField)
arcpy.AddMessage("Setting parameters for the CRW Map Service. During this process, the script will specify the the service definition type as a replacement...")
# Create the service definition draft for the CRW Map Service
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, 'CRW', 'ARCGIS_SERVER', server, True, None, summary, tags)
# Set service type to be 'esriServiceDefinitionType_Replacement' to serve as a replacement for the existing service
newType = 'esriServiceDefinitionType_Replacement'
xml = sddraft
doc = DOM.parse(xml)
descriptions = doc.getElementsByTagName('Type')
for desc in descriptions:
if desc.parentNode.tagName == 'SVCManifest':
if desc.hasChildNodes():
desc.firstChild.data = newType
outXml = xml
f = open(outXml, 'w')
doc.writexml( f )
f.close()
# After analyzing the service definition draft, if there are no errors, stage and upload the service
if analysis['errors'] == {}:
arcpy.AddMessage("There were noe errors...the service should now publish.")
# Execute Stage Service
arcpy.StageService_server(sddraft, sd)
# Upload the service
arcpy.UploadServiceDefinition_server(sd, server)
else:
arcpy.AddError("There seem to have been some errors with some of the parameters that have been specified. Please see the messages below.")
arcpy.AddError(str(analysis['errors']))
arcpy.AddWarning("The tool ran successfully. Please make sure that the CRW Map Service has successfully been uploaded.")
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS: \nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_type) + ":" +str(sys.exc_value) + "\n"
arcpy.AddError(pymsg)
msgs = "ArcPy ERRORS: \n" +arcpy.GetMessages(2) + "\n"
arcpy.AddError(msgs)
print pymsg + "\n"
print msgs
... View more
08-19-2016
07:38 AM
|
0
|
3
|
2583
|
POST
|
Thanks so much for all of the information. It turns out that the field mapping controls in Feature Class to Feature Class will better help me to accomplish what I need to do. Thank so much again.
... View more
06-17-2016
01:26 PM
|
0
|
0
|
921
|
POST
|
Hello, I am just curious to know what exactly the primary difference is between each of these operations. I am currently working with a Polygon Feature Class on an SDE, and I want to create a shapefile in a different location using the features within this Polygon Feature Class. I understand that I can just add the Feature Class to an MXD file, right click the layer in the table of contents, and click 'Export Data', and specify the location of the folder that I want to create the shapefile in as well as its name. My concern is that I do not want the original dataset that I am working with on the SDE to be deleted or compromised in any way. Thank you. -Jacob
... View more
06-17-2016
11:06 AM
|
0
|
5
|
3516
|
POST
|
Robert, This was exactly what I needed. Thanks so much for your time and help. -Jacob
... View more
04-22-2016
12:38 PM
|
0
|
0
|
929
|
POST
|
Also, to clarify, 'Restaurants' is a layer within the map service in the application, and this is what I am trying to perform the intersect on. Thank you. -Jacob
... View more
04-22-2016
11:28 AM
|
0
|
2
|
929
|
POST
|
Robert, Yes, there is a reason. When the buffer is completed, I would like to find the intersections of restaurants, and would like to add the results to the map as additional graphics. Unless the GeometryService or GeometryEngine that you referring to can do this, in which case I am completely willing to try that instead. Would this be possible to do with GeometryService or GeometryEngine? I would like to accomplish essentially what is shown in the geoprocessing model that I sent to you. Thanks so much again. -Jacob
... View more
04-22-2016
11:21 AM
|
0
|
3
|
929
|
POST
|
Robert, Absolutely. I have attached a ZIP file which contains the full HTML file, and a toolbox that contains the model that I have created. Again, I really appreciate your time and efforts. -Jacob
... View more
04-22-2016
09:24 AM
|
0
|
5
|
929
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|