sdnotify-0.3.2/0000775000175000017500000000000013140427520014405 5ustar bbethkebbethke00000000000000sdnotify-0.3.2/sdnotify/0000775000175000017500000000000013140427520016244 5ustar bbethkebbethke00000000000000sdnotify-0.3.2/sdnotify/__init__.py0000664000175000017500000000405513140416276020367 0ustar bbethkebbethke00000000000000import socket import os import sys __version__ = "0.3.2" # Byte conversion utility for compatibility between # Python 2 and 3. # http://python3porting.com/problems.html#nicer-solutions if sys.version_info < (3,): def _b(x): return x else: import codecs def _b(x): return codecs.latin_1_encode(x)[0] class SystemdNotifier: """This class holds a connection to the systemd notification socket and can be used to send messages to systemd using its notify method.""" def __init__(self, debug=False): """Instantiate a new notifier object. This will initiate a connection to the systemd notification socket. Normally this method silently ignores exceptions (for example, if the systemd notification socket is not available) to allow applications to function on non-systemd based systems. However, setting debug=True will cause this method to raise any exceptions generated to the caller, to aid in debugging. """ self.debug = debug try: self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) addr = os.getenv('NOTIFY_SOCKET') if addr[0] == '@': addr = '\0' + addr[1:] self.socket.connect(addr) except: self.socket = None if self.debug: raise def notify(self, state): """Send a notification to systemd. state is a string; see the man page of sd_notify (http://www.freedesktop.org/software/systemd/man/sd_notify.html) for a description of the allowable values. Normally this method silently ignores exceptions (for example, if the systemd notification socket is not available) to allow applications to function on non-systemd based systems. However, setting debug=True will cause this method to raise any exceptions generated to the caller, to aid in debugging.""" try: self.socket.sendall(_b(state)) except: if self.debug: raise sdnotify-0.3.2/PKG-INFO0000664000175000017500000000215513140427520015505 0ustar bbethkebbethke00000000000000Metadata-Version: 1.1 Name: sdnotify Version: 0.3.2 Summary: A pure Python implementation of systemd's service notification protocol (sd_notify) Home-page: https://github.com/bb4242/sdnotify Author: Brett Bethke Author-email: bbethke@gmail.com License: UNKNOWN Download-URL: https://github.com/bb4242/sdnotify/tarball/v0.3.2 Description: systemd Service Notification This is a pure Python implementation of the systemd sd_notify protocol. This protocol can be used to inform systemd about service start-up completion, watchdog events, and other service status changes. Thus, this package can be used to write system services in Python that play nicely with systemd. sdnotify is compatible with both Python 2 and Python 3. Keywords: systemd Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: POSIX :: Linux Classifier: Topic :: Software Development :: Libraries :: Python Modules sdnotify-0.3.2/setup.py0000664000175000017500000000235113140416211016113 0ustar bbethkebbethke00000000000000from distutils.core import setup VERSION='0.3.2' setup( name = 'sdnotify', packages = ['sdnotify'], version = VERSION, description = 'A pure Python implementation of systemd\'s service notification protocol (sd_notify)', author = 'Brett Bethke', author_email = 'bbethke@gmail.com', url = 'https://github.com/bb4242/sdnotify', download_url = 'https://github.com/bb4242/sdnotify/tarball/v{}'.format(VERSION), keywords = ['systemd'], classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Topic :: Software Development :: Libraries :: Python Modules", ], long_description = """\ systemd Service Notification This is a pure Python implementation of the systemd sd_notify protocol. This protocol can be used to inform systemd about service start-up completion, watchdog events, and other service status changes. Thus, this package can be used to write system services in Python that play nicely with systemd. sdnotify is compatible with both Python 2 and Python 3. """ ) sdnotify-0.3.2/LICENSE.txt0000664000175000017500000000206713140415020016225 0ustar bbethkebbethke00000000000000The MIT License (MIT) Copyright (c) 2016 Brett Bethke Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. sdnotify-0.3.2/setup.cfg0000664000175000017500000000004713140415020016217 0ustar bbethkebbethke00000000000000[metadata] description-file = README.md