From 4b19c677b3a7ac9f3b8b25a918d8a9ccaa298a8c Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 23 Jun 2017 11:46:43 +0200 Subject: [PATCH] [chrootcfg] PEP8 modification --- src/modules/chrootcfg/main.py | 54 ++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/src/modules/chrootcfg/main.py b/src/modules/chrootcfg/main.py index 59f9409b6..fa0d38509 100644 --- a/src/modules/chrootcfg/main.py +++ b/src/modules/chrootcfg/main.py @@ -4,6 +4,7 @@ # === This file is part of Calamares - === # # Copyright 2016, Artoo +# Copyright 2017, Philip Müller # # Calamares is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,14 +19,18 @@ # You should have received a copy of the GNU General Public License # along with Calamares. If not, see . -import os, shutil, subprocess, sys, re - +import os +import shutil +import subprocess +import sys +import re import libcalamares from libcalamares.utils import check_target_env_call, target_env_call, debug from os.path import join from subprocess import call + class OperationTracker: def __init__(self): self._downloaded = 0 @@ -82,9 +87,14 @@ ON_POSIX = 'posix' in sys.builtin_module_names class PacmanController: def __init__(self, root): self.__root = root - self.__operations = libcalamares.globalstorage.value("packageOperations") + self.__operations = libcalamares.globalstorage.value( + "packageOperations" + ) self.__tracker = OperationTracker() - self.__keyrings = libcalamares.job.configuration.get('keyrings', []) + self.__keyrings = libcalamares.job.configuration.get( + 'keyrings', + [] + ) @property def tracker(self): @@ -114,7 +124,13 @@ class PacmanController: last = [] phase = 0 - process = subprocess.Popen(cmd, env=cal_env, bufsize=1, stdout=subprocess.PIPE, close_fds=ON_POSIX) + 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()) @@ -141,7 +157,6 @@ class PacmanController: debug("Installed packages: {}".format(self.tracker.installed)) self.tracker.send_progress(self.tracker.installed, phase) - if process.returncode != 0: return process.kill() @@ -156,7 +171,14 @@ class PacmanController: else: args.extend(["-Sy"]) - args.extend(["--cachedir", cachedir, "--root", self.root, "--dbpath", dbdir]) + args.extend([ + "--cachedir", + cachedir, + "--root", + self.root, + "--dbpath", + dbdir + ]) cmd = args + pkglist self.parse_output(cmd) @@ -195,10 +217,14 @@ class PacmanController: return None + class ChrootController: def __init__(self): self.__root = libcalamares.globalstorage.value('rootMountPoint') - self.__requirements = libcalamares.job.configuration.get('requirements', []) + self.__requirements = libcalamares.job.configuration.get( + 'requirements', + [] + ) self.__isRank = libcalamares.job.configuration['isRank'] @property @@ -226,8 +252,11 @@ class ChrootController: call(["pacman-mirrors", "-f", "5"]) def copy_file(self, file): - if os.path.exists(os.path.join("/",file)): - shutil.copy2(os.path.join("/",file), os.path.join(self.root, file)) + if os.path.exists(os.path.join("/", file)): + shutil.copy2( + os.path.join("/", file), + os.path.join(self.root, file) + ) def prepare(self): cal_umask = os.umask(0) @@ -249,7 +278,10 @@ class ChrootController: return pacman.run() def run(): - """ Create chroot dirs and install pacman, kernel and netinstall selection """ + """ + Create chroot dirs and install pacman, + kernel and netinstall selection + """ targetRoot = ChrootController()