转换地图服务器缓存存储格式 (服务器)
摘要
可用来在松散(低于 10.0 版)格式和紧密格式之间转换地图服务缓存的存储。此工具可“直接”转换格式,这意味着它并不复制现有格式。它会在同一个缓存文件夹中创建新的格式缓存,并删除旧的格式。
用法
-
要使用此工具,可指定想要转换缓存的地图服务。此工具会检测当前存储格式,并使用此信息自动将目标格式设置为相反格式。可以选择缓存转换的服务实例数。
语法
ConvertMapServerCacheStorageFormat_Server (server_name, object_name, data_frame, {storage_format_type}, {thread_count})
| 参数 | 说明 | 数据类型 |
server_name |
对缓存格式将要被更改的服务进行托管的 ArcGIS Server 计算机。 | String |
object_name |
要更改缓存格式的地图服务。 警告:新的缓存格式会替代旧的缓存格式。如果希望回到旧的模式,需要备份缓存。 | String |
data_frame |
地图服务的源数据框。 | String |
storage_format_type (可选) |
新缓存转换后的存储格式。工具用户界面会检测当前缓存格式并将其他格式作为此参数的唯一选项列出。这些格式为“松散”和“紧密”。 | String |
thread_count (可选) |
转换缓存时使用的地图服务实例的数量。默认情况下,使用实例的最大允许数量(对于 ArcGIS Server 服务,其默认值是 2)。如果服务器功能更强大,可增加实例的最大允许数量(可从 ArcCatalog 中的服务属性 对话框、目录 窗口或管理器访问),然后在运行此工具时增大此参数。 | Long |
代码示例
本例使用 ConvertMapServerCacheStorageFormat 将松散缓存转换为紧密缓存。
# ConvertMapServerCacheStorageFormat example (stand-alone script)
# Name: ConvertMapServerCacheStorageFormat.py
# Description: The following stand-alone script demonstrates how to convert map
# server cache storage format to the alteranate storage format
# 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, string, datetime, traceback
# Set environment settings
env.workspace = "C:/data"
# List of variables for mapservice properties
server = "MyServer"
service = "Rainfall"
dataFrame = ""
threadCount = "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')
# One can leave the variable for storage format marked "COMPACT" to "" (default)
try:
starttime = time.clock()
result = arcpy.ConvertMapServerCacheStorageFormat_server (server, service, dataFrame,
"COMPACT" , threadCount)
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 "Converted Map Server Cache Storage format 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 "Converted Map Server Cache Storage format "
环境
此工具不使用任何地理处理环境
相关主题
许可信息
ArcView: 是
ArcEditor: 是
ArcInfo: 是
7/10/2012
