~chicharreros/magicicada-protocol/1.0

« back to all changes in this revision

Viewing changes to ubuntuone/storageprotocol/client.py

  • Committer: Magicicada Bot
  • Author(s): Natalia
  • Date: 2018-04-08 19:46:34 UTC
  • mfrom: (169.1.1 update-copyright-headers)
  • Revision ID: magicicada_bot-20180408194634-ydg0ytcwmo683l2z
[r=nataliabidart] - Added proper copyright notices and coding headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
1
3
# Copyright 2009-2015 Canonical Ltd.
2
 
# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)
 
4
# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
3
5
#
4
6
# This program is free software: you can redistribute it and/or modify it
5
7
# under the terms of the GNU Affero General Public License version 3,
616
618
 
617
619
    def processMessage(self, message):
618
620
        """Process messages."""
619
 
        # pylint: disable=W0201
620
621
        if message.type == protocol_pb2.Message.NODE_ATTR:
621
622
            if self.node_attr_callback is not None:
622
623
                self.node_attr_callback(
667
668
 
668
669
    def _start(self):
669
670
        """Send the LIST_SHARES message to the server."""
670
 
        # pylint: disable=W0201
671
671
        message = protocol_pb2.Message()
672
672
        message.type = protocol_pb2.Message.LIST_SHARES
673
673
        self.sendMessage(message)
935
935
 
936
936
    @ivar new_generation: the generation that the volume is at now
937
937
    """
938
 
    # pylint: disable=C0111
939
938
 
940
939
    __slots__ = ('share', 'node', 'new_generation')
941
940
 
1361
1360
 
1362
1361
    def processMessage(self, message):
1363
1362
        """Handle messages."""
1364
 
        # pylint: disable=W0201
1365
1363
        if message.type == self.create_response:
1366
1364
            self.new_id = message.new.node
1367
1365
            self.new_parent_id = message.new.parent_node
1406
1404
 
1407
1405
    def processMessage(self, message):
1408
1406
        """Handle messages."""
1409
 
        # pylint: disable=W0201
1410
1407
        if message.type == protocol_pb2.Message.PROTOCOL_VERSION:
1411
1408
            self.other_protocol_version = message.protocol.version
1412
1409
            self.done()
1520
1517
 
1521
1518
    def _start(self):
1522
1519
        """Send the FREE_SPACE_INQUIRY message to the server."""
1523
 
        # pylint: disable=W0201
1524
1520
        message = protocol_pb2.Message()
1525
1521
        message.type = protocol_pb2.Message.FREE_SPACE_INQUIRY
1526
1522
        message.free_space_inquiry.share_id = self.share_id
1529
1525
 
1530
1526
    def processMessage(self, message):
1531
1527
        """Process the answer from the server."""
1532
 
        # pylint: disable=W0201
1533
1528
        if message.type == protocol_pb2.Message.FREE_SPACE_INFO:
1534
1529
            self.free_bytes = message.free_space_info.free_bytes
1535
1530
            self.done()
1544
1539
 
1545
1540
    def _start(self):
1546
1541
        """Send the FREE_SPACE_INQUIRY message to the server."""
1547
 
        # pylint: disable=W0201
1548
1542
        message = protocol_pb2.Message()
1549
1543
        message.type = protocol_pb2.Message.ACCOUNT_INQUIRY
1550
1544
        self.sendMessage(message)
1552
1546
 
1553
1547
    def processMessage(self, message):
1554
1548
        """Process the answer from the server."""
1555
 
        # pylint: disable=W0201
1556
1549
        if message.type == protocol_pb2.Message.ACCOUNT_INFO:
1557
1550
            self.purchased_bytes = message.account_info.purchased_bytes
1558
1551
            self.done()
1682
1675
 
1683
1676
class StorageClientFactory(ClientFactory):
1684
1677
    """StorageClient factory."""
1685
 
    # pylint: disable=W0232
 
1678
 
1686
1679
    protocol = StorageClient
1687
1680
 
1688
1681
 
1735
1728
        if not self.valid_limit(limit):
1736
1729
            raise ValueError('Read limit must be greater than 0.')
1737
1730
        self._readLimit = limit
1738
 
    # it's a property, pylint: disable=W0212
 
1731
 
1739
1732
    readLimit = property(lambda self: self._readLimit, _set_read_limit)
1740
1733
    writeLimit = property(lambda self: self._writeLimit, _set_write_limit)
1741
 
    # pylint: enable=W0212
1742
1734
 
1743
1735
    def callLater(self, period, func, *args, **kwargs):
1744
1736
        """Wrapper around L{reactor.callLater} for test purpose."""