我正在尝试为 django 创建一个可以运行的自定义命令python manage.py cert_transparency,我已经快完成了,但遇到了一些麻烦。这个的目的是在后台创建一个 24/7 运行的命令,我只是在 docker 容器中运行它。我收到此错误消息certificate_update: 0cert [00:00, ?cert/s]Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/src/scraper/management/commands/cert_transparency.py", line 184, in handle certstream.listen_for_events(callback, url=certstream_url)NameError: name 'callback' is not defined基本上我想做的只是将此脚本作为 django 中的自定义管理命令导入。
1 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
您定义了该.callback(…)
方法两次,所以我认为您应该删除其中之一。.callback(…)
您可以使用以下方法传递对该方法的引用self.callback
:
def handle(self, *args, **options): # … certstream.listen_for_events(self.callback, url=certstream_url)
添加回答
举报
0/150
提交
取消