Skip to main content

Linux system administration tools for Python

Project description

https://travis-ci.org/xolox/python-linux-utils.svg?branch=master https://coveralls.io/repos/xolox/python-linux-utils/badge.svg?branch=master

The Python package linux-utils provides utility functions that make it easy to script system administration tasks on Linux systems in Python. At the moment only parsing of the /etc/fstab and /etc/crypttab configuration files is implemented, but more functionality will soon be released. The package is currently tested on cPython 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy (2.7).

Installation

The linux-utils package is available on PyPI which means installation should be as simple as:

$ pip install linux-utils

There’s actually a multitude of ways to install Python packages (e.g. the per user site-packages directory, virtual environments or just installing system wide) and I have no intention of getting into that discussion here, so if this intimidates you then read up on your options before returning to these instructions ;-).

Usage

Please refer to the API documentation available on Read the Docs.

History

Back in 2015 I wrote some Python code to parse the Linux configuration files /etc/fstab and /etc/crypttab for use in crypto-drive-manager. Fast forward to 2017 and I found myself wanting to use the same functionality in rsync-system-backup. Three options presented themselves to me:

  1. Copy/paste the relevant code. Having to maintain the same code in multiple places causes lower quality code because having to duplicate the effort of writing documentation, developing tests and fixing bugs is a very demotivating endeavor.

    In fact sometime in 2016 I did copy/paste parts of this code into a project at work, because I needed similar functionality there. Of course since then the two implementations have started diverging :-p.

  2. Make crypto-drive-manager a dependency of rsync-system-backup. Although this approach is less ugly than copy/pasting the code, it still isn’t exactly elegant because the two projects have nothing to do with each other apart from working with LUKS encrypted disks on Linux.

  3. Extract the functionality into a new package. In my opinion this is clearly the most elegant approach, unfortunately it also requires the most work from me :-). On the plus side I’m publishing the new package with a test suite which means less untested code remains in crypto-drive-manager (which doesn’t have a test suite at the time of writing).

While extracting the code I shortly considered integrating the functionality into debuntu-tools, however the /etc/fstab and /etc/crypttab parsing isn’t specific to Debian or Ubuntu at all and debuntu-tools has several dependencies that aren’t relevant to Linux configuration file parsing.

Tangentially related: The reason I went with the extremely generic name linux-utils is because I will be adding more “specific to Linux but not Debian” functionality to this package in the very near future :-).

Contact

The latest version of linux-utils is available on PyPI and GitHub. The documentation is hosted on Read the Docs. For bug reports please create an issue on GitHub. If you have questions, suggestions, etc. feel free to send me an e-mail at peter@peterodding.com.

License

This software is licensed under the MIT license.

© 2017 Peter Odding.

Download files

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

Source Distribution

linux-utils-0.1.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

linux_utils-0.1-py2.py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 2 Python 3

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