Initial attempt at python3 conversion
[time-slider.git] / usr / share / time-slider / lib / time_slider / autosnapsmf.py
index 7a15529..5999955 100755 (executable)
@@ -21,8 +21,8 @@
 #
 
 import threading
-import smf
-import util
+from . import smf
+from . import util
 
 factoryDefaultSchedules = ("monthly", "weekly", "daily", "hourly", "frequent")
 
@@ -50,9 +50,9 @@ class AutoSnap(smf.SMFInstance):
             period = int(self.get_prop(ZFSPROPGROUP, "period"))
             keep =  int(self.get_prop(ZFSPROPGROUP, "keep"))
 
-        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)))
         finally:
             _scheddetaillock.release()
       
@@ -119,11 +119,11 @@ def get_default_schedules():
             instance = AutoSnap(s)
             try:
                 _defaultSchedules.append(instance.get_schedule_details())
-            except RuntimeError, message:
-                raise RuntimeError"Error getting schedule details for " + \
+            except RuntimeError as message:
+                raise RuntimeError("Error getting schedule details for " + \
                                     "default auto-snapshot SMF instance:" + \
                                     "\n\t" + instanceName + "\nDetails:\n" + \
-                                    str(message)
+                                    str(message))
     return _defaultSchedules
 
 def get_custom_schedules():
@@ -154,11 +154,11 @@ def get_custom_schedules():
                 instance = AutoSnap(label)
                 try:
                     _customSchedules.append(instance.get_schedule_details())
-                except RuntimeError, message:
-                    raise RuntimeError"Error getting schedule details " + \
+                except RuntimeError as message:
+                    raise RuntimeError("Error getting schedule details " + \
                                         "for custom auto-snapshot SMF " + \
                                         "instance:\n\t" + label + "\n" + \
-                                        "Details:\n" + str(message) 
+                                        "Details:\n" + str(message)) 
     return _customSchedules
 
 
@@ -166,5 +166,5 @@ if __name__ == "__main__":
     defaults = get_default_schedules()
     for sched in defaults:
         S = AutoSnap(sched[0])
-        print S.get_schedule_details()
+        print(S.get_schedule_details())