From e26335d2da67cb1f99cb5273eda5669e91f2b273 Mon Sep 17 00:00:00 2001 From: demmm Date: Tue, 28 Oct 2014 11:15:35 -0400 Subject: [PATCH] proper check for existing sddm.conf second set of if/else is obsolete with this, sddm.conf always exists at this point --- src/modules/displaymanager/main.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 48a571659..187a52a04 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -136,19 +136,19 @@ def set_autologin(username, displaymanagers, root_mount_point): # Systems with Sddm as Desktop Manager sddm_conf_path = os.path.join(root_mount_point, "etc/sddm.conf") if sddm_conf_path != os.path.join(root_mount_point, "etc/sddm.conf"): + if os.path.isfile(sddm_conf_path): + print('SDDM config file exists') + else: check_chroot_call("sddm --example-config > etc/sddm.conf", shell=True) text = [] - if os.path.exists(sddm_conf_path): - with open(sddm_conf_path, 'r') as sddm_conf: - text = sddm_conf.readlines() - with open(sddm_conf_path, 'w') as sddm_conf: - for line in text: - if 'User=' in line: - line = 'User={}\n'.format(username) - sddm_conf.write(line) - else: - return "Cannot write SDDM configuration file", "SDDM config file %s does not exist" % sddm_conf_path - + with open(sddm_conf_path, 'r') as sddm_conf: + text = sddm_conf.readlines() + with open(sddm_conf_path, 'w') as sddm_conf: + for line in text: + if 'User=' in line: + line = 'User={}\n'.format(username) + sddm_conf.write(line) + return None