008fce3f

sysdirs

pipeline coverage

Code: https://rolln.de/knoppo/sysdirs

Documentation: https://docs.rolln.de/knoppo/sysdirs/master

Coverage: https://coverage.rolln.de/knoppo/sysdirs/master

Python library to access and install system directories.

It comes with a highly customizable Installer class that allows you to create simple and flexible installers to package and deploy your applications.

The installer looks for a directory layout standard to use and returns a class representing it. The directory layout standards (specifications) have the same set of methods you can use in your application. If more than one layout is available during installation, the user will be shown a selection dialog.

The selection dialog uses timeouts so it can be wrapped inside other installation processes, e.g. chef, puppet or in .deb/.rpm package postinst.

sysdirs ships with the directory layout standards FHS and XDG while the DevDir class can be used to include a single development directory.

Note

The provided FHS class is (by default) compatible to hier (7) and therefore stores runtime files in /var/run instead of /run!

Example

from sysdirs import Installer, FHS, XDG, NotInstalled
installer = Installer('my_project', specifications=[FHS(), XDG()])

try:
   dirs = installer.load()
except NotInstalled:
   dirs = installer.install()
   dirs.install_config('/path/to/config/template.ini', relpath='config.ini')
   dirs.install_data('/path/to/static/logo.jpg')
   dirs.install_var()


db_path = os.path.join(dirs.var, 'database.sqlite3')

from configparser import ConfigParser
config = ConfigParser()
filenames = config.read(dirs.get_config_files('config.ini'))

License

Copyright (c) 2017-2018 Mathias Stelzer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.