Skip to content
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
pymogile
tests
MANIFEST.in
README
setup.py

README

MogileFS client library for Python
(based on python-mogilefs-client written by Chihio Sakatoku)

1. Connect to MogileFS

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


2. New file

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


3. 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')
[]

4. Get file data

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


5. 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'


6. Remove file

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



Something went wrong with that request. Please try again.