https://github.com/bwind/pymogilefs
Python client for MogileFS
https://github.com/bwind/pymogilefs
Last synced: about 2 months ago
JSON representation
Python client for MogileFS
- Host: GitHub
- URL: https://github.com/bwind/pymogilefs
- Owner: bwind
- License: mit
- Created: 2016-12-02T11:57:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T05:27:57.000Z (about 2 years ago)
- Last Synced: 2025-10-27T10:27:11.139Z (7 months ago)
- Language: Python
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pymogilefs
==========
[](https://travis-ci.org/bwind/pymogilefs) [](https://codecov.io/gh/bwind/pymogilefs)
Python client for MogileFS, based on https://github.com/AloneRoad/pymogile.
There are a few Python client projects for MogileFS around (pymogile,
python-mogilefs-client), however these projects seem to be outdated and
abandoned. This client was written from scratch, uses the excellent
[requests](https://github.com/kennethreitz/requests) library to handle all HTTP
requests and is compatible with Python versions 2.7 and 3.4-3.7.
A handfull of management commands haven't been implemented (yet). These include
slave, rebalance, and fsck related commands.
To install pymogilefs, simply:
$ pip install pymogilefs
Usage:
>>> from pymogilefs.client import Client
>>> client = Client(trackers=['0.0.0.0:7001'], domain='testdomain')
>>> response = client.list_keys(prefix='test', limit=5)
>>> print(response.data)
{'key_count': 5,
'keys': {1: 'testkey',
2: 'test_file2_0.115351657953_1480606271.65',
3: 'test_file2_0.380149553659_1480606080.71',
4: 'test_file_0.0129341319339_1480606080.74',
5: 'test_file_0.0397767495074_1480606080.8'},
'next_after': 'testkey'}
>>> buf = client.get_file('testkey')
>>> len(buf.read())
4
Backend usage:
>>> from pymogilefs.backend import Backend
>>> backend = Backend(trackers=['0.0.0.0:7001'])
>>> devices = backend.get_devices()
>>> print(devices.data['devices']['9'])
{'devid': '16',
'hostid': '5',
'mb_asof': '',
'mb_free': '45181',
'mb_total': '59640',
'mb_used': '14459',
'observed_state': '',
'reject_bad_md5': '',
'status': 'dead',
'utilization': '',
'weight': '100'}
Forks and pull requests are highly appreciated.