def start(self): """ Start the host setup session. """ self.set_config_bytes() self.make_mode = "system" maker = MakeHosts(self) maker.make()
def __init__(self, parent): """ Initialize a new instance of this class. Retrieve configuration from the main dialog to make a new hosts file. :param parent: An instance of :class:`~gui.qdialog_d.QDialogDaemon` class to fetch settings from. :type parent: :class:`~gui.qdialog_d.QDialogDaemon` .. warning:: :attr:`parent` MUST NOT be set as `None`. """ QtCore.QThread.__init__(self, parent) MakeHosts.__init__(self, parent)
def start(cls,silent=0,mode='system'): cls.make_mode=mode #Possible values are 'utf-8', 'ansi' and 'system'. cls.silent=silent cls.set_platform() cls.check_connection() cls.update = cls.check_update() if cls.check_version(): cls.show_status("Update found!") cls.fetch_update() RetrieveData.unpack() RetrieveData.connect_db() cls.set_func_list() cls.select_all() cls.set_config_bytes() mk=MakeHosts(cls) mk.make() RetrieveData.clear() return 1 else: cls.show_status("No update!") RetrieveData.clear() return 0
def session_daemon(self): """ Operations processed while running a TUI session of `Hosts Setup Utility`. :return: A flag indicating whether to reload the current session or all operations have been finished. The return value could only be `0` or `1`. To be specific: ==== ========= flag operation ==== ========= 0 Finish 1 Reload ==== ========= .. note:: Reload operation is called only when a new data file is retrieved from server. :rtype: int .. note:: IF hosts data file does not exists in current working directory, a warning message box would popup. And operations to change the hosts file on current system could be done only until a new data file has been downloaded. """ screen = self._stdscr.subwin(0, 0, 0, 0) screen.keypad(1) # Draw Menu self.banner() self.footer() # Key Press Operations key_in = None tab = 0 pos = 0 tab_entry = [self.configure_settings, self.select_func] while key_in != 27: self.setup_menu() self.status() self.process_bar(0, 0, 0, 0) for i, sec in enumerate(tab_entry): tab_entry[i](pos if i == tab else None) if key_in is None: test = self.settings[0][2][0]["test_url"] self.check_connection(test) key_in = screen.getch() if key_in == 9: if self.choice == [[], []]: tab = 0 else: tab = not tab pos = 0 elif key_in in self._hot_keys: pos = tab_entry[tab](pos, key_in) elif key_in in self._ops_keys: if key_in == curses.KEY_F10: if self._funcs == [[], []]: self.messagebox( "No data file found! Press F6 to get " "data file first.", 1) else: msg = "Apply Changes to hosts file?" confirm = self.messagebox(msg, 2) if confirm: self.set_config_bytes() self.make_mode = "system" maker = MakeHosts(self) maker.make() self.move_hosts() elif key_in == curses.KEY_F5: self._update = self.check_update() elif key_in == curses.KEY_F6: if self._update == {}: self._update = self.check_update() # Check if data file up-to-date if self.new_version(): self.fetch_update() return 1 else: self.messagebox("Data file is up-to-date!", 1) else: pass return 0
def session_daemon(self): """ Operations processed while running a TUI session of `Hosts Setup Utility`. :return: A flag indicating whether to reload the current session or all operations have been finished. The return value could only be `0` or `1`. To be specific: ==== ========= flag operation ==== ========= 0 Finish 1 Reload ==== ========= .. note:: Reload operation is called only when a new data file is retrieved from server. :rtype: int .. note:: IF hosts data file does not exists in current working directory, a warning message box would popup. And operations to change the hosts file on current system could be done only until a new data file has been downloaded. """ screen = self._stdscr.subwin(0, 0, 0, 0) screen.keypad(1) # Draw Menu self.banner() self.footer() # Key Press Operations key_in = None tab = 0 pos = 0 tab_entry = [self.configure_settings, self.select_func] while key_in != 27: self.setup_menu() self.status() self.process_bar(0, 0, 0, 0) for i, sec in enumerate(tab_entry): tab_entry[i](pos if i == tab else None) if key_in is None: test = self.settings[0][2][0]["test_url"] self.check_connection(test) key_in = screen.getch() if key_in == 9: if self.choice == [[], []]: tab = 0 else: tab = not tab pos = 0 elif key_in in self._hot_keys: pos = tab_entry[tab](pos, key_in) elif key_in in self._ops_keys: if key_in == curses.KEY_F10: if self._funcs == [[], []]: self.messagebox("No data file found! Press F6 to get " "data file first.", 1) else: msg = "Apply Changes to hosts file?" confirm = self.messagebox(msg, 2) if confirm: self.set_config_bytes() self.make_mode = "system" maker = MakeHosts(self) maker.make() self.move_hosts() elif key_in == curses.KEY_F5: self._update = self.check_update() elif key_in == curses.KEY_F6: if self._update == {}: self._update = self.check_update() # Check if data file up-to-date if self.new_version(): self.fetch_update() return 1 else: self.messagebox("Data file is up-to-date!", 1) else: pass return 0