[Python-modules-commits] [python-sdnotify] 01/05: import python-sdnotify_0.3.1.orig.tar.gz

Orestis Ioannou oorestisime-guest at moszumanska.debian.org
Sat Jul 16 20:55:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

oorestisime-guest pushed a commit to branch master
in repository python-sdnotify.

commit cac674e7fd5bb16737bbe24030d9f5ab237149d0
Author: Orestis Ioannou <orestis at oioannou.com>
Date:   Sat Jul 16 22:50:15 2016 +0200

    import python-sdnotify_0.3.1.orig.tar.gz
---
 LICENSE.txt          |  9 ++++++++
 PKG-INFO             | 22 ++++++++++++++++++++
 sdnotify/__init__.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 setup.cfg            |  2 ++
 setup.py             | 30 ++++++++++++++++++++++++++
 5 files changed, 122 insertions(+)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..efab5e1
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,9 @@
+The 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.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..b62c319
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,22 @@
+Metadata-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 at 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
diff --git a/sdnotify/__init__.py b/sdnotify/__init__.py
new file mode 100644
index 0000000..8ab3d44
--- /dev/null
+++ b/sdnotify/__init__.py
@@ -0,0 +1,59 @@
+import 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
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..224a779
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[metadata]
+description-file = README.md
\ No newline at end of file
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..7a37dc5
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,30 @@
+from 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 at 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.
+"""
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-sdnotify.git



More information about the Python-modules-commits mailing list