Merge lp:~phablet-team/urfkill/monitor-script into lp:ubuntu/vivid/urfkill

Proposed by Alfonso Sanchez-Beato
Status: Merged
Merge reported by: Martin Pitt
Merged at revision: not available
Proposed branch: lp:~phablet-team/urfkill/monitor-script
Merge into: lp:ubuntu/vivid/urfkill
Diff against target: 121 lines (+109/-0)
2 files modified
debian/changelog (+6/-0)
debian/scripts/monitor-urfkill (+103/-0)
To merge this branch: bzr merge lp:~phablet-team/urfkill/monitor-script
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Review via email: mp+257592@code.launchpad.net

Commit message

[Alfonso Sanchez-Beato]
* Add monitor-urfkill debugging script

Description of the change

Add monitor-urfkill debugging script

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Can you please forward this to upstream as well, so that we don't keep this around as a delta forever? Please also give some rationale, i. e. what does this what you cannot already do with dbus-monitor or gdbus monitor?

Thanks!

Revision history for this message
Martin Pitt (pitti) :
review: Needs Information
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Upstream urfkill is apparently dead, so for practical purposes we are upstream. monitor-urfkill does nothing that cannot be done with dbus-monitor, it is simply a helper script that produces more readable output for urfkill than dbus-monitor. It is similar to the monitor-ofono script for ofono.

Revision history for this message
Martin Pitt (pitti) wrote :

OK, fair enough. Uploaded to wily with an Ubuntu-only version bump. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-03-19 20:50:13 +0000
+++ debian/changelog 2015-04-27 22:25:46 +0000
@@ -1,3 +1,9 @@
1urfkill (0.6.0~20150427.103828.5539c0d.1-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Add monitor-urfkill debugging script
4
5 -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Mon, 27 Apr 2015 17:17:27 -0500
6
1urfkill (0.6.0~20150318.103828.5539c0d.1-0ubuntu1) vivid; urgency=medium7urfkill (0.6.0~20150318.103828.5539c0d.1-0ubuntu1) vivid; urgency=medium
28
3 * New upstream snapshot, bugfix only:9 * New upstream snapshot, bugfix only:
410
=== added file 'debian/scripts/monitor-urfkill'
--- debian/scripts/monitor-urfkill 1970-01-01 00:00:00 +0000
+++ debian/scripts/monitor-urfkill 2015-04-27 22:25:46 +0000
@@ -0,0 +1,103 @@
1#!/usr/bin/python3
2
3from gi.repository import GLib
4
5import dbus
6import dbus.mainloop.glib
7
8_dbus2py = {
9 dbus.String : str,
10 dbus.UInt32 : int,
11 dbus.Int32 : int,
12 dbus.Int16 : int,
13 dbus.UInt16 : int,
14 dbus.UInt64 : int,
15 dbus.Int64 : int,
16 dbus.Byte : int,
17 dbus.Boolean : bool,
18 dbus.ByteArray : str,
19 dbus.ObjectPath : str
20 }
21
22def dbus2py(d):
23 t = type(d)
24 if t in _dbus2py:
25 return _dbus2py[t](d)
26 if t is dbus.Dictionary:
27 return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
28 if t is dbus.Array and d.signature == "y":
29 return "".join([chr(b) for b in d])
30 if t is dbus.Array or t is list:
31 return [dbus2py(v) for v in d]
32 if t is dbus.Struct or t is tuple:
33 return tuple([dbus2py(v) for v in d])
34 return d
35
36def pretty(d):
37 d = dbus2py(d)
38 t = type(d)
39
40 if t in (dict, tuple, list) and len(d) > 0:
41 if t is dict:
42 d = ", ".join(["%s = %s" % (k, pretty(v))
43 for k, v in d.items()])
44 return "{ %s }" % d
45
46 d = " ".join([pretty(e) for e in d])
47
48 if t is tuple:
49 return "( %s )" % d
50
51 if t is str:
52 return "%s" % d
53
54 return str(d)
55
56def property_changed(name, changed, invalidated, path, member):
57 print("{%s} [%s] %s: %s" % (name, path, member, pretty(changed)))
58
59def signal_no_arg(interface, path, member):
60 print("{%s} [%s] %s" % (interface, path, member))
61
62def device_changed(obj, interface, path, member):
63 print("{%s} [%s] %s: %s" % (interface, path, member, obj))
64
65def flight_mode_changed(val, interface, path, member):
66 print("{%s} [%s] %s: %s" % (interface, path, member, pretty(val)))
67
68if __name__ == '__main__':
69 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
70
71 bus = dbus.SystemBus()
72
73 bus.add_signal_receiver(property_changed,
74 bus_name="org.freedesktop.URfkill",
75 signal_name = "PropertiesChanged",
76 path_keyword="path",
77 member_keyword="member")
78
79 for signal in ["StateChanged",
80 "Changed"]:
81 bus.add_signal_receiver(signal_no_arg,
82 bus_name="org.freedesktop.URfkill",
83 signal_name = signal,
84 interface_keyword="interface",
85 path_keyword="path",
86 member_keyword="member")
87
88 bus.add_signal_receiver(device_changed,
89 bus_name="org.freedesktop.URfkill",
90 signal_name = "DeviceChanged",
91 interface_keyword="interface",
92 path_keyword="path",
93 member_keyword="member")
94
95 bus.add_signal_receiver(flight_mode_changed,
96 bus_name="org.freedesktop.URfkill",
97 signal_name = "FlightModeChanged",
98 interface_keyword="interface",
99 path_keyword="path",
100 member_keyword="member")
101
102 mainloop = GLib.MainLoop()
103 mainloop.run()

Subscribers

People subscribed via source and target branches