Permalink
Browse files

Update for distribution

- fix setup.py, adding default dir for backend data
- add release.sh to generate tarballs
- add doc dirs and examples
  • Loading branch information...
1 parent 0410f6d commit 4a1bb76c85742729211cc92addf588d7f85aca85 J. Victor Martins committed Mar 11, 2011
Showing with 102 additions and 8 deletions.
  1. +30 −0 doc/examples/list_media.py
  2. +44 −0 doc/examples/task.py
  3. +4 −0 mdvpkg/__init__.py
  4. +3 −1 mdvpkg/daemon.py
  5. +11 −0 release.sh
  6. +10 −7 setup.py
View
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+
+import dbus
+import mdvpkg
+import gobject
+from dbus.mainloop.glib import DBusGMainLoop
+
+DBusGMainLoop(set_as_default=True)
+loop = gobject.MainLoop()
+
+bus = dbus.SessionBus()
+proxy = bus.get_object(mdvpkg.DBUS_SERVICE, mdvpkg.DBUS_PATH)
+task_path = proxy.GetTask('ListMedia', dbus_interface=mdvpkg.DBUS_INTERFACE)
+
+def media_cb(*args):
+ print 'media %s (update=%s, ignore=%s)' % args
+
+def finished_cb():
+ loop.quit()
+
+proxy = bus.get_object(mdvpkg.DBUS_SERVICE, task_path)
+proxy.connect_to_signal('Media',
+ media_cb,
+ dbus_interface=mdvpkg.DBUS_TASK_INTERFACE)
+proxy.connect_to_signal('Finished',
+ finished_cb,
+ dbus_interface=mdvpkg.DBUS_TASK_INTERFACE)
+proxy.Run(dbus_interface=mdvpkg.DBUS_TASK_INTERFACE)
+
+loop.run()
View
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+import mdvpkg
+import gobject
+from dbus.mainloop.glib import DBusGMainLoop
+
+try:
+ task_name = sys.argv[1]
+except IndexError:
+ print 'Missing task name.'
+ sys.exit(1)
+
+print 'TASK:', task_name, sys.argv[2:]
+DBusGMainLoop(set_as_default=True)
+loop = gobject.MainLoop()
+
+bus = dbus.SessionBus()
+
+def signal_cb(*args, **kwargs):
+ signal = kwargs['signal']
+ print 'SIGNAL %s: %s' % (signal, args)
+ if signal == 'Finished':
+ loop.quit()
+
+bus.add_signal_receiver(signal_cb, dbus_interface=mdvpkg.DBUS_INTERFACE,
+ member_keyword='signal')
+bus.add_signal_receiver(signal_cb, dbus_interface=mdvpkg.DBUS_TASK_INTERFACE,
+ member_keyword='signal')
+
+proxy = bus.get_object(mdvpkg.DBUS_SERVICE, mdvpkg.DBUS_PATH)
+task_path = proxy.GetTask(task_name, dbus_interface=mdvpkg.DBUS_INTERFACE)
+
+proxy = bus.get_object(mdvpkg.DBUS_SERVICE, task_path)
+iface = dbus.Interface(proxy, dbus_interface=mdvpkg.DBUS_TASK_INTERFACE)
+
+for cmd in sys.argv[2:]:
+ (name, args) = cmd.split('=')
+ method = getattr(iface, name)
+ method(*args.split(','))
+
+iface.Run()
+loop.run()
View
@@ -30,3 +30,7 @@
DBUS_TASK_PATH = '%stask' % DBUS_PATH
DBUS_TASK_INTERFACE = '%s.task' % DBUS_INTERFACE
+
+DEFAULT_DATA_DIR = '/usr/share/mdvpkg'
+DEFAULT_BACKEND_DIR = '%s/backend' % DEFAULT_DATA_DIR
+DEFAULT_BACKEND_PATH = '%s/urpmi_backend.pl' % DEFAULT_BACKEND_DIR
View
@@ -47,10 +47,12 @@ class MDVPKGDaemon(dbus.service.Object):
base of package managing operations.
"""
- def __init__(self, bus=None, backend_path='urpmi_backend.pl'):
+ def __init__(self, bus=None, backend_path=None):
if not bus:
bus = dbus.SystemBus()
self._bus = bus
+ if not backend_path:
+ backend_path = mdvpkg.DEFAULT_BACKEND_PATH
self._loop = gobject.MainLoop()
try:
bus_name = dbus.service.BusName(mdvpkg.DBUS_SERVICE,
View
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+VERSION=`python -c 'import mdvpkg; print mdvpkg.__version__'`
+TARBALL=mdvpkg-$VERSION.tar
+if [ -e $TARBALL.bz2 ]; then
+ echo "Archive already created"
+ exit 1
+fi
+
+git archive --format=tar HEAD > $TARBALL
+bzip2 $TARBALL
View
@@ -1,18 +1,21 @@
-import mdvpkgd
+import mdvpkg
from distutils.core import setup
from glob import glob
data_files = [ ('/etc/dbus-1/system.d/',
glob('dbus/*.conf')),
('/usr/share/dbus-1/system-services/',
- glob('dbus/*.service')) ]
+ glob('dbus/*.service')),
+ (mdvpkg.MDVPKG_BACKEND_DIR,
+ glob('backend/*')),
+ ('/usr/sbin/',
+ ['bin/mdvpkgd']) ]
-setup(name='mdvpkgd',
- version=mdvpkgd.__version__,
+setup(name='mdvpkg',
+ version=mdvpkg.__version__,
description='Mandriva Package Daemon',
- license='GNU GPLv3',
+ license='GNU GPL',
author='J. Victor Martins',
author_email='jvdm@mandriva.com',
- packages=['mdvpkgd'],
- scripts=['bin/mdvpkgd'],
+ packages=['mdvpkg'],
data_files=data_files)

0 comments on commit 4a1bb76

Please sign in to comment.