~ubuntu-branches/ubuntu/raring/iotop/raring

« back to all changes in this revision

Viewing changes to iotop/genetlink.py

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2011-03-29 09:16:38 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110329091638-juk7up310n41fhsp
Tags: 0.4.3-1
* New upstream release
  - Drop all patches, included upstream
  - Fixes crash with non-ASCII characters (Closes: #616481)
  - Fixes startup with invalid locales (Closes: #593846)
  - Adds support for ioprio on armel and hppa (Closes: #595426)
* Wrap deps and build-deps one per line
* Drop quilt stuff, not needed with dpkg-source v3
* Bump Standards-Version, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
Copyright 2007        Johannes Berg <johannes@sipsolutions.net>
5
5
 
6
 
GPLv2
 
6
GPLv2+; See copying for details.
7
7
'''
8
8
 
9
9
import struct
45
45
        Message.__init__(self, family, flags=flags,
46
46
                         payload=[GenlHdr(self.cmd)]+attrs)
47
47
 
 
48
    @staticmethod
 
49
    def recv(conn):
 
50
        msg = conn.recv()
 
51
        packet = msg.payload
 
52
        hdr = _genl_hdr_parse(packet[:4])
 
53
 
 
54
        genlmsg = GeNlMessage(msg.type, hdr.cmd, [], msg.flags)
 
55
        genlmsg.attrs = parse_attributes(packet[4:])
 
56
        genlmsg.version = hdr.version
 
57
 
 
58
        return genlmsg
 
59
 
48
60
class Controller:
49
61
    def __init__(self, conn):
50
62
        self.conn = conn
53
65
        m = GeNlMessage(GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
54
66
                        flags=NLM_F_REQUEST, attrs=[a])
55
67
        m.send(self.conn)
56
 
        m = self.conn.recv()
57
 
        gh = _genl_hdr_parse(m.payload[:4])
58
 
        attrs = parse_attributes(m.payload[4:])
59
 
        return attrs[CTRL_ATTR_FAMILY_ID].u16()
 
68
        m = GeNlMessage.recv(self.conn)
 
69
        return m.attrs[CTRL_ATTR_FAMILY_ID].u16()
60
70
 
61
71
connection = Connection(NETLINK_GENERIC)
62
72
controller = Controller(connection)