def __init__(self, base, ip_addr): self._base = base self._ip_addr = ip_addr self._dmn_config = ini.Daemon(self._base, self._ip_addr) self._heading = ('Global', 'Local') self._lang = None for heading in self._heading: setattr(self, f'_get{heading}Heading', self._get_heading(heading))
def __init__(self, base, ip_addr): self._base = base self._ip_addr = ip_addr self._sw_config = ini.SWConfig(self._base) self._dmn_config = ini.Daemon(self._base, self._ip_addr) self._dmn_ui = None self._ssh = periphery.SSH(self._base, self._ip_addr) self._top = device.USBTop(self._base, self._ip_addr) self._interface = { self._ssh: (self._ssh.isOpen, self._ssh.close), self._top: (self._top.isRunning, self._top.cancel) } self._log = log.Manager(self._base) self._lang = LangDaemon
def __init__(self, base, ip_addr): self._base = base self._ip_addr = ip_addr self._dmn_config = ini.Daemon(self._base, self._ip_addr) self._utl_type = namedtuple('utl_type', 'hubctrl uhubctl') self._loc = self._utl_type('-h', '-l') self._port = self._utl_type('-P', '-p') self._action = self._utl_type('-p', '-a') self.on = None self.off = None self._actions = {'on': 1, 'off': 0} for action in self._actions: setattr(self, action, self._get_action(action))
def load_action(self): """ Load the daemon to the main configuration """ if form_empty(self._form_req): return self._log.setError(LangFormValidation.FormEmptyError) if form_valid(self._form_ip): return self._log.setError(LangFormValidation.FormValidError) _ip_addr = self.dmn_addr.text() try: self._dmn_manage.load(_ip_addr) except ini.InsertError: return self._log.setError(f'{_ip_addr} {LangConfig.InsertError}') _dmn_config = ini.Daemon(self._base, _ip_addr) for form in self._setter_param: if self._setter_param[form] != form.text(): setattr(_dmn_config, form.objectName(), form.text()) _dmn_config.write() self.close()
def __init__(self, base, ip_addr): super(DaemonConfigUI, self).__init__(parent=base) uic.loadUi('ui/modal/DaemonConfig.ui', self) self.setAttribute(Qt.WA_DeleteOnClose) self._base = base self._ip_addr = ip_addr self.setWindowTitle(f'{self.windowTitle()} {self._ip_addr}') self._interface_manager = InterfaceManager(self) self.config = ini.Daemon(self._base, self._ip_addr) self.form_req = ( self.dmn_name, self.dmn_port, self.ssh, self.hub, self.sniffer ) _header = self.hub_cfg_param.horizontalHeader() _header.setSectionResizeMode(0, QHeaderView.ResizeToContents) _header.setSectionResizeMode(1, QHeaderView.Stretch) _header = self.hub_cfg_param.verticalHeader() _header.setSectionResizeMode(QHeaderView.ResizeToContents) _hub_cfg = listdir('hub') if _hub_cfg: self.hub_cfg.addItems([path.splitext(_cfg)[0] for _cfg in _hub_cfg if _cfg.endswith('.json')]) self.hub_cfg.currentTextChanged.connect(self._hub_cfg_update) self.apply_btn.clicked.connect(self.apply_action) self.cancel_btn.clicked.connect(self.close) self._interface_manager.setup()