Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: /, dbus-listener/, PMSTestSuite/
Date: Sun, 29 May 2011 18:17:13
Message-Id: 20a517879090c82a402085491b6846549fd6c718.mgorny@gentoo
1 commit: 20a517879090c82a402085491b6846549fd6c718
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 29 18:16:37 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun May 29 18:16:37 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=20a51787
7
8 Add a minimal D-Bus module.
9
10 ---
11 PMSTestSuite/dbus.py | 43 ++++++++++++++++++++
12 dbus-listener/test-listener.py | 26 ------------
13 ...STestSuite.conf => org.gentoo.PMSTestSuite.conf | 0
14 3 files changed, 43 insertions(+), 26 deletions(-)
15
16 diff --git a/PMSTestSuite/dbus.py b/PMSTestSuite/dbus.py
17 new file mode 100644
18 index 0000000..f19c098
19 --- /dev/null
20 +++ b/PMSTestSuite/dbus.py
21 @@ -0,0 +1,43 @@
22 +# vim:fileencoding=utf-8
23 +# (c) 2011 Michał Górny <mgorny@g.o>
24 +# Released under the terms of the 2-clause BSD license.
25 +
26 +import dbus, dbus.service
27 +from dbus.mainloop.glib import DBusGMainLoop
28 +
29 +dbus_interface_name = 'org.gentoo.PMSTestSuite'
30 +dbus_object_prefix = '/org/gentoo/PMSTestSuite'
31 +
32 +class RunningTest(dbus.service.Object):
33 + """ A class encapsulating a running test. """
34 +
35 + def __init__(self, test_name, parent):
36 + """
37 + Initialize the object for test <test_name>, for DBusHandler <parent>.
38 + """
39 + self.test_name = test_name
40 + self.output = []
41 + dbus.service.Object.__init__(
42 + parent.bus,
43 + '%s/%s' % (dbus_object_prefix, test_name)
44 + )
45 +
46 + @dbus.service.method(
47 + dbus_interface=dbus_interface_name,
48 + in_signature='ss', out_signature='')
49 + def append_output(self, l):
50 + """ Append the line <l> to the test output. """
51 + self.output.append(l)
52 +
53 +class DBusHandler(object):
54 + """ A class handling all D-Bus interaction for PMS Test Suite. """
55 +
56 + def __init__(self):
57 + """ Initialize DBusHandler. Add it to main GLib loop. """
58 + DBusGMainLoop(set_as_default=True)
59 + self.bus = dbus.SystemBus()
60 + self.busname = dbus.service.BusName(dbus_interface_name, self.bus)
61 +
62 + def add_test(self, test):
63 + """ Add the object for <test> to the handler. """
64 + test._dbusobj = RunningTest(test.pn, self)
65
66 diff --git a/dbus-listener/test-listener.py b/dbus-listener/test-listener.py
67 deleted file mode 100755
68 index 22a0c89..0000000
69 --- a/dbus-listener/test-listener.py
70 +++ /dev/null
71 @@ -1,26 +0,0 @@
72 -#!/usr/bin/python
73 -
74 -import sys
75 -
76 -import dbus, dbus.mainloop.glib, dbus.service
77 -import gobject
78 -
79 -class PMSTestSuite(dbus.service.Object):
80 - @dbus.service.method(
81 - dbus_interface='org.gentoo.PMSTestSuite',
82 - in_signature='ss', out_signature='')
83 - def append_output(self, test_name, l):
84 - print('%s: %s' % (test_name, l))
85 -
86 -def main(argv):
87 - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
88 - bus = dbus.SystemBus()
89 -
90 - bname = dbus.service.BusName("org.gentoo.PMSTestSuite", bus)
91 - obj = PMSTestSuite(bus, '/org/gentoo/PMSTestSuite')
92 -
93 - loop = gobject.MainLoop()
94 - loop.run()
95 -
96 -if __name__ == '__main__':
97 - main(sys.argv[1:])
98
99 diff --git a/dbus-listener/org.gentoo.PMSTestSuite.conf b/org.gentoo.PMSTestSuite.conf
100 similarity index 100%
101 rename from dbus-listener/org.gentoo.PMSTestSuite.conf
102 rename to org.gentoo.PMSTestSuite.conf