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

Subscribers

People subscribed via source and target branches