当前位置: 首页>>代码示例>>Python>>正文


Python Event.setData方法代码示例

本文整理汇总了Python中wishbone.event.Event.setData方法的典型用法代码示例。如果您正苦于以下问题:Python Event.setData方法的具体用法?Python Event.setData怎么用?Python Event.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wishbone.event.Event的用法示例。


在下文中一共展示了Event.setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_module_funnel

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_funnel():

    actor_config = ActorConfig('funnel', 100, 1, {})
    funnel = Funnel(actor_config)
    funnel.pool.queue.outbox.disableFallThrough()

    funnel.pool.createQueue("one")
    funnel.pool.queue.one.disableFallThrough()

    funnel.pool.createQueue("two")
    funnel.pool.queue.two.disableFallThrough()

    funnel.start()

    event_one = Event("test")
    event_one.setData("one")

    event_two = Event("test")
    event_two.setData("two")

    funnel.pool.queue.one.put(event_one)
    funnel.pool.queue.two.put(event_two)

    assert getter(funnel.pool.queue.outbox).raw()["test"]["data"] in ["one", "two"]
    assert getter(funnel.pool.queue.outbox).raw()["test"]["data"] in ["one", "two"]

    funnel.stop()
开发者ID:tf198,项目名称:wishbone,代码行数:29,代码来源:test_module_funnel.py

