pombreda / python-xmp-toolkit

Automatically exported from code.google.com/p/python-xmp-toolkit
Other
0 stars 1 forks source link

Cannot write to file. #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. from libxmp import *
2. xmp = XMPFiles(
file_path="/home/clr/ruby/rails/spitzer.caltech.edu/spec/fixtures/test.tif" )
3. xmp_data = xmp.get_xmp()
4. xmp_data.set_property( "http://ns.adobe.com/photoshop/1.0/", 'Headline',
"Some really long text blurb which clearly goes longer than 255 characters
because it repeats three times because it is some really long text blurb
which clearly goes longer than 255 characters because it repeats three
times because it is some really long text blurb which clearly goes longer
than 255 characters because it repeats three times." )
5. xmp.put_xmp( xmp_data )

What is the expected output? What do you see instead?
expected: TRUE
got:
XMPFiles::PutXMP - Not open for update
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libxmp/files.py", line 146, in put_xmp
    _check_for_error()
  File "libxmp/__init__.py", line 129, in _check_for_error
    raise XMPError( _XMP_ERROR_CODES[err] )
libxmp.XMPError: XMPErr_BadObject

What version of the product are you using? On what operating system?
python-xmp-toolkit-1.0-rc1
Fedora GNU/Linux

Please provide any additional information below.

Original issue reported on code.google.com by clr.port...@gmail.com on 8 May 2009 at 9:59

GoogleCodeExporter commented 9 years ago
You need to open the file in read/write mode by using the XMP_OPEN_FORUPDATE 
flag:

xmpfile = XMPFiles(file_path=yourfile, open_forupdate=files.XMP_OPEN_FORUPDATE)

Original comment by ghi...@gmail.com on 17 Jun 2009 at 10:03

GoogleCodeExporter commented 9 years ago
Yeah, as ghiron mention the file needs to be opened with OPEN_FOR_UPDATE. This 
is now done like this:

xmpfile.open_file( '.tempsamples/sig05-002a.tif', open_forupdate=True )   

See XMPFilesTestCase.test_write_in_readonly in test/test_files.py

Original comment by lniel...@spacetelescope.org on 16 Feb 2010 at 5:16