src/gui/modules/installupdate.py
author Shawn Walker <shawn.walker@sun.com>
Tue, 30 Sep 2008 19:37:17 -0500
changeset 556 1c3526ca7b9e
parent 551 233f0eeddd02
child 562 afe71b27984d
permissions -rw-r--r--
2022 client should provide operational intent to server 3565 client should provide version information when providing intent to server
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     1
#!/usr/bin/python2.4
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     2
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     4
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     8
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    13
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    19
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    21
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    22
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    23
# Use is subject to license terms.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    24
#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    25
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    26
import errno
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    27
import gettext # XXX Temporary workaround
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    28
import itertools
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    29
import os
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    30
import sys
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    31
import time
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    32
from threading import Thread
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    33
from urllib2 import URLError
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    34
try:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    35
        import gobject
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    36
        import gtk
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    37
        import gtk.glade
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    38
        import pygtk
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    39
        pygtk.require("2.0")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    40
except ImportError:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    41
        sys.exit(1)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    42
import pkg.client.bootenv as bootenv
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
    43
import pkg.client.history as history
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    44
import pkg.client.imageplan as imageplan
556
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 551
diff changeset
    45
import pkg.client.imagestate as imagestate
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    46
import pkg.client.progress as progress
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    47
import pkg.fmri as fmri
516
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
    48
import pkg.client.indexer as indexer
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    49
import pkg.search_errors as search_errors
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    50
from pkg.misc import TransferTimedOutException
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    51
from pkg.misc import CLIENT_DEFAULT_MEM_USE_KB
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    52
import pkg.gui.enumerations as enumerations
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    53
import pkg.gui.filelist as filelist
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    54
import pkg.gui.thread as guithread
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    55
from pkg.gui.filelist import CancelException
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    56
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    57
class InstallUpdate(progress.ProgressTracker):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    58
        def __init__(self, install_list, parent, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    59
            image_update = False, ips_update = False):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    60
                # XXX Workaround as BE is using msg(_("message")) 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    61
                # which bypasses the self._ mechanism the GUI is using
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    62
                gettext.install("pkg","/usr/lib/locale")
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    63
                progress.ProgressTracker.__init__(self)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    64
                self.gui_thread = guithread.ThreadRun()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    65
                self.install_list = install_list
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
    66
                self.update_list = None
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    67
                self.parent = parent
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    68
                self.image_update = image_update
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
    69
                self.ips_update = ips_update
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    70
                self.ip = None
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    71
                self.progress_stop_timer_thread = False
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    72
                self.progress_stop_timer_running = False                
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    73
                w_tree_createplan = gtk.glade.XML(parent.gladefile, "createplandialog")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    74
                w_tree_installupdate = gtk.glade.XML(parent.gladefile, "installupdate")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    75
                w_tree_downloadingfiles = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    76
                    gtk.glade.XML(parent.gladefile, "downloadingfiles")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    77
                w_tree_installingdialog = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    78
                    gtk.glade.XML(parent.gladefile, "installingdialog") 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    79
                w_tree_networkdown = gtk.glade.XML(parent.gladefile, "networkdown")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    80
                self.w_createplan_dialog = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    81
                    w_tree_createplan.get_widget("createplandialog")                    
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    82
                self.w_createplan_progressbar = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    83
                    w_tree_createplan.get_widget("createplanprogress") 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    84
                self.w_createplan_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    85
                    w_tree_createplan.get_widget("createplantextview")
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    86
                self.w_createplan_label = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    87
                    w_tree_createplan.get_widget("packagedependencies")
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    88
                self.w_createplancancel_button = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
    89
                    w_tree_createplan.get_widget("cancelcreateplan")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    90
                self.w_installupdate_dialog = w_tree_installupdate.get_widget("installupdate")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    91
                self.w_summary_label = w_tree_installupdate.get_widget("packagenamelabel3")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    92
                self.w_review_treeview = w_tree_installupdate.get_widget("treeview1")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    93
                self.w_downloadingfiles_dialog = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    94
                    w_tree_downloadingfiles.get_widget("downloadingfiles")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    95
                self.w_download_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    96
                    w_tree_downloadingfiles.get_widget("downloadtextview")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    97
                self.w_download_progressbar = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    98
                    w_tree_downloadingfiles.get_widget("downloadprogress")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
    99
                self.w_installing_dialog = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   100
                    w_tree_installingdialog.get_widget("installingdialog")
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   101
                self.w_installingdialog_label = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   102
                    w_tree_installingdialog.get_widget("packagedependencies3")                    
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   103
                self.w_installingdialog_expander = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   104
                    w_tree_installingdialog.get_widget("expander4")                     
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   105
                self.w_installing_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   106
                    w_tree_installingdialog.get_widget("installingtextview")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   107
                self.w_installing_progressbar = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   108
                    w_tree_installingdialog.get_widget("installingprogress")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   109
                self.w_networkdown_dialog = w_tree_networkdown.get_widget("networkdown")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   110
                self.w_createplan_progressbar.set_pulse_step(0.1)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   111
                installed_updated_column = gtk.TreeViewColumn('Installed/Updated')
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   112
                self.w_review_treeview.append_column(installed_updated_column)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   113
                cell = gtk.CellRendererText()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   114
                installed_updated_column.pack_start(cell, True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   115
                installed_updated_column.add_attribute(cell, 'text', 0)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   116
                self.w_review_treeview.expand_all()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   117
                try:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   118
                        dic_createplan = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   119
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   120
                                "on_cancelcreateplan_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   121
                                    self.__on_cancelcreateplan_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   122
                            }
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   123
                        dic_installupdate = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   124
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   125
                                "on_cancel_button_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   126
                                    self.__on_cancel_button_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   127
                                "on_next_button_clicked":self.__on_next_button_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   128
                            }
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   129
                        dic_downloadingfiles = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   130
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   131
                                "on_canceldownload_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   132
                                    self.__on_cancel_download_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   133
                            }
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   134
                        dic_networkdown = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   135
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   136
                                "on_networkdown_close_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   137
                                    self.__on_networkdown_close_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   138
                            }
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   139
                        w_tree_createplan.signal_autoconnect(dic_createplan)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   140
                        w_tree_installupdate.signal_autoconnect(dic_installupdate)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   141
                        w_tree_downloadingfiles.signal_autoconnect(dic_downloadingfiles)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   142
                        w_tree_networkdown.signal_autoconnect(dic_networkdown)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   143
                except AttributeError, error:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   144
                        print self.parent._('GUI will not respond to any event! %s. \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   145
                            Check installupdate.py signals') \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   146
                            % error
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   147
                if image_update or ips_update:
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   148
                        list_of_packages = install_list
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   149
                else:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   150
                        list_of_packages = self.__prepare_list_of_packages()
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   151
                # XXX Hidden until progress will give information about fmri                        
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   152
                self.w_installingdialog_expander.hide()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   153
                pulse_t = Thread(target = self.__progressdialog_progress_pulse)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   154
                thread = Thread(target = self.__plan_the_install_updateimage, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   155
                    args = (list_of_packages, ))
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   156
                pulse_t.start()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   157
                thread.start()
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   158
                self.w_createplan_label.set_text(\
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   159
                    self.parent._("Checking package dependencies..."))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   160
                self.w_createplancancel_button.set_sensitive(True)           
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   161
                self.w_createplan_dialog.run()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   162
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   163
        def __on_cancelcreateplan_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   164
                '''Handler for signal send by cancel button, which user might press during
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   165
                evaluation stage - while the dialog is creating plan'''
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   166
                self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   167
                    history.RESULT_CANCELED
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   168
                self.w_createplan_label.set_text(\
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   169
                    self.parent._("Canceling..."))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   170
                self.w_createplancancel_button.set_sensitive(False)                    
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   171
                self.gui_thread.cancel()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   172
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   173
        def __on_cancel_button_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   174
                '''Handler for signal send by cancel button, which is available for the 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   175
                user after evaluation stage on the dialog showing what will be installed
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   176
                or updated'''
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   177
                self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   178
                    history.RESULT_CANCELED
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   179
                self.gui_thread.cancel()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   180
                self.w_installupdate_dialog.destroy()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   181
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   182
        def __on_next_button_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   183
                '''Handler for signal send by next button, which is available for the 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   184
                user after evaluation stage on the dialog showing what will be installed
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   185
                or updated'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   186
                download_thread = Thread(target = self.__download_stage, args = ())
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   187
                download_thread.start()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   188
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   189
        def __on_cancel_download_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   190
                '''Handler for signal send by cancel button, which user might press during
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   191
                download stage.'''
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   192
                self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   193
                    history.RESULT_CANCELED
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   194
                self.gui_thread.cancel()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   195
                self.w_downloadingfiles_dialog.destroy()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   196
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   197
        def __on_networkdown_close_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   198
                '''Handler for signal send by close button on the dialog showing that
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   199
                there was some problem with the network connection.'''
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   200
                self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   201
                    history.RESULT_FAILED_TRANSPORT
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   202
                self.gui_thread.cancel()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   203
                self.w_networkdown_dialog.destroy()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   204
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   205
        def __update_createplan_progress(self, action):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   206
                buf = self.w_createplan_textview.get_buffer()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   207
                textiter = buf.get_end_iter()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   208
                buf.insert(textiter, action)
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   209
                
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   210
        def __progressdialog_progress_pulse(self):
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   211
                while not self.progress_stop_timer_thread:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   212
                        gobject.idle_add(self.w_createplan_progressbar.pulse)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   213
                        time.sleep(0.1)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   214
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   215
        def __update_download_progress(self, cur_bytes, total_bytes):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   216
                prog = float(cur_bytes)/total_bytes
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   217
                self.w_download_progressbar.set_fraction(prog)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   218
                a = str(cur_bytes/1024)
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   219
                b = str(total_bytes/1024)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   220
                c = "Downloaded: " + a + " / " + b + " KB"
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   221
                self.w_download_progressbar.set_text(c)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   222
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   223
        def __update_install_progress(self, current, total):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   224
                prog = float(current)/total
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   225
                self.w_installing_progressbar.set_fraction(prog)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   226
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   227
        def __update_install_pulse(self):
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   228
                while not self.progress_stop_timer_thread:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   229
                        self.progress_stop_timer_running = True
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   230
                        gobject.idle_add(self.w_installing_progressbar.pulse)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   231
                        time.sleep(0.1)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   232
                self.progress_stop_timer_running = False
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   233
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   234
        def __prepare_list_of_packages(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   235
                ''' This method return the dictionary of 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   236
                images and newest marked packages'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   237
                fmri_to_install_update = {}
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   238
                for row in self.install_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   239
                        if row[enumerations.MARK_COLUMN]:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   240
                                image = row[enumerations.IMAGE_OBJECT_COLUMN]
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   241
                                packages = row[enumerations.PACKAGE_OBJECT_COLUMN]
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   242
                                im = fmri_to_install_update.get(image)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   243
                                # XXX Hack to be bug to bug compatible - incorporations
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   244
                                pkg_name = packages[0].get_name()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   245
                                if im:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   246
                                        im.append(pkg_name)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   247
                                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   248
                                        fmri_to_install_update[image] = [pkg_name, ]
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   249
                return fmri_to_install_update
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   250
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   251
        def __plan_the_install_updateimage(self, list_of_packages):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   252
                '''Function which plans the image'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   253
                self.gui_thread.run()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   254
                filters = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   255
                verbose = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   256
                noexecute = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   257
                for image in list_of_packages:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   258
                        # Take a list of packages, specified in pkg_list, and attempt
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   259
                        # to assemble an appropriate image plan.  This is a helper
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   260
                        # routine for some common operations in the client.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   261
                        #
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   262
                        # This method checks all authorities for a package match;
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   263
                        # however, it defaults to choosing the preferred authority
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   264
                        # when an ambiguous package name is specified.  If the user
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   265
                        # wishes to install a package from a non-preferred authority,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   266
                        # the full FMRI that contains an authority should be used
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   267
                        # to name the package.
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   268
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   269
                        pkg_list = list_of_packages.get(image)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   270
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   271
                        error = 0
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   272
                        self.ip = imageplan.ImagePlan(image, self, filters = filters)
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   273
                        if self.image_update:
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   274
                                self.ip.image.history.operation_name = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   275
                                    "image-update"
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   276
                        else:
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   277
                                self.ip.image.history.operation_name = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   278
                                    "install"
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   279
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   280
                        self.__load_optional_dependencies(image)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   281
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   282
                        for p in pkg_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   283
                                try:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   284
                                        conp = image.apply_optional_dependencies(p)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   285
                                        matches = list(image.inventory([ conp ],
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   286
                                            all_known = True))
526
8c243883ae41 822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents: 516
diff changeset
   287
                                except (RuntimeError, InventoryException):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   288
                                        # XXX Module directly printing.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   289
                                        error = 1
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   290
                                        continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   291
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   292
                                pnames = {}
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   293
                                pmatch = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   294
                                npnames = {}
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   295
                                npmatch = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   296
                                for m, state in matches:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   297
                                        if m.preferred_authority():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   298
                                                pnames[m.get_pkg_stem()] = 1
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   299
                                                pmatch.append(m)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   300
                                        else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   301
                                                npnames[m.get_pkg_stem()] = 1
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   302
                                                npmatch.append(m)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   303
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   304
                                if len(pnames.keys()) > 1:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   305
                                        # XXX Module directly printing.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   306
                                        error = 1
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   307
                                        continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   308
                                elif len(pnames.keys()) < 1 and len(npnames.keys()) > 1:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   309
                                        # XXX Module directly printing.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   310
                                        error = 1
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   311
                                        continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   312
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   313
                                # matches is a list reverse sorted by version, so take
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   314
                                # the first; i.e., the latest.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   315
                                if len(pmatch) > 0:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   316
                                        self.ip.propose_fmri(pmatch[0])
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   317
                                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   318
                                        self.ip.propose_fmri(npmatch[0])
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   319
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   320
                        if error != 0:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   321
                                raise RuntimeError, "Unable to assemble image plan"
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   322
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   323
                        self.ip.image.history.operation_start_state = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   324
                            self.ip.get_plan()
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   325
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   326
                        try:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   327
                                self.__evaluate(image)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   328
                        except CancelException, e:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   329
                                self.progress_stop_timer_thread = True
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   330
                                gobject.idle_add(self.w_createplan_dialog.hide)
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   331
                        else:
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   332
                                self.ip.image.history.operation_end_state = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   333
                                    self.ip.get_plan(full=False)
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   334
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   335
                        image.imageplan = self.ip
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   336
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   337
                return
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   338
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   339
        def __load_optional_dependencies(self, image):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   340
                for b_fmri in image.gen_installed_pkgs():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   341
                        if self.gui_thread.is_cancelled():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   342
                                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   343
                        mfst = image.get_manifest(b_fmri, filtered = True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   344
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   345
                        for dep in mfst.gen_actions_by_type("depend"):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   346
                                required, min_fmri, max_fmri = dep.parse(image)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   347
                                if required == False:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   348
                                        image.update_optional_dependency(min_fmri)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   349
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   350
        def __evaluate(self, image):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   351
                '''Code duplication from imageplan.evaluate()'''
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   352
                assert self.ip.state == imageplan.UNEVALUATED
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   353
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   354
                self.ip.progtrack.evaluate_start()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   355
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   356
                outstring = ""
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   357
                
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   358
                # Operate on a copy, as it will be modified in flight.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   359
                for f in self.ip.target_fmris[:]:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   360
                        self.ip.progtrack.evaluate_progress()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   361
                        try:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   362
                                self.__evaluate_fmri(f, image)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   363
                        except KeyError, e:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   364
                                outstring += "Attemping to install %s causes:\n\t%s\n" % \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   365
                                    (f.get_name(), e)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   366
                        except NameError:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   367
                                gobject.idle_add(self.__creating_plan_net_error)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   368
                                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   369
                if outstring:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   370
                        raise RuntimeError("No packages were installed because "
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   371
                            "package dependencies could not be satisfied\n" +
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   372
                            outstring)                        
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   373
                                
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   374
                for f in self.ip.target_fmris:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   375
                        self.ip.add_pkg_plan(f)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   376
                        self.ip.progtrack.evaluate_progress()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   377
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   378
                for f in self.ip.target_rem_fmris[:]:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   379
                        self.ip.evaluate_fmri_removal(f)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   380
                        self.ip.progtrack.evaluate_progress()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   381
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   382
                # we now have a workable set of packages to add/upgrade/remove
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   383
                # now combine all actions together to create a synthetic single
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   384
                # step upgrade operation, and handle editable files moving from
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   385
                # package to package.  See theory comment in execute, below.
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   386
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   387
                self.ip.state = imageplan.EVALUATED_PKGS
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   388
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   389
                self.ip.removal_actions = [ (p, src, dest)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   390
                                         for p in self.ip.pkg_plans
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   391
                                         for src, dest in p.gen_removal_actions()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   392
                ]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   393
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   394
                self.ip.update_actions = [ (p, src, dest)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   395
                                        for p in self.ip.pkg_plans
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   396
                                        for src, dest in p.gen_update_actions()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   397
                ]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   398
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   399
                self.ip.install_actions = [ (p, src, dest)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   400
                                         for p in self.ip.pkg_plans
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   401
                                         for src, dest in p.gen_install_actions()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   402
                ]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   403
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   404
                self.ip.progtrack.evaluate_progress()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   405
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   406
                # iterate over copy of removals since we're modding list
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   407
                # keep track of deletion count so later use of index works
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   408
                named_removals = {}
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   409
                deletions = 0
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   410
                for i, a in enumerate(self.ip.removal_actions[:]):
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   411
                        # remove dir removals if dir is still in final image
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   412
                        if a[1].name == "dir" and \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   413
                            os.path.normpath(a[1].attrs["path"]) in \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   414
                            self.ip.get_directories():
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   415
                                del self.ip.removal_actions[i - deletions]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   416
                                deletions += 1
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   417
                                continue
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   418
                        # store names of files being removed under own name
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   419
                        # or original name if specified
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   420
                        if a[1].name == "file":
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   421
                                attrs = a[1].attrs
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   422
                                fname = attrs.get("original_name",
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   423
                                    "%s:%s" % (a[0].origin_fmri.get_name(), attrs["path"]))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   424
                                named_removals[fname] = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   425
                                    (i - deletions,
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   426
                                    id(self.ip.removal_actions[i-deletions][1]))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   427
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   428
                self.ip.progtrack.evaluate_progress()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   429
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   430
                for a in self.ip.install_actions:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   431
                        # In order to handle editable files that move their path or
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   432
                        # change pkgs, for all new files with original_name attribute,
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   433
                        # make sure file isn't being removed by checking removal list.
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   434
                        # if it is, tag removal to save file, and install to recover
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   435
                        # cached version... caching is needed if directories
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   436
                        # are removed or don't exist yet.
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   437
                        if a[2].name == "file" and "original_name" in a[2].attrs and \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   438
                            a[2].attrs["original_name"] in named_removals:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   439
                                cache_name = a[2].attrs["original_name"]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   440
                                index = named_removals[cache_name][0]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   441
                                assert(id(self.ip.removal_actions[index][1]) ==
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   442
                                       named_removals[cache_name][1])
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   443
                                self.ip.removal_actions[index][1].attrs["save_file"] = \
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   444
                                    cache_name
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   445
                                a[2].attrs["save_file"] = cache_name
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   446
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   447
                self.ip.progtrack.evaluate_progress()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   448
                # Go over update actions
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   449
                l_actions = self.ip.get_link_actions()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   450
                l_refresh = []
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   451
                for a in self.ip.update_actions:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   452
                        # for any files being updated that are the target of
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   453
                        # _any_ hardlink actions, append the hardlink actions
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   454
                        # to the update list so that they are not broken...
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   455
                        if a[2].name == "file":
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   456
                                path = a[2].attrs["path"]
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   457
                                if path in l_actions:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   458
                                        l_refresh.extend([(a[0], l, l) for l in l_actions[path]])
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   459
                self.ip.update_actions.extend(l_refresh)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   460
                # sort actions to match needed processing order
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   461
                self.ip.removal_actions.sort(key = lambda obj:obj[1], reverse=True)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   462
                self.ip.update_actions.sort(key = lambda obj:obj[2])
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   463
                self.ip.install_actions.sort(key = lambda obj:obj[2])
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   464
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   465
                self.ip.progtrack.evaluate_done()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   466
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   467
                self.ip.state = imageplan.EVALUATED_OK
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   468
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   469
        def __creating_plan_net_error(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   470
                '''Helper method which shows the dialog informing user that there was
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   471
                problem with network connection'''
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   472
                self.progress_stop_timer_thread = True
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   473
                self.w_createplan_dialog.hide()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   474
                self.w_networkdown_dialog.show()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   475
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   476
        def __evaluate_fmri(self, pfmri, image):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   477
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   478
                if self.gui_thread.is_cancelled():
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   479
                        raise CancelException
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   480
                gobject.idle_add(self.__update_createplan_progress, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   481
                    self.parent._("Evaluating: %s\n") % pfmri.get_fmri())
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   482
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   483
                self.ip.progtrack.evaluate_progress()
556
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 551
diff changeset
   484
                self.ip.image.state.set_target(pfmri, imagestate.INTENT_PROCESS)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   485
                m = image.get_manifest(pfmri)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   486
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   487
                # [manifest] examine manifest for dependencies
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   488
                for a in m.actions:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   489
                        if a.name != "depend":
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   490
                                continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   491
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   492
                        type = a.attrs["type"]
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   493
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   494
                        f = fmri.PkgFmri(a.attrs["fmri"],
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   495
                            self.ip.image.attrs["Build-Release"])
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   496
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   497
                        if self.ip.image.has_version_installed(f) and \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   498
                                    type != "exclude":
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   499
                                continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   500
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   501
                        # XXX This alone only prevents infinite recursion when a
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   502
                        # cycle member is on the commandline, as we never update
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   503
                        # target_fmris.  Is target_fmris supposed to be just
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   504
                        # what was specified on the commandline, or include what
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   505
                        # we've found while processing dependencies?
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   506
                        # XXX probably should just use propose_fmri() here
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   507
                        # instead of this and the has_version_installed() call
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   508
                        # above.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   509
                        if self.ip.is_proposed_fmri(f):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   510
                                continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   511
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   512
                        # XXX LOG  "%s not in pending transaction;
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   513
                        # checking catalog" % f
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   514
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   515
                        required = True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   516
                        excluded = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   517
                        if type == "optional" and \
551
233f0eeddd02 856 Image properties
Tom Mueller <Tom.Mueller@sun.com>
parents: 539
diff changeset
   518
                            not self.ip.image.cfg_cache.get_policy(imageconfig.REQUIRE_OPTIONAL):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   519
                                required = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   520
                        elif type == "transfer" and \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   521
                            not self.ip.image.older_version_installed(f):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   522
                                required = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   523
                        elif type == "exclude":
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   524
                                excluded = True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   525
                        elif type == "incorporate":
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   526
                                self.ip.image.update_optional_dependency(f)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   527
                                if self.ip.image.older_version_installed(f) or \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   528
                                    self.ip.older_version_proposed(f):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   529
                                        required = True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   530
                                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   531
                                        required = False
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   532
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   533
                        if not required:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   534
                                continue
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   535
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   536
                        if excluded:
556
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 551
diff changeset
   537
                                self.ip.image.state.set_target()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   538
                                raise RuntimeError, "excluded by '%s'" % f
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   539
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   540
                        # treat-as-required, treat-as-required-unless-pinned,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   541
                        # ignore
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   542
                        # skip if ignoring
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   543
                        #     if pinned
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   544
                        #       ignore if treat-as-required-unless-pinned
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   545
                        #     else
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   546
                        #       **evaluation of incorporations**
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   547
                        #     [imageplan] pursue installation of this package
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   548
                        #     -->
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   549
                        #     backtrack or reset??
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   550
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   551
                        # This will be the newest version of the specified
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   552
                        # dependency package, coming from the preferred
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   553
                        # authority, if it's available there.
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   554
                        cf = self.ip.image.inventory([ a.attrs["fmri"] ],
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   555
                            all_known = True, preferred = True,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   556
                            first_only = True).next()[0]
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   557
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   558
                        # XXX LOG "adding dependency %s" % pfmri
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   559
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   560
                        #msg("adding dependency %s" % cf)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   561
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   562
                        self.ip.propose_fmri(cf)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   563
                        self.__evaluate_fmri(cf, image)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   564
556
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 551
diff changeset
   565
                self.ip.image.state.set_target()
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 551
diff changeset
   566
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   567
        def __download_stage(self, rebuild=False):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   568
                '''Parts of the code duplicated from install and image-update from pkg(1) 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   569
                and pkg.client.ImagePlan.preexecute()'''
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   570
                self.gui_thread.run()
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   571
                if not rebuild:
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   572
                        gobject.idle_add(self.w_installupdate_dialog.hide)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   573
                if rebuild:
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   574
                        gobject.idle_add(self.w_installing_dialog.hide)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   575
                gobject.idle_add(self.w_downloadingfiles_dialog.show)
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   576
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   577
                # Checks the index to make sure it exists and is
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   578
                # consistent. If it's inconsistent an exception is thrown.
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   579
                # If it's totally absent, it will index the existing packages
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   580
                # so that the incremental update that follows at the end of
516
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   581
                # the function will work correctly. It also repairs the index
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   582
                # for this BE so the user can boot into this BE and have a
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   583
                # correct index.
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   584
                try:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   585
                        self.ip.image.update_index_dir()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   586
                        ind = indexer.Indexer(self.ip.image.index_dir,
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   587
                            CLIENT_DEFAULT_MEM_USE_KB, progtrack=self.ip.progtrack)
516
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   588
                        if not ind.check_index_existence() or \
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   589
                            not ind.check_index_has_exactly_fmris(
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   590
                                self.ip.image.gen_installed_pkg_names()):
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   591
                                # XXX Once we have a framework for emitting a
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   592
                                # message to the user in this spot in the
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   593
                                # code, we should tell them something has gone
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   594
                                # wrong so that we continue to get feedback to
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   595
                                # allow us to debug the code.
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   596
                                ind.rebuild_index_from_scratch(
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   597
                                    self.ip.image.get_fmri_manifest_pairs())
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   598
                except search_errors.IndexingException:
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   599
                        # If there's a problem indexing, we want to attempt
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   600
                        # to finish the installation anyway. If there's a
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   601
                        # problem updating the index on the new image,
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   602
                        # that error needs to be communicated to the user.
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   603
                        pass
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   604
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   605
                
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   606
                try:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   607
                        for p in self.ip.pkg_plans:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   608
                                p.preexecute()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   609
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   610
                        for package_plan in self.ip.pkg_plans:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   611
                                if self.gui_thread.is_cancelled():
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   612
                                       return
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   613
                                self.__download(package_plan)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   614
                except TransferTimedOutException:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   615
                        gobject.idle_add(self.w_downloadingfiles_dialog.hide)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   616
                        gobject.idle_add(self.w_networkdown_dialog.show)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   617
                        return
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   618
                except URLError, e:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   619
                        #if e.reason[0] == 8:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   620
                        gobject.idle_add(self.w_downloadingfiles_dialog.hide)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   621
                        gobject.idle_add(self.w_networkdown_dialog.show)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   622
                        return
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   623
                except CancelException:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   624
                        gobject.idle_add(self.w_downloadingfiles_dialog.hide)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   625
                        return
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   626
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   627
                self.ip.progtrack.download_done()
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   628
                gobject.idle_add(self.w_downloadingfiles_dialog.hide)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   629
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   630
                try:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   631
                        be = bootenv.BootEnv(self.ip.image.get_root())
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   632
                except RuntimeError:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   633
                        be = bootenv.BootEnvNull(self.ip.image.get_root())
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   634
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   635
                if self.image_update:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   636
                        be.init_image_recovery(self.ip.image)
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   637
                        if self.ip.image.is_liveroot():
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   638
                                return 1
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   639
                try:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   640
                        self.__installation_stage()
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   641
                        if self.image_update:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   642
                                be.activate_image()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   643
                        else:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   644
                                be.activate_install_uninstall()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   645
                        ret_code = 0
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   646
                except RuntimeError, e:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   647
                        if self.image_update:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   648
                                be.restore_image()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   649
                        else:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   650
                                be.restore_install_uninstall()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   651
                        ret_code = 1
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   652
                except search_errors.InconsistentIndexException, e:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   653
                        ret_code = 2
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   654
                except search_errors.PartialIndexingException, e:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   655
                        ret_code = 2
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   656
                except search_errors.ProblematicPermissionsIndexException, e:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   657
                        ret_code = 2
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   658
                except Exception, e:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   659
                        if self.image_update:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   660
                                be.restore_image()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   661
                        else:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   662
                                be.restore_install_uninstall()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   663
                        self.ip.image.cleanup_downloads()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   664
                        raise
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   665
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   666
                self.ip.image.cleanup_downloads()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   667
                if ret_code == 0:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   668
                        self.ip.image.cleanup_cached_content()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   669
                elif ret_code == 2:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   670
                        return_code = 0
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   671
                        return_code = self.__rebuild_index()
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   672
                        if return_code == 1:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   673
                                return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   674
                        self.__download_stage(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   675
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   676
        def __download(self, package_plan):
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   677
                '''Code duplication from pkg.client.PkgPlan.download() except that
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   678
                pkg.gui.filelist is called instead of pkg.client.fileobject with shared
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   679
                cancel object - self.gui_thread that allows to cancel download 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   680
                operation'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   681
                flist = filelist.FileList(self,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   682
                    package_plan.image,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   683
                    package_plan.destination_fmri,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   684
                    self.gui_thread,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   685
                    maxbytes = None
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   686
                    )
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   687
                _PkgPlan__prog = package_plan._PkgPlan__progtrack
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   688
                _PkgPlan__prog.download_start_pkg(package_plan.get_xfername())
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   689
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   690
                for src, dest in itertools.chain(*package_plan.actions):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   691
                        if dest:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   692
                                if dest.needsdata(src):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   693
                                        flist.add_action(dest)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   694
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   695
                flist.flush()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   696
                package_plan._PkgPlan__progtrack.download_end_pkg()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   697
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   698
        def __rebuild_index(self):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   699
                '''Code duplication from pkg(1):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   700
                       Forcibly rebuild the search indexes. Will remove existing indexes
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   701
                       and build new ones from scratch.'''
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   702
                quiet = False
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   703
                
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   704
                try:
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   705
                        self.ip.image.rebuild_search_index(self.ip.progtrack)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   706
                except search_errors.InconsistentIndexException, iie:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   707
                        return 1
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   708
                except search_errors.ProblematicPermissionsIndexException, ppie:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   709
                        return 1
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   710
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   711
        def __installation_stage(self):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   712
                '''Code duplication from imageplan.py def execute(self)'''
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   713
                self.gui_thread.run()
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   714
                text = self.parent._("Installing Packages...")
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   715
                gobject.idle_add(self.w_installingdialog_label.set_text, text)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   716
                gobject.idle_add(self.w_installing_dialog.show)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   717
                self.ip.state = imageplan.PREEXECUTED_OK
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   718
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   719
                if self.ip.nothingtodo():
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   720
                        self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   721
                            history.RESULT_NOTHING_TO_DO
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   722
                        self.ip.state = imageplan.EXECUTED_OK
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   723
                        self.ip.progtrack.actions_done()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   724
                        return
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   725
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   726
                # execute removals
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   727
                self.ip.progtrack.actions_set_goal("Removal Phase", len(self.ip.removal_actions))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   728
                for p, src, dest in self.ip.removal_actions:                        
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   729
                        p.execute_removal(src, dest)
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   730
                        self.ip.progtrack.actions_add_progress()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   731
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   732
                # execute installs
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   733
                self.ip.progtrack.actions_set_goal("Install Phase", len(self.ip.install_actions))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   734
                for p, src, dest in self.ip.install_actions:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   735
                        p.execute_install(src, dest)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   736
                        self.ip.progtrack.actions_add_progress()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   737
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   738
                # execute updates
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   739
                self.ip.progtrack.actions_set_goal("Update Phase", len(self.ip.update_actions))
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   740
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   741
                for p, src, dest in self.ip.update_actions:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   742
                        p.execute_update(src, dest)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   743
                        self.ip.progtrack.actions_add_progress()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   744
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   745
                # handle any postexecute operations
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   746
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   747
                for p in self.ip.pkg_plans:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   748
                        p.postexecute()
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   749
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   750
                self.ip.state = imageplan.EXECUTED_OK
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   751
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   752
                # reduce memory consumption
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   753
                del self.ip.removal_actions
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   754
                del self.ip.update_actions
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   755
                del self.ip.install_actions
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   756
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   757
                del self.ip.target_rem_fmris
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   758
                del self.ip.target_fmris
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   759
                # XXX This is accessing private member, and this fix should go
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   760
                # Once we will remove code duplication.
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   761
                del self.ip._ImagePlan__directories
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   762
                
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   763
                # Perform the incremental update to the search indexes
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   764
                # for all changed packages
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   765
                plan_info = []
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   766
                for p in self.ip.pkg_plans:
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   767
                        d_fmri = p.destination_fmri
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   768
                        d_manifest_path = None
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   769
                        if d_fmri:
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   770
                                d_manifest_path = \
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   771
                                    self.ip.image.get_manifest_path(d_fmri)
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   772
                        o_fmri = p.origin_fmri
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   773
                        o_manifest_path = None
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   774
                        o_filter_file = None
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   775
                        if o_fmri:
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   776
                                o_manifest_path = \
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   777
                                    self.ip.image.get_manifest_path(o_fmri)
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   778
                        plan_info.append((d_fmri, d_manifest_path, o_fmri,
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   779
                                          o_manifest_path))
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   780
                self.update_list = self.ip.pkg_plans[:]
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   781
                del self.ip.pkg_plans
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   782
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   783
                self.ip.progtrack.actions_set_goal("Index Phase", len(plan_info))
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   784
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   785
                try:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   786
                        self.ip.image.update_index_dir()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   787
                        ind = indexer.Indexer(self.ip.image.index_dir,
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   788
                            CLIENT_DEFAULT_MEM_USE_KB, progtrack=self.ip.progtrack)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   789
                        ind.client_update_index((self.ip.filters, plan_info))
516
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   790
                except (KeyboardInterrupt,
53da6297fb65 3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents: 510
diff changeset
   791
                    search_errors.ProblematicPermissionsIndexException):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   792
                        # ProblematicPermissionsIndexException is included here
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   793
                        # as there's little chance that trying again will fix
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   794
                        # this problem.
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   795
                        self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   796
                            history.RESULT_FAILED_STORAGE
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   797
                        raise
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   798
                except Exception, e:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   799
                        del(ind)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   800
                        # XXX Once we have a framework for emitting a message
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   801
                        # to the user in this spot in the code, we should tell
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   802
                        # them something has gone wrong so that we continue to
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   803
                        # get feedback to allow us to debug the code.
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   804
                        self.ip.image.rebuild_search_index(self.ip.progtrack)
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   805
                        self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   806
                            history.RESULT_FAILED_UNKNOWN
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   807
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   808
                self.ip.image.history.operation_result = \
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 526
diff changeset
   809
                    history.RESULT_SUCCEEDED
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   810
                self.ip.progtrack.actions_done()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   811
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   812
        def actions_done(self):
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   813
                if self.parent != None:
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   814
                        if not self.ips_update and not self.image_update:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   815
                                gobject.idle_add(self.__update_package_list)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   816
                gobject.idle_add(self.w_installing_dialog.hide)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   817
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   818
                if self.ips_update:
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   819
                        gobject.idle_add(self.parent.shutdown_after_ips_update)
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   820
                elif self.image_update:
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   821
                        gobject.idle_add(self.parent.shutdown_after_image_update)
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   822
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   823
        def __update_package_list(self):
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   824
                for pkg in self.update_list:
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   825
                        pkg_name = pkg.get_xfername()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   826
                        self.__update_install_list(pkg_name)
459
02de46bede49 2889 gui doesn't update search indices
John.Rice@Sun.COM
parents: 457
diff changeset
   827
                del self.update_list
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   828
                self.parent.update_package_list()
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   829
                        
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   830
        def __update_install_list(self, pkg_name):
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   831
                for row in self.install_list:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   832
                        if row[enumerations.NAME_COLUMN] == pkg_name:
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   833
                                row[enumerations.MARK_COLUMN] = True
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   834
                                return
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   835
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   836
        def download_file_path(self, file_path):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   837
                '''Called by GUI's filelist.py through the progress, which is passed 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   838
                to the filelist.'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   839
                # XXX this function should be removed and also pkg.gui.filelist should 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   840
                # not call it, since we don't want to show single file progress
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   841
                gobject.idle_add(self.__add_file_to_downloadtext, file_path)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   842
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   843
        def __add_file_to_downloadtext(self, file_path):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   844
                '''Function which adds another line text in the "more details" download 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   845
                dialog'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   846
                buf = self.w_download_textview.get_buffer()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   847
                textiter = buf.get_end_iter()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   848
                buf.insert(textiter, self.parent._("Downloading: ") + file_path + "\n")
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   849
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   850
        def __add_info_to_installtext(self, text):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   851
                '''Function which adds another line text in the "more details" install 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   852
                dialog'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   853
                buf = self.w_installing_textview.get_buffer()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   854
                textiter = buf.get_end_iter()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   855
                buf.insert(textiter, text)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   856
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   857
        def cat_output_start(self): 
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   858
                return
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   859
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   860
        def cat_output_done(self): 
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   861
                return
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   862
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   863
        def eval_output_start(self):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   864
                '''Called by progress tracker when the evaluation of the packages just 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   865
                started.'''
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   866
                return
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   867
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   868
        def eval_output_progress(self):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   869
                '''Called by progress tracker each time some package was evaluated. The
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   870
                call is being done by calling progress tracker evaluate_progress() 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   871
                function'''
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   872
                return
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   873
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   874
        def eval_output_done(self):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   875
                gobject.idle_add(self.__eval_output_done)
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   876
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   877
        def __eval_output_done(self):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   878
                '''Called by progress tracker after the evaluation of the packages is 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   879
                finished. Gets information like how many packages will be 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   880
                updated/installed and maximum amount of data which will be downloaded. 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   881
                Later this information is being adjusted, while downloading'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   882
                if self.gui_thread.is_cancelled():
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   883
                        self.progress_stop_timer_thread = True
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   884
                        self.w_createplan_dialog.hide()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   885
                        return
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   886
                updated_installed = \
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   887
                    [
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   888
                        ["Packages To Be Installed:"],
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   889
                        ["Packages To Be Updated:"]
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   890
                    ]
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   891
                treestore = gtk.TreeStore(str)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   892
                install_iter = None 
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   893
                updated_iter = None
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   894
                install_count = 0
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   895
                updated_count = 0
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   896
                total_download_count = 0
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   897
                total_files_count = 0
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   898
                npkgs = 0
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   899
                for package_plan in self.ip.pkg_plans:
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   900
                        npkgs += 1
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   901
                        if package_plan.origin_fmri and package_plan.destination_fmri:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   902
                                if not updated_iter:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   903
                                        updated_iter = treestore.append(None, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   904
                                            updated_installed[1])
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   905
                                d_fmri = package_plan.destination_fmri
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   906
                                dt = self.get_datetime(d_fmri.version)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   907
                                dt_str = (":%02d%02d") % (dt.month, dt.day)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   908
                                pkg_version = d_fmri.version.get_short_version() + dt_str
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   909
                                pkg = d_fmri.get_name() + "@" + pkg_version
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   910
                                updated_count = updated_count + 1
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   911
                                treestore.append(updated_iter, [pkg])
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   912
                        elif package_plan.destination_fmri:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   913
                                if not install_iter:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   914
                                        install_iter = treestore.append(None, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   915
                                            updated_installed[0])
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   916
                                d_fmri = package_plan.destination_fmri
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   917
                                dt = self.get_datetime(d_fmri.version)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   918
                                dt_str = (":%02d%02d") % (dt.month, dt.day)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   919
                                pkg_version = d_fmri.version.get_short_version() + dt_str
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   920
                                pkg = d_fmri.get_name() + "@" + pkg_version
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   921
                                install_count = install_count + 1
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   922
                                treestore.append(install_iter, [pkg])
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   923
                        xferfiles, xfersize = package_plan.get_xferstats()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   924
                        total_download_count = total_download_count + xfersize
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   925
                        total_files_count = total_files_count + xferfiles
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   926
                self.ip.progtrack.download_set_goal(npkgs, total_files_count, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   927
                    total_download_count)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   928
                self.w_review_treeview.set_model(treestore)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   929
                self.w_review_treeview.expand_all()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   930
                updated_str = self.parent._("%d packages will be updated\n")
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   931
                if updated_count == 1:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   932
                        updated_str = self.parent._("%d package will be updated\n")
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   933
                install_str = self.parent._("%d packages will be installed\n\n")
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   934
                if install_count == 1:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   935
                        install_str = self.parent._("%d package will be installed\n\n")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   936
                self.w_summary_label.set_text((updated_str + install_str + \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   937
                    self.parent._("%d MB will be downloaded"))% \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   938
                    (updated_count, install_count, (total_download_count/1024/1024)))
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   939
                self.progress_stop_timer_thread = True
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   940
                self.w_createplan_dialog.hide()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   941
                self.w_installupdate_dialog.show()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   942
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   943
        def ver_output(self): 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   944
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   945
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   946
        def ver_output_error(self, actname, errors): 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   947
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   948
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   949
        def dl_output(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   950
                gobject.idle_add(self.__update_download_progress, self.dl_cur_nbytes, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   951
                    self.dl_goal_nbytes)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   952
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   953
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   954
        def dl_output_done(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   955
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   956
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   957
        def act_output(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   958
                gobject.idle_add(self.__update_install_progress, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   959
                    self.act_cur_nactions, self.act_goal_nactions)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   960
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   961
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   962
        def act_output_done(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   963
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   964
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   965
        def ind_output(self):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   966
                self.progress_stop_timer_thread = False
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   967
                gobject.idle_add(self.__indexing_progress)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   968
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   969
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   970
        def __indexing_progress(self):
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   971
                if not self.progress_stop_timer_running:
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   972
                        self.w_installingdialog_label.set_text(\
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   973
                            self.parent._("Creating packages index..."))
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   974
                        Thread(target = self.__update_install_pulse).start()
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   975
                        
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   976
        def ind_output_done(self):
510
35ac691b5187 3193 IPS GUI throws exceptions when installing/upgrading a package
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 483
diff changeset
   977
                self.progress_stop_timer_thread = True
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   978
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   979
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   980
        @staticmethod
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   981
        def get_datetime(version):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   982
                '''Support function for change in the IPS API: get_timestamp() was
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 460
diff changeset
   983
                replaced by get_datetime()'''
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   984
                dt = None
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   985
                try:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   986
                        dt = version.get_datetime()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   987
                except AttributeError:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   988
                        dt = version.get_timestamp()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   989
                return dt
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   990