Comments (5)
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.
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.
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.
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.
-
Import module
import arcpy_metadata as md print("Exiting") sys.exit(0) # Prints: # Exiting # Results: # Returns 0
-
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
-
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
-
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.
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)
- test_layer_file fails HOT 1
- Convert to using logging instead of simple custom logging code
- Tags and Place Keywords overwriting one another HOT 1
- suppress messages to console HOT 1
- Unable to obtain information in the useLimit tag HOT 4
- Dropdowns with code values? HOT 9
- file_identifier does not get written to feature classes
- Lock prevents removal of fGDB for test cases HOT 1
- Attribute Error HOT 4
- Upload 0.5.1 to pypi HOT 4
- write to text: metadata description has xml code HOT 6
- TypeError: unhashable type: 'dict' HOT 9
- Spatial Reference or Bounding Box Extent parameters? HOT 1
- Metadata abstract writen with wrong font HOT 3
- FGDB Tests not passing on 10.7 HOT 6
- How to add text with hyperlink HOT 1
- facing issue when using dictionary in my code HOT 1
- ModuleNotFoundError HOT 2
- Upgrades to support ArcGIS Pro HOT 2
- Server-based dataset editing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arcpy_metadata.