]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- convert python examples to python 3 797/head
authorArvin Schnell <aschnell@suse.de>
Tue, 28 Mar 2023 13:00:27 +0000 (15:00 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 28 Mar 2023 13:00:27 +0000 (15:00 +0200)
12 files changed:
examples/python/comparison.py
examples/python/create.py
examples/python/debug.py
examples/python/delete.py
examples/python/get-config.py
examples/python/get-snapshot.py
examples/python/list-configs.py
examples/python/list-snapshots.py
examples/python/lock-config.py
examples/python/set-config.py
examples/python/set-snapshot.py
examples/python/signals.py

index 5c6461c7b27a74ee927d997e3320891083d6f353..d30664590d5c3ac4237975e616ca9d2a147bc5b3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -17,5 +17,4 @@ snapper.CreateComparison(config_name, num_pre, num_post)
 files = snapper.GetFiles(config_name, num_pre, num_post)
 
 for file in files:
-    print file[0], file[1]
-
+    print(file[0], file[1])
index 3d739571764164186c6ab3ea0c02a57321492278..3e1778b53ea64d761a9976f1ce1ce349dd133928 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -8,5 +8,4 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
                          dbus_interface='org.opensuse.Snapper')
 
 
-print snapper.CreateSingleSnapshot("root", "test", "", { "id" : "123" })
-
+print(snapper.CreateSingleSnapshot("root", "test", "", { "id" : "123" }))
index 9bd998c755661ff8215de5585625b3146acaf899..1520519aba733fa07864eee1d10a701983d39b68 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -11,5 +11,4 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 lines = snapper.Debug()
 
 for line in lines:
-    print line
-
+    print(line)
index 63b93d14f105dc19f5c0b6e17957a63123da8afe..0ef7e64ec1dc07de2f5f2e732d141e03154e388d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -9,4 +9,3 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 
 
 snapper.DeleteSnapshots("root", [ 510 ])
-
index c383c4ce5f250759f42ba00ffe2be25c48c2f420..35ef9254902f306b86b3ac664f776aca3ec5a2ea 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -10,8 +10,7 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 
 config = snapper.GetConfig("root")
 
-print config[0], config[1]
+print(config[0], config[1])
 
 for k, v in config[2].items():
-    print "%s=%s" % (k, v)
-
+    print("%s=%s" % (k, v))
index e940812c96c0d6a9d030fd4b619f6529c34226ca..29b0f8647264c67eac43fd6726f3cf5784522d1e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from time import gmtime, asctime
 from pwd import getpwuid
@@ -12,9 +12,8 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 
 snapshot = snapper.GetSnapshot("root", 1)
 
-print snapshot[0], snapshot[1], snapshot[2], asctime(gmtime(snapshot[3])),
-print getpwuid(snapshot[4])[0], snapshot[5], snapshot[6],
+print(snapshot[0], snapshot[1], snapshot[2], asctime(gmtime(snapshot[3])),
+      getpwuid(snapshot[4])[0], snapshot[5], snapshot[6], end='')
 for k, v in snapshot[7].items():
-    print "%s=%s" % (k, v),
-print
-
+    print("", "%s=%s" % (k, v), end='')
+print()
index bc1ab981e585c0f4a50bfd199eefcf45ab54dbae..d33f317e6ead10fc9edb47eb4a04e60bc034b513 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -11,5 +11,4 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 configs = snapper.ListConfigs()
 
 for config in configs:
-    print config[0], config[1]
-
+    print(config[0], config[1])
index 31c10b5c70a36e529579090ae80d36b752c30060..f00346f4938cdee94a7e958b3224306119b7ca88 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from time import gmtime, asctime
 from pwd import getpwuid
@@ -13,15 +13,14 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 snapshots = snapper.ListSnapshots("root")
 
 for snapshot in snapshots:
-    print snapshot[0], snapshot[1], snapshot[2],
+    print(snapshot[0], snapshot[1], snapshot[2], end='')
 
     if snapshot[3] != -1:
-        print asctime(gmtime(snapshot[3])),
+        print("", asctime(gmtime(snapshot[3])), end='')
     else:
-        print "now",
+        print("", "now", end='')
 
-    print getpwuid(snapshot[4])[0], snapshot[5], snapshot[6],
+    print("", getpwuid(snapshot[4])[0], snapshot[5], snapshot[6], end='')
     for k, v in snapshot[7].items():
-        print "%s=%s" % (k, v),
-    print
-
+        print("", "%s=%s" % (k, v), end='')
+    print()
index 89afe0d978d56823a08d8fe5afc4c5698dd44713..0a626428f60475919f42e43def408361cd8a0da6 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from time import sleep
 import dbus
@@ -14,4 +14,3 @@ snapper.LockConfig("root")
 sleep(10)
 
 snapper.UnlockConfig("root")
-
index be4f8afec22140c83b35ece28869455cb5ef4458..f1751f491948d55dbc42106f349fb56f3a8e45d3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -7,7 +7,7 @@ bus = dbus.SystemBus()
 snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/Snapper'),
                          dbus_interface='org.opensuse.Snapper')
 
+
 data = { "NUMBER_CLEANUP" : "yes", "NUMBER_LIMIT" : "10" }
 
 snapper.SetConfig("root", data)
-
index 8db0e83f80464acb0537e609ed8763612a8e4ebc..73991a991dcc07646dcd3fdba2d1320720f23931 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 
@@ -9,4 +9,3 @@ snapper = dbus.Interface(bus.get_object('org.opensuse.Snapper', '/org/opensuse/S
 
 
 snapper.SetSnapshot("root", 1, "test", "", { "id" : "123" })
-
index fecead56f66513814d24f43cc6007b03eb3d3910..c2dce41c37f05ca705f2705560257393250b15bd 100755 (executable)
@@ -1,8 +1,8 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
-from gobject import MainLoop
+from gi.repository.GLib import MainLoop
 
 
 DBusGMainLoop(set_as_default=True)
@@ -31,28 +31,27 @@ class MessageListener:
 
 
     def config_created(self, config):
-        print "ConfigCreated", config
+        print("ConfigCreated", config)
 
     def config_modified(self, config):
-        print "ConfigModified", config
+        print("ConfigModified", config)
 
     def config_deleted(self, config):
-        print "ConfigDeleted", config
+        print("ConfigDeleted", config)
 
     def snapshot_created(self, config, number):
-        print "SnapshotCreated", config, number
+        print("SnapshotCreated", config, number)
 
     def snapshot_modified(self, config, number):
-        print "SnapshotModified", config, number
+        print("SnapshotModified", config, number)
 
     def snapshots_deleted(self, config, numbers):
-        print "SnapshotsDeleted", config,
+        print("SnapshotsDeleted", config, end='')
         for number in numbers:
-            print number,
-        print
+            print("", number, end='')
+        print()
 
 
 MessageListener()
 
 MainLoop().run()
-