FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Desktop

 
 
LinkBack Thread Tools
 
Old 12-17-2009, 01:22 PM
Radek Vykydal
 
Default Ask about disk initialization only in storageinit step.

Don't ask again and again e.g. when going back and forth in custom partitioning
UI. Related to bug #527711 which is itself fixed by another patch.
---
gui.py | 31 ++++++++++++++++++++++++++++
storage/__init__.py | 3 ++
storage/devicetree.py | 53 ++++++++++++++----------------------------------
3 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/gui.py b/gui.py
index 4e65362..17a7c4f 100755
--- a/gui.py
+++ b/gui.py
@@ -986,6 +986,7 @@ class InstallInterface:
root = gtk.gdk.get_default_root_window()
cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
root.set_cursor(cursor)
+ self.initLabelAnswers = {}

def __del__ (self):
pass
@@ -1122,6 +1123,36 @@ class InstallInterface:
d.destroy()
return rc

+ def resetInitializeDiskQuestion(self):
+ self.initLabelAnswers = {}
+
+ def questionInitializeDisk(self, path="", description="", size=0,
+ details=""):
+ retVal = False # The less destructive default
+ if path:
+ # we are caching answers so that we don't
+ # ask in each storage.reset() again
+ if path in self.initLabelAnswers:
+ return self.initLabelAnswers[path]
+
+ rc = self.messageWindow(_("Warning"),
+ _("Error processing drive:

"
+ "%(path)s
%(size)-0.fMB
%(description)s

"
+ "This device may need to be reinitialized.

"
+ "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!%(details)s")
+ % {'path': path, 'size': size,
+ 'description': description, 'details': details},
+ type="custom",
+ custom_buttons = [ _("_Ignore drive"),
+ _("_Re-initialize drive") ],
+ custom_icon="question")
+ if rc == 0:
+ pass
+ else:
+ retVal = True
+ self.initLabelAnswers[path] = retVal
+ return retVal
+
def beep(self):
gtk.gdk.beep()

diff --git a/storage/__init__.py b/storage/__init__.py
index ea89633..4e2af50 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -75,6 +75,9 @@ def storageInitialize(anaconda):
# populate the udev db
udev_trigger(subsystem="block", action="change")

+
+ anaconda.intf.resetInitializeDiskQuestion()
+
# Set up the protected partitions list now.
if os.path.exists("/dev/live") and
stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]):
diff --git a/storage/devicetree.py b/storage/devicetree.py
index b528ab2..ea93c74 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -123,41 +123,6 @@ def getLUKSPassphrase(intf, device, globalPassphrase):

return (passphrase, isglobal)

-# Don't really know where to put this.
-def questionInitializeDisk(intf=None, path=None, description=None):
- retVal = False # The less destructive default
- if not intf or not path:
- pass
- else:
- if not path.startswith('/dev/'):
- path = '/dev/' + path
-
- dev = parted.getDevice(path)
- bypath = os.path.basename(deviceNameToDiskByPath(path))
- details = ""
-
- if description is None:
- description = dev.model
-
- if bypath:
- details = "

Device details:
%s" % (bypath,)
-
- rc = intf.messageWindow(_("Warning"),
- _("Error processing drive:

"
- "%(path)s
%(size)-0.fMB
%(description)s

"
- "This device may need to be reinitialized.

"
- "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!%(details)s")
- % {'path': path, 'size': dev.getSize(),
- 'description': description, 'details': details},
- type="custom",
- custom_buttons = [ _("_Ignore drive"),
- _("_Re-initialize drive") ],
- custom_icon="question")
- if rc == 0:
- pass
- else:
- retVal = True
- return retVal

