圆弧10.2中的断开路径无法

2024-04-27 00:36:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试用新的sde路径“替换数据源”。我使用的是Arc10.2中的v2.7。我们有多个直接连接路径名和一个服务连接,它将服务器从使用Oracle改为使用Sql Server。我的代码在print语句中一直工作,但是我收到错误消息“unable to saveACopy,check My privileges”。请让我知道,如果我把所有不同的连接名称放入一个列表中,然后按我写的方式迭代它们。而且,我试过每一个缩进保存副本而delmxd,但两周后似乎什么也没起作用,所以我想我终于需要一些地理奇才的智慧了!在

Code:

import arcpy, os, glob arcpy.env.workspace = "C:\Users\kmetivier\Documents\BrokenPaths\Folder5"

for root, subFolders, files in >os.walk(r"C:\Users\kmetivier\Documents\BrokenPaths\Folder5"):

for filename in files:
  fullpath = os.path.join(root, filename)
   basename, extension = os.path.splitext(fullpath)
   if extension.lower() == ".mxd":
       print "------------------------------"
       print filename
       #open the map document
       mxd = arcpy.mapping.MapDocument(fullpath)
       #get all the layers
       for lyr in arcpy.mapping.ListLayers(mxd):
           #get the source from the layer
           if lyr.supports("datasource"):
               pathList = ["Database Connections\PWDB.arvada.org.sde","Database >Connections\GIS - PWDB.sde","Database Connections\PROD - GIS.sde","Database Connections\DC >- PROD - GIS.sde","Database Connections\GIS to SDE1.sde"]
               print "%s -> %s" % (lyr, pathList[0])
               basename, extension = os.path.splitext (pathList[0])
               if extension.lower() == ".sde":
                   #NEW SOURCE
                   datapath = r"Database Connections\GEODATA - GIS.sde"
                   #overwrite the old path
                   lyr.replaceDataSource(datapath, "SDE_WORKSPACE", "")
                   print "replaced " + pathList[0] + " with " + datapath
                   print "---------finished " + filename
               mxd.saveACopy(filename +"_2")
           del mxd
^{pr2}$

Tags: thepathforosextensionfilenameconnectionsdatabase