~super-friends/friends/raring

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3

"""Usage: ./tools/debug_slave.py

Run this script in parallel with debug_live.py to watch changes to the Friends
database model as it is updated over dbus.

It is not intended for use with an installed friends package.
"""

from gi.repository import Dee
from gi.repository import GLib

from friends.utils.model import COLUMN_NAMES

class Slave:
    def __init__(self):
        model_name = 'com.canonical.Friends.Streams'
        print('Joining model ' + model_name)
        self.model = Dee.SharedModel.new(model_name)
        self.model.connect('row-added', self.on_row_added)

    def on_row_added(self, model, itr):
        row = self.model.get_row(itr)
        print('\n' * 5)
        for i, col in enumerate(row):
            print('{:12}: {}'.format(COLUMN_NAMES[i], col))
        print('ROWS: ', len(self.model))


if __name__ == '__main__':
    s = Slave()
    GLib.MainLoop().run()