def questionReinitILVM(intf=None, pv_names=None, lv_name=None, vg_name=None):
retVal = False # The less destructive default
@@ -1363,8 +1328,22 @@ class DeviceTree(object):
if self.zeroMbr:
initcb = lambda: True
else:
- initcb = lambda: questionInitializeDisk(self.intf, device.path,
- device.description)
+ # TODO RV is this check still necessary?
+ if device.path.startswith('/dev/'):
+ path = device.path
+ else:
+ path = '/dev/' + device.path
+ description = device.description or device.model
+ bypath = os.path.basename(deviceNameToDiskByPath(path))
+ if bypath:
+ details = "

Device details:
%s" % (bypath,)
+ else:
+ datails = ""
+
+ initcb = lambda: self.intf.questionInitializeDisk(path,
+ description,
+ device.size,
+ details)

try:
format = getFormat("disklabel",
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-06-2010, 11:44 AM
Radek Vykydal
 
Default Ask about disk initialization only in storageinit step.

Don't ask again and again e.g. when going back and forth in custom partitioning
UI. Related to bug #527711 which is itself fixed by another patch.
(*) Answers are cached in InstallInterface classes.
(*) Dialog callback is moved from storage code to InstallInterface
classes.
---
cmdline.py | 10 +++++++++
gui.py | 37 ++++++++++++++++++++++++++++++++++
storage/__init__.py | 3 ++
storage/devicetree.py | 53 ++++++++++++++----------------------------------
text.py | 37 ++++++++++++++++++++++++++++++++++
5 files changed, 103 insertions(+), 37 deletions(-)

diff --git a/cmdline.py b/cmdline.py
index c6c98be..24485f7 100644
--- a/cmdline.py
+++ b/cmdline.py
@@ -134,6 +134,16 @@ class InstallInterface:
while 1:
time.sleep(5)

+ def resetInitializeDiskQuestion(self):
+ pass
+
+ def questionInitializeDisk(self, path, description, size, details=""):
+ print(_("Can't have a question in command line mode!"))
+ print("(questionInitializeDisk)")
+ # don't exit
+ while 1:
+ time.sleep(5)
+
def mainExceptionWindow(self, shortText, longTextFile):
print(shortText)

diff --git a/gui.py b/gui.py
index fc93af4..2f9f925 100755
--- a/gui.py
+++ b/gui.py
@@ -987,6 +987,7 @@ class InstallInterface:
root = gtk.gdk.get_default_root_window()
cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
root.set_cursor(cursor)
+ self._initLabelAnswers = {}

def __del__ (self):
pass
@@ -1123,6 +1124,42 @@ class InstallInterface:
d.destroy()
return rc

+ def resetInitializeDiskQuestion(self):
+ self._initLabelAnswers = {}
+
+ def questionInitializeDisk(self, path, description, size, details=""):
+
+ retVal = False # The less destructive default
+
+ if not path:
+ return retVal
+
+ # we are caching answers so that we don't
+ # ask in each storage.reset() again
+ if path in self._initLabelAnswers:
+ log.info("UI not asking about disk initialization, "
+ "using cached answer: %s" % self._initLabelAnswers[path])
+ return self._initLabelAnswers[path]
+
+ rc = self.messageWindow(_("Warning"),
+ _("Error processing drive:

"
+ "%(path)s
%(size)-0.fMB
%(description)s

"
+ "This device may need to be reinitialized.

"
+ "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!%(details)s")
+ % {'path': path, 'size': size,
+ 'description': description, 'details': details},
+ type="custom",
+ custom_buttons = [ _("_Ignore drive"),
+ _("_Re-initialize drive") ],
+ custom_icon="question")
+ if rc == 0:
+ pass
+ else:
+ retVal = True
+
+ self._initLabelAnswers[path] = retVal
+ return retVal
+
def beep(self):
gtk.gdk.beep()

diff --git a/storage/__init__.py b/storage/__init__.py
index d50987d..c748362 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -78,6 +78,9 @@ def storageInitialize(anaconda):
# populate the udev db
udev_trigger(subsystem="block", action="change")

+
+ anaconda.intf.resetInitializeDiskQuestion()
+
# Set up the protected partitions list now.
if os.path.exists("/dev/live") and
stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]):
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 6c956fc..f93e44f 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -126,41 +126,6 @@ def getLUKSPassphrase(intf, device, globalPassphrase):

