删除地图服务器缓存 (服务器)

摘要

删除现有地图服务缓存,包括磁盘中的所有关联文件。

用法

语法

DeleteMapServerCache_Server (server_name, object_name, data_frame, Layer)
参数说明数据类型
server_name

对要删除缓存的服务进行托管的 ArcGIS Server 计算机。

String
object_name

要删除缓存的地图服务。

String
data_frame

要删除的缓存的源数据框。此项显示在用户界面中,仅用于提供信息,不可更改。

String
Layer
[Layer,...]

要从缓存中删除的图层(仅适用于多图层缓存)。将从缓存中删除包含在内的那些图层,而保留排除在外的那些图层。

String

代码示例

在本例中,将使用 DeleteMapServerCache 针对名为 Rainfall 的地图服务删除一个缓存。

# DeleteMapServerCache example (stand-alone script)

# 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
server = "MyServer"
service = "Rainfall"
dataFrame = "" 
layer = ""

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(server, service, dataFrame, layer)
    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 " + service + "\n   at "
    + cacheDir + service + " in " + str(elapsedtime) + " sec \n on " + arg2
    
except Exception, e:
    # If an error occurred, print line number and error message
    tb = sys.exc_info()[2]
    report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
    report.write(e.message)


print "Deleted Map server Cache Tiles "

report.close()

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcView: 是
ArcEditor: 是
ArcInfo: 是

7/10/2012