当前位置:网站首页>ArcGIS secondary development -- arcpy batch automatic map publishing service
ArcGIS secondary development -- arcpy batch automatic map publishing service
2022-06-26 14:22:00 【Chaoying.】
Add : Before publishing the map service , First you need to connect to ArcGIS for Server The server , Need to make use of arcpy.mapping.CreateGISServerConnectionFile Interface ,, stay ArcGIS There are also detailed instructions in the help document of , The code is as follows :
import arcpy
outdir = r'C:\Users\user\Desktop\SeaGIS\Server'
out_folder_path = outdir
out_name = 'connection.ags'
server_url = 'https://localhost:6443/arcgis/admin'
use_arcgis_desktop_staging_folder = False
staging_folder_path = outdir
username = 'siteadmin'
password = 'arcgis'
arcpy.mapping.CreateGISServerConnectionFile("PUBLISH_GIS_SERVICES",
out_folder_path,
out_name,
server_url,
"ARCGIS_SERVER",
use_arcgis_desktop_staging_folder,
staging_folder_path,
username,
password,
"SAVE_USERNAME")
For the description of related functions, see ArcGIS Help document
import arcpy
import os
def publishServer(mxd):
# define local variables
wrkspc = 'C:/Users/user/Desktop/SeaGIS'
mapDoc = arcpy.mapping.MapDocument(wrkspc + '/mxds' + '/{}'.format(mxd))
con = wrkspc + '/Server' + '/connection.ags'
service = mxd[0:-4]
sddraft = wrkspc + '/Server' + '/' + service + '.sddraft'
sd = wrkspc + '/Server' + '/' + service + '.sd'
summary = '{} Ser Wave'.format(mxd[0:-4])
tags = 'Sea Wave'
# create service definition draft
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER',
con, True, 'SeaGIS', summary, tags)
# stage and upload the service if the sddraft analysis did not contain errors
if analysis['errors'] == {
}:
# Execute StageService
arcpy.StageService_server(sddraft, sd)
# Execute UploadServiceDefinition
arcpy.UploadServiceDefinition_server(sd, con)
print '{} has been published!'.format(mxd)
else:
# if the sddraft analysis contained errors, display them
print analysis['errors']
mds = os.listdir('./mxds')
for md in mds:
publishServer(md)
print 'finished!'
边栏推荐
猜你喜欢
随机推荐
Jianzhi offer 43.47.46.48 dynamic planning (medium)
Obtain information about hard disk and volume or partition (capacity, ID, volume label name, etc.)
Sword finger offer 40.41 Sort (medium)
Eigen(3):error: ‘Eigen’ has not been declared
Stream常用操作以及原理探索
[ahoi2005] route planning
C language | the difference between heap and stack
Hands on data analysis unit 3 model building and evaluation
Notes: the 11th and 12th generation mobile versions of Intel support the native thunderbolt4 interface, but the desktop version does not
9 regulations and 6 prohibitions! The Ministry of education and the emergency management department jointly issued the nine provisions on fire safety management of off campus training institutions
9项规定6个严禁!教育部、应急管理部联合印发《校外培训机构消防安全管理九项规定》
Setup instance of layout manager login interface
Freefilesync folder comparison and synchronization software
How to call self written functions in MATLAB
[scoi2016] lucky numbers
Exercise set 1
Sword finger offer 09.30 Stack
Introduction to granular computing
Wechat applet SetData dynamic variable value sorting
Related knowledge of libsvm support vector machine