return (passphrase, isglobal)

-# Don't really know where to put this.
-def questionInitializeDisk(intf=None, path=None, description=None):
- retVal = False # The less destructive default
- if not intf or not path:
- pass
- else:
- if not path.startswith('/dev/'):
- path = '/dev/' + path
-
- dev = parted.getDevice(path)
- bypath = os.path.basename(deviceNameToDiskByPath(path))
- details = ""
-
- if description is None:
- description = dev.model
-
- if bypath:
- details = "

Device details:
%s" % (bypath,)
-
- rc = intf.messageWindow(_("Warning"),
- _("Error processing drive:

"
- "%(path)s
%(size)-0.fMB
%(description)s

"
- "This device may need to be reinitialized.

"
- "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!%(details)s")
- % {'path': path, 'size': dev.getSize(),
- 'description': description, 'details': details},
- type="custom",
- custom_buttons = [ _("_Ignore drive"),
- _("_Re-initialize drive") ],
- custom_icon="question")
- if rc == 0:
- pass
- else:
- retVal = True
- return retVal

def questionReinitILVM(intf=None, pv_names=None, lv_name=None, vg_name=None):
retVal = False # The less destructive default
@@ -1364,8 +1329,22 @@ class DeviceTree(object):
if self.zeroMbr:
initcb = lambda: True
else:
- initcb = lambda: questionInitializeDisk(self.intf, device.path,
- device.description)
+ # TODO RV is this check still necessary?
+ if device.path.startswith('/dev/'):
+ path = device.path
+ else:
+ path = '/dev/' + device.path
+ description = device.description or device.model
+ bypath = os.path.basename(deviceNameToDiskByPath(path))
+ if bypath:
+ details = "

Device details:
%s" % (bypath,)
+ else:
+ datails = ""
+
+ initcb = lambda: self.intf.questionInitializeDisk(path,
+ description,
+ device.size,
+ details)

try:
format = getFormat("disklabel",
diff --git a/text.py b/text.py
index 60eafb7..6972417 100644
--- a/text.py
+++ b/text.py
@@ -437,6 +437,7 @@ class InstallInterface:
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTSTP, signal.SIG_IGN)
self.screen = SnackScreen()
+ self._initLabelAnswers = {}

def __del__(self):
if self.screen:
@@ -453,6 +454,42 @@ class InstallInterface:
return False
return True

+ def resetInitializeDiskQuestion(self):
+ self._initLabelAnswers = {}
+
+ def questionInitializeDisk(self, path, description, size, details=""):
+
+ retVal = False # The less destructive default
+
+ if not path:
+ return retVal
+
+ # we are caching answers so that we don't
+ # ask in each storage.reset() again
+ if path in self._initLabelAnswers:
+ log.info("UI not asking about disk initialization, "
+ "using cached answer: %s" % self._initLabelAnswers[path])
+ return self._initLabelAnswers[path]
+
+ rc = self.messageWindow(_("Warning"),
+ _("Error processing drive:

"
+ "%(path)s
%(size)-0.fMB
%(description)s

"
+ "This device may need to be reinitialized.

"
+ "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!%(details)s")
+ % {'path': path, 'size': size,
+ 'description': description, 'details': details},
+ type="custom",
+ custom_buttons = [ _("_Ignore drive"),
+ _("_Re-initialize drive") ],
+ custom_icon="question")
+ if rc == 0:
+ pass
+ else:
+ retVal = True
+
+ self._initLabelAnswers[path] = retVal
+ return retVal
+
def run(self, anaconda):
self.anaconda = anaconda
instLang = anaconda.id.instLanguage
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 07:48 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org