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


Python Agent.service_handler["Payload+Command"]方法代码示例

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


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

示例1: test_timeout

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import service_handler["Payload+Command"] [as 别名]
def test_timeout():
    # Create an agent that throws an exception when it receives
    # a payload command packet.
    a = Agent()
    a.bind_udp_sockets()
    a.service_handler["Payload Command"] = Agent.raise_exception

    # Set a timeout that is << delay.
    Agent.TIMEOUT = 0.005

    # Run agent.
    t = threading.Thread(target=Agent.run, args=(a,))
    t.daemon = True
    t.start()

    # Delay
    time.sleep(0.02)

    # Send a payload command packet -- SHUTDOWN
    p = Packet()
    p.service = Supernova.service_id("Payload Command")
    p.dest_node = Supernova.get_my_id()
    Send.send_to_self(p)   

    # Wait for and then assert that thread has exited.
    t.join(0.01)
    assert not t.is_alive()
开发者ID:SpaceVR-O1,项目名称:OverviewOne,代码行数:29,代码来源:test_agent.py

示例2: test_startup_and_shutdown

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import service_handler["Payload+Command"] [as 别名]
def test_startup_and_shutdown():
    # Create an agent that throws an exception when it receives
    # a payload command packet.
    a = Agent()
    a.bind_udp_sockets()
    a.service_handler["Payload Command"] = Agent.raise_exception

    # Run agent.
    t = threading.Thread(target=Agent.run, args=(a,))
    t.daemon = True
    t.start()

    # Send an ACK packet
    p = Packet()
    p.service = Supernova.service_id("Payload Command")
    p.dest_node = Supernova.get_my_id()
    p.ack = 1
    Send.send_to_self(p)   

    # Wait for and then assert that thread has *not* exited.
    t.join(0.01)
    assert t.is_alive()

    # Send a payload command packet -- SHUTDOWN
    p = Packet()
    p.service = Supernova.service_id("Payload Command")
    p.dest_node = Supernova.get_my_id()
    Send.send_to_self(p)   

    # Wait for and then assert that thread has exited.
    t.join(0.01)
    assert not t.is_alive()
开发者ID:SpaceVR-O1,项目名称:OverviewOne,代码行数:34,代码来源:test_agent.py

示例3: main

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import service_handler["Payload+Command"] [as 别名]
def main():
    # Initialize an Agent to print out all command responses
    cmd_handler = PayloadCommandHandler()
    cmd_handler.handlers[PayloadCommandHandler.SHELL_RESP] = Agent.print_it

    a = Agent()
    a.service_handler["Payload Command"] = cmd_handler.dispatch

    # Thread 1: Wait for keyboard events and send packages
    t = threading.Thread(target=thread1_keyboard)
    t.daemon = True
    t.start()

    # Thread 2: Wait for replies and print output
    thread2_network(a)
开发者ID:SpaceVR-O1,项目名称:OverviewOne,代码行数:17,代码来源:run_terminal.py

示例4: main

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import service_handler["Payload+Command"] [as 别名]
def main():
    """ Main entry point for executable. """

    a = Agent()
    Agent.DEBUG = True

    cmd_handler = PayloadCommandHandler()

    # Register some callbacks
    a.service_handler["Payload Command"] = cmd_handler.dispatch;
    a.service_handler["Telemetry Packet"] = Agent.print_it;

    print("Binding UDP sockets")
    a.bind_udp_sockets()

    print("Waiting for bus")
    a.run()
开发者ID:SpaceVR-O1,项目名称:OverviewOne,代码行数:19,代码来源:run_agent.py


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