[Python-apps-commits] r8376 - in packages/autokey/trunk/debian (6 files)
adejong at users.alioth.debian.org
adejong at users.alioth.debian.org
Sun Mar 25 13:03:31 UTC 2012
Date: Sunday, March 25, 2012 @ 13:03:29
Author: adejong
Revision: 8376
* Use simpler mechanism to install the init script.
Added:
packages/autokey/trunk/debian/autokey-common.autokey.init
(from rev 8374, packages/autokey/trunk/debian/autokey-common.init)
Modified:
packages/autokey/trunk/debian/autokey-common.postinst
packages/autokey/trunk/debian/autokey-common.prerm
packages/autokey/trunk/debian/changelog
packages/autokey/trunk/debian/rules
Deleted:
packages/autokey/trunk/debian/autokey-common.init
Copied: packages/autokey/trunk/debian/autokey-common.autokey.init (from rev 8374, packages/autokey/trunk/debian/autokey-common.init)
===================================================================
--- packages/autokey/trunk/debian/autokey-common.autokey.init (rev 0)
+++ packages/autokey/trunk/debian/autokey-common.autokey.init 2012-03-25 13:03:29 UTC (rev 8376)
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+### BEGIN INIT INFO
+# Provides: autokey
+# Required-Start: $local_fs
+# Required-Stop: $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start AutoKey daemon.
+# Description: Enable AutoKey's EvDev interface daemon.
+### END INIT INFO
+
+import sys, os, socket, glob, shutil, time
+try:
+ from autokey import evdev, daemon, configmanager
+ from autokey.common import DOMAIN_SOCKET_PATH, PACKET_SIZE
+except ImportError:
+ # Per DPM § 9.3.2 script should fail gracefully if not installed.
+ print "It does not seem Autokey is installed. Exiting..."
+ sys.exit(0)
+
+PACKET_STRING = "%s,%s,%s"
+
+BUTTON_MAP = {
+ "BTN_LEFT" : '1',
+ "BTN_MIDDLE": '2',
+ "BTN_RIGHT" : '3'
+ }
+
+class AutoKeyDaemon(daemon.Daemon):
+
+ def __init__(self):
+ logFile = "/var/log/autokey-daemon.log"
+ daemon.Daemon.__init__(self, '/var/run/autokey-daemon.pid', stdout=logFile, stderr=logFile)
+
+ def canrecord(self):
+ return configmanager._chooseInterface() == "XRecord"
+
+ def get_device_paths(self):
+ keyboardLocations = glob.glob("/dev/input/by-path/*-event-kbd")
+ mouseLocations = glob.glob("/dev/input/by-path/*-event-mouse")
+
+ sys.stdout.write("Keyboards: %s\nMice: %s\n" % (repr(keyboardLocations), repr(mouseLocations)))
+ return keyboardLocations + mouseLocations
+
+ def run(self):
+ print "AutoKey daemon starting"
+
+ if os.path.exists(self.stdout):
+ shutil.move(self.stdout, self.stdout + '.old')
+
+ if os.path.exists(DOMAIN_SOCKET_PATH):
+ os.remove(DOMAIN_SOCKET_PATH)
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.bind(DOMAIN_SOCKET_PATH)
+ os.chmod(DOMAIN_SOCKET_PATH, 0777)
+ print "Created domain socket"
+
+ while True:
+ time.sleep(5) # sleep 5 seconds, waiting for devices to appear after resume from S3
+ s.listen(1)
+ try:
+ conn, addr = s.accept()
+ print "Accepted connection"
+ except Exception, e:
+ print "Fatal error while accepting connections - daemon shutting down"
+ print str(e)
+ break
+
+ devices = evdev.DeviceGroup(self.get_device_paths())
+ sys.stdout.flush()
+ sys.stderr.flush()
+
+ while True:
+ try:
+ event = devices.next_event()
+ except OSError:
+ print "Unable to read from device(s). Connection will be closed and restarted"
+ break
+
+ if event is not None:
+ if event.type == "EV_KEY" and isinstance(event.code, str):
+ if event.code.startswith("KEY"):
+ # Keyboard event
+ code = event.scanCode
+ button = ''
+ state = event.value
+
+ try:
+ self.send_packet(conn, code, button, state)
+ except:
+ break
+
+ elif event.code.startswith("BTN") and event.value == 1:
+ # Mouse event - only care about button press, not release
+ code = ''
+ if event.code in BUTTON_MAP:
+ button = BUTTON_MAP[event.code]
+ else:
+ button = -1
+ state = event.value
+
+ try:
+ self.send_packet(conn, code, button, state)
+ except:
+ break
+
+ conn.close()
+ devices.close()
+ print "Connection closed"
+ sys.stdout.flush()
+ sys.stderr.flush()
+
+ def send_packet(self, conn, code, button, state):
+ if code:
+ code = self.translate_keycode(code)
+ sendData = PACKET_STRING % (code, button, state)
+ sendData += (PACKET_SIZE - len(sendData)) * ' '
+ conn.send(sendData)
+
+ def translate_keycode(self, keyCode):
+ if keyCode < 151:
+ keyCode += 8
+ else:
+ print "Got untranslatable evdev keycode: %d\n" % keyCode
+ keyCode = 0
+ return keyCode
+
+
+if __name__ == "__main__":
+ #daemon = AutoKeyDaemon('/tmp/autokey-daemon.pid', stdout=sys.__stdout__, stderr=sys.__stderr__)
+ daemon = AutoKeyDaemon()
+ if len(sys.argv) == 2:
+ if 'start' == sys.argv[1]:
+ daemon.start()
+ elif 'stop' == sys.argv[1]:
+ daemon.stop()
+ elif 'restart' == sys.argv[1]:
+ daemon.restart()
+ elif 'force-reload' == sys.argv[1]:
+ # we don't support on-the-fly reloading,
+ # so just restart the daemon per DPM 9.3.2
+ daemon.restart()
+ elif 'status' == sys.argv[1]:
+ if daemon.checkpid():
+ print "AutoKey daemon is running"
+ else:
+ print "AutoKey daemon is stopped"
+ sys.exit(3)
+ elif 'status-xrecord' == sys.argv[1]:
+ if not daemon.canrecord():
+ print "XRecord not available"
+ sys.exit(1)
+ else:
+ print "XRecord is available"
+ else:
+ print "Unknown command"
+ sys.exit(2)
+ sys.exit(0)
+ else:
+ print "usage: %s {status|start|stop|restart|force-reload}" % sys.argv[0]
+ sys.exit(2)
+
+ sys.exit(0)
+
+
Deleted: packages/autokey/trunk/debian/autokey-common.init
===================================================================
--- packages/autokey/trunk/debian/autokey-common.init 2012-03-25 12:48:32 UTC (rev 8375)
+++ packages/autokey/trunk/debian/autokey-common.init 2012-03-25 13:03:29 UTC (rev 8376)
@@ -1,167 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-### BEGIN INIT INFO
-# Provides: autokey
-# Required-Start: $local_fs
-# Required-Stop: $local_fs
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Start AutoKey daemon.
-# Description: Enable AutoKey's EvDev interface daemon.
-### END INIT INFO
-
-import sys, os, socket, glob, shutil, time
-try:
- from autokey import evdev, daemon, configmanager
- from autokey.common import DOMAIN_SOCKET_PATH, PACKET_SIZE
-except ImportError:
- # Per DPM § 9.3.2 script should fail gracefully if not installed.
- print "It does not seem Autokey is installed. Exiting..."
- sys.exit(0)
-
-PACKET_STRING = "%s,%s,%s"
-
-BUTTON_MAP = {
- "BTN_LEFT" : '1',
- "BTN_MIDDLE": '2',
- "BTN_RIGHT" : '3'
- }
-
-class AutoKeyDaemon(daemon.Daemon):
-
- def __init__(self):
- logFile = "/var/log/autokey-daemon.log"
- daemon.Daemon.__init__(self, '/var/run/autokey-daemon.pid', stdout=logFile, stderr=logFile)
-
- def canrecord(self):
- return configmanager._chooseInterface() == "XRecord"
-
- def get_device_paths(self):
- keyboardLocations = glob.glob("/dev/input/by-path/*-event-kbd")
- mouseLocations = glob.glob("/dev/input/by-path/*-event-mouse")
-
- sys.stdout.write("Keyboards: %s\nMice: %s\n" % (repr(keyboardLocations), repr(mouseLocations)))
- return keyboardLocations + mouseLocations
-
- def run(self):
- print "AutoKey daemon starting"
-
- if os.path.exists(self.stdout):
- shutil.move(self.stdout, self.stdout + '.old')
-
- if os.path.exists(DOMAIN_SOCKET_PATH):
- os.remove(DOMAIN_SOCKET_PATH)
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.bind(DOMAIN_SOCKET_PATH)
- os.chmod(DOMAIN_SOCKET_PATH, 0777)
- print "Created domain socket"
-
- while True:
- time.sleep(5) # sleep 5 seconds, waiting for devices to appear after resume from S3
- s.listen(1)
- try:
- conn, addr = s.accept()
- print "Accepted connection"
- except Exception, e:
- print "Fatal error while accepting connections - daemon shutting down"
- print str(e)
- break
-
- devices = evdev.DeviceGroup(self.get_device_paths())
- sys.stdout.flush()
- sys.stderr.flush()
-
- while True:
- try:
- event = devices.next_event()
- except OSError:
- print "Unable to read from device(s). Connection will be closed and restarted"
- break
-
- if event is not None:
- if event.type == "EV_KEY" and isinstance(event.code, str):
- if event.code.startswith("KEY"):
- # Keyboard event
- code = event.scanCode
- button = ''
- state = event.value
-
- try:
- self.send_packet(conn, code, button, state)
- except:
- break
-
- elif event.code.startswith("BTN") and event.value == 1:
- # Mouse event - only care about button press, not release
- code = ''
- if event.code in BUTTON_MAP:
- button = BUTTON_MAP[event.code]
- else:
- button = -1
- state = event.value
-
- try:
- self.send_packet(conn, code, button, state)
- except:
- break
-
- conn.close()
- devices.close()
- print "Connection closed"
- sys.stdout.flush()
- sys.stderr.flush()
-
- def send_packet(self, conn, code, button, state):
- if code:
- code = self.translate_keycode(code)
- sendData = PACKET_STRING % (code, button, state)
- sendData += (PACKET_SIZE - len(sendData)) * ' '
- conn.send(sendData)
-
- def translate_keycode(self, keyCode):
- if keyCode < 151:
- keyCode += 8
- else:
- print "Got untranslatable evdev keycode: %d\n" % keyCode
- keyCode = 0
- return keyCode
-
-
-if __name__ == "__main__":
- #daemon = AutoKeyDaemon('/tmp/autokey-daemon.pid', stdout=sys.__stdout__, stderr=sys.__stderr__)
- daemon = AutoKeyDaemon()
- if len(sys.argv) == 2:
- if 'start' == sys.argv[1]:
- daemon.start()
- elif 'stop' == sys.argv[1]:
- daemon.stop()
- elif 'restart' == sys.argv[1]:
- daemon.restart()
- elif 'force-reload' == sys.argv[1]:
- # we don't support on-the-fly reloading,
- # so just restart the daemon per DPM 9.3.2
- daemon.restart()
- elif 'status' == sys.argv[1]:
- if daemon.checkpid():
- print "AutoKey daemon is running"
- else:
- print "AutoKey daemon is stopped"
- sys.exit(3)
- elif 'status-xrecord' == sys.argv[1]:
- if not daemon.canrecord():
- print "XRecord not available"
- sys.exit(1)
- else:
- print "XRecord is available"
- else:
- print "Unknown command"
- sys.exit(2)
- sys.exit(0)
- else:
- print "usage: %s {status|start|stop|restart|force-reload}" % sys.argv[0]
- sys.exit(2)
-
- sys.exit(0)
-
-
Modified: packages/autokey/trunk/debian/autokey-common.postinst
===================================================================
--- packages/autokey/trunk/debian/autokey-common.postinst 2012-03-25 12:48:32 UTC (rev 8375)
+++ packages/autokey/trunk/debian/autokey-common.postinst 2012-03-25 13:03:29 UTC (rev 8376)
@@ -1,42 +1,10 @@
#!/bin/sh
-# postinst script for test
-#
-# see: dh_installdeb(1)
set -e
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <postinst> `abort-remove'
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
+# we ship an empty postinst file because svn-buildpackage keeps the
+# upstream debian/ files (see #623163)
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
#DEBHELPER#
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/autokey" ]; then
- /etc/init.d/autokey status-xrecord
- if [ $? -eq 0 ]; then
- update-rc.d autokey disable
- else
- if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
- invoke-rc.d autokey start || exit $?
- else
- /etc/init.d/autokey start || exit $?
- fi
- fi
-fi
-# End automatically added section
-
-
exit 0
Modified: packages/autokey/trunk/debian/autokey-common.prerm
===================================================================
--- packages/autokey/trunk/debian/autokey-common.prerm 2012-03-25 12:48:32 UTC (rev 8375)
+++ packages/autokey/trunk/debian/autokey-common.prerm 2012-03-25 13:03:29 UTC (rev 8376)
@@ -1,34 +1,10 @@
#!/bin/sh
-# prerm script for test
-#
-# see: dh_installdeb(1)
set -e
-# summary of how this script can be called:
-# * <prerm> `remove'
-# * <old-prerm> `upgrade' <new-version>
-# * <new-prerm> `failed-upgrade' <old-version>
-# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
-# * <deconfigured's-prerm> `deconfigure' `in-favour'
-# <package-being-installed> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
+# we ship an empty postinst file because svn-buildpackage keeps the
+# upstream debian/ files (see #623163)
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/autokey" ]; then
- if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
- invoke-rc.d autokey stop || exit $?
- else
- /etc/init.d/autokey stop || exit $?
- fi
-fi
-# End automatically added section
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
#DEBHELPER#
exit 0
Modified: packages/autokey/trunk/debian/changelog
===================================================================
--- packages/autokey/trunk/debian/changelog 2012-03-25 12:48:32 UTC (rev 8375)
+++ packages/autokey/trunk/debian/changelog 2012-03-25 13:03:29 UTC (rev 8376)
@@ -2,8 +2,9 @@
* Update uploader to Python Applications Packaging Team.
* Fix format of debian/copyright file.
+ * Use simpler mechanism to install the init script.
- -- Arthur de Jong <adejong at debian.org> Sun, 25 Mar 2012 14:47:38 +0200
+ -- Arthur de Jong <adejong at debian.org> Sun, 25 Mar 2012 15:03:08 +0200
autokey (0.82.2-2) unstable; urgency=low
Modified: packages/autokey/trunk/debian/rules
===================================================================
--- packages/autokey/trunk/debian/rules 2012-03-25 12:48:32 UTC (rev 8375)
+++ packages/autokey/trunk/debian/rules 2012-03-25 13:03:29 UTC (rev 8376)
@@ -9,4 +9,4 @@
# Add here any variable or target overrides you need.
DEB_INSTALL_MANPAGES_autokey_qt = debian/autokey-qt.1
DEB_INSTALL_MANPAGES_autokey_gtk = debian/autokey-gtk.1
-DEB_DH_INSTALLINIT_ARGS := --no-start --init-script=autokey --error-handler=init_failure
+DEB_DH_INSTALLINIT_ARGS := --no-start --name=autokey
More information about the Python-apps-commits
mailing list