~aptdaemon-developers/aptdaemon/add-license-key-call

« back to all changes in this revision

Viewing changes to aptdaemon/client.py

  • Committer: Martin Pitt
  • Date: 2011-08-17 05:58:09 UTC
  • Revision ID: martin.pitt@ubuntu.com-20110817055809-g42ql4v2uekt1fs0
convert aptdaemon/client.py and aptdaemon/debconf.py from gobject to GObject as well; works with earlier pygobject versions and gtkclient.py, and makes this work with pygobject 2.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import dbus.glib
36
36
import dbus.mainloop.glib
37
37
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
38
 
import gobject
 
38
from gi.repository import GObject
39
39
 
40
40
import enums
41
41
import debconf
62
62
            return value
63
63
 
64
64
 
65
 
class MemoizedMixIn(MemoizedTransaction, gobject.GObjectMeta):
 
65
class MemoizedMixIn(MemoizedTransaction, GObject.GObjectMeta):
66
66
 
67
67
    """Helper meta class for merging"""
68
68
 
69
69
 
70
 
class AptTransaction(gobject.GObject):
 
70
class AptTransaction(GObject.GObject):
71
71
 
72
72
    """Represents an aptdaemon transaction.
73
73
 
407
407
 
408
408
    __metaclass__ = MemoizedMixIn
409
409
 
410
 
    __gsignals__ = {"finished": (gobject.SIGNAL_RUN_FIRST,
411
 
                                 gobject.TYPE_NONE,
412
 
                                 (gobject.TYPE_STRING,)),
413
 
                    "dependencies-changed": (gobject.SIGNAL_RUN_FIRST,
414
 
                                             gobject.TYPE_NONE,
415
 
                                             (gobject.TYPE_PYOBJECT,
416
 
                                              gobject.TYPE_PYOBJECT,
417
 
                                              gobject.TYPE_PYOBJECT,
418
 
                                              gobject.TYPE_PYOBJECT,
419
 
                                              gobject.TYPE_PYOBJECT,
420
 
                                              gobject.TYPE_PYOBJECT,
421
 
                                              gobject.TYPE_PYOBJECT)),
422
 
                    "download-changed": (gobject.SIGNAL_RUN_FIRST,
423
 
                                         gobject.TYPE_NONE,
424
 
                                         (gobject.TYPE_INT,)),
425
 
                    "space-changed": (gobject.SIGNAL_RUN_FIRST,
426
 
                                      gobject.TYPE_NONE,
427
 
                                      (gobject.TYPE_INT,)),
428
 
                    "error": (gobject.SIGNAL_RUN_FIRST,
429
 
                              gobject.TYPE_NONE,
430
 
                              (gobject.TYPE_STRING, gobject.TYPE_STRING)),
431
 
                    "role-changed": (gobject.SIGNAL_RUN_FIRST,
432
 
                                     gobject.TYPE_NONE,
433
 
                                     (gobject.TYPE_STRING,)),
434
 
                    "terminal-attached-changed": (gobject.SIGNAL_RUN_FIRST,
435
 
                                                    gobject.TYPE_NONE,
436
 
                                                    (gobject.TYPE_BOOLEAN,)),
437
 
                    "cancellable-changed": (gobject.SIGNAL_RUN_FIRST,
438
 
                                            gobject.TYPE_NONE,
439
 
                                            (gobject.TYPE_BOOLEAN,)),
440
 
                    "meta-data-changed": (gobject.SIGNAL_RUN_FIRST,
441
 
                                          gobject.TYPE_NONE,
442
 
                                          (gobject.TYPE_PYOBJECT,)),
443
 
                    "status-changed": (gobject.SIGNAL_RUN_FIRST,
444
 
                                       gobject.TYPE_NONE,
445
 
                                       (gobject.TYPE_STRING,)),
446
 
                    "status-details-changed": (gobject.SIGNAL_RUN_FIRST,
447
 
                                               gobject.TYPE_NONE,
448
 
                                               (gobject.TYPE_STRING,)),
449
 
                    "progress-changed": (gobject.SIGNAL_RUN_FIRST,
450
 
                                 gobject.TYPE_NONE,
451
 
                                 (gobject.TYPE_INT,)),
452
 
                    "progress-details-changed": (gobject.SIGNAL_RUN_FIRST,
453
 
                                         gobject.TYPE_NONE,
454
 
                                         (gobject.TYPE_INT, gobject.TYPE_INT,
455
 
                                          gobject.TYPE_INT, gobject.TYPE_INT,
456
 
                                          gobject.TYPE_INT, gobject.TYPE_INT)),
457
 
                    "progress-download-changed": (gobject.SIGNAL_RUN_FIRST,
458
 
                                         gobject.TYPE_NONE,
459
 
                                         (gobject.TYPE_STRING,
460
 
                                          gobject.TYPE_STRING,
461
 
                                          gobject.TYPE_STRING,
462
 
                                          gobject.TYPE_INT,
463
 
                                          gobject.TYPE_INT,
464
 
                                          gobject.TYPE_STRING)),
465
 
                    "packages-changed": (gobject.SIGNAL_RUN_FIRST,
466
 
                                         gobject.TYPE_NONE,
467
 
                                         (gobject.TYPE_PYOBJECT,
468
 
                                          gobject.TYPE_PYOBJECT,
469
 
                                          gobject.TYPE_PYOBJECT,
470
 
                                          gobject.TYPE_PYOBJECT,
471
 
                                          gobject.TYPE_PYOBJECT,
472
 
                                          gobject.TYPE_PYOBJECT)),
473
 
                    "unauthenticated-changed": (gobject.SIGNAL_RUN_FIRST,
474
 
                                                gobject.TYPE_NONE,
475
 
                                                (gobject.TYPE_PYOBJECT,
 
410
    __gsignals__ = {"finished": (GObject.SIGNAL_RUN_FIRST,
 
411
                                 GObject.TYPE_NONE,
 
412
                                 (GObject.TYPE_STRING,)),
 
413
                    "dependencies-changed": (GObject.SIGNAL_RUN_FIRST,
 
414
                                             GObject.TYPE_NONE,
 
415
                                             (GObject.TYPE_PYOBJECT,
 
416
                                              GObject.TYPE_PYOBJECT,
 
417
                                              GObject.TYPE_PYOBJECT,
 
418
                                              GObject.TYPE_PYOBJECT,
 
419
                                              GObject.TYPE_PYOBJECT,
 
420
                                              GObject.TYPE_PYOBJECT,
 
421
                                              GObject.TYPE_PYOBJECT)),
 
422
                    "download-changed": (GObject.SIGNAL_RUN_FIRST,
 
423
                                         GObject.TYPE_NONE,
 
424
                                         (GObject.TYPE_INT,)),
 
425
                    "space-changed": (GObject.SIGNAL_RUN_FIRST,
 
426
                                      GObject.TYPE_NONE,
 
427
                                      (GObject.TYPE_INT,)),
 
428
                    "error": (GObject.SIGNAL_RUN_FIRST,
 
429
                              GObject.TYPE_NONE,
 
430
                              (GObject.TYPE_STRING, GObject.TYPE_STRING)),
 
431
                    "role-changed": (GObject.SIGNAL_RUN_FIRST,
 
432
                                     GObject.TYPE_NONE,
 
433
                                     (GObject.TYPE_STRING,)),
 
434
                    "terminal-attached-changed": (GObject.SIGNAL_RUN_FIRST,
 
435
                                                    GObject.TYPE_NONE,
 
436
                                                    (GObject.TYPE_BOOLEAN,)),
 
437
                    "cancellable-changed": (GObject.SIGNAL_RUN_FIRST,
 
438
                                            GObject.TYPE_NONE,
 
439
                                            (GObject.TYPE_BOOLEAN,)),
 
440
                    "meta-data-changed": (GObject.SIGNAL_RUN_FIRST,
 
441
                                          GObject.TYPE_NONE,
 
442
                                          (GObject.TYPE_PYOBJECT,)),
 
443
                    "status-changed": (GObject.SIGNAL_RUN_FIRST,
 
444
                                       GObject.TYPE_NONE,
 
445
                                       (GObject.TYPE_STRING,)),
 
446
                    "status-details-changed": (GObject.SIGNAL_RUN_FIRST,
 
447
                                               GObject.TYPE_NONE,
 
448
                                               (GObject.TYPE_STRING,)),
 
449
                    "progress-changed": (GObject.SIGNAL_RUN_FIRST,
 
450
                                 GObject.TYPE_NONE,
 
451
                                 (GObject.TYPE_INT,)),
 
452
                    "progress-details-changed": (GObject.SIGNAL_RUN_FIRST,
 
453
                                         GObject.TYPE_NONE,
 
454
                                         (GObject.TYPE_INT, GObject.TYPE_INT,
 
455
                                          GObject.TYPE_INT, GObject.TYPE_INT,
 
456
                                          GObject.TYPE_INT, GObject.TYPE_INT)),
 
457
                    "progress-download-changed": (GObject.SIGNAL_RUN_FIRST,
 
458
                                         GObject.TYPE_NONE,
 
459
                                         (GObject.TYPE_STRING,
 
460
                                          GObject.TYPE_STRING,
 
461
                                          GObject.TYPE_STRING,
 
462
                                          GObject.TYPE_INT,
 
463
                                          GObject.TYPE_INT,
 
464
                                          GObject.TYPE_STRING)),
 
465
                    "packages-changed": (GObject.SIGNAL_RUN_FIRST,
 
466
                                         GObject.TYPE_NONE,
 
467
                                         (GObject.TYPE_PYOBJECT,
 
468
                                          GObject.TYPE_PYOBJECT,
 
469
                                          GObject.TYPE_PYOBJECT,
 
470
                                          GObject.TYPE_PYOBJECT,
 
471
                                          GObject.TYPE_PYOBJECT,
 
472
                                          GObject.TYPE_PYOBJECT)),
 
473
                    "unauthenticated-changed": (GObject.SIGNAL_RUN_FIRST,
 
474
                                                GObject.TYPE_NONE,
 
475
                                                (GObject.TYPE_PYOBJECT,
476
476
                                                 )),
477
 
                    "paused": (gobject.SIGNAL_RUN_FIRST,
478
 
                               gobject.TYPE_NONE,
 
477
                    "paused": (GObject.SIGNAL_RUN_FIRST,
 
478
                               GObject.TYPE_NONE,
479
479
                               ()),
480
 
                    "resumed": (gobject.SIGNAL_RUN_FIRST,
481
 
                                gobject.TYPE_NONE,
 
480
                    "resumed": (GObject.SIGNAL_RUN_FIRST,
 
481
                                GObject.TYPE_NONE,
482
482
                                ()),
483
 
                    "allow-unauthenticated-changed": (gobject.SIGNAL_RUN_FIRST,
484
 
                                                      gobject.TYPE_NONE,
485
 
                                                      (gobject.TYPE_BOOLEAN,)),
486
 
                    "remove-obsoleted-depends-changed": (gobject.SIGNAL_RUN_FIRST,
487
 
                                                 gobject.TYPE_NONE,
488
 
                                                 (gobject.TYPE_BOOLEAN,)),
489
 
                    "locale-changed": (gobject.SIGNAL_RUN_FIRST,
490
 
                                       gobject.TYPE_NONE,
491
 
                                       (gobject.TYPE_STRING,)),
492
 
                    "terminal-changed": (gobject.SIGNAL_RUN_FIRST,
493
 
                                         gobject.TYPE_NONE,
494
 
                                         (gobject.TYPE_STRING,)),
495
 
                    "debconf-socket-changed": (gobject.SIGNAL_RUN_FIRST,
496
 
                                               gobject.TYPE_NONE,
497
 
                                               (gobject.TYPE_STRING,)),
498
 
                    "http-proxy-changed": (gobject.SIGNAL_RUN_FIRST,
499
 
                                           gobject.TYPE_NONE,
500
 
                                           (gobject.TYPE_STRING,)),
501
 
                    "medium-required": (gobject.SIGNAL_RUN_FIRST,
502
 
                                        gobject.TYPE_NONE,
503
 
                                        (gobject.TYPE_STRING,
504
 
                                         gobject.TYPE_STRING)),
505
 
                    "config-file-conflict": (gobject.SIGNAL_RUN_FIRST,
506
 
                                             gobject.TYPE_NONE,
507
 
                                             (gobject.TYPE_STRING,
508
 
                                              gobject.TYPE_STRING)),
 
483
                    "allow-unauthenticated-changed": (GObject.SIGNAL_RUN_FIRST,
 
484
                                                      GObject.TYPE_NONE,
 
485
                                                      (GObject.TYPE_BOOLEAN,)),
 
486
                    "remove-obsoleted-depends-changed": (GObject.SIGNAL_RUN_FIRST,
 
487
                                                 GObject.TYPE_NONE,
 
488
                                                 (GObject.TYPE_BOOLEAN,)),
 
489
                    "locale-changed": (GObject.SIGNAL_RUN_FIRST,
 
490
                                       GObject.TYPE_NONE,
 
491
                                       (GObject.TYPE_STRING,)),
 
492
                    "terminal-changed": (GObject.SIGNAL_RUN_FIRST,
 
493
                                         GObject.TYPE_NONE,
 
494
                                         (GObject.TYPE_STRING,)),
 
495
                    "debconf-socket-changed": (GObject.SIGNAL_RUN_FIRST,
 
496
                                               GObject.TYPE_NONE,
 
497
                                               (GObject.TYPE_STRING,)),
 
498
                    "http-proxy-changed": (GObject.SIGNAL_RUN_FIRST,
 
499
                                           GObject.TYPE_NONE,
 
500
                                           (GObject.TYPE_STRING,)),
 
501
                    "medium-required": (GObject.SIGNAL_RUN_FIRST,
 
502
                                        GObject.TYPE_NONE,
 
503
                                        (GObject.TYPE_STRING,
 
504
                                         GObject.TYPE_STRING)),
 
505
                    "config-file-conflict": (GObject.SIGNAL_RUN_FIRST,
 
506
                                             GObject.TYPE_NONE,
 
507
                                             (GObject.TYPE_STRING,
 
508
                                              GObject.TYPE_STRING)),
509
509
                    }
510
510
 
511
511
 
512
512
    def __init__(self, tid, bus=None):
513
 
        gobject.GObject.__init__(self)
 
513
        GObject.GObject.__init__(self)
514
514
        self.tid = tid
515
515
        self.role = enums.ROLE_UNSET
516
516
        self.error = None
1557
1557
        else:
1558
1558
            # Iterate on the main loop - we cannot use a sub loop here,
1559
1559
            # since the D-Bus python bindings only work on the main loop
1560
 
            context = gobject.main_context_default()
 
1560
            context = GObject.main_context_default()
1561
1561
            while not hasattr(deferred, "result"):
1562
1562
                context.iteration(True)
1563
1563
           # If there has been an error in the helper raise it
1600
1600
                                     deferred_wait.callback(exit)))
1601
1601
            yield trans.run()
1602
1602
            yield deferred_wait
1603
 
            gobject.source_remove(sig)
 
1603
            GObject.source_remove(sig)
1604
1604
            defer.return_value(trans.exit)
1605
1605
        elif wait:
1606
1606
            yield trans.run()