Debian Codegraph @

installpackage.py

raw
1 #!/usr/bin/python3
2
3 ## system-config-printer
4
5 ## Copyright (C) 2008, 2009, 2014 Red Hat, Inc.
6 ## Copyright (C) 2008, 2009 Tim Waugh <[email protected]>
7
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
17
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; if not, write to the Free Software
20 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 import os
23 import dbus
24 import dbus.glib
25 from gi.repository import GLib
26 from debug import *
27
28 class PackageKit:
29 DBUS_NAME="org.freedesktop.PackageKit"
30 DBUS_PATH="/org/freedesktop/PackageKit"
31 DBUS_IFACE="org.freedesktop.PackageKit.Modify"
32
33 def __init__ (self):
34 try:
35 bus = dbus.SessionBus ()
36 remote_object = bus.get_object(self.DBUS_NAME, self.DBUS_PATH)
37 iface = dbus.Interface(remote_object, self.DBUS_IFACE)
38 except dbus.exceptions.DBusException:
39 # System bus not running.
40 iface = None
41 self.iface = iface
42
43 def InstallPackageName (self, xid, timestamp, name):
44 try:
45 if self.iface is not None:
46 self.iface.InstallPackageNames(xid, [name],
47 "show-progress,show-finished,show-warning",
48 timeout = 999999)
49 except dbus.exceptions.DBusException:
50 pass
51
52 def InstallProvideFile (self, xid, timestamp, filename):
53 try:
54 if self.iface is not None:
55 self.iface.InstallProvideFiles(xid, [filename],
56 "show-progress,show-finished,show-warning",
57 timeout = 999999)
58 except dbus.exceptions.DBusException:
59 pass