Skip to main content
Question

arcpy geodatabase deletion script causing a fatal error in fme server


Forum|alt.badge.img

We're trying to run a script in FME Server 2018 that replaces a geodatabase with a new dataset using arcpy. In a few months we'll be attempting to use FME's native geodatabase writer, but for now I need to troubleshoot why the following doesn't work:

import fme
import fmeobjects
import arcpy

# Main Function
def delme(feature):

	# Variables
	table_2b_deld = feature.getAttribute('SOURCE_ETL_TABLE')
	sde_conn = FME_MacroValues['SDE_Connection']
	full_del_str = sde_conn + '\\' + table_2b_deld + 'X'
	# print full_del_str

	# Process
	try:
		arcpy.Delete_management(full_del_str)
		feature.setAttribute('deletion_result','success')

	except Exception, e:
		logger = fmeobjects.FMELogFile()
		logger.logException(e,2)
		feature.setAttribute('deletion_result','failure')
		feature.setAttribute('deletion_result_detail',e)
		pass

After that script runs, we move data in Oracle from our staging schema into our production schema, then attempt a geodatabase registration script with a virtually identical syntax.

If the geodatabase isn't there already, the script works perfectly well. If the geodatabase is already there, it fails with the following log message:

2018-06-06 12:10:19|  21.5|  0.1|WARN  |Failed to execute. Parameters are not valid.
ERROR 001050: Either registered with geodatabase already or cannot open the dataset.
Failed to execute (RegisterWithGeodatabase).


2018-06-06 12:10:19|  21.5|  0.0|ERROR |Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.
2018-06-06 12:10:19|  21.5|  0.0|ERROR |Error encountered while calling function `regme'
2018-06-06 12:10:19|  21.5|  0.0|FATAL |Register_X_Table(PythonFactory)PythonFactory failed to process feature
2018-06-06 12:10:19|  21.5|  0.0|ERROR |A fatal error has occurredCheck the logfile above for details
2018-06-06 12:10:19|  21.5|  0.0|ERROR |... Last line repeated 3 times ...
2018-06-06 12:10:19|  21.5|  0.0|ERROR |Bridge failed to output feature on tag `PYOUTPUT'
2018-06-06 12:10:19|  21.5|  0.0|FATAL |Delete_X_Table(PythonFactory)PythonFactory failed to process feature
2018-06-06 12:10:19|  21.5|  0.0|ERROR |A fatal error has occurredCheck the logfile above for details

The error log is showing that both python scripts generated a fatal error.

5 replies

david_r
Evangelist
  • June 7, 2018

The script you've posted contains a function "delme()" while the error message references the function "regme()". Are you sure the error comes from this particular script?


Forum|alt.badge.img
david_r wrote:

The script you've posted contains a function "delme()" while the error message references the function "regme()". Are you sure the error comes from this particular script?

the regme() function happens later in the script - its code is identical to the delme() function except where delme() deletes the geodatabase, regme() registers the geodatabase. the fatal error seems to occur when the geodatabase is already there - the delme() script doesn't seem to work? i'm honestly not sure what's the issue, but since the log is showing that both scripts are failing, i was hoping somebody better at arcpy than me could help out

 

 


david_r
Evangelist
  • June 11, 2018

I think this line is the culprit:

feature.setAttribute('deletion_result_detail', e)

The issue is that the object "e" is an Exception object, where as setAttribute() expects a string or a numeric value. It does not know what to do with an Exception object.

Try this instead, which will give you the ArcGIS error message:

feature.setAttribute('deletion_result_detail', arcpy.GetMessages())

Documentation: http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/getmessage.htm


Forum|alt.badge.img
david_r wrote:

I think this line is the culprit:

feature.setAttribute('deletion_result_detail', e)

The issue is that the object "e" is an Exception object, where as setAttribute() expects a string or a numeric value. It does not know what to do with an Exception object.

Try this instead, which will give you the ArcGIS error message:

feature.setAttribute('deletion_result_detail', arcpy.GetMessages())

Documentation: http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/getmessage.htm

ooh i'll try that now. thanks!

 

 


Forum|alt.badge.img
david_r wrote:

I think this line is the culprit:

feature.setAttribute('deletion_result_detail', e)

The issue is that the object "e" is an Exception object, where as setAttribute() expects a string or a numeric value. It does not know what to do with an Exception object.

Try this instead, which will give you the ArcGIS error message:

feature.setAttribute('deletion_result_detail', arcpy.GetMessages())

Documentation: http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/getmessage.htm

that was the culprit - script works without issue now. thanks very much!

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings