Python MogileFS Client
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
pymogile
tests more nicer unittest Jan 5, 2011
.editorconfig
.style.yapf
README.md
setup.cfg
setup.py

README.md

MogileFS client library for Python

Installation

$ pip install pymogile

Examples

Connect to MogileFS

>>> from pymogile import Client, MogileFSError
>>> datastore = Client(domain='test', trackers=['127.0.0.1:7001'])

New file

>>> fp = datastore.new_file('foobar.txt')
>>> fp.write('foo')
>>> fp.close()

Get paths

>>> datastore.get_paths('foobar.txt')
['http://127.0.0.1:7500/dev4/0/000/251/0000251237.fid', 'http://127.0.0.1:7500/dev6/0/000/251/0000251237.fid']
>>> print datastore.get_paths('404.txt')
[]

Get file data

>>> datastore.get_file_data('404.txt')
>>> datastore.get_file_data('foobar.txt')
'foo'

File info

>>> datastore.file_info('foobar.txt')
{'class': 'default',
 'devcount': '2',
 'domain': 'test',
 'fid': '0000251237',
 'key': 'foobar.txt',
 'length': 3}
>>> datastore.file_info('foobar.txt', devices=True)
{'class': 'default',
 'devcount': '2',
 'devids': ['4', '6'],
 'domain': 'test',
 'fid': '0000251237',
 'key': 'foobar.txt',
 'length': 3}

Rename file

>>> datastore.rename('404.txt', 'test.txt')
False
>>> datastore.rename('foobar.txt', 'foo.txt')
True
>>> datastore.get_file_data('foobar.txt')
>>> datastore.get_file_data('test.txt')
>>> datastore.get_file_data('foo.txt')
'foo'

Remove file

>>> datastore.delete('foobar.txt')
False
>>> datastore.delete('foo.txt')
True
>>> datastore.get_file_data('foo.txt')