DrColgate

os.walk and ListRasters exits with 'unexpected error'

Discussion created by DrColgate on Oct 25, 2011
Latest reply on Jan 19, 2012 by DrColgate
This is a pretty basic walk and look adventure.  Nothing much happens except I walk through the drive looking at the directories and then when I get a raster list print each file name to screen. 

Every time I run this code it exits with an 'Unexpected Error'.  Not a 'Python Error' so to speak where the error gets printed to the standard out put where I am printing file names but a Windows error box with a nice Python logo. 


drive_list = ['V:/']#["G:\\", "I:\\", "U:\\", "V:\\"]

for drive in drive_list:
    
    for root, dirs, files in os.walk(drive):

        arcpy.env.workspace = root            

        #Obtain and print Raster dataset information
        rasterList = arcpy.ListRasters("*", "All")
        for raster in rasterList:
            print raster



The code usually has a similar run time but will stop in different directories and on different files even when run on the same drive. 

This code will run quite well on a small directory or sparsely populated drive.  However large drives with complex and long directory trees it falls over.

Outcomes