本文整理汇总了Python中zeroless.Client.connect_local方法的典型用法代码示例。如果您正苦于以下问题:Python Client.connect_local方法的具体用法?Python Client.connect_local怎么用?Python Client.connect_local使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zeroless.Client
的用法示例。
在下文中一共展示了Client.connect_local方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_data_is_not_bytes
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def test_data_is_not_bytes(self):
client = Client()
client.connect_local(port=7050)
push = client.push()
with pytest.raises(TypeError):
push(u'msg')
示例2: test_port_under_range
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例3: test_there_was_no_connection_to_disconnect
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例4: test_subscribed_topics_are_not_bytes
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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'])
示例5: test_connection_after_pattern_was_established
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例6: test_disconnect_all
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def test_disconnect_all(self):
client = Client()
client.connect_local(port=1024)
client.connect_local(port=1025)
client.connect_local(port=1026)
client.connect_local(port=1027)
client.disconnect_all()
client.connect_local(port=1024)
client.connect_local(port=1025)
client.connect_local(port=1026)
client.connect_local(port=1027)
示例7: test_port_on_range
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例8: test_connection_already_exist
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例9: test_pair_client_cannot_connect_more_than_once
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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)
示例10: listen_for_pub_with_embedded_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def listen_for_pub_with_embedded_topic():
client = Client()
client.connect_local(port=7894)
return client.sub(topics=[b'sh'])
示例11: import
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
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")
示例12: Client
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
from aura.managers import StorageManager as db
from aura.managers import SemanticManager as graph
from zeroless import Client, Server
from aura.managers import helpers
import json
zmq_broker = Client()
zmq_broker.connect_local(port=helpers.ports["broker"])
push_to_broker = zmq_broker.push()
zmq_task = Client()
zmq_task.connect_local(port=helpers.ports["task_manager"])
push_to_task = zmq_task.push()
def verify(collection, obj_id):
return db.get(collection, obj_id) != None
def create(collection, obj):
if not verify(collection, obj["@id"]):
graph.parse(json.dumps(obj))
db.store(collection, obj)
else:
print("Already have " + str(obj["@id"]) + " in database.")
def notify_unknown_object(obj_type, obj_id):
obj = {}
obj["id"] = obj_id
obj["type"] = obj_type
示例13: pair
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def pair():
client = Client()
client.connect_local(port=7890)
send, _ = client.pair()
return send
示例14: listen_for_pub
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def listen_for_pub():
client = Client()
client.connect_local(port=7893)
return client.sub()
示例15: listen_for_pub_with_empty_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import connect_local [as 别名]
def listen_for_pub_with_empty_topic():
client = Client()
client.connect_local(port=7896)
return client.sub()