管理地图服务器缓存比例 (服务器)

摘要

在现有已缓存地图服务中更新比例级别。使用此工具可添加新比例或从地图缓存中删除现有比例。

用法

语法

ManageMapServerCacheScales_Server (server_name, object_name, levels)
参数说明数据类型
server_name

用于托管要移除缓存比例的服务的 ArcGIS Server 计算机。

String
object_name

要移除缓存比例的地图服务的名称。

String
levels
[levels,...]

要包含在已更新切片方案中的比例值。

警告警告:

如果要保留现有比例值必须对它们进行指定。所有未在本工具中指定的现有比例级别都将被永久性删除。例如,如果您具有四个现有比例,而您希望再添加两个比例,请确保最终列表中共有六个比例。

Value Table

代码示例

在本例中,将地图缓存切片方案修改为包含四个比例。

# ManageMapServerCacheScales example (stand-alone script)

# Name: ManageMapServerCacheScales.py
# Description: The following stand-alone script demonstrates how to add/delete
#               MapServer cache scales for a map service with an existing schema
#               
# 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 input variables for map service properties
server = "MyServer"
service = "Rainfall"
scaleValues = "250000;125000;64000;5250"

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')


try:
    starttime = time.clock()
    result = arcpy.ManageMapServerCacheScales_server(server, service ,
                                            scaleValues)
    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 "Updated the number of cache scales successfully for " + 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)
report.close()
    
print "Updated Map server Cache scales "

环境

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

相关主题

许可信息

ArcView: 是
ArcEditor: 是
ArcInfo: 是

7/10/2012