【发布时间】:2019-08-26 21:53:13
【问题描述】:
我正在将 Scapy 与 Volttron 相结合,并且我想在数据包进入并具有某些功能时发布到主题。但是,我一直遇到这个错误:
Traceback(最近一次调用最后一次):文件“sniff.py”,第 373 行,在 sys.exit(main()) 文件“sniff.py”,第 342 行,在 main utils.vip_main(sniffer, version=version) 文件“/home/jenny/workspace/volttron/volttron/platform/agent/utils.py”,
第 314 行,在 vip_main 中 version=version, **kwargs) 文件“sniff.py”,第 336 行,在嗅探器中 Sniffer(**kwargs) 文件“sniff.py”,第 138 行,在 init 中 self.vip.pubsub.publish('pubsub', "some/topic", message="blah")
文件“/home/jenny/workspace/volttron/volttron/platform/vip/agent/subsystems/pubsub.py”,第 602 行,在发布中 self._save_parameters(result.ident, **kwargs)
文件“/home/jenny/workspace/volttron/volttron/platform/vip/agent/subsystems/pubsub.py”, 第 706 行,在 _save_parameters 中 事件 = self.core().schedule(end_time, self._cancel_event, result_id)
文件“/home/jenny/workspace/volttron/volttron/platform/vip/agent/core.py”, 第 409 行,按计划进行 self._schedule_callback(deadline, event) 文件 "/home/jenny/workspace/volttron/volttron/platform/vip/agent/core.py", 第 417 行,在 _schedule_callback 中 self._schedule_event.set()AttributeError: 'NoneType' 对象没有属性 'set'
最接近我找到的解决方案是RPC crashes with AttributeError: 'NoneType' object has no attribute 'call'。但是,我注意到它们不是完全相同的问题,因此当我尝试那里提供的解决方案并且它对我不起作用时并没有太大的惊喜。
我的代码如下所示:
def sniffer(config_path, **kwargs):
''' Initializations '''
global pkt_counter
global IP_counter
# Defined other parameters here
class Sniffer(Agent):
def __init__(self, **kwargs):
super(Sniffer, self).__init__(**kwargs)
# I am just testing the publish function here
self.vip.pubsub.publish('pubsub', "some/topic", message="blah")
sniff(count=0, iface=conf.iface, prn = self.pkt_action, store=0)
def pkt_action(self, pkt):
#Process every packet, updates values and rises and alert if necessary
# some checks are run here and later a publish is called
谁能告诉我我做错了什么?
编辑:我没有添加我想运行这个脚本,因为我会在终端上运行一个简单的 python 脚本(例如 python somescript.py):没有安装。我尝试这样做的原因是在安装代理并启动它时出现错误。该平台不允许 Scapy 创建和连接套接字。
【问题讨论】:
标签: volttron