删除影像服务器上文件,删除地图服务器缓存

# Name: DeleteMapServerCache.py

# Description: The following stand-alone script demonstrates how to delete map server cache

# tiles if the corresponding cache schema or tiles has been created

# Requirements: os, sys, time & traceback modules

# Any line that begins with a pound sign is a comment and will not be executed

# Empty quotes take the default value.

# To accept arguments from the command line replace values of variables to

# "sys.argv[]"

# Import system modules

import arcpy

from arcpy import env

import os, sys, time, datetime, traceback, string

# Set environment settings

env.workspace = "C:/data"

# List of variables for mapservice properties

connectionFile = r"C:\Users\\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"

server = "arcgis on MyServer_6080 (publisher)"

serviceName = "Rainfall.MapServer"

inputService = connectionFile + "\\" + server + "\\" + serviceName

numOfCachingServiceInstances = 2

currentTime = datetime.datetime.now()

arg1 = currentTime.strftime("%H-%M")

arg2 = currentTime.strftime("%Y-%m-%d%H:%M")

file = 'C:/data/report_%s.txt' % arg1

# print results of the script to a report

report = open (file,'w')

# To Recreate all the tiles for the default number of scales generated

try:

starttime = time.clock()

result = arcpy.DeleteMapServerCache_server(inputService,

numOfCachingServiceInstances)

finishtime = time.clock()

elapsedtime = finishtime - starttime

#print messages to a file

while result.status < 4:

time.sleep(0.2)

resultValue = result.getMessages()

report.write ("completed " + str(resultValue))

print "Deleted cache tiles & schema for mapservice " + serviceName

"\nin " + str(elapsedtime) + " sec\non " + arg2

except Exception, e:

# If an error occurred, print line number and error message

tb = sys.exc_info()[2]

report.write("Failed at\n" "Line%i" % tb.tb_lineno)

report.write(e.message)

print "Deleted Map server Cache Tiles "

report.close()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值