def make_dirs(self): for target in self.requirements: dest = self.root + target["name"] if not os.path.exists(dest): debug("Create: {}".format(dest)) mod = int(target["mode"],8) debug("Mode: {}".format(oct(mod))) os.makedirs(dest, mode=mod)
def detect(self): isPlymouth = target_env_call(["which", "plymouth"]) debug("which plymouth exit code: {!s}".format(isPlymouth)) if isPlymouth == 0: libcalamares.globalstorage.insert("hasPlymouth", True) else: libcalamares.globalstorage.insert("hasPlymouth", False) return isPlymouth
def detect_plymouth(): """ Checks existence (runnability) of plymouth in the target system. @return True if plymouth exists in the target, False otherwise """ # Used to only check existence of path /usr/bin/plymouth in target isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) debug("which plymouth exit code: {!s}".format(isPlymouth)) return isPlymouth == 0
def send_progress(self, counter, phase): for p in range(phase): if self.total == 0: continue step = 0.05 step += 0.95 * (counter / float(self.total)) self.progress += step / self.total debug("Progress: {}".format(self.progress)) libcalamares.job.setprogress(self.progress)
def parse_output(self, cmd): cal_env = os.environ cal_env["LC_ALL"] = "C" last = [] phase = 0 process = subprocess.Popen(cmd, env=cal_env, bufsize=1, stdout=subprocess.PIPE, close_fds=ON_POSIX) for line in iter(process.stdout.readline, b''): pkgs = re.findall(r'\((\d+)\)', line.decode()) dl = re.findall(r'downloading\s+(.*).pkg.tar.xz', line.decode()) inst = re.findall(r'installing(.*)\.\.\.', line.decode()) if pkgs: self.tracker.total = (int(pkgs[0])) debug("Number of packages: {}".format(self.tracker.total)) if dl: if dl != last: self.tracker.downloaded += 1 phase = 1 debug("Downloading: {}".format(dl[0])) debug("Downloaded packages: {}".format( self.tracker.downloaded)) self.tracker.send_progress(self.tracker.downloaded, phase) last = dl elif inst: self.tracker.installed += 1 phase = 2 debug("Installing: {}".format(inst[0])) debug("Installed packages: {}".format(self.tracker.installed)) self.tracker.send_progress(self.tracker.installed, phase) if process.returncode != 0: return process.kill() return None
def detect(self): isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) debug("which plymouth exit code: {!s}".format(isPlymouth)) return isPlymouth