当前位置:网站首页>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!'
边栏推荐
- GC is not used in D
- AGCO AI frontier promotion (6.26)
- The most critical elements of team management
- 7.consul service registration and discovery
- A solution to the problem that the display of newff function in neural network cannot be converted from double to struct
- Server create virtual environment run code
- Use performance to see what the browser is doing
- [scoi2016] lucky numbers
- Is expression of D
- Logical operation
猜你喜欢

Sword finger offer 18.22.25.52 Double pointer (simple)

Cloudcompare - Poisson reconstruction

Hands on data analysis unit 3 model building and evaluation

Gartner 2022年顶级战略技术趋势报告

Pychar remotely connects to the server to run code

character constants

BP neural network for prediction

Codeforces Global Round 21A~D

Sword finger offer 40.41 Sort (medium)

AGCO AI frontier promotion (6.26)
随机推荐
Sword finger offer 15.65.56 I 56Ⅱ. Bit operation (simple - medium)
Sword finger offer 09.30 Stack
ICML 2022 | LIMO: 一种快速生成靶向分子的新方法
Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
character constants
Luogu p4145 seven minutes of God created questions 2 / Huashen travels around the world
Bucket of P (segment tree + linear basis)
The most critical elements of team management
Record: why is there no lightning 4 interface graphics card docking station and mobile hard disk?
Hard (magnetic) disk (I)
Hard (magnetic) disk (II)
[sdoi2013] forest
虫子 运算符重载的一个好玩的
Exercises under insect STL string
[hcsd application development training camp] one line of code second cloud evaluation article - experience from the experiment process
A must for programmers, an artifact utools that can improve your work efficiency n times
Exercise set 1
How to call self written functions in MATLAB
C language ---getchar() and putchar()
Recent important news