0

我不明白为什么我的脚本在运行大约 200 个图块后因内存不足错误而失败。我查看了脚本,但不确定它写入的内存太大以至于失败了......

剧本

import os, glob, arcpy, csv, sys, shutil, datetime
top = r'L:\Raster_Data' # Source directory for all files to check and process
#top = os.getcwd()
RootOutput = r'H:\Raster' # Directory to copy/move files to
FileList = csv.reader(open(r'P:\2013\508_Data_Split_MSC\Working\LiDAR_Tiles_index2_MSC.csv')) # list of files to use with unique name
RootDirDelete="L:\\" #repatative name of roor file path to remove from new directory name
filecount=0
successcount=0
errorcount=0

print "Working in: "+ top

list =[]
f = open(RootOutput+'\\Success_LOG.txt', 'a')
f.write("Log of files Succesfully processed. RESULT of process run @:"+str(datetime.datetime.now())+"\n")
f.close()

for File in FileList:
  for root, dirs, files in os.walk(top, topdown=False):
    for directory in dirs:
        currentPath=os.path.join(root,directory)
        os.chdir(currentPath)
        #arcpy.env.workspace = currentPath
        print os.getcwd()
        lstFCs = glob.glob('*'+File[0]+'*.*')
        print lstFCs
        for fc in lstFCs:
            OutPutDir=RootOutput+"\\"+str(os.getcwd()).strip(RootDirDelete)
            filecount=filecount+1
            if OutPutDir.endswith(".gdb"):
                print "File in GDB...SKIPPING"
            else:
                try:
                    os.makedirs(OutPutDir)
                    print "Created: "+OutPutDir
                except:
                    #pass
                    print "Unexpected error:", sys.exc_info()[0]

                try:
                    fcIn=currentPath+"\\"+fc
                    fcOut=OutPutDir+"\\"+fc
                    successcount=successcount+1
                    print "Copied: "+fcIn+" to " +fcOut
                    shutil.copy2(fcIn,fcOut)
                    f = open(RootOutput+'\\Success_LOG.txt', 'a')
                    f.write(str(filecount)+","+str(successcount)+","+str(fcIn)+","+str(fcOut)+"\n")
                    f.close()

                except:
                    #pass
                    print "Unexpected error:", sys.exc_info()[0]
                    errorcount=errorcount+1
                    f = open(RootOutput+'\\Error_LOG.txt', 'a')
                    f.write(str(filecount)+","+str(errorcount)+","+str(fcIn)+","+str(fcOut)+","+str(sys.exc_info()[0])+"\n")
                    f.close()

错误报告。

L:\Raster_Data\Satellite_Imagery\Spot\Eastern_QLD_and_TRC_2010\Shapefiles\AUO_Australia
[]
Traceback (most recent call last):
  File "<string>", line 73, in execInThread
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 196, in __call__
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 71, in syncreq
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 431, in sync_request
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 379, in serve
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 337, in _recv
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py", line 50, in recv
  File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 166, in read
EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host
>>> 
*** Remote Interpreter Reinitialized  ***
>>> 

这是错误: 在此处输入图像描述

4

0 回答 0