大赵传奇

援引事类,扬搉古今,举要删芜,言辩而理切--QQ276605216

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

#coding=utf-8
import arcpy
import arcpy.mapping as mapping
import os
import sys

ws = r'd:\out'
mdpath = os.path.join(ws, r'彩票店数量300m内1.tif')      
con = os.path.join(ws, r'connection.ags')
service = 'lottery'
sddraft = os.path.join(ws, service + '.sddraft')
arcpy.CreateImageSDDraft(mdpath, sddraft, service, 'ARCGIS_SERVER', 
                         con, True, None, "Publish las MD", 
                         "las,image service")

sd = os.path.join(ws, service+".sd")
analysis = arcpy.mapping.AnalyzeForSD(sddraft)
if analysis['errors'] == {}:
    try:
        print 'stage..'
        arcpy.StageService_server(sddraft, sd)
        arcpy.UploadServiceDefinition_server(sd, con)
        print "Service successfully published"
    except arcpy.ExecuteError:
        print 'error:'
        print(arcpy.GetMessages() + "\n\n")
    except Exception as err:
        print(err[0] + "\n\n")
        sys.exit("Failed to stage and upload service")
else:
    print(analysis['errors'])

 

 

 

posted on 2020-09-26 19:58  赵长青  阅读(246)  评论(0编辑  收藏  举报