File: pk-spawn-dispatcher.py

package info (click to toggle)
packagekit 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,704 kB
  • sloc: ansic: 56,209; cpp: 13,919; python: 4,970; xml: 4,945; sh: 313; perl: 60; makefile: 57
file content (47 lines) | stat: -rwxr-xr-x 1,497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
#
# 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Copyright (C) 2008 Tim Lauridsen <timlau@fedoraproject.org>
# Copyright (C) 2008 Richard Hughes <richard@hughsie.com>

# Dispacher script to run pk commands from stdin

import sys
import time
import os

sys.path.insert(0,os.path.join(os.getcwd(), 'lib', 'python'))

from packagekit.backend import *

class PackageKitYumBackend(PackageKitBaseBackend):
    def __init__(self, args, lock=True):
        PackageKitBaseBackend.__init__(self, args)
        PackageKitBaseBackend.doLock(self)
        # simulate doing something
        time.sleep(2)

    def unLock(self):
        PackageKitBaseBackend.unLock(self)
        # simulate doing something
        time.sleep(0.5)

    def search_name(self, filters, key):
        # check we escape spaces properly
        if key == ['power manager']:
            self.package("polkit;0.0.1;i386;data", INFO_AVAILABLE, "PolicyKit daemon")

def main():
    backend = PackageKitYumBackend('', lock=True)
    backend.dispatcher(sys.argv[1:])

if __name__ == "__main__":
    main()