sdnotify-0.3.1/0000775000175000017500000000000012730340250014402 5ustar bbethkebbethke00000000000000sdnotify-0.3.1/LICENSE.txt0000664000175000017500000000206712646236611016245 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.1/setup.cfg0000664000175000017500000000004712646236431016237 0ustar bbethkebbethke00000000000000[metadata] description-file = README.mdsdnotify-0.3.1/sdnotify/0000775000175000017500000000000012730340250016241 5ustar bbethkebbethke00000000000000sdnotify-0.3.1/sdnotify/__init__.py0000664000175000017500000000405512646271211020364 0ustar bbethkebbethke00000000000000import socket import os import sys __version__ = "0.3.0" # 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.1/PKG-INFO0000664000175000017500000000215512730340250015502 0ustar bbethkebbethke00000000000000Metadata-Version: 1.1 Name: sdnotify Version: 0.3.1 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.1 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.1/setup.py0000664000175000017500000000242312730336746016134 0ustar bbethkebbethke00000000000000from distutils.core import setup VERSION='0.3.1' 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", ], data_files = [("", ["LICENSE.txt"])], 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. """ )