backup
authorMichael Andres <ma@suse.de>
Fri, 3 Jun 2011 21:26:55 +0000 (23:26 +0200)
committerMichael Andres <ma@suse.de>
Fri, 3 Jun 2011 21:26:55 +0000 (23:26 +0200)
devel/devel.ma/PluginTest.cc
devel/devel.ma/PluginTest.py [new file with mode: 0755]

index c2856ec..249c7be 100644 (file)
@@ -74,6 +74,14 @@ PluginFrame receive()
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 
+#define DOLOG(C) USR << #C << ": " << endl; C;
+
+namespace zypp {
+  namespace target {
+    void testCommitPlugins( const Pathname & path_r );
+  }
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -86,6 +94,29 @@ try {
   INT << "===[START]==========================================" << endl;
   //////////////////////////////////////////////////////////////////
 
+  zypp::target::testCommitPlugins( "/tmp/pltest" );
+
+  if ( 0 )
+  {
+  Pathname script( "PluginTest.py" );
+  PluginScript plugin( script );
+  USR << plugin << endl;
+
+  DOLOG( plugin.open() );
+
+  DOLOG( plugin.send( PluginFrame( "PLUGINBEGIN" ) ) );
+
+  PluginFrame ret;
+  DOLOG( ret = plugin.receive() );
+  MIL << ret << endl;
+
+  DOLOG( plugin.send( PluginFrame( "PLUGINEND" ) ) );
+  DOLOG( ret = plugin.receive() );
+  MIL << ret << endl;
+
+  DOLOG( plugin.close() );
+  }
+
   if ( 0 ) {
     Pathname script( ZConfig::instance().pluginsPath()/"system/spacewalkx" );
     if ( PathInfo( script ).isX() )
diff --git a/devel/devel.ma/PluginTest.py b/devel/devel.ma/PluginTest.py
new file mode 100755 (executable)
index 0000000..e3a5873
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+#
+# ZYpp plugin
+#
+import os
+import sys
+import traceback
+import time
+
+from zypp_plugin import Plugin
+
+class MyPlugin(Plugin):
+
+  def PLUGINBEGIN(self, headers, body):
+    # commit is going to start.
+    #self.error( {}, 'oops' )
+    self.ack()
+
+  def PLUGINEND(self, headers, body):
+    # commit ended
+    self.ack()
+
+plugin = MyPlugin()
+plugin.main()