當前位置: 首頁>>代碼示例>>Python>>正文


Python zeroless.Client類代碼示例

本文整理匯總了Python中zeroless.Client的典型用法代碼示例。如果您正苦於以下問題:Python Client類的具體用法?Python Client怎麽用?Python Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_data_is_not_bytes

    def test_data_is_not_bytes(self):
        client = Client()
        client.connect_local(port=7050)
        push = client.push()

        with pytest.raises(TypeError):
            push(u'msg')
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:7,代碼來源:test_exceptions.py

示例2: test_client_addresses_property

    def test_client_addresses_property(self):
        client = Client()
        addresses = (('10.0.0.1', 1567), ('10.0.0.2', 1568), ('10.0.0.3', 1569))

        for ip, port in addresses:
            client.connect(ip, port)

        assert client.addresses == addresses
開發者ID:jkhoogland,項目名稱:python-zeroless,代碼行數:8,代碼來源:test_client_server.py

示例3: test_port_under_range

    def test_port_under_range(self):
        client = Client()
        with pytest.raises(ValueError):
           client.connect_local(port=1023)

        with pytest.raises(ValueError):
           client.disconnect_local(port=1023)

        with pytest.raises(ValueError):
            Server(port=1023)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:10,代碼來源:test_exceptions.py

示例4: test_connection_already_exist

    def test_connection_already_exist(self):
        client = Client()
        client.connect_local(port=1024)

        with pytest.raises(ValueError):
            client.connect_local(port=1024)

        client.disconnect_local(port=1024)
        client.connect_local(port=1024)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:9,代碼來源:test_exceptions.py

示例5: test_connection_after_pattern_was_established

    def test_connection_after_pattern_was_established(self):
        client = Client()
        listen_for_push = client.pull()

        client.connect_local(port=1024)

        with pytest.raises(ValueError):
            client.connect_local(port=1024)

        client.disconnect_local(port=1024)

        with pytest.raises(ValueError):
            client.disconnect_local(port=1024)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:13,代碼來源:test_exceptions.py

示例6: test_subscribed_topics_are_not_bytes

    def test_subscribed_topics_are_not_bytes(self):
        client = Client()
        client.connect_local(port=7099)

        client.sub(topics=[b'topic1'])

        with pytest.raises(TypeError):
            client.sub(topics=[u'topic1'])

        with pytest.raises(TypeError):
            client.sub(topics=[b'topic1', u'topic2'])
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:11,代碼來源:test_exceptions.py

示例7: test_there_was_no_connection_to_disconnect

    def test_there_was_no_connection_to_disconnect(self):
        client = Client()
        client.connect_local(port=1024)

        with pytest.raises(ValueError):
            client.disconnect_local(port=1025)

        client.disconnect_local(port=1024)

        with pytest.raises(ValueError):
            client.disconnect_local(port=1024)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:11,代碼來源:test_exceptions.py

示例8: test_port_on_range

 def test_port_on_range(self):
     client = Client()
     client.connect_local(port=1024)
     client.disconnect_local(port=1024)
     client.connect_local(port=7000)
     client.disconnect_local(port=7000)
     client.connect_local(port=65535)
     client.disconnect_local(port=65535)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:8,代碼來源:test_exceptions.py

示例9: test_pair_client_cannot_connect_more_than_once

    def test_pair_client_cannot_connect_more_than_once(self):
        client = Client()
        client.connect_local(port=7200)
        client.connect_local(port=7201)

        with pytest.raises(RuntimeError):
            client.pair()

        client = Client()
        client.connect_local(port=7200)

        client.pair()

        with pytest.raises(RuntimeError):
            client.connect_local(port=7201)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:15,代碼來源:test_exceptions.py

示例10: import

import logging

from zeroless import (Client, log)

# Setup console logging
consoleHandler = logging.StreamHandler()
log.setLevel(logging.DEBUG)
log.addHandler(consoleHandler)

# Connects the client to as many servers as desired
client = Client()
client.connect_local(port=12345)

# Initiate a push client
# And assigns a callable to push messages
push = client.push()

for msg in [b"Msg1", b"Msg2", b"Msg3"]:
    push(msg)
開發者ID:EnTeQuAk,項目名稱:python-zeroless,代碼行數:19,代碼來源:pushPullClient.py

示例11: import

from zeroless import (Client, Server)
import json
from aura.managers import SemanticManager as graph
from aura.managers import StorageManager as db
from aura.managers import helpers

zmq_device = Client()
zmq_device.connect_local(port=helpers.ports['device_manager'])
push_to_device = zmq_device.push()

def create_condition(condition):
    print("create_condition")
    # TaskManager -> StorageManager
    db.store('conditions', condition)


def update_condition():
    # TaskManager -> StorageManager
    print("update_condition")


def remove_condition():
    # TaskManager -> StorageManager
    print("remove_condition")


def send_command(device, command):
    # TaskManager -> DeviceManager
    print("send_command")

開發者ID:AuraMiddleware,項目名稱:aura-middleware,代碼行數:29,代碼來源:TaskManager.py

示例12: listen_for_pub_with_empty_topic

def listen_for_pub_with_empty_topic():
    client = Client()
    client.connect_local(port=7896)
    return client.sub()
開發者ID:jkhoogland,項目名稱:python-zeroless,代碼行數:4,代碼來源:test_pubsub.py

示例13: import

import logging

from zeroless import (Client, log)

# Setup console logging
consoleHandler = logging.StreamHandler()
log.setLevel(logging.DEBUG)
log.addHandler(consoleHandler)

# Connects the client to as many servers as desired
client = Client()
client.connect_local(port=12345)

# Initiate a subscriber client
# Assigns an iterable to wait for incoming messages with the topic 'sh'
listen_for_pub = client.sub(topics=[b'sh'])

for topic, msg in listen_for_pub:
    print(topic, ' - ', msg)
開發者ID:davinirjr,項目名稱:zeroless,代碼行數:19,代碼來源:pubSubServer.py

示例14: import

import logging

from zeroless import (Client, log)

# Setup console logging
consoleHandler = logging.StreamHandler()
log.setLevel(logging.DEBUG)
log.addHandler(consoleHandler)

# Connects the client to a single server
client = Client()
client.connect_local(port=12345)

# Initiate a pair client
# And assigns a callable and an iterable
# To both transmit and wait for incoming messages
pair, listen_for_pair = client.pair()

for msg in [b"Msg1", b"Msg2", b"Msg3"]:
    pair(msg)
    response = next(listen_for_pair)
    print(response)
開發者ID:EnTeQuAk,項目名稱:python-zeroless,代碼行數:22,代碼來源:pairClient.py

示例15: pair

def pair():
    client = Client()
    client.connect_local(port=7890)
    send, _ = client.pair()
    return send
開發者ID:EnTeQuAk,項目名稱:python-zeroless,代碼行數:5,代碼來源:test_pair.py


注:本文中的zeroless.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。