[gnome-lirc-properties] Add Fedora support



commit bf5a2cef6db729152c1bf83b4e77c376e85f97fd
Author: Bastien Nocera <hadess hadess net>
Date:   Mon May 17 13:52:02 2010 +0100

    Add Fedora support
    
    Use the startup-style changes to allow for both Debian and Fedora
    styles of configuration to co-exist.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=530359
    https://bugzilla.gnome.org/show_bug.cgi?id=530647
    https://bugzilla.gnome.org/show_bug.cgi?id=530648

 gnome_lirc_properties/backend.py                   |   92 +++++++++++++------
 .../ui/RemoteControlProperties.py                  |   22 +++--
 2 files changed, 78 insertions(+), 36 deletions(-)
---
diff --git a/gnome_lirc_properties/backend.py b/gnome_lirc_properties/backend.py
index b9e11f0..e81dbe2 100644
--- a/gnome_lirc_properties/backend.py
+++ b/gnome_lirc_properties/backend.py
@@ -487,12 +487,15 @@ class BackendService(PolicyKitService):
 
     __re_receiver_directive = re.compile(r'^\s*RECEIVER_(VENDOR|MODEL)=')
 
-    # These are used by the Debian/Ubuntu packages, as of 2008-02-12.
-    # The "REMOTE_" prefix is made optional, since it only was introduced
-    # with lirc 0.8.3~pre1-0ubuntu4 of Hardy Heron.
-
-    __re_remote_directive = re.compile(r'^\s*(?:REMOTE_)?(DRIVER|DEVICE|MODULES|' +
-                                       r'LIRCD_ARGS|LIRCD_CONF|VENDOR|MODEL)=')
+    if config.STARTUP_STYLE is 'fedora':
+        __re_remote_directive = re.compile(r'^\s*(LIRC_DRIVER|LIRC_DEVICE|MODULES|' +
+                                           r'LIRCD_OPTIONS|LIRCD_CONF|VENDOR|MODEL)=')
+    else:
+        # These are used by the Debian/Ubuntu packages, as of 2008-02-12.
+        # The "REMOTE_" prefix is made optional, since it only was introduced
+        # with lirc 0.8.3~pre1-0ubuntu4 of Hardy Heron.
+        __re_remote_directive = re.compile(r'^\s*(?:REMOTE_)?(DRIVER|DEVICE|MODULES|' +
+                                           r'LIRCD_ARGS|LIRCD_CONF|VENDOR|MODEL)=')
     __re_start_lircd      = re.compile(r'^\s*START_LIRCD=')
 
     def __init__(self, connection=None, path='/'):
@@ -596,22 +599,33 @@ class BackendService(PolicyKitService):
                     print >> output, ('%s"%s"' % (match.group(0), ShellQuote.shellquote(value)))
                 continue
 
-            # Deal with the START_LIRCD line:
-
-            match = self.__re_start_lircd.match(line)
-
-            if match:
-                # pychecker says "Using a conditional statement with a constant value (true)",
-                # which is ridicilous, considering Python 2.4 doesn't have conditional statements
-                # yet (PEP 308, aka. 'true_value if condition else false_value') and the expression
-                # below ('condition and true_value or false_value') is the recommended aquivalent.
+            if config.STARTUP_STYLE is 'fedora':
+                output.write(line)
                 value = (start_lircd is None) and 'true' or start_lircd
                 start_lircd = None
+                if 'true' == value:
+                    args = '/sbin/chkconfig', 'lirc', 'on'
+                else:
+                    args = '/sbin/chkconfig', 'lirc', 'off'
+                os.spawnv(os.P_WAIT, args[0], args)
+            else:
+                # Deal with the START_LIRCD line:
 
-                print >> output, (match.group(0) + ShellQuote.shellquote(value))
-                continue
+                match = self.__re_start_lircd.match(line)
+
+                if match:
+                    # pychecker says "Using a conditional statement with a constant value (true)",
+                    # which is ridicilous, considering Python 2.4 doesn't have conditional statements
+                    # yet (PEP 308, aka. 'true_value if condition else false_value') and the expression
+                    # below ('condition and true_value or false_value') is the recommended equivalent.
+                    value = (start_lircd is None) and 'true' or start_lircd
+                    start_lircd = None
+
+                    print >> output, (match.group(0) + ShellQuote.shellquote(value))
+                    continue
 
-            output.write(line)
+            if config.STARTUP_STYLE is not 'fedora':
+                output.write(line)
 
         # Write out any values that were not already in the file,
         # and therefore just replaced:
@@ -619,14 +633,17 @@ class BackendService(PolicyKitService):
         if remote_values:
             print >> output, '\n# Remote settings required by gnome-lirc-properties'
         for key, value in remote_values.items():
-            print >> output, ('REMOTE_%s="%s"' % (key, ShellQuote.shellquote(value)))
+            if config.STARTUP_STYLE is not 'fedora':
+                print >> output, ('REMOTE_%s="%s"' % (key, ShellQuote.shellquote(value)))
+            else:
+                print >> output, ('%s="%s"' % (key, ShellQuote.shellquote(value)))
 
         if receiver_values:
             print >> output, '\n# Receiver settings required by gnome-lirc-properties'
         for key, value in receiver_values.items():
             print >> output, ('RECEIVER_%s="%s"' % (key, ShellQuote.shellquote(value)))
 
-        if start_lircd is not None:
+        if start_lircd is not None and config.STARTUP_STYLE is not 'fedora':
             print >> output, '\n# Daemon settings required by gnome-lirc-properties'
             print >> output, ('START_LIRCD=%s' % start_lircd)
 
@@ -649,13 +666,22 @@ class BackendService(PolicyKitService):
 
         self._check_permission(sender)
 
-        remote_values = {
-            'DRIVER': driver,
-            'DEVICE': device,
-            'MODULES': modules,
-            'LIRCD_ARGS': '',
-            'LIRCD_CONF': '',
-        }
+        if config.STARTUP_STYLE is 'fedora':
+            remote_values = {
+                'LIRC_DRIVER': driver,
+                'LIRC_DEVICE': device,
+                'MODULES': modules,
+                'LIRCD_OPTIONS': '',
+                'LIRCD_CONF': '',
+            }
+        else:
+            remote_values = {
+                'DRIVER': driver,
+                'DEVICE': device,
+                'MODULES': modules,
+                'LIRCD_ARGS': '',
+                'LIRCD_CONF': '',
+            }
 
         receiver_values = {
             'VENDOR': vendor,
@@ -776,10 +802,18 @@ class BackendService(PolicyKitService):
 	    raise AccessDeniedException
 
         if 'enable' == action:
-            self._write_hardware_configuration(start_lircd=True)
+            if config.STARTUP_STYLE is 'fedora':
+                args = '/sbin/chkconfig', 'lirc', 'on'
+                os.spawnv(os.P_WAIT, args[0], args)
+            else:
+                self._write_hardware_configuration(start_lircd=True)
 
         elif 'disable' == action:
-            self._write_hardware_configuration(start_lircd=False)
+            if config.STARTUP_STYLE is 'fedora':
+                args = '/sbin/chkconfig', 'lirc', 'off'
+                os.spawnv(os.P_WAIT, args[0], args)
+            else:
+                self._write_hardware_configuration(start_lircd=False)
 
         else:
             args = '/etc/init.d/lirc', action
diff --git a/gnome_lirc_properties/ui/RemoteControlProperties.py b/gnome_lirc_properties/ui/RemoteControlProperties.py
index fea3fbe..3796721 100644
--- a/gnome_lirc_properties/ui/RemoteControlProperties.py
+++ b/gnome_lirc_properties/ui/RemoteControlProperties.py
@@ -301,11 +301,20 @@ class RemoteControlProperties(object):
         # reason the device node's name is stored in REMOTE_DEVICE, instead
         # of RECEIVER_DEVICE.
         #
-        self.selected_receiver = (
-            settings.get('RECEIVER_VENDOR'),
-            settings.get('RECEIVER_MODEL'),
-            settings.get('REMOTE_DEVICE'),
-        )
+        # The setting is called LIRC_DEVICE is Fedora.
+        #
+        if config.STARTUP_STYLE is 'fedora':
+            self.selected_receiver = (
+                settings.get('RECEIVER_VENDOR'),
+                settings.get('RECEIVER_MODEL'),
+                settings.get('LIRC_DEVICE'),
+            )
+        else:
+            self.selected_receiver = (
+                settings.get('RECEIVER_VENDOR'),
+                settings.get('RECEIVER_MODEL'),
+                settings.get('REMOTE_DEVICE'),
+            )
 
         # Try to select configured remote vendor:
         self.selected_remote = (
@@ -887,8 +896,7 @@ class RemoteControlProperties(object):
 
         except OSError, ex:
             if errno.ENOENT == ex.errno:
-                error_message = 
-                    _('Cannot display help since the GNOME Help Browser ("yelp") cannot be found.')
+                error_message = _('Cannot display help since the GNOME Help Browser ("yelp") cannot be found.')
 
             else:
                 error_message = _('Cannot display help for unexpected reason: %s') % ex.strerror



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]