示例2: test_module_loglevelfilter

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_loglevelfilter():

    actor_config = ActorConfig('loglevelfilter', 100, 1, {})
    loglevelfilter = LogLevelFilter(actor_config)
    loglevelfilter.pool.queue.inbox.disableFallThrough()
    loglevelfilter.pool.queue.outbox.disableFallThrough()
    loglevelfilter.start()

    e_one = Event('test')
    e_one.setData((7, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.'))

    e_two = Event('test')
    e_two.setData((1, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.'))

    loglevelfilter.pool.queue.inbox.put(e_one)
    loglevelfilter.pool.queue.inbox.put(e_two)

    one=getter(loglevelfilter.pool.queue.outbox)
    assert one.data == (1, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.')
    try:
        two=getter(loglevelfilter.pool.queue.outbox)
    except Exception:
        assert True
    else:
        assert False
开发者ID:tf198,项目名称:wishbone,代码行数:27,代码来源:test_module_loglevelfilter.py

示例3: test_module_jsonvalidate

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_jsonvalidate():

    actor_config = ActorConfig('jsonvalidate', 100, 1, {})

    with open("/tmp/jsonvalidate.jsonschema", "w") as j:
        j.write('{"type": "object", "properties": {"one": { "type": "integer"}}}')

    jsonvalidate = JSONValidate(actor_config, "/tmp/jsonvalidate.jsonschema")

    jsonvalidate.pool.queue.inbox.disableFallThrough()
    jsonvalidate.pool.queue.outbox.disableFallThrough()
    jsonvalidate.pool.queue.failed.disableFallThrough()
    jsonvalidate.start()

    valid = Event('valid')
    valid.setData({"one": 1})

    invalid = Event('invalid')
    invalid.setData({"one": "one"})

    jsonvalidate.pool.queue.inbox.put(valid)
    valid_event = getter(jsonvalidate.pool.queue.outbox)

    jsonvalidate.pool.queue.inbox.put(invalid)
    invalid_event = getter(jsonvalidate.pool.queue.failed)

    os.remove("/tmp/jsonvalidate.jsonschema")
    assert valid_event.data == {"one": 1}
    assert invalid_event.data == {"one": "one"}
开发者ID:tf198,项目名称:wishbone,代码行数:31,代码来源:test_module_jsonvalidate.py

示例4: test_module_fanout

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_fanout():

    actor_config = ActorConfig('fanout', 100, 1, {})
    fanout = Fanout(actor_config, deep_copy=True)
    fanout.pool.queue.inbox.disableFallThrough()

    fanout.pool.createQueue("one")
    fanout.pool.queue.one.disableFallThrough()

    fanout.pool.createQueue("two")
    fanout.pool.queue.two.disableFallThrough()

    fanout.start()

    e = Event('test')
    e.setData("hello")

    fanout.pool.queue.inbox.put(e)
    one = getter(fanout.pool.queue.one)
    two = getter(fanout.pool.queue.two)

    fanout.stop()

    assert one.raw()["test"]["data"] == "hello"
    assert two.raw()["test"]["data"] == "hello"
    assert id(one) != id(two)
开发者ID:tf198,项目名称:wishbone,代码行数:28,代码来源:test_module_fanout.py

示例5: test_module_roundrobin

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_roundrobin():

    actor_config = ActorConfig('roundrobin', 100, 1, {})
    roundrobin = RoundRobin(actor_config)

    roundrobin.pool.queue.inbox.disableFallThrough()

    roundrobin.pool.createQueue("one")
    roundrobin.pool.queue.one.disableFallThrough()

    roundrobin.pool.createQueue("two")
    roundrobin.pool.queue.two.disableFallThrough()

    roundrobin.start()

    event_one = Event("test")
    event_one.setData("one")

    event_two = Event("test")
    event_two.setData("two")

    roundrobin.pool.queue.inbox.put(event_one)
    roundrobin.pool.queue.inbox.put(event_two)

    assert getter(roundrobin.pool.queue.one).raw()["test"]["data"] in ["one", "two"]
    assert getter(roundrobin.pool.queue.two).raw()["test"]["data"] in ["one", "two"]

    roundrobin.stop()
开发者ID:tf198,项目名称:wishbone,代码行数:30,代码来源:test_module_roundrobin.py

示例6: test_file_load

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_file_load():

    import os
    import yaml
    import shutil

    os.mkdir('/tmp/wishbone_tests')
    actor_config = ActorConfig('match', 100, 1, {})
    match = Match(actor_config, location="/tmp/wishbone_tests")
    match.pool.createQueue("file")
    match.pool.queue.file.disableFallThrough()
    match.pool.queue.inbox.disableFallThrough()

    #Test 1
    rule_1 = {
        "condition": [
            {"file": "re:.*?one.*"}
        ],
        "queue": [
            {"file": {}}
        ]
    }

    with open('/tmp/wishbone_tests/one.yaml', 'w') as one:
        one.write(yaml.dump(rule_1, default_flow_style=False))
    match.start()
    sleep(1)

    e = Event("test")
    e.setData({"file": "zero one two"})
    match.pool.queue.inbox.put(e)

    assert getter(match.pool.queue.file).data["file"] == "zero one two"

    #Test 2
    rule_2 = {
        "condition": [
            {"file": "re:.*?two.*"}
        ],
        "queue": [
            {"file": {}}
        ]
    }
    with open('/tmp/wishbone_tests/two.yaml', 'w') as one:
        one.write(yaml.dump(rule_2, default_flow_style=False))
    sleep(1)

    e = Event("test")
    e.setData({"file": "one two three"})
    match.pool.queue.inbox.put(e)
    assert getter(match.pool.queue.file).data["file"] == "one two three"
    shutil.rmtree('/tmp/wishbone_tests')
开发者ID:tf198,项目名称:wishbone,代码行数:54,代码来源:test_module_match.py

示例7: test_module_humanlogformat

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_humanlogformat():

    actor_config = ActorConfig('humanlogformat', 100, 1, {})
    humanlogformat = HumanLogFormat(actor_config, colorize=False, ident='setup.py')
    humanlogformat.pool.queue.inbox.disableFallThrough()
    humanlogformat.pool.queue.outbox.disableFallThrough()
    humanlogformat.start()

    e = Event('test')
    e.setData(Log(1367682301.430527, 6, 3342, 'Router', 'Received SIGINT. Shutting down.'))

    humanlogformat.pool.queue.inbox.put(e)
    one = getter(humanlogformat.pool.queue.outbox)
    assert one.data == "2013-05-04T17:45:01 setup.py[3342]: informational Router: Received SIGINT. Shutting down."
开发者ID:tf198,项目名称:wishbone,代码行数:16,代码来源:test_module_humanlogformat.py

示例8: test_module_msgpackencode

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_msgpackencode():

    actor_config = ActorConfig("msgpackencode", 100, 1, {})
    msgpackencode = MSGPackEncode(actor_config)

    msgpackencode.pool.queue.inbox.disableFallThrough()
    msgpackencode.pool.queue.outbox.disableFallThrough()
    msgpackencode.start()

    e = Event("test")
    e.setData([1, 2, 3])

    msgpackencode.pool.queue.inbox.put(e)
    one = getter(msgpackencode.pool.queue.outbox)
    assert one.data == "\x93\x01\x02\x03"
开发者ID:tf198,项目名称:wishbone,代码行数:17,代码来源:test_module_msgpackencode.py

示例9: test_module_jsonencode

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_jsonencode():

    actor_config = ActorConfig('jsonencode', 100, 1, {})
    jsonencode = JSONEncode(actor_config)

    jsonencode.pool.queue.inbox.disableFallThrough()
    jsonencode.pool.queue.outbox.disableFallThrough()
    jsonencode.start()

    e = Event('test')
    e.setData(["one", "two", "three"])

    jsonencode.pool.queue.inbox.put(e)
    one = getter(jsonencode.pool.queue.outbox)
    assert one.data == '["one", "two", "three"]'
开发者ID:tf198,项目名称:wishbone,代码行数:17,代码来源:test_module_jsonencode.py

示例10: test_module_header

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_header():

    actor_config = ActorConfig('header', 100, 1, {})
    header = Header(actor_config, header={"greeting": "hello"})

    header.pool.queue.inbox.disableFallThrough()
    header.pool.queue.outbox.disableFallThrough()
    header.start()

    e = Event('test')
    e.setData('hello')

    header.pool.queue.inbox.put(e)
    one = getter(header.pool.queue.outbox)
    assert one.getHeaderValue("header", "greeting") == "hello"
开发者ID:tf198,项目名称:wishbone,代码行数:17,代码来源:test_module_header.py

示例11: test_module_msgpackdecode

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_module_msgpackdecode():

    actor_config = ActorConfig('msgpackdecode', 100, 1, {})
    msgpackdecode = MSGPackDecode(actor_config)

    msgpackdecode.pool.queue.inbox.disableFallThrough()
    msgpackdecode.pool.queue.outbox.disableFallThrough()
    msgpackdecode.start()

    e = Event('test')
    e.setData('\x93\x01\x02\x03')

    msgpackdecode.pool.queue.inbox.put(e)
    one = getter(msgpackdecode.pool.queue.outbox)
    assert one.data == [1, 2, 3]
开发者ID:tf198,项目名称:wishbone,代码行数:17,代码来源:test_module_msgpackdecode.py

示例12: test_regex

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_regex():

    rule = {"regex": {
        "condition": [
            {"regex": "re:.*?two.*"}
        ],
        "queue": [
            {"regex": {}}
        ]
    }}

    actor = generate_actor(rule)
    e = Event("test")
    e.setData({"regex": "one two three"})
    actor.pool.queue.inbox.put(e)
    assert getter(actor.pool.queue.regex).data["regex"] == "one two three"
开发者ID:tf198,项目名称:wishbone,代码行数:18,代码来源:test_module_match.py

示例13: test_equal_to

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_equal_to():

    rule = {"equal": {
        "condition": [
            {"equal": "=:100"}
        ],
        "queue": [
            {"equal": {}}
        ]
    }}

    actor = generate_actor(rule)
    one = Event("test")
    one.setData({"equal": "100"})
    actor.pool.queue.inbox.put(one)
    assert int(getter(actor.pool.queue.equal).data["equal"]) == 100
开发者ID:tf198,项目名称:wishbone,代码行数:18,代码来源:test_module_match.py

示例14: test_smaller_than

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_smaller_than():

    rule = {"smaller": {
        "condition": [
            {"smaller": "<:100"}
        ],
        "queue": [
            {"smaller": {}}
        ]
    }}

    actor = generate_actor(rule)
    one = Event("test")
    one.setData({"smaller": "99"})
    actor.pool.queue.inbox.put(one)
    assert int(getter(actor.pool.queue.smaller).data["smaller"]) < 100
开发者ID:tf198,项目名称:wishbone,代码行数:18,代码来源:test_module_match.py

示例15: test_bigger_than

# 需要导入模块: from wishbone.event import Event [as 别名]
# 或者: from wishbone.event.Event import setData [as 别名]
def test_bigger_than():

    rule = {"bigger": {
        "condition": [
            {"bigger": ">:10"}
        ],
        "queue": [
            {"bigger": {}}
        ]
    }}

    actor = generate_actor(rule)
    e = Event("test")
    e.setData({"bigger": "100"})
    actor.pool.queue.inbox.put(e)
    assert getter(actor.pool.queue.bigger).data["bigger"] == "100"
开发者ID:tf198,项目名称:wishbone,代码行数:18,代码来源:test_module_match.py


注:本文中的wishbone.event.Event.setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。