ahankinson / pybagit

Python library for manipulating bagit files.
http://ahankinson.github.io/pybagit
Other
20 stars 8 forks source link

Installing via pip does not set the execution bit correctly. #5

Open jerroydmoore opened 9 years ago

jerroydmoore commented 9 years ago

After installing pybagit via pip, I get the following error

12:08:20 pybagittest$  ./run.py
Traceback (most recent call last):
  File "./run.py", line 6, in <module>
    bag.update()
  File "/Library/Python/2.7/site-packages/pybagit/bagit.py", line 262, in update
    p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

After flipping the execute bit ON for multichecksum.pyc and multichecksum.py, it is able to proceed, but fails with the following:

12:11:25 pybagittest$  ./run.py
/Users/jnmoore/Develop/pybagittest/mycontents/data
Traceback (most recent call last):
  File "./run.py", line 7, in <module>
    bag.update()
  File "/Library/Python/2.7/site-packages/pybagit/bagit.py", line 274, in update
    csum = self._calculate_checksum(os.path.join(self.bag_directory, f))
  File "/Library/Python/2.7/site-packages/pybagit/bagit.py", line 411, in _calculate_checksum
    fd = open(filepath, 'rb')
IOError: [Errno 2] No such file or directory: '/Users/jnmoore/Develop/pybagittest/mycontents/bagit.txt'

I'm not sure how to initiate a new bag after reading the docs. It looks like it could work with existing bags, but I haven't tried it.

Additionally, is there a way to customize the data directory? I don't want all my contents living in /mycontents/data. I would like to leave my contents undisturbed as other processes require it. I would however, like a manifest file to live at mycontents/file.manifest.

Additionally, here is my PoC:

#!/usr/bin/env python
import pybagit.bagit as b

bag = b.BagIt("mycontents/")
print bag.get_data_directory()
bag.update()
ahankinson commented 9 years ago

Thanks Jerry.

The execute bit is set on multichecksum.py on my version of the repo, so I'm surprised that it was unset on yours. Any more info you can give me would help track it down.

The data directory is a requirement under the IETF draft of the specs, so not keeping your data in data would not conform to the specs. See: https://tools.ietf.org/html/draft-kunze-bagit-10#section-2.1.2

Additionally, the manifest file must live at manifest-<alg>.txt, where alg is one of SHA1 or MD5. This is also part of the spec: https://tools.ietf.org/html/draft-kunze-bagit-10#section-2.1.3

Initiating a new bag is pretty easy. You can see how to do it in the examples/newbag.py file.

Let me know if I can be any more help.