UpgradeMetadata Works As A Model Not In A Script

01-13-2012 02:20 PM
Occasional Contributor III
We need to run the upgrade metadata on over 100 feature classes in a ArcSDE geodatabase.  I created a simple model to use as an example that I could export just to get the correct syntax.  It runs as a model but not when exported to python.  The code and error message are listed below

# ---------------------------------------------------------------------------
# Upgrade Example.py
# Created on: 2012-01-13 15:59:14.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Local variables:
targetFC = "Database Connections\\myDB.sde\\myDB.DBO.BLMLands"

# Process: Upgrade Metadata
arcpy.UpgradeMetadata_conversion(targetFC, "FGDC_TO_ARCGIS")

Traceback (most recent call last):
  File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
  File "H:\SDE Management\Upgrade Example.py", line 16, in <module>
    arcpy.UpgradeMetadata_conversion(targetFC, "FGDC_TO_ARCGIS")
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 656, in UpgradeMetadata
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000816: The tool is not valid.
Failed to execute (UpgradeMetadata).
0 Kudos
1 Reply
New Contributor II
Just worked through this with ESRI tech support.  To use arcpy.UpgradeMetadata_conversion(Source_Metadata, Upgrade_Type)  in a python script environment, you need to add GpmetadataFunctions.dll and metadataTranslator.dll from "%ProgramFiles(x86)%\ArcGIS\Desktop10.0\  to the global assembly cache.  For windows XP and related OS you can drag and drop the files to C:windows\assembly.  For Windows Server 2008 R2, the UAC policies block a simple drag and drop of the .dlls.  Below is a script for the task using gacutil.exe (which is not installed on win server 2008 by default �?? see http://msdn.microsoft.com/en-us/library/ex0ss12c(v=vs.100).aspx for info on where to find it).

"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -i "%ProgramFiles(x86)%\ArcGIS\Desktop10.0\Bin\MetadataTranslator.dll"
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" -i "%ProgramFiles(x86)%\ArcGIS\Desktop10.0\Bin\GpMetadataFunctions.dll"
0 Kudos