Re: crazy ideas for yum/pup/that_damned_applet

Paul Nasrat <[email protected]> Thu, 03 Mar 2005 15:13:08 +0000
Newsgroups gmane.linux.redhat.fedora.configuration
Organization Red Hat, Inc.
Message-ID <[email protected]>
On Thu, 2005-03-03 at 09:23 -0500, seth vidal wrote:
>> I think that's the first step.  I'll try and play today.
>> 
>
>here's the simplest form of the class to do the checking.
>
>it doesn't do anything other than setup, build the updates/obsoletes and
>iterates them.
>
>I don't have any dbus knowledge, yet, so I don't have the event sending
>in there, of course.

Noddy dbus example.

Drop yum.conf in /etc/dbus-1/system.d

/sbin/service messagebus restart

in a terminal on the console run

dbus-monitor --system

elsewhere sudo python yum-test-check.py

See the lovely output:

string:('evolution-webcal', 'i386', '0', '2.1.92', '1')
signal interface=edu.duke.linux.Yum; member=updates; sender=:1.10
string:('up2date-gnome', 'i386', '0', '4.4.9', '1')
signal interface=edu.duke.linux.Yum; member=updates; sender=:1.10
string:('cups', 'i386', '1', '1.1.23', '12')

Paul

-- 
Fedora-config-list mailing list
[email protected]
http://www.redhat.com/mailman/listinfo/fedora-config-list
yum-test-check.py (application/x-python, 1.9 KB)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# seth vidal 2005 (c) etc etc

import yum
import yum.Errors
import sys
import os
import libxml2
import dbus

class YumNotifier(dbus.Object):
    def __init__(self,service):
        dbus.Object.__init__(self, "/edu/duke/linux/Yum/object", service, [self.notify])

    def notify(self, type, msg):
        self.emit_signal("edu.duke.linux.Yum", type, str(msg))


class YumQuiet(yum.YumBase):
    def __init__(self):
        yum.YumBase.__init__(self)
    
    def log(self, value, msg):
        pass

def main():
    my = YumQuiet()
    my.doConfigSetup()
    try:
        my.doRepoSetup()
    except yum.Errors.RepoError, e:
        print >> sys.stderr, '%s' % e
        print >> sys.stderr, 'Cannot continue'
        sys.exit(1)
    my.doSackSetup()
    my.doTsSetup()
    my.doRpmDBSetup()
    my.doUpdateSetup()
    updates = my.up.getUpdatesTuples()
    obsoletes = []
    if my.conf.obsoletes:
        obsoletes = my.up.getObsoletesTuples(newest=1)

    bus = dbus.SystemBus ()
    service = dbus.Service("edu.duke.linux.Yum", bus=bus)
    notifier = YumNotifier(service)

    for (obs, ins) in obsoletes:
        notifier.notify("obsoletes", obs)
    
    for (new, old) in updates:
        notifier.notify("updates", new)

if __name__ == "__main__":
    main()
yum.conf (text/plain, 798 B)
<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
        <policy user="root">
                <allow own="edu.duke.linux.Yum"/>

                <allow send_destination="edu.duke.linux.Yum"/>
                <allow send_interface="edu.duke.linux.Yum"/>
        </policy>
        <policy at_console="true">
                <allow receive_sender="edu.duke.linux.Yum"/>
                <allow receive_interface = "edu.duke.linux.Yum"/>
        </policy>
        <policy context="default">
                <deny own="edu.duke.linux.Yum"/>
                <deny send_destination="edu.duke.linux.Yum"/>
                <deny send_interface="edu.duke.linux.Yum"/>
        </policy>
</busconfig>