Giter VIP home page Giter VIP logo

Comments (5)

thomas-maschler avatar thomas-maschler commented on September 14, 2024 1

@KellyThomas

So I got to talk to ESRI support and we explored this issue a bit more.
The exit code only changes when using SDE databases. For SHP and GDB it works fine.
It doesn't seem to be a ArcGIS issue either, more an underlying windows issue.

The exit code is also not an error, but a warning. I actually got different warnings, depending on how I called it. If you run it in task manager it will still show up as successfully run just with the different exit code.

For SQL Server, we got it do run with exit code 0 when running it as administor and highest privileges. For PostgreSQL we didn't manage to figure out how to get an exit code 0.

However, the tool itself behaves correctly and I don't have an means to influence the result.
Please check if you get similar results running your scripts as admin and highest privileges.

In the meantime I will close this ticket labeling it as won't fixed

from arcpy_metadata.

nickrsan avatar nickrsan commented on September 14, 2024

Hi Kelly,

I don't know how much testing has been done on SDE data - I'm wondering if it is failing and exiting rather than intentionally modifying the exit code. Does the metadata get successfully edited? What if you add another line logging after the editor.finish() line that it has moved past that. I'm assuming that it's not getting to your sys.exit(0) line at all.

from arcpy_metadata.

thomas-maschler avatar thomas-maschler commented on September 14, 2024

Agree with Nick. Exit codes doesn't get actively changed. There might be something wrong while saving? Which version are you on?

I just tested v0.4.1 (not yet merged into main branch) on SDE data and it works fine. It should work similar in v0.3.x

from arcpy_metadata.

KellyThomas avatar KellyThomas commented on September 14, 2024

Hi Nick, Thomas,

Thank you for looking at this issue.

I am running arcpy_metadata 0.3.2 against ArcMap 10.3.1 on Windows 7, the python environment is 2.7.8 32bit as installed by ArcMap.

I am experiencing the same behavior when working on SDE tables or shapefiles.

The changes to the metadata are written successfully, execution within the python script continues uneventfully.

Here are a few staged examples starting with a simple import and progressing to an update-commit workflow.

  1. Import module

    import arcpy_metadata as md
    
    print("Exiting")
    sys.exit(0)
    
    # Prints:
    #    Exiting
    # Results:
    #    Returns 0
    
  2. Instantiate editor

    import arcpy_metadata as md
    
    table = "sde\\connection.sde\\OWNER.TABLE"
    editor = md.MetadataEditor(table)
    
    print("Exiting")
    sys.exit(0)
    
    # Prints:
    #    Exporting metadata to temporary file C:\Users\<user>\AppData\Local\Temp\scratch\OWNER.TABLE.xml
    #    Exiting
    # Results:
    #    Returns -2146234327
    
  3. Finish editor session

    import arcpy_metadata as md
    
    table = "sde\\connection.sde\\OWNER.TABLE"
    editor = md.MetadataEditor(table)
    
    editor.finish()
    
    print("Exiting")
    sys.exit(0)
    
    # Prints:
    #    Exporting metadata to temporary file C:\Users\<user>\AppData\Local\Temp\scratch\OWNER.TABLE.xml
    #    Saving metadata
    #    cleaning up from metadata operation
    #    Exiting
    # Results:
    #    Returns -2146234327
    
  4. Update metadata

    import arcpy_metadata as md
    from datetime import datetime
    
    table = "sde\\connection.sde\\OWNER.TABLE"
    editor = md.MetadataEditor(table)
    
    timestamp = datetime.now().isoformat()
    editor.last_update.set(timestamp)
    
    editor.finish()
    
    print("Exiting")
    sys.exit(0)
    
    # Prints:
    #    Exporting metadata to temporary file C:\Users\<user>\AppData\Local\Temp\scratch\OWNER.TABLE.xml
    #    Saving metadata
    #    cleaning up from metadata operation
    #    Exiting
    # Results:
    #    Returns -2146234327
    #    Metadata dataIdInfo/idCitation/date/reviseDate is updated 
    

from arcpy_metadata.

thomas-maschler avatar thomas-maschler commented on September 14, 2024

Hi Kelly,

Metadata of geodatabases are stored inside the GDB and we can't access them directly. We have to use the arcpy.XSLTransform_conversion tool to export them temporally to an XML file, modify the data and then use arcpy.ImportMetadata_conversion to reimport the modified metadata.

arcpy.XSLTransform_conversion seems to be a bit buggy, the 64bit version of this tool crashes. It is also this tool which changes the exit code. I modified your test code and reduced it only export metadata and I got the same results as you (see script below).

If you work with shapefiles, metadata are stored as XML files direclty on disc and we don't need to export them first. When using a shapefile, you will get an exit code of 0.

I will report the bug to ESRI and keep this ticket open but label it as won't fix for now.

import arcpy
import os

if sys.argv[1] == "true":

    print("Exporting  metadata")
    table = r"conncetion.sde\my_table"
    installDir = arcpy.GetInstallInfo("desktop")["InstallDir"]
    xslt = os.path.join(installDir, r"Metadata\Stylesheets\gpTools\exact copy of.xslt")
    arcpy.XSLTransform_conversion(table, xslt, "test.xml")

else:
    print("Skipping metadata")

from arcpy_metadata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.