From 2d0660a54af8fde800038cc4c88b5bc0fe15c82c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 20 Aug 2018 11:00:20 -0400 Subject: [PATCH] [displaymanager] Fix up missing methods - Add (empty) implementations of all the abstract methods that are not needed (or supported) by various DMs. - Order the abstract methods by calling order - Fix up have_dm --- src/modules/displaymanager/main.py | 69 ++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 559a5bcf0..b5b5bb0c1 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -96,25 +96,25 @@ class DisplayManager(metaclass=abc.ABCMeta): def __init__(self, root_mount_point): self.root_mount_point = root_mount_point - def have_dm(cls): - if cls.executable is None: + def have_dm(self): + """ + Is this DM installed in the target system? + The default implementation checks for `executable` + in the target system. + """ + if self.executable is None: return True - bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, cls.executable) - sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, cls.executable) + bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, self.executable) + sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, self.executable) return ( os.path.exists(bin_path) or os.path.exists(sbin_path) ) - @abc.abstractmethod - def set_autologin(self, username, do_autologin, default_desktop_environment): - """ - Configure the DM inside the given @p root_mount_point with - autologin (if @p do_autologin is True) for the given @p username. - If the DM supports it, set the default DE to @p default_desktop_environment - as well. - """ + # The four abstract methods below are called in the order listed here. + # They must all be implemented by subclasses, but not all of them + # actually do something for all DMs. @abc.abstractmethod def basic_setup(self): @@ -138,6 +138,15 @@ class DisplayManager(metaclass=abc.ABCMeta): """ # Most implementations do nothing + @abc.abstractmethod + def set_autologin(self, username, do_autologin, default_desktop_environment): + """ + Configure the DM inside the given @p root_mount_point with + autologin (if @p do_autologin is True) for the given @p username. + If the DM supports it, set the default DE to @p default_desktop_environment + as well. + """ + class DMmdm(DisplayManager): name = "mdm" @@ -221,6 +230,9 @@ class DMmdm(DisplayManager): ) ) + def greeter_setup(self): + pass + class DMgdm(DisplayManager): name = "gdm" @@ -305,6 +317,12 @@ class DMgdm(DisplayManager): ['chown', '-R', 'gdm:gdm', '/var/lib/gdm'] ) + def desktop_environment_setup(self, desktop_environment): + pass + + def greeter_setup(self): + pass + class DMkdm(DisplayManager): name = "kdm" @@ -377,6 +395,12 @@ class DMkdm(DisplayManager): ['chown', '-R', '135:135', 'var/lib/kdm'] ) + def desktop_environment_setup(self, desktop_environment): + pass + + def greeter_setup(self): + pass + class DMlxdm(DisplayManager): name = "lxdm" @@ -433,6 +457,9 @@ class DMlxdm(DisplayManager): ) ) + def greeter_setup(self): + pass + class DMlightdm(DisplayManager): name = "lightdm" @@ -592,6 +619,12 @@ class DMslim(DisplayManager): def basic_setup(self): pass + def desktop_environment_setup(self, desktop_environment): + pass + + def greeter_setup(self): + pass + class DMsddm(DisplayManager): name = "sddm" @@ -630,6 +663,12 @@ class DMsddm(DisplayManager): def basic_setup(self): pass + def desktop_environment_setup(self, desktop_environment): + pass + + def greeter_setup(self): + pass + class DMsysconfig(DisplayManager): name = "sysconfig" @@ -651,6 +690,12 @@ class DMsysconfig(DisplayManager): def basic_setup(self): pass + def desktop_environment_setup(self, desktop_environment): + pass + + def greeter_setup(self): + pass + # Collect all the subclasses of DisplayManager defined above, # and index them based on the name property of each class.