[packagekit] packagekit: Branch 'master' - 4 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Sep 26 11:30:47 PDT 2007
Makefile.am | 1
data/Makefile.am | 1
dev/null |binary
python/packagekit/__init__.py | 167 +++---------------------------------------
python/packagekit/frontend.py | 159 +++++++++++++++++++++++++++++++++++++++
python/pk-frontend-test.py | 2
6 files changed, 175 insertions(+), 155 deletions(-)
New commits:
diff-tree 00229dd1868eea15321198bc96f77d7b154ff389 (from 857cdecbb3e7fd76fe6869074e4a0f92cd4db8d9)
Author: Tom Parker <palfrey at tevp.net>
Date: Wed Sep 26 14:42:47 2007 +0200
Add new tid stuff to python interface
diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index 6c71eb7..21bb908 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -76,6 +76,9 @@ class PackageKit:
return jid
return wrapper
+ def tid(self):
+ return self.pk_iface.GetTid()
+
def __init__(self):
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
@@ -140,18 +143,17 @@ class PackageKit:
@dbusException
@job_id
def SearchName(self,pattern,filter="none"):
- return self.pk_iface.SearchName(filter,pattern)
+ return self.pk_iface.SearchName(self.tid(),filter,pattern)
@dbusException
@job_id
def GetDescription(self,package_id):
- return self.pk_iface.GetDescription(package_id)
+ return self.pk_iface.GetDescription(self.tid(),package_id)
@dbusException
@job_id
def RefreshCache(self,force=False):
- return self.pk_iface.RefreshCache(force)
+ return self.pk_iface.RefreshCache(self.tid(),force)
# hack to avoid exporting them
-#del job_id
del dbusException
diff-tree 857cdecbb3e7fd76fe6869074e4a0f92cd4db8d9 (from c304d59b59f9615184aaca587c32e61af4eb22f0)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Wed Sep 26 10:36:38 2007 +0200
Renamed python/pkt -> python/pk-frontend-test.py & make it use import packagekit.frontend
Added GPL header to python/__init__.py
Added python/frontend.py to Makefile
diff --git a/Makefile.am b/Makefile.am
index 43fb928..705c05e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,6 +26,7 @@ packagekitpythondir = ${PYTHON_PACKAGE_D
packagekitpython_PYTHON = \
python/packagekit/__init__.py \
python/packagekit/backend.py \
+ python/packagekit/frontend.py \
$(NULL)
diff --git a/python/packagekit/__init__.py b/python/packagekit/__init__.py
index e69de29..3485bf0 100644
--- a/python/packagekit/__init__.py
+++ b/python/packagekit/__init__.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python -tt
+# 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.
+#
+# Copyright (C) 2007 Tim Lauridsen <timlau at fedoraproject.org>
+
+# packagekit python module common stuff.
\ No newline at end of file
diff --git a/python/pk-frontend-test.py b/python/pk-frontend-test.py
new file mode 100755
index 0000000..358b48d
--- /dev/null
+++ b/python/pk-frontend-test.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+#
+# "pkt" python test program for PackageKit
+#
+# pkt serves both as a simple PackageKit client, and as an example user of the
+# PackageKit python API
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License v2 as published by
+# the Free Software Foundation.
+
+from sys import argv,exit
+from optparse import OptionParser
+from types import FunctionType
+
+from packagekit.frontend import *
+
+class pkt(PackageKit):
+ def Percentage(self,progress):
+ print "Progress: %.2f%%"%progress
+
+ def JobStatus(self,type):
+ print "Job type: %s"%type
+
+ def Package(self,name,description):
+ print "Package: %s - %s"%(name,description)
+
+try:
+ p = pkt()
+except PackageKitNotStarted:
+ print "PackageKit doesn't appear to be started. You may need to enable dbus autostart"
+ exit(1)
+
+def search(*args):
+ patt = " ".join(args[0])
+ if len(patt)==0:
+ print "need something to search for"
+ raise PackageKitTransactionFailure
+ return p.SearchName(patt)
+
+def desc(*args):
+ if len(args)!=1 or len(args[0])!=1:
+ print "desc only takes single arg"
+ raise PackageKitTransactionFailure
+ return p.GetDescription(args[0][0])
+
+def update(args):
+ if len(args)>0 and len(args[0])>0:
+ print "update doesn't take args"
+ raise PackageKitTransactionFailure
+ return p.RefreshCache()
+
+def usage():
+ print "Usage: %s <command> <options>"%argv[0]
+ print "Valid commands are:"
+ for k in globals().keys():
+ if k in ["usage","catchall_signal_handler"]: #ignore
+ continue
+ g = globals()[k]
+ if type(g) == FunctionType:
+ print "\t%s"%k
+ exit(1)
+
+parser = OptionParser()
+(options, args) = parser.parse_args()
+
+if len(args)==0:
+ usage()
+
+if not globals().has_key(args[0]):
+ print "Don't know operation '%s'"%args[0]
+ usage()
+
+try:
+ job = globals()[args[0]](args[1:])
+except PackageKitAccessDenied:
+ print "You don't have sufficient permissions to access PackageKit (on the org.freedesktop.PackageKit dbus service)"
+ exit(1)
+except PackageKitTransactionFailure:
+ usage()
+
+p.run()
diff --git a/python/pkt b/python/pkt
deleted file mode 100755
index ab8b71b..0000000
--- a/python/pkt
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/python
-#
-# "pkt" python test program for PackageKit
-#
-# pkt serves both as a simple PackageKit client, and as an example user of the
-# PackageKit python API
-#
-# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
-#
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License v2 as published by
-# the Free Software Foundation.
-
-from sys import argv,exit
-from optparse import OptionParser
-from types import FunctionType
-
-from packagekit import *
-
-class pkt(PackageKit):
- def Percentage(self,progress):
- print "Progress: %.2f%%"%progress
-
- def JobStatus(self,type):
- print "Job type: %s"%type
-
- def Package(self,name,description):
- print "Package: %s - %s"%(name,description)
-
-try:
- p = pkt()
-except PackageKitNotStarted:
- print "PackageKit doesn't appear to be started. You may need to enable dbus autostart"
- exit(1)
-
-def search(*args):
- patt = " ".join(args[0])
- if len(patt)==0:
- print "need something to search for"
- raise PackageKitTransactionFailure
- return p.SearchName(patt)
-
-def desc(*args):
- if len(args)!=1 or len(args[0])!=1:
- print "desc only takes single arg"
- raise PackageKitTransactionFailure
- return p.GetDescription(args[0][0])
-
-def update(args):
- if len(args)>0 and len(args[0])>0:
- print "update doesn't take args"
- raise PackageKitTransactionFailure
- return p.RefreshCache()
-
-def usage():
- print "Usage: %s <command> <options>"%argv[0]
- print "Valid commands are:"
- for k in globals().keys():
- if k in ["usage","catchall_signal_handler"]: #ignore
- continue
- g = globals()[k]
- if type(g) == FunctionType:
- print "\t%s"%k
- exit(1)
-
-parser = OptionParser()
-(options, args) = parser.parse_args()
-
-if len(args)==0:
- usage()
-
-if not globals().has_key(args[0]):
- print "Don't know operation '%s'"%args[0]
- usage()
-
-try:
- job = globals()[args[0]](args[1:])
-except PackageKitAccessDenied:
- print "You don't have sufficient permissions to access PackageKit (on the org.freedesktop.PackageKit dbus service)"
- exit(1)
-except PackageKitTransactionFailure:
- usage()
-
-p.run()
diff-tree c304d59b59f9615184aaca587c32e61af4eb22f0 (from c664de2cf607494cd39412d2e00d4f6e06423197)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Wed Sep 26 10:27:30 2007 +0200
moved frontend python code from packagekit/__init__.py to frontend.py
diff --git a/python/packagekit/__init__.py b/python/packagekit/__init__.py
index 6c71eb7..e69de29 100644
--- a/python/packagekit/__init__.py
+++ b/python/packagekit/__init__.py
@@ -1,157 +0,0 @@
-# PackageKit python interface
-#
-# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
-#
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License v2 as published by
-# the Free Software Foundation.
-
-from types import *
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-
-class PackageKitException(Exception):
- def __init__(self):
- Exception.__init__(self)
-
- def __init__(self,e=None):
- Exception.__init__(self)
- if e == None:
- self._pk_name = None
- self._full_str = None
- else:
- if not isinstance(e,dbus.exceptions.DBusException):
- raise Exception,"Can only handle DBusExceptions"
- self._pk_name = str(e.get_dbus_name())
- self._full_str = str(e)
-
- def get_backend_name(self):
- return self._pk_name
-
- def __str__(self):
- if self._full_str!=None:
- return self._full_str
- else:
- return ""
-
-class PackageKitNotStarted(PackageKitException):
- pass
-
-class PackageKitAccessDenied(PackageKitException):
- pass
-
-class PackageKitTransactionFailure(PackageKitException):
- pass
-
-class PackageKitBackendFailure(PackageKitException):
- pass
-
-def dbusException(func):
- def wrapper(*args,**kwargs):
- try:
- return func(*args,**kwargs)
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
- raise PackageKitAccessDenied
- elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
- raise PackageKitBackendFailure
- else:
- raise PackageKitException(e)
- except Exception:
- print "wibble"
- raise
- return wrapper
-
-
-class PackageKit:
- def job_id(func):
- def wrapper(*args,**kwargs):
- jid = func(*args,**kwargs)
- if jid == -1:
- raise PackageKitTransactionFailure
- else:
- return jid
- return wrapper
-
- def __init__(self):
- DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- try:
- pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
- self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
- raise PackageKitNotStarted
- else:
- raise PackageKitException(e)
-
- #self.job = None
- self.progress = 0.0
- bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
-
- def run(self):
- self.loop = gobject.MainLoop()
- self.loop.run()
-
- def catchall_signal_handler(self,*args, **kwargs):
- #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
- # print "args",args,kwargs
- # return
- if kwargs['member'] == "Finished":
- self.loop.quit()
- self.Finish()
- elif kwargs['member'] == "PercentageChanged":
- progress = float(args[1])+(progress%1.0)
- self.Percentage(progress)
- elif kwargs['member'] == "SubPercentageChanged":
- progress = (float(args[1])/100.0)+int(progress)
- self.Percentage(progress)
- elif kwargs['member'] == "TransactionStatusChanged":
- self.JobStatus(args[1])
- elif kwargs['member'] == "Package":
- self.Package(args[2],args[3])
- elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
- pass
- elif kwargs['member'] == "Description":
- self.Description(args[1],args[3],args[4],args[5])
- else:
- print "Caught signal %s"% kwargs['member']
- for arg in args:
- print " " + str(arg)
-
- def Percentage(self,value):
- pass
-
- def JobStatus(self,string):
- pass
-
- def Finish(self):
- pass
-
- def Package(self,package_name,package_summary):
- pass
-
- def Description(self,package_name,package_group,package_description,package_url):
- pass
-
- @dbusException
- @job_id
- def SearchName(self,pattern,filter="none"):
- return self.pk_iface.SearchName(filter,pattern)
-
- @dbusException
- @job_id
- def GetDescription(self,package_id):
- return self.pk_iface.GetDescription(package_id)
-
- @dbusException
- @job_id
- def RefreshCache(self,force=False):
- return self.pk_iface.RefreshCache(force)
-
-# hack to avoid exporting them
-#del job_id
-del dbusException
diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
new file mode 100644
index 0000000..6c71eb7
--- /dev/null
+++ b/python/packagekit/frontend.py
@@ -0,0 +1,157 @@
+# PackageKit python interface
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License v2 as published by
+# the Free Software Foundation.
+
+from types import *
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+import gobject
+
+class PackageKitException(Exception):
+ def __init__(self):
+ Exception.__init__(self)
+
+ def __init__(self,e=None):
+ Exception.__init__(self)
+ if e == None:
+ self._pk_name = None
+ self._full_str = None
+ else:
+ if not isinstance(e,dbus.exceptions.DBusException):
+ raise Exception,"Can only handle DBusExceptions"
+ self._pk_name = str(e.get_dbus_name())
+ self._full_str = str(e)
+
+ def get_backend_name(self):
+ return self._pk_name
+
+ def __str__(self):
+ if self._full_str!=None:
+ return self._full_str
+ else:
+ return ""
+
+class PackageKitNotStarted(PackageKitException):
+ pass
+
+class PackageKitAccessDenied(PackageKitException):
+ pass
+
+class PackageKitTransactionFailure(PackageKitException):
+ pass
+
+class PackageKitBackendFailure(PackageKitException):
+ pass
+
+def dbusException(func):
+ def wrapper(*args,**kwargs):
+ try:
+ return func(*args,**kwargs)
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
+ raise PackageKitAccessDenied
+ elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
+ raise PackageKitBackendFailure
+ else:
+ raise PackageKitException(e)
+ except Exception:
+ print "wibble"
+ raise
+ return wrapper
+
+
+class PackageKit:
+ def job_id(func):
+ def wrapper(*args,**kwargs):
+ jid = func(*args,**kwargs)
+ if jid == -1:
+ raise PackageKitTransactionFailure
+ else:
+ return jid
+ return wrapper
+
+ def __init__(self):
+ DBusGMainLoop(set_as_default=True)
+ bus = dbus.SystemBus()
+ try:
+ pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
+ self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
+ raise PackageKitNotStarted
+ else:
+ raise PackageKitException(e)
+
+ #self.job = None
+ self.progress = 0.0
+ bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
+
+ def run(self):
+ self.loop = gobject.MainLoop()
+ self.loop.run()
+
+ def catchall_signal_handler(self,*args, **kwargs):
+ #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
+ # print "args",args,kwargs
+ # return
+ if kwargs['member'] == "Finished":
+ self.loop.quit()
+ self.Finish()
+ elif kwargs['member'] == "PercentageChanged":
+ progress = float(args[1])+(progress%1.0)
+ self.Percentage(progress)
+ elif kwargs['member'] == "SubPercentageChanged":
+ progress = (float(args[1])/100.0)+int(progress)
+ self.Percentage(progress)
+ elif kwargs['member'] == "TransactionStatusChanged":
+ self.JobStatus(args[1])
+ elif kwargs['member'] == "Package":
+ self.Package(args[2],args[3])
+ elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
+ pass
+ elif kwargs['member'] == "Description":
+ self.Description(args[1],args[3],args[4],args[5])
+ else:
+ print "Caught signal %s"% kwargs['member']
+ for arg in args:
+ print " " + str(arg)
+
+ def Percentage(self,value):
+ pass
+
+ def JobStatus(self,string):
+ pass
+
+ def Finish(self):
+ pass
+
+ def Package(self,package_name,package_summary):
+ pass
+
+ def Description(self,package_name,package_group,package_description,package_url):
+ pass
+
+ @dbusException
+ @job_id
+ def SearchName(self,pattern,filter="none"):
+ return self.pk_iface.SearchName(filter,pattern)
+
+ @dbusException
+ @job_id
+ def GetDescription(self,package_id):
+ return self.pk_iface.GetDescription(package_id)
+
+ @dbusException
+ @job_id
+ def RefreshCache(self,force=False):
+ return self.pk_iface.RefreshCache(force)
+
+# hack to avoid exporting them
+#del job_id
+del dbusException
diff-tree c664de2cf607494cd39412d2e00d4f6e06423197 (from a6cf9cb051d9e8f3ff6c32b6818087627b989ec8)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 25 23:07:14 2007 +0100
don't install the package.db file, we don't use it
diff --git a/data/Makefile.am b/data/Makefile.am
index 02e8c04..e9a8150 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -17,7 +17,6 @@ localcache_DATA = \
databasedir = $(PK_DB_DIR)
database_DATA = \
- packages.db \
transactions.db \
$(NULL)
diff --git a/data/packages.db b/data/packages.db
deleted file mode 100644
index 23386fe..0000000
Binary files a/data/packages.db and /dev/null differ
More information about the PackageKit
mailing list