Python自動發佈Image service的實現

使用Python自動發佈地圖服務已經在上一篇博客中講到,使用Python創建.sd服務定義文件,實現腳本自動發佈ArcGIS服務,下面是利用Python自動發佈Image service的實現。

-----------華麗的分割線-----------
<span style="font-size:14px;"># -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# PublishImageService.py
# Created on: 2015-08-15 15:49:27.00000
#   (generated by HUIHUI)
# Usage:  
# Description: python publish service
# ---------------------------------------------------------------------------

# Import arcpy module
import os as OS
import arcpy

# createGISServerConnectionFile,define local variable
wrkpc = r"\\qnap.geoWindPower.com\WPServices\hh\PublishService\ToolData"
out_folder_path = wrkpc
con_Filename = "test.ags"
server_url = r"http://gisserver018207.geoWindPower.com/arcgis"
staging_folder_path = wrkpc
username = "admin"
password = "admin"

arcpy.mapping.CreateGISServerConnectionFile("PUBLISH_GIS_SERVICES",
                                            out_folder_path,
                                            con_Filename,
                                            server_url,
                                            "ARCGIS_SERVER",
                                            False,
                                            staging_folder_path,
                                            username,
                                            password,
                                            "SAVE_USERNAME")

# define local variables
wrkpc = r"\\qnap.geoWindPower.com\WPServices\hh\PublishService\ToolData"
mxdpath = OS.path.join(wrkpc,"mymxd.mxd")
mapDoc = arcpy.mapping.MapDocument(mxdpath)
servicename = "GeoTurbine_Test"
sddraft = OS.path.join(wrkpc,"GeoTurbine_Test.sddraft")
sd = OS.path.join(wrkpc,"GeoTurbine_Test.sd")
connectionfile = "test.ags"
summary = "this is a test"
tags = "this is a test"

# creste service definition draft
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc,
                                          sddraft,
                                          servicename,
                                          "ARCGIS_SERVER",
                                          connectionfile,
                                          False,
                                          "WP_MapService",
                                          summary,tags)

#stage and upload the service if the sddraft analysis didn't contain errors
if analysis['errors'] == {}:
    # excute StageService
    arcpy.StageService_server(sddraft,sd)
    # excute UploadServiceDfinition
    arcpy.UploadServiceDefinition_server(sd,connectionfile)
else:
    # if the sddraft analysis contained errors,display them
    print analysis['errors']
</span>

--------歡迎來訪,拒絕轉載--------



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章