我是Python和气流的新手。尝试如下实现一个传感器,错误显示“AttributeError:'mySensor'object has no attribute'l'”我查看了其他属性错误问题,但我不知道我的错误中的“l”来自何处。有人能帮我解释一下吗?以下是mySensor的全部课程。非常感谢。在
class mySensor(SFTPSensor):
"""
Subclass of SFTPSensor to override the poke() method
"""
template_fields = "previous_month"
@apply_defaults
def __init__(self,
last_day_previous_month,
*args,
**kwargs):
self.previous_month = previous_month
super(mySensor, self).__init__(*args, **kwargs)
def poke(self, context):
remote_path = self.path+"file_to_check"+self.previous_month
file_count = len(self.hook.list_directory(remote_path))
if file_count == 0:
return False
else:
logging.info("Found %d files", file_count)
return True
以及我使用传感器的地方
^{pr2}$
我和一个气流操作员也遇到了类似的错误:
要解决此问题,请检查
template_fields
与您的__init__
参数相比是否有意义。在您有
template_fields = "previous_month"
,但在您的__init__
中没有这样的参数。在在我的例子中,}确实对齐。但是,我用了}。逗号必须存在。在
__init__
和{template_fields = ("myfield")
而不是{相关问题 更多 >
编程相关推荐