--- /dev/null
+#! /usr/bin/python
+import zypp
+
+# ---------------------------------------------------------
+
+def myProgress( val ):
+ print "myProgress %d" % val
+ return True
+
+rec = zypp.ScanRpmDbReceive()
+rec.set_pymethod( myProgress )
+
+# ---------------------------------------------------------
+
+Z = zypp.ZYppFactory_instance().getZYpp()
+
+if True:
+ Z.initializeTarget( zypp.Pathname("/Local/ROOT") )
+ Z.addResolvables( Z.target().resolvables(), True );
+
+if False:
+ repoManager = zypp.RepoManager()
+ repos = repoManager.knownRepositories()
+ for repo in repos:
+ if not repo.enabled():
+ continue
+ if not repoManager.isCached( repo ):
+ repoManager.buildCache( repo )
+ Z.addResolvables( repoManager.createFromCache( repo ).resolvables() )
+
+print "Items: %d" % ( Z.pool().size() )
+
+if False:
+ for item in Z.pool():
+ if item.status().isInstalled():
+ t = "i"
+ else:
+ t = "*"
+ print "%s %s:%s-%s.%s\t(%s)" % ( t,
+ item.resolvable().kind(),
+ item.resolvable().name(),
+ item.resolvable().edition(),
+ item.resolvable().arch(),
+ item.resolvable().repository().info().alias() )
void removeRepository( const RepoInfo & info,
const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
RepoInfo getRepositoryInfo( const std::string &alias,
- const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
};
--- /dev/null
+
+struct ScanRpmDbReceive
+{
+ void set_pymethod(PyObject *pyfunc);
+};
+
+%{
+ namespace zypp
+ {
+ struct ScanRpmDbReceive : public callback::ReceiveReport<target::rpm::ScanDBReport>
+ {
+ typedef target::rpm::ScanDBReport Report;
+
+ ScanRpmDbReceive()
+ : _pyfunc( 0 )
+ { connect(); }
+
+ ~ScanRpmDbReceive()
+ { disconnect(); }
+
+ virtual void start()
+ {
+ std::cerr << "ScanRpmDbReceive start" << std::endl;
+ _last = -1;
+ }
+
+ virtual bool progress(int value)
+ {
+ if ( value == _last )
+ return Report::progress( value );
+ _last = value;
+
+ if ( ! _pyfunc )
+ return Report::progress( value );
+
+ bool ret = Report::progress( value );
+ PyObject * arglist = Py_BuildValue( "(i)", value ); // Build argument list
+ PyObject * result = PyEval_CallObject( _pyfunc, arglist ); // Call Python
+ Py_DECREF( arglist ); // Trash arglist
+ if ( result ) { // If no errors, return bool
+ ret = PyLong_AsLong( result );
+ }
+ Py_XDECREF( result );
+ return ret;
+ }
+
+ virtual Action problem( target::rpm::ScanDBReport::Error error, const std::string & description )
+ {
+ //std::cerr << "ScanRpmDbReceive problem" << std::endl;
+ return Report::problem( error, description );
+ }
+
+ virtual void finish( Error error, const std::string & reason )
+ {
+ //std::cerr << "ScanRpmDbReceive finish" << std::endl;
+ }
+
+ void set_pymethod( PyObject * pyfunc_r )
+ {
+ Py_INCREF( pyfunc_r );
+ if ( _pyfunc )
+ Py_DECREF( _pyfunc );
+ _pyfunc = pyfunc_r;
+ }
+
+ private:
+ int _last;
+ PyObject * _pyfunc;
+ };
+ }
+%}
%include "TmpPath.i"
%include "ItemCapKind.i"
%include "Resolver.i"
+#ifdef SWIGPYTHON
+%include "python/callbacks.i"
+#endif
class ZYpp