49 import pkg.fmri as fmri |
49 import pkg.fmri as fmri |
50 import pkg.gui.beadmin as beadm |
50 import pkg.gui.beadmin as beadm |
51 import pkg.gui.installupdate as installupdate |
51 import pkg.gui.installupdate as installupdate |
52 import pkg.gui.enumerations as enumerations |
52 import pkg.gui.enumerations as enumerations |
53 import pkg.gui.misc as gui_misc |
53 import pkg.gui.misc as gui_misc |
|
54 import pkg.client.api_errors as api_errors |
54 import pkg.misc as misc |
55 import pkg.misc as misc |
55 from pkg.client import global_settings |
56 from pkg.client import global_settings |
56 logger = global_settings.logger |
57 logger = global_settings.logger |
57 |
58 |
58 # Put _() in the global namespace |
59 # Put _() in the global namespace |
369 |
370 |
370 count = 0 |
371 count = 0 |
371 list_option = api.ImageInterface.LIST_UPGRADABLE |
372 list_option = api.ImageInterface.LIST_UPGRADABLE |
372 if list_uninstalled: |
373 if list_uninstalled: |
373 list_option = api.ImageInterface.LIST_INSTALLED_NEWEST |
374 list_option = api.ImageInterface.LIST_INSTALLED_NEWEST |
374 pkgs_from_api = self.api_obj.get_pkg_list(pkg_list = list_option) |
375 try: |
|
376 pkgs_from_api = self.api_obj.get_pkg_list(pkg_list = list_option) |
|
377 except api_errors.ApiException, ex: |
|
378 gobject.idle_add(gui_misc.error_occurred, |
|
379 self.w_um_dialog, |
|
380 str(ex), _("Update Manager")) |
|
381 return |
375 for entry in pkgs_from_api: |
382 for entry in pkgs_from_api: |
376 (pkg_pub, pkg_name, ver) = entry[0] |
383 (pkg_pub, pkg_name, ver) = entry[0] |
377 states = entry[3] |
384 states = entry[3] |
378 pkg_fmri = fmri.PkgFmri("%s@%s" % (pkg_name, ver), |
385 pkg_fmri = fmri.PkgFmri("%s@%s" % (pkg_name, ver), |
379 publisher = pkg_pub) |
386 publisher = pkg_pub) |
545 def restart_after_ips_update(self): |
552 def restart_after_ips_update(self): |
546 self.__exit_app(restart = True) |
553 self.__exit_app(restart = True) |
547 |
554 |
548 def __on_updateall_button_clicked(self, widget): |
555 def __on_updateall_button_clicked(self, widget): |
549 self.__selectall_toggle(True) |
556 self.__selectall_toggle(True) |
550 self.__get_api_obj().reset() |
557 try: |
|
558 self.__get_api_obj().reset() |
|
559 except api_errors.ApiException, ex: |
|
560 gobject.idle_add(gui_misc.error_occurred, |
|
561 self.w_um_dialog, |
|
562 str(ex), _("Update Manager")) |
|
563 return |
551 installupdate.InstallUpdate([], self, |
564 installupdate.InstallUpdate([], self, |
552 self.__get_image_path(), action = enumerations.IMAGE_UPDATE, |
565 self.__get_image_path(), action = enumerations.IMAGE_UPDATE, |
553 parent_name = _("Update Manager"), |
566 parent_name = _("Update Manager"), |
554 pkg_list = ["SUNWipkg", "SUNWipkg-gui", "SUNWipkg-um"], |
567 pkg_list = ["SUNWipkg", "SUNWipkg-gui", "SUNWipkg-um"], |
555 main_window = self.w_um_dialog, |
568 main_window = self.w_um_dialog, |
557 return |
570 return |
558 |
571 |
559 def __on_selectall_checkbutton_toggled(self, widget): |
572 def __on_selectall_checkbutton_toggled(self, widget): |
560 self.__selectall_toggle(widget.get_active()) |
573 self.__selectall_toggle(widget.get_active()) |
561 |
574 |
562 def __handle_cancel_exception(self): |
|
563 gobject.idle_add(self.w_progress_dialog.hide) |
|
564 gobject.idle_add(self.w_progressinfo_expander.set_expanded, False) |
|
565 self.__cleanup() |
|
566 |
|
567 def __prompt_to_load_beadm(self): |
575 def __prompt_to_load_beadm(self): |
568 msgbox = gtk.MessageDialog(parent = self.w_progress_dialog, |
576 msgbox = gtk.MessageDialog(parent = self.w_progress_dialog, |
569 buttons = gtk.BUTTONS_OK_CANCEL, flags = gtk.DIALOG_MODAL, |
577 buttons = gtk.BUTTONS_OK_CANCEL, flags = gtk.DIALOG_MODAL, |
570 type = gtk.MESSAGE_ERROR, |
578 type = gtk.MESSAGE_ERROR, |
571 message_format = _( |
579 message_format = _( |
589 def __unique(list1, list2): |
597 def __unique(list1, list2): |
590 """Return a list containing all items |
598 """Return a list containing all items |
591 in 'list1' that are not in 'list2'""" |
599 in 'list1' that are not in 'list2'""" |
592 list2 = dict([(k, None) for k in list2]) |
600 list2 = dict([(k, None) for k in list2]) |
593 return [item for item in list1 if item not in list2] |
601 return [item for item in list1 if item not in list2] |
594 |
|
595 def __cleanup(self): |
|
596 self.api_obj.reset() |
|
597 self.pr.reset() |
|
598 self.progress_stop_thread = True |
|
599 |
602 |
600 @staticmethod |
603 @staticmethod |
601 def __on_um_expander_activate(widget): |
604 def __on_um_expander_activate(widget): |
602 return |
605 return |
603 |
606 |