Skip to main content

A python wrapper for littlefs

Project description

Build Status: Linux Build Status: Windows Documentation Status

littlefs-python provides a thin wrapper around littlefs, a filesystem targeted for small embedded systems. The wrapper provides a pythonic interface to the filesystem and allows the creation, inspection and modification of the filesystem or individual files. Even if this package uses Cython, the goal is not to provide a high performance implementation. Cython was chosen as an easy method is offered to generate the binding and the littlefs library in one step.

Quick Examples

Let’s create a image ready to transfer to a flash memory using the pythonic interface:

from littlefs import LittleFS

# Initialize the File System according to your specifications
fs = LittleFS(block_size=512, block_count=256)

# Open a file and write some content
with fs.open('first-file.txt', 'w') as fh:
    fh.write(b'Some text to begin with\n')

# Dump the filesystem content to a file
with open('FlashMemory.bin', 'wb') as fh:
    fh.write(fs.context.buffer)

The same can be done by using the more verbose C-Style API, which closely resembels the steps which must be performed in C:

from littlefs import lfs

cfg = lfs.LFSConfig(block_size=512, block_count=256)
fs = lfs.LFSFilesystem()

# Format and mount the filesystem
lfs.format(fs, cfg)
lfs.mount(fs, cfg)

# Open a file and write some content
fh = lfs.file_open(fs, 'first-file.txt', 'w') as fh:
lfs.file_write(fs, fh, b'Some text to begin with\n')
lfs.file_close(fs, fh)

# Dump the filesystem content to a file
with open('FlashMemory.bin', 'wb') as fh:
    fh.write(cfg.user_context.buffer)

Installation

This is as simple as it can be:

pip install littlefs-python

At the moment wheels (which require no build) are provided for the following platforms, on other platforms the source package is provided:

  • Linux: Python 3.5, 3.6, 3.7 & 3.8 / 32- & 64-bit

  • Windows: Python 3.5, 3.6 & 3.7 / 32- & 64-bit

Development Setup

Start by checking out the source repository of littlefs-python:

git clone https://github.com/jrast/littlefs-python.git

The source code for littlefs is included as a submodule which must be checked out after the clone:

cd <littlefs-python>
git submodule update --init

this ensures that the correct version of littlefs is cloned into the littlefs folder. As a next step install the dependencies and install the package:

pip install -r requirements.txt
pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

littlefs-python-0.1.2.tar.gz (238.4 kB view hashes)

Uploaded Source

Built Distributions

littlefs_python-0.1.2-cp38-cp38-manylinux2010_x86_64.whl (366.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

littlefs_python-0.1.2-cp38-cp38-manylinux1_x86_64.whl (366.2 kB view hashes)

Uploaded CPython 3.8

littlefs_python-0.1.2-cp37-cp37m-win_amd64.whl (74.9 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

littlefs_python-0.1.2-cp37-cp37m-win32.whl (59.3 kB view hashes)

Uploaded CPython 3.7m Windows x86

littlefs_python-0.1.2-cp37-cp37m-manylinux2010_x86_64.whl (338.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

littlefs_python-0.1.2-cp37-cp37m-manylinux1_x86_64.whl (343.2 kB view hashes)

Uploaded CPython 3.7m

littlefs_python-0.1.2-cp37-cp37m-manylinux1_i686.whl (301.9 kB view hashes)

Uploaded CPython 3.7m

littlefs_python-0.1.2-cp36-cp36m-win_amd64.whl (74.9 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

littlefs_python-0.1.2-cp36-cp36m-win32.whl (59.5 kB view hashes)

Uploaded CPython 3.6m Windows x86

littlefs_python-0.1.2-cp36-cp36m-manylinux2010_x86_64.whl (338.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

littlefs_python-0.1.2-cp36-cp36m-manylinux1_x86_64.whl (343.6 kB view hashes)

Uploaded CPython 3.6m

littlefs_python-0.1.2-cp36-cp36m-manylinux1_i686.whl (301.3 kB view hashes)

Uploaded CPython 3.6m

littlefs_python-0.1.2-cp35-cp35m-win_amd64.whl (73.6 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

littlefs_python-0.1.2-cp35-cp35m-win32.whl (58.4 kB view hashes)

Uploaded CPython 3.5m Windows x86

littlefs_python-0.1.2-cp35-cp35m-manylinux2010_x86_64.whl (332.0 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

littlefs_python-0.1.2-cp35-cp35m-manylinux1_x86_64.whl (336.8 kB view hashes)

Uploaded CPython 3.5m

littlefs_python-0.1.2-cp35-cp35m-manylinux1_i686.whl (295.4 kB view hashes)

Uploaded CPython 3.5m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page