def _do_install(self): cmd = install_lib.get_init_dirs_cmd() res = ai_dialog_exec(cmd, msg='Initializing directories...', showcmd=False) if res != 0: return res cmd = install_lib.get_copy_files_cmd() gauge_text_base = 'Copying files...' gauge_text = gauge_text_base gauge_text_prev = gauge_text gauge_percent = 0 gauge_percent_prev = 0 dialog.gauge_start(gauge_text, width=40, height=9) p = ai_popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True) for x in p.stdout: x = x.split() if len(x) == 4 and x[1].endswith('%'): gauge_percent = int(x[1][:-1]) speed = x[2] eta = x[3] gauge_text = gauge_text_base + \ '\nSpeed: ' + speed + \ '\n ETA: ' + eta if gauge_percent != gauge_percent_prev or \ gauge_text != gauge_text_prev: dialog.gauge_update(percent=gauge_percent, text=gauge_text, update_text=True) gauge_text_prev = gauge_text gauge_percent = gauge_percent p.communicate() dialog.gauge_stop() if p.returncode != 0: return p.returncode install_lib.update_mirrorlist() cmd = install_lib.get_configure_cmd() res = ai_dialog_exec(cmd, linger=True, msg='Configuring...', width=75, height=20, showcmd=False) return res
def _exec_thread(self, cmd, msg): p = ai_popen(cmd, universal_newlines=True, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self._add_log_thread(msg) for x in p.stdout: self._add_log_thread(x.rstrip('\n')) p.communicate() return p.returncode
def _exec(self, cmd, msg='', **kwargs): if not gui.started: ai_dialog_exec(cmd, msg=msg, **kwargs) else: from partition_gui import partition_gui p = ai_popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) partition_gui.add_log_lib(msg) partition_gui.add_log_lib('- ' + cmd) for x in p.stdout: partition_gui.add_log_lib(x.rstrip('\n'))
def _copy_files_thread(self): cmd = install_lib.get_copy_files_cmd() text_base = _('Copying files...') text = text_base text_prev = text percent = 0 percent_prev = 0 p = ai_popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True) self._set_progress_thread(text) self._add_log_thread('Copying files...') for x in p.stdout: x = x.split() if len(x) == 4 and x[1].endswith('%'): percent = int(x[1][:-1]) speed = x[2] eta = x[3] text = text_base + \ '\nSpeed: ' + speed + \ '\nETA: ' + eta if percent != percent_prev: self._set_percent_thread(percent) percent_prev = percent if text != text_prev: self._set_progress_thread(text) text_prev = text p.communicate() if p.returncode != 0: self._install_fail_thread() return self._update_mirrorlist_thread()