Metadata-Version: 2.1
Name: systemd
Version: 0.16.1
Summary: Python systemd wrapper
Home-page: http://github.com/mosquito/python-systemd
Author: Dmitry Orlov <me@mosquito.su>
Author-email: me@mosquito.su
License: Apache
Keywords: systemd,python,daemon,sd_notify,cython
Platform: POSIX
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Natural Language :: Russian
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System
Classifier: Topic :: System :: Operating System
Provides: systemd
Requires-Dist: dictproxyhack ; python_version < "3.3"
Requires-Dist: enum34 ; python_version < "3.4"

SystemD for Python
==================

.. image:: https://img.shields.io/pypi/v/systemd.svg
    :target: https://pypi.python.org/pypi/systemd/
    :alt: Latest Version

.. image:: https://img.shields.io/pypi/wheel/systemd.svg
    :target: https://pypi.python.org/pypi/systemd/

.. image:: https://img.shields.io/pypi/pyversions/systemd.svg
    :target: https://pypi.python.org/pypi/systemd/

.. image:: https://img.shields.io/pypi/l/systemd.svg
    :target: https://pypi.python.org/pypi/systemd/


Python systemd wrapper using Cython


Installation
------------

You should install systemd headers 

For debian users:


.. code-block:: bash

    apt-get install build-essential \
        libsystemd-journal-dev \
        libsystemd-daemon-dev \
        libsystemd-dev


For CentOS/RHEL

.. code-block:: bash

    yum install gcc systemd-devel


And install it from pypi

.. code-block:: bash

    pip install systemd


Usage examples
--------------

Systemd daemon notification


.. code-block:: python

    from systemd.daemon import notify, Notification

    # Send READY=1
    notify(Notification.READY)

    # Send status
    notify(Notification.STATUS, "I'm fine.")

    # Send stopping
    notify(Notification.STOPPING)


Write message into Systemd journal


.. code-block:: python

    from systemd import journal


    journal.write("Hello Lennart")

    # Or send structured data
    journal.send(
        message="Hello Lennart",
        priority=journal.Priority.INFO,
        some_field='some value',
    )



Or add logging handler to python logger

.. code-block:: python

    from systemd import journal
    import logging
    import uuid

    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger()
    logger.addHandler(journal.JournaldLogHandler())

    try:
        log.info("Trying to do something")
        raise Exception('foo')
    except:
        logger.exception("Test Exception %s", 1)




