]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- handle userdata in zypp plugin (fate #312521)
authorArvin Schnell <aschnell@suse.de>
Wed, 21 Nov 2012 10:57:21 +0000 (11:57 +0100)
committerArvin Schnell <aschnell@suse.de>
Wed, 21 Nov 2012 10:57:21 +0000 (11:57 +0100)
package/snapper.changes
scripts/zypp-plugin.py

index 592c710784663904ccaf1053a4809c98df5ad7cf..24f9df45b04fa59e0dcb2edf756f3fb0bc65663b 100644 (file)
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Nov 21 11:55:28 CET 2012 - aschnell@suse.de
+
+- handle userdata in zypp plugin (fate #312521)
+
 -------------------------------------------------------------------
 Mon Nov 12 15:37:25 CET 2012 - aschnell@suse.de
 
index e893bd9cee8ffae1781c9b92a3cfccf79927cda2..af115250b28baabf7b90fd9e4981ce00cf3c0d6f 100755 (executable)
@@ -2,16 +2,36 @@
 
 from os import readlink, getppid
 from os.path import basename
+from sys import stderr
 from dbus import SystemBus, Interface
 from zypp_plugin import Plugin
 
 class MyPlugin(Plugin):
 
+  def parse_userdata(self, s):
+    ud = {}
+    for kv in s.split(","):
+      k, v = kv.split("=", 1)
+      k = k.strip()
+      if not k:
+        raise ValueError
+      ud[k] = v.strip()
+    return ud
+
   def PLUGINBEGIN(self, headers, body):
 
     exe = basename(readlink("/proc/%d/exe" % getppid()))
 
-    self.num1 = snapper.CreatePreSnapshot("root", "zypp(%s)" % exe, "number", {})
+    userdata = {}
+
+    try:
+      userdata = self.parse_userdata(headers['userdata'])
+    except KeyError:
+      pass
+    except ValueError:
+      stderr.write("invalid userdata")
+
+    self.num1 = snapper.CreatePreSnapshot("root", "zypp(%s)" % exe, "number", userdata)
 
     self.ack()