__init__
PYL-W020117 @endpoint(api=True)
18 def handle_api_get_which_iptables(self, http_context):
19 try:
20 self.iptables = subprocess.check_output(['which', 'iptables']).decode().strip()21 except subprocess.CalledProcessError as e:
22 raise EndpointError(_('Iptables is not installed on this host'))
23
88 :rtype: dict in load mode
89 """
90
91 self.fstab_config = FSTabConfig(path='/etc/fstab') 92 self.fstab_config.load()
93 return self.fstab_config.tree.to_dict()
94
83 progress_callback(message=message, done=self.current_items, total=self.total_items)
84
85 def stop(self):
86 self.done = True 87
88 cache = apt.Cache()
89 ack = Progress()
Defining an instance attribute outside __init__
affects the readability of code. It is expected to find all the attributes an instance may have by reading its __init__
method. If there is a need to initialize attribute via sub-initialization methods, it is recommended to assign attributes to None
in the init then call the sub-initialization methods.