~ubuntu-branches/ubuntu/lucid/jockey/lucid

« back to all changes in this revision

Viewing changes to jockey/ui.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-03-11 17:48:11 UTC
  • mfrom: (2.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20100311174811-v5kwz6dor2ystu50
Tags: 0.5.8-0ubuntu1
* New upstream bug fix release:
  - Make Control-C work properly. Thanks Adys! (LP: #479548)
  - Read system vendor/product from sysfs, not from hal
  - OSLib: Add new method has_repositories(), as a foundation for fixing
    #442776
  - backend.py, new_used_available(): Skip check if no package repositories
    are available, to avoid writing an empty cache file and thus never
    showing Jockey notifications again once they become available.
    (LP: #442776)
  - Shutdown D-BUS backend on UI shutdown, to not start the next UI with
    potentially outdated information.
  - backend.py: Expose has_repositories() and update_repository_indexes() to
    clients.
  - ui.py: Download/update package indexes if they are missing.
    (LP: #439530)
* jockey/oslib.py: Provide an apt implementation of has_repositories().
* jockey/oslib.py: Provide an apt implementation of
  update_repository_indexes().

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
functions with an appropriate toolkit.
21
21
'''
22
22
 
23
 
import gettext, optparse, urllib2, tempfile, sys, time, os, threading
 
23
import gettext, optparse, urllib2, tempfile, sys, time, os, threading, signal
24
24
 
25
25
import gobject
26
26
import dbus
85
85
        self.have_ui = False
86
86
        self.current_search = (None, None) # query, result
87
87
 
 
88
        # make Control-C work properly
 
89
        signal.signal(signal.SIGINT, signal.SIG_DFL)
 
90
 
88
91
    def backend(self):
89
92
        '''Return D-BUS backend client interface.
90
93
 
104
107
                    sys.exit(1)
105
108
                else:
106
109
                    raise
 
110
            self._check_repositories()
107
111
            self._call_progress_dialog(
108
112
                self._('Searching for available drivers...'),
109
113
                self._dbus_iface.detect, timeout=600)
115
119
                if hasattr(e, '_dbus_error_name') and e._dbus_error_name == \
116
120
                    'org.freedesktop.DBus.Error.ServiceUnknown':
117
121
                    self._dbus_iface = Backend.create_dbus_client()
 
122
                    self._check_repositories()
118
123
                    self._call_progress_dialog(
119
124
                        self._('Searching for available drivers...'),
120
125
                        self._dbus_iface.detect, timeout=600)
420
425
 
421
426
        # start the UI
422
427
        self.ui_show_main()
423
 
        return self.ui_main_loop()
 
428
        res = self.ui_main_loop()
 
429
        self.backend().shutdown()
 
430
        return res
424
431
 
425
432
    def list(self):
426
433
        '''Print a list of available handlers and their status to stdout.'''
499
506
            # we need to stay in the main loop so that the tray icon stays
500
507
            # around
501
508
            self.ui_main_loop()
 
509
            self.backend().shutdown()
502
510
 
503
511
        return len(new_avail) > 0
504
512
 
534
542
        self.ui_progress_update(cur, total)
535
543
        self.ui_idle()
536
544
 
 
545
    def _repository_progress_handler(self, cur, total):
 
546
        if not self._repository_progress_shown:
 
547
            self.ui_progress_start('', 
 
548
                self._('Downloading and updating package indexes...'), total)
 
549
            self._repository_progress_shown = True
 
550
        self.ui_progress_update(cur, total)
 
551
        self.ui_idle()
 
552
 
537
553
    def set_handler_enable(self, handler_id, action, confirm, gui=True):
538
554
        '''Enable, disable, or toggle a handler.
539
555
 
763
779
 
764
780
        return hwid
765
781
 
 
782
    def _check_repositories(self):
 
783
        '''Check if we have package repositories, and if not, offer to update.'''
 
784
 
 
785
        if self._dbus_iface.has_repositories():
 
786
            return
 
787
 
 
788
        success = False
 
789
        try:
 
790
            self._repository_progress_shown = False
 
791
            success = convert_dbus_exceptions(dbus_sync_call_signal_wrapper,
 
792
                    self._dbus_iface, 'update_repository_indexes',
 
793
                    {'repository_update_progress':
 
794
                        self._repository_progress_handler})
 
795
        finally:
 
796
            if self._repository_progress_shown:
 
797
                self.ui_progress_finish()
 
798
 
 
799
        # check success
 
800
        if not success:
 
801
            self.error_message('', self._(
 
802
    'Downloading package indexes failed, please check your network status. '
 
803
    'Most drivers will not be available.'))
 
804
 
766
805
    #
767
806
    # Session D-BUS server methods
768
807
    #