Example #1
0
    def _encode_signed_varint(cls, value):
        data = []

        def write(x):
            data.append(x)

        protobuf_encoder._SignedVarintEncoder()(write, value)
        return b''.join(data)
Example #2
0
    def _encode_signed_varint(cls, value):
        data = []

        def write(x):
            data.append(x)

        protobuf_encoder._SignedVarintEncoder()(write, value)
        return b''.join(data)
Example #3
0
import base64
import os
import unittest
import websocket
import krpc.schema.KRPC_pb2 as KRPC
import google.protobuf
from google.protobuf.internal.decoder import _DecodeVarint, _DecodeSignedVarint
from google.protobuf.internal import encoder as protobuf_encoder
from google.protobuf.internal.wire_format import ZigZagEncode, ZigZagDecode


# The following unpacks the internal protobuf decoders, whose signature
# depends on the version of protobuf installed
# pylint: disable=invalid-name,protected-access
_pb_SignedVarintEncoder = protobuf_encoder._SignedVarintEncoder()
_pb_version = google.protobuf.__version__.split('.')
if int(_pb_version[0]) >= 3 and int(_pb_version[1]) >= 4:
    # protobuf v3.4.0 and above
    def _SignedVarintEncoder(write, value):
        return _pb_SignedVarintEncoder(write, value, True)
else:
    # protobuf v3.3.0 and below
    _SignedVarintEncoder = _pb_SignedVarintEncoder
# pylint: enable=invalid-name,protected-access


class WebSocketsTest(unittest.TestCase):

    @staticmethod
    def address():
        return '127.0.0.1'
Example #4
0
import base64
import os
import unittest
import websocket
import krpc.schema.KRPC_pb2 as KRPC
import google.protobuf
from google.protobuf.internal.decoder import _DecodeVarint, _DecodeSignedVarint
from google.protobuf.internal import encoder as protobuf_encoder
from google.protobuf.internal.wire_format import ZigZagEncode, ZigZagDecode

# The following unpacks the internal protobuf decoders, whose signature
# depends on the version of protobuf installed
# pylint: disable=invalid-name,protected-access
_pb_SignedVarintEncoder = protobuf_encoder._SignedVarintEncoder()
_pb_version = google.protobuf.__version__.split('.')
if int(_pb_version[0]) >= 3 and int(_pb_version[1]) >= 4:
    # protobuf v3.4.0 and above
    def _SignedVarintEncoder(write, value):
        return _pb_SignedVarintEncoder(write, value, True)
else:
    # protobuf v3.3.0 and below
    _SignedVarintEncoder = _pb_SignedVarintEncoder
# pylint: enable=invalid-name,protected-access


class WebSocketsTest(unittest.TestCase):
    @staticmethod
    def address():
        return '127.0.0.1'

    @staticmethod