README 1.51 KB
Newer Older
Bahadır Kandemir's avatar
Bahadır Kandemir committed
1
COMAR API package offers modules for accessing COMAR over D-Bus without pain and 
Ozan Çağlayan's avatar
Ozan Çağlayan committed
2
common methods/classes for COMAR scripts.
Bahadır Kandemir's avatar
Bahadır Kandemir committed
3

Ozan Çağlayan's avatar
Ozan Çağlayan committed
4
Here are some examples for accessing COMAR:
Bahadır Kandemir's avatar
Bahadır Kandemir committed
5 6 7 8

    import comar
    link = comar.Link()

9 10 11
    # Localize strings
    link.setLocale()

12 13 14
    # Never use authentication agent (GUI)
    link.useAgent(False)

Bahadır Kandemir's avatar
Bahadır Kandemir committed
15 16 17 18 19 20
    # Get a list of packages that provide system.service method
    packages = list(link.System.Service)

    # Start a service
    link.System.Service["kdebase"].start()

Ozan Çağlayan's avatar
Ozan Çağlayan committed
21
    # Stop all services and ignore replies from packages.
22
    link.System.Service.stop(quiet=True)
Bahadır Kandemir's avatar
Bahadır Kandemir committed
23

Ozan Çağlayan's avatar
Ozan Çağlayan committed
24
Asynchronous calls:
Bahadır Kandemir's avatar
Bahadır Kandemir committed
25 26 27 28 29 30 31 32 33

    import gobject
    import dbus.mainloop.glib
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    mainloop = gobject.MainLoop()

    import comar
    link = comar.Link()

34 35 36
    # Localize strings
    link.setLocale()

Bahadır Kandemir's avatar
Bahadır Kandemir committed
37 38 39
    # Use authentication agent (GUI)
    link.useAgent()

Bahadır Kandemir's avatar
Bahadır Kandemir committed
40 41 42 43 44 45 46 47 48
    # Make an asynchronous call to get service information
    def handler(package, exception, result):
        if exception:
            print "%s error: %s" % (package, exception)
        else:
            print "%s result: %s" % (package, result)
    link.System.Service.info(async=handler)

    mainloop.run()
49 50 51 52 53 54 55 56 57

Connecting COMAR service on alternate destination:

    import comar
    link = comar.Link(alternate=True)

This will simply try to connect tr.org.pardus.comar2 instead 
of tr.org.pardus.comar

Bahadır Kandemir's avatar
Bahadır Kandemir committed
58 59 60 61
Connecting to alternative DBus server:

    import comar
    link = comar.Link(socket="/mnt/target/var/run/dbus/system_bus_socket")