This file is indexed.

/usr/share/pyshared/circuits/node/client.py is in python-circuits 2.1.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Module:   client
# Date:     ...
# Author:   ...

"""Client

...
"""

from weakref import WeakValueDictionary

from circuits import handler, BaseComponent
from circuits.net.sockets import Close, Connect, TCPClient, Write

from .utils import dump_event, load_value

DELIMITER = b"\r\n\r\n"


class Client(BaseComponent):
    """Client

    ...
    """

    channel = "node"

    def __init__(self, host, port, channel=channel):
        super(Client, self).__init__(channel=channel)

        self._host = host
        self._port = port

        self._nid = 0
        self._buffer = b""
        self._values = WeakValueDictionary()

        TCPClient(channel=self.channel).register(self)
        self.fire(Connect(self._host, self._port))

    def process(self, packet):
        v, id, errors = load_value(packet)

        if id in self._values:
            value = self._values[id]
            value.value = v
            value.errors = errors

    def close(self):
        self.fire(Close())

    def connect(self, host, port):
        self.fire(Connect(host, port))

    def send(self, event, e):
        id = self._nid
        self._nid += 1

        self._values[id] = event.value
        data = dump_event(e, id)
        packet = data.encode("utf-8") + DELIMITER

        self.fire(Write(packet))

    @handler("read")
    def _on_read(self, data):
        self._buffer += data

        delimiter = self._buffer.find(DELIMITER)
        if delimiter > 0:
            packet = self._buffer[:delimiter].decode("utf-8")
            self._buffer = self._buffer[(delimiter + len(DELIMITER)):]
            self.process(packet)