[PEP 8] General Style Part 3
This commit is contained in:
parent
09dc6bb5d7
commit
5c1ee7bbcb
@ -50,6 +50,7 @@ def get_bootloader_entry_name():
|
||||
branding = libcalamares.globalstorage.value("branding")
|
||||
return branding["bootloaderEntryName"]
|
||||
|
||||
|
||||
def create_conf(uuid, conf_path):
|
||||
distribution = get_bootloader_entry_name()
|
||||
kernel = libcalamares.job.configuration["kernel"]
|
||||
@ -128,9 +129,11 @@ def install_bootloader(boot_loader, fw_type):
|
||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||
conf_path = os.path.join(
|
||||
install_efi_directory, "loader", "entries", "{!s}.conf".format(distribution_translated))
|
||||
install_efi_directory, "loader", "entries",
|
||||
"{!s}.conf".format(distribution_translated))
|
||||
fallback_path = os.path.join(
|
||||
install_efi_directory, "loader", "entries", "{!s}-fallback.conf".format(distribution_translated))
|
||||
install_efi_directory, "loader", "entries",
|
||||
"{!s}-fallback.conf".format(distribution_translated))
|
||||
loader_path = os.path.join(
|
||||
install_efi_directory, "loader", "loader.conf")
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
@ -142,17 +145,17 @@ def install_bootloader(boot_loader, fw_type):
|
||||
device = boot_device[:-1]
|
||||
print(device)
|
||||
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
||||
subprocess.call(
|
||||
["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
||||
subprocess.call(["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
||||
create_conf(uuid, conf_path)
|
||||
create_fallback(uuid, fallback_path)
|
||||
create_loader(loader_path)
|
||||
else:
|
||||
install_path = boot_loader["installPath"]
|
||||
check_chroot_call(
|
||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc", install_path])
|
||||
check_chroot_call([libcalamares.job.configuration[
|
||||
"grubMkconfig"], "-o", libcalamares.job.configuration["grubCfg"]])
|
||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
||||
install_path])
|
||||
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
||||
libcalamares.job.configuration["grubCfg"]])
|
||||
|
||||
|
||||
def run():
|
||||
|
@ -43,17 +43,25 @@ desktop_environments = [
|
||||
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
||||
]
|
||||
|
||||
|
||||
def find_desktop_environment(root_mount_point):
|
||||
for desktop_environment in desktop_environments:
|
||||
if os.path.exists("{!s}{!s}".format(root_mount_point,desktop_environment.executable)) \
|
||||
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,desktop_environment.desktop_file)):
|
||||
if os.path.exists(
|
||||
"{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \
|
||||
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,
|
||||
desktop_environment.desktop_file)):
|
||||
return desktop_environment
|
||||
return None
|
||||
|
||||
def have_dm(dm_name, root_mount_point):
|
||||
return os.path.exists("{!s}/usr/bin/{!s}".format(root_mount_point,dm_name)) or os.path.exists("{!s}/usr/sbin/{!s}".format(root_mount_point,dm_name))
|
||||
|
||||
def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point):
|
||||
def have_dm(dm_name, root_mount_point):
|
||||
return os.path.exists(
|
||||
"{!s}/usr/bin/{!s}".format(root_mount_point, dm_name)) or os.path.exists(
|
||||
"{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name))
|
||||
|
||||
|
||||
def set_autologin(username, displaymanagers, default_desktop_environment,
|
||||
root_mount_point):
|
||||
""" Enables automatic login for the installed desktop managers """
|
||||
|
||||
if "mdm" in displaymanagers:
|
||||
@ -95,12 +103,15 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
||||
gdm_conf.write('AutomaticLoginEnable=True\n')
|
||||
if os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
||||
os.system(
|
||||
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point,username))
|
||||
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||
root_mount_point, username))
|
||||
if default_desktop_environment is not None:
|
||||
os.system(
|
||||
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(default_desktop_environment.desktop_file,root_mount_point,username))
|
||||
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||
default_desktop_environment.desktop_file, root_mount_point, username))
|
||||
os.system(
|
||||
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point,username))
|
||||
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||
root_mount_point, username))
|
||||
|
||||
if "kdm" in displaymanagers:
|
||||
# Systems with KDM as Desktop Manager
|
||||
@ -209,7 +220,7 @@ def run():
|
||||
displaymanagers = libcalamares.globalstorage.value("displaymanagers")
|
||||
|
||||
if displaymanagers is None:
|
||||
return "No display managers selected for the displaymanager module.",\
|
||||
return "No display managers selected for the displaymanager module.", \
|
||||
"The displaymanagers list is empty or undefined in both globalstorage and displaymanager.conf."
|
||||
|
||||
username = libcalamares.globalstorage.value("autologinUser")
|
||||
@ -217,7 +228,8 @@ def run():
|
||||
|
||||
if "default_desktop_environment" in libcalamares.job.configuration:
|
||||
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
||||
default_desktop_environment = DesktopEnvironment(entry["executable"], entry["desktopFile"])
|
||||
default_desktop_environment = DesktopEnvironment(entry["executable"],
|
||||
entry["desktopFile"])
|
||||
else:
|
||||
default_desktop_environment = find_desktop_environment(root_mount_point)
|
||||
|
||||
@ -247,7 +259,8 @@ def run():
|
||||
libcalamares.utils.chroot_call(
|
||||
['groupadd', '-g', '620', 'lightdm'])
|
||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['useradd', '-c', '"LightDM Display Manager"',
|
||||
libcalamares.utils.chroot_call(
|
||||
['useradd', '-c', '"LightDM Display Manager"',
|
||||
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
|
||||
'-s', '/usr/bin/nologin', 'lightdm'])
|
||||
libcalamares.utils.chroot_call(['passwd', '-l', 'lightdm'])
|
||||
@ -257,7 +270,8 @@ def run():
|
||||
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
||||
if default_desktop_environment is not None:
|
||||
os.system(
|
||||
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(default_desktop_environment.desktop_file,root_mount_point))
|
||||
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
||||
default_desktop_environment.desktop_file, root_mount_point))
|
||||
else:
|
||||
libcalamares.utils.debug("lightdm selected but not installed")
|
||||
displaymanagers.remove("lightdm")
|
||||
@ -269,7 +283,8 @@ def run():
|
||||
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['useradd', '-c', '"Gnome Display Manager"',
|
||||
libcalamares.utils.chroot_call(
|
||||
['useradd', '-c', '"Gnome Display Manager"',
|
||||
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
|
||||
'-s', '/usr/bin/nologin', 'gdm'])
|
||||
libcalamares.utils.chroot_call(['passwd', '-l', 'gdm'])
|
||||
@ -286,7 +301,8 @@ def run():
|
||||
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['useradd', '-c', '"Linux Mint Display Manager"',
|
||||
libcalamares.utils.chroot_call(
|
||||
['useradd', '-c', '"Linux Mint Display Manager"',
|
||||
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
|
||||
'-s', '/usr/bin/nologin', 'mdm'])
|
||||
libcalamares.utils.chroot_call(['passwd', '-l', 'mdm'])
|
||||
@ -295,7 +311,8 @@ def run():
|
||||
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
||||
if default_desktop_environment is not None:
|
||||
os.system(
|
||||
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(default_desktop_environment.desktop_file,root_mount_point))
|
||||
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
||||
default_desktop_environment.desktop_file, root_mount_point))
|
||||
else:
|
||||
libcalamares.utils.debug("mdm selected but not installed")
|
||||
displaymanagers.remove("mdm")
|
||||
@ -314,7 +331,8 @@ def run():
|
||||
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
||||
if default_desktop_environment is not None:
|
||||
os.system(
|
||||
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(default_desktop_environment.executable,root_mount_point))
|
||||
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
||||
default_desktop_environment.executable, root_mount_point))
|
||||
else:
|
||||
libcalamares.utils.debug("lxdm selected but not installed")
|
||||
displaymanagers.remove("lxdm")
|
||||
@ -326,7 +344,8 @@ def run():
|
||||
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
||||
libcalamares.utils.chroot_call(['useradd', '-u', '135', '-g', 'kdm', '-d',
|
||||
libcalamares.utils.chroot_call(
|
||||
['useradd', '-u', '135', '-g', 'kdm', '-d',
|
||||
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
|
||||
libcalamares.utils.chroot_call(
|
||||
['chown', '-R', '135:135', 'var/lib/kdm'])
|
||||
|
@ -32,16 +32,13 @@ def run():
|
||||
accumulator += "This job's path: " + libcalamares.job.working_path + "\n"
|
||||
accumulator += str(libcalamares.job.configuration)
|
||||
accumulator += " *** globalstorage test ***\n"
|
||||
accumulator += "lala: " + \
|
||||
str(libcalamares.globalstorage.contains("lala")) + "\n"
|
||||
accumulator += "foo: " + \
|
||||
str(libcalamares.globalstorage.contains("foo")) + "\n"
|
||||
accumulator += "lala: " + str(libcalamares.globalstorage.contains("lala")) + "\n"
|
||||
accumulator += "foo: " + str(libcalamares.globalstorage.contains("foo")) + "\n"
|
||||
accumulator += "count: " + str(libcalamares.globalstorage.count()) + "\n"
|
||||
libcalamares.globalstorage.insert("item2", "value2")
|
||||
libcalamares.globalstorage.insert("item3", 3)
|
||||
accumulator += "keys: {}\n".format(str(libcalamares.globalstorage.keys()))
|
||||
accumulator += "remove: {}\n".format(
|
||||
str(libcalamares.globalstorage.remove("item2")))
|
||||
accumulator += "remove: {}\n".format(str(libcalamares.globalstorage.remove("item2")))
|
||||
accumulator += "values: {} {} {}\n".format(
|
||||
str(libcalamares.globalstorage.value("foo")),
|
||||
str(libcalamares.globalstorage.value("item2")),
|
||||
|
@ -26,16 +26,17 @@ import shutil
|
||||
from collections import OrderedDict
|
||||
from libcalamares.utils import check_chroot_call
|
||||
|
||||
|
||||
def cpuinfo():
|
||||
''' Return the information in /proc/cpuinfo
|
||||
as a dictionary in the following format:
|
||||
"""
|
||||
Return the information in /proc/cpuinfo as a dictionary in the following format:
|
||||
cpu_info['proc0']={...}
|
||||
cpu_info['proc1']={...}
|
||||
|
||||
'''
|
||||
"""
|
||||
|
||||
cpuinfo=OrderedDict()
|
||||
procinfo=OrderedDict()
|
||||
cpuinfo = OrderedDict()
|
||||
procinfo = OrderedDict()
|
||||
|
||||
nprocs = 0
|
||||
with open('/proc/cpuinfo') as f:
|
||||
@ -45,7 +46,7 @@ def cpuinfo():
|
||||
cpuinfo["proc{!s}".format(nprocs)] = procinfo
|
||||
nprocs += 1
|
||||
# Reset
|
||||
procinfo=OrderedDict()
|
||||
procinfo = OrderedDict()
|
||||
else:
|
||||
if len(line.split(':')) == 2:
|
||||
procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
|
||||
@ -54,6 +55,7 @@ def cpuinfo():
|
||||
|
||||
return cpuinfo
|
||||
|
||||
|
||||
def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
||||
""" Set up mkinitcpio.conf """
|
||||
|
||||
@ -72,6 +74,7 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
||||
with open(path, "w") as mkinitcpio_file:
|
||||
mkinitcpio_file.write("\n".join(mklins) + "\n")
|
||||
|
||||
|
||||
def modify_mkinitcpio_conf(partitions, root_mount_point):
|
||||
""" Modifies mkinitcpio.conf """
|
||||
|
||||
|
@ -35,7 +35,6 @@ except ImportError:
|
||||
|
||||
|
||||
class Job:
|
||||
|
||||
def __init__(self, working_path, doc, cfg_doc):
|
||||
self.module_name = doc["name"]
|
||||
self.pretty_name = "Testing job " + doc["name"]
|
||||
|
Loading…
Reference in New Issue
Block a user