7140506 Package Manager and Update Manager should use get_default_image_dir
authorthejaswini.k@oracle.com
Fri, 07 Sep 2012 11:30:52 +0530
changeset 2791 4361a284bbcb
parent 2790 ad2a0669d661
child 2792 94435d89e7c5
7140506 Package Manager and Update Manager should use get_default_image_dir 7140761 Package Manager window title wrong
src/checkforupdates.py
src/modules/gui/installupdate.py
src/modules/gui/misc.py
src/modules/gui/misc_non_gui.py
src/packagemanager.py
src/svc/pkg-update.xml
src/um/update-refresh.sh
src/updatemanager.py
src/updatemanagernotifier.py
--- a/src/checkforupdates.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/checkforupdates.py	Fri Sep 07 11:30:52 2012 +0530
@@ -37,6 +37,7 @@
 import traceback
 import warnings
 
+import pkg.client.api as api
 import pkg.client.api_errors as apx
 import pkg.client.progress as progress
 import pkg.client.printengine as printengine
@@ -63,8 +64,15 @@
                 global_settings.client_name = nongui_misc.get_um_name()
                 self.api_lock = nrlock.NRLock()
                 self.image_dir_arg = image_directory
+                self.exact_match = True
                 if self.image_dir_arg == None:
-                        self.image_dir_arg = nongui_misc.get_image_path()
+                        self.image_dir_arg, self.exact_match =  \
+                            api.get_default_image_root()
+                if not self.exact_match:
+                        if debug:
+                                print >> sys.stderr, ("Unable to get image directory")
+                                sys.exit(enumerations.UPDATES_UNDETERMINED)
+                        
                 self.application_path = application_path
                 self.check_all = check_all
                 self.check_cache_only = check_cache
@@ -264,7 +272,7 @@
         """Main routine for this utility"""
         set_check_all = True
         set_check_cache = False
-        image_dir = "/"
+        image_dir = None 
         try:
                 # Unused variable pargs; pylint: disable-msg=W0612
                 opts, pargs = getopt.getopt(sys.argv[1:], "hdnacR:",
--- a/src/modules/gui/installupdate.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/modules/gui/installupdate.py	Fri Sep 07 11:30:52 2012 +0530
@@ -558,8 +558,11 @@
 
         def __on_confirm_cancel_button_clicked(self, widget):
                 self.w_confirm_dialog.hide()
-                if self.top_level and widget: # User clicked cacnel, widget != None
-                        gobject.idle_add(self.parent.install_terminated)
+                if widget: # User clicked cancel, widget != None
+                     if self.top_level:
+                         gobject.idle_add(self.parent.install_terminated)
+                     else:
+                         self.w_dialog.hide()
 
         def __on_createplandialog_delete(self, widget, event):
                 self.__on_cancelcreateplan_clicked(None)
@@ -1023,10 +1026,8 @@
                 self.w_confirm_ok_button.grab_focus()
                 self.__start_substage(None,
                             bounce_progress=False)
-                if self.top_level:
+                if not self.top_level:
                         self.__reset_window_title()
-                else:
-                        self.w_dialog.hide()
                 self.w_confirm_dialog.show()
 
 
--- a/src/modules/gui/misc.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/modules/gui/misc.py	Fri Sep 07 11:30:52 2012 +0530
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 SPECIAL_CATEGORIES = ["locale", "plugin"] # We should cut all, but last part of the
@@ -66,7 +66,6 @@
 from pkg.gui.misc_non_gui import get_log_info_ext as ge_log_info_ext
 from pkg.gui.misc_non_gui import get_catalogrefresh_exception_msg as get_msg
 from pkg.gui.misc_non_gui import get_um_name as get_um
-from pkg.gui.misc_non_gui import get_image_path as g_image_path
 from pkg.gui.misc_non_gui import is_frameworkerror as is_frameworke
 
 from pkg.client import global_settings
@@ -187,9 +186,6 @@
                     gtk.MESSAGE_INFO)
                 return False
         return True
-
-def get_image_path():
-        return g_image_path()
                 
 def get_version():
         return g_version()
--- a/src/modules/gui/misc_non_gui.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/modules/gui/misc_non_gui.py	Fri Sep 07 11:30:52 2012 +0530
@@ -46,19 +46,6 @@
 LOG_ERROR_EXT = "_error.log"
 LOG_INFO_EXT = "_info.log"
 PKG_CLIENT_NAME_UM = "updatemanager"
-IMAGE_DIRECTORY_DEFAULT = "/"   # Image default directory
-IMAGE_DIR_COMMAND = "svcprop -p update/image_dir svc:/application/pkg/update"
-
-
-def get_image_path():
-        try:
-                image_directory = os.environ["PKG_IMAGE"]
-        except KeyError:
-                image_directory = \
-                    os.popen(IMAGE_DIR_COMMAND).readline().rstrip()
-                if len(image_directory) == 0:
-                        image_directory = IMAGE_DIRECTORY_DEFAULT
-        return image_directory
 
 def get_log_dir():
         return LOG_DIR
