[chrootcfg] PEP8 modification

This commit is contained in:
Philip 2017-06-23 11:46:43 +02:00
parent 779f602df7
commit 4b19c677b3

View File

@ -4,6 +4,7 @@
# === This file is part of Calamares - <http://github.com/calamares> ===
#
# Copyright 2016, Artoo <artoo@manjaro.org>
# Copyright 2017, Philip Müller <philm@manjaro.org>
#
# 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 <http://www.gnu.org/licenses/>.
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
@ -227,7 +253,10 @@ class ChrootController:
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))
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()