When using geoprocessing tools in a Python (2.5) script it appears to be preventing the script from outputting any further "print" command text to the screen. I am using various gp tools and they all appear to exhibit the same behavior. I use python "write" commands to write script processing progress into a text log, which is still working correctly. An example would be where I'm using the gp.FeatureClassToShapefile_conversion tool to export shapefiles from a geodatabase to a folder. If I comment out the gp tool the While loop proceeds perfectly and will print to the screen and write to the log. Here is a snippet of the code (it is properly indented, but won't display properly in this post):
# Sample Variables
New_Geo_GDB = "\\\\c:\\test\\ blahblah.gdb
try:
print "Start exporting shapefiles from feature classes of " + New_Geo_GDB + " " + time.strftime("%H:%M:%S", time.localtime())
writeLog.write('Start exporting shapefiles from feature classes of ' + New_Geo_GDB + ' ' + time.strftime("%H:%M:%S", time.localtime()) + ' \n')
# SET WORKSPACE TO THE GEODATABASE
gp.Workspace = New_Geo_GDB
# CREATE OBJECT TO HOLD GEODATABASE OBJECTS
desc = gp.Describe(New_Geo_GDB)
# CREATE CHILDREN VARIABLE TO HOLD LIST OF FEATURE CLASS NAMES
children = desc.Children
# RESET THE LIST TO THE BEGINNING
children.Reset()
# MOVE TO THE FIRST OBJECT IN THE LIST
child = children.Next()
# LOOP THORUGH THE CHILD OBJECTS WHILE THEY EXIST
while child:
# CREATE VARIABLE TO STORE THE GEODATABASE AND THE FEATURE CLASS NAME TO EXPORT
InGeo_Dataset = New_Geo_GDB + "\\" + child.Name
# PRINT AND WRITE TO THE LOG
print "Exporting to shapefile folder: " + child.Name
writeLog.write('Exporting to shapefile folder: ' + child.Name + ' \n')
# GEOPROCESSING OBJECT TO EXPORT FEATURE CLASS TO SHAPEFILE
gp.FeatureClassToShapefile_conversion(InGeo_Dataset, shapeDir)
# MOVE TO THE NEXT FEATURE CLASS
child = children.Next()
print "Finished exporting feature classes to shapefiles: " + time.strftime("%H:%M:%S", time.localtime())
print " "
writeLog.write('Finished exporting feature classes to shapefiles: ' + time.strftime("%H:%M:%S", time.localtime()) + ' \n')
writeLog.write(' \n')
except:
print "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! "
print "Export shapefiles failed!"
print gp.GetMessages(2)
writeLog.write('! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! \n')
writeLog.write('Export shapefiles failed! \n')
writeLog.write(gp.GetMessages(2) + ' \n')