Skip to main content
2 of 3
edited tags; edited title; added 10 characters in body
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Printing error message to console or log file in ArcPy?

My code is as follows:

    for foundFile in tables:
    foundName = foundFile.split('.')[-1]
    foundPath = os.path.join (output_fgdb_path, foundName)
    if not arcpy.Exists(foundPath):
        # Convert tables to FGDB
        try:
            print 'Attempting to convert: ' + foundName
            logging.info ('Attempting to convert: ' + foundName)
            arcpy.TableToGeodatabase_conversion(foundFile, output_fgdb_path)
            logging.info ('Finished converting: ' + foundName)

        except arcpy.ExecuteError:
            arcpy.AddError(arcpy.GetMessages(2))

        except:
            e = sys.exc_info()[1]
            print(e.args[0])

Essentially, I have one table in my database that is not able to convert into my FGDB. When I run on command line, I am able to get an error message of:

WARNING: Failed to convert Database Connections\DB.sde\Tablexxx. ERROR 999999: Error executing function.

Failed to execute (CopyRows).

But i am not able to print/write this error message to console (via print statement) or to a log file (via log.write). It seems that in my code, the except statements are not even being reached, even though an error is occuring?