Initial attempt at python3 conversion
[time-slider.git] / usr / share / time-slider / lib / plugin / plugin.py
index 7d1e3d1..e509b19 100644 (file)
@@ -23,7 +23,7 @@
 import os
 import sys
 import subprocess
-import pluginsmf
+from . import pluginsmf
 
 from time_slider import smf, autosnapsmf, util
 
@@ -46,15 +46,15 @@ class Plugin(Exception):
         command = self.smfInst.get_trigger_command()
         try:
             statinfo = os.stat(command)
-            other_x = (statinfo.st_mode & 01)
+            other_x = (statinfo.st_mode & 0o1)
             if other_x == 0:
-              raise RuntimeError'Plugin: %s:\nConfigured trigger command is not ' \
+              raise RuntimeError('Plugin: %s:\nConfigured trigger command is not ' \
                                   'executable:\n%s' \
-                                  % (self.smfInst.instanceName, command)  
+                                  % (self.smfInst.instanceName, command))  
         except OSError:
-            raise RuntimeError'Plugin: %s:\nCan not access the configured ' \
+            raise RuntimeError('Plugin: %s:\nCan not access the configured ' \
                                 'plugin/trigger_command:\n%s' \
-                                % (self.smfInst.instanceName, command)      
+                                % (self.smfInst.instanceName, command))      
 
 
     def execute(self, schedule, label):
@@ -96,9 +96,9 @@ class Plugin(Exception):
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.PIPE,
                                           close_fds=True)
-        except OSError, message:
-            raise RuntimeError"%s subprocess error:\n %s" % \
-                                (cmd, str(message))
+        except OSError as message:
+            raise RuntimeError("%s subprocess error:\n %s" % \
+                                (cmd, str(message)))
             self._proc = None
 
     def is_running(self):
@@ -142,8 +142,8 @@ class PluginManager():
         err = p.wait()
         if err != 0:
             self._refreshLock.release()
-            raise RuntimeError'%s failed with exit code %d\n%s' % \
-                                (str(cmd), err, errdata)
+            raise RuntimeError('%s failed with exit code %d\n%s' % \
+                                (str(cmd), err, errdata))
         for line in outdata.rstrip().split('\n'):
             line = line.rstrip().split()
             state = line[0]
@@ -158,7 +158,7 @@ class PluginManager():
                 try:
                     plugin = Plugin(fmri, self.verbose)
                     self.plugins.append(plugin)
-                except RuntimeError, message:
+                except RuntimeError as message:
                     sys.stderr.write("Ignoring misconfigured plugin: %s\n" \
                                      % (fmri))
                     sys.stderr.write("Reason:\n%s\n" % (message))