--- a/src/packagemanager.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/packagemanager.py	Fri Sep 07 11:30:52 2012 +0530
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 NOTEBOOK_PACKAGE_LIST_PAGE = 0            # Main Package List page index
@@ -4957,11 +4957,13 @@
                 elif option in ("-i", "--info-install"):
                         info_install_arg = argument
 
+        provided_image_dir = True
         if image_dir == None:
-                try:
-                        image_dir = os.environ["PKG_IMAGE"]
-                except KeyError:
-                        image_dir = "/"
+                image_dir, provided_image_dir = api.get_default_image_root()
+
+        if not provided_image_dir:
+                print _("Unable to get the image directory")
+                sys.exit(1)
 
         try:
                 gtk.init_check()
--- a/src/svc/pkg-update.xml	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/svc/pkg-update.xml	Fri Sep 07 11:30:52 2012 +0530
@@ -19,7 +19,7 @@
 
 	CDDL HEADER END
 
-	Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+	Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 
 	NOTE:  This service manifest is not editable; its contents will
 	be overwritten by package or patch operations, including
@@ -76,10 +76,6 @@
 		<propval name='duration' type='astring' value='transient' />
 	</property_group>
 
-	<property_group name='update' type='application'>
-		<propval name='image_dir' type='astring' value='/' />
-	</property_group>
-
 	<stability value='Unstable' />
 
 	<template>
--- a/src/um/update-refresh.sh	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/um/update-refresh.sh	Fri Sep 07 11:30:52 2012 +0530
@@ -77,9 +77,9 @@
 let dither=dither/32767
 sleep $dither
 
-image_dir=$(svcprop -p update/image_dir $fmri || echo "/")
+image_dir=/
 pkg -R $image_dir refresh -q 2>/dev/null
 
 # Check and cache whether updates are available
-/usr/lib/pm-checkforupdates -R $image_dir --nice
+/usr/lib/pm-checkforupdates --nice
 exit 0
--- a/src/updatemanager.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/updatemanager.py	Fri Sep 07 11:30:52 2012 +0530
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 import getopt
@@ -38,6 +38,7 @@
 except ImportError:
         sys.exit(1)
 
+import pkg.client.api as api
 import pkg.client.progress as progress
 import pkg.gui.enumerations as enumerations
 import pkg.gui.installupdate as installupdate
@@ -64,8 +65,14 @@
                 global_settings.client_name = gui_misc.get_um_name()
                 self.api_lock = nrlock.NRLock()
                 self.image_dir_arg = image_directory
+                self.exact_match = True
                 if self.image_dir_arg == None:
-                        self.image_dir_arg = gui_misc.get_image_path()
+                        self.image_dir_arg, self.exact_match = \
+                            api.get_default_image_root()
+                if not self.exact_match:
+                        if debug:
+                                print >> sys.stderr, ("Unable to get the image directory")
+                        sys.exit(enumerations.UPDATES_UNDETERMINED)
                 self.application_path = application_path
                 self.gconf = pmgconf.PMGConf()
                 try:
--- a/src/updatemanagernotifier.py	Fri Sep 07 11:09:36 2012 +0530
+++ b/src/updatemanagernotifier.py	Fri Sep 07 11:30:52 2012 +0530
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 import os
@@ -62,7 +62,6 @@
 SHOW_NOTIFY_ICON_DEFAULT = True
 IMAGE_DIRECTORY_DEFAULT = "/"
 LASTCHECK_DIR_NAME = os.path.join(os.path.expanduser("~"),'.updatemanager/notify')
-IMAGE_DIR_COMMAND = "svcprop -p update/image_dir svc:/application/pkg/update"
 CHECKFOR_UPDATES = "/usr/lib/pm-checkforupdates"
 UPDATEMANAGER = "pm-updatemanager"
 
@@ -316,14 +315,9 @@
                 gobject.timeout_add(random_delay * 1000, self.check_for_updates)
 
         def check_for_updates(self):
-                image_directory = os.popen(IMAGE_DIR_COMMAND).readline().rstrip()
-                if debug == True:
-                        print "image_directory: %s" % image_directory
-                if len(image_directory) == 0:
-                        image_directory = IMAGE_DIRECTORY_DEFAULT
                 proc = subprocess.Popen([CHECKFOR_UPDATES,
                             '--nice', '--checkupdates-cache',
-                            '--image-dir', image_directory],
+                            '--image-dir', IMAGE_DIRECTORY_DEFAULT],
                             stdout=subprocess.PIPE)
 
                 output = proc.communicate()[0].strip()