diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 418: * All hardware that is available is shown on page 1

Message ID 20110822080414.2035.97435.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

James Tunnicliffe Aug. 22, 2011, 8:04 a.m. UTC
Merge authors:
  James Tunnicliffe (dooferlad)
Related merge proposals:
  https://code.launchpad.net/~dooferlad/linaro-image-tools/ui_hw_availability_fix/+merge/72294
  proposed by: James Tunnicliffe (dooferlad)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 418 [merge]
committer: James Tunnicliffe <james.tunnicliffe@linaro.org>
branch nick: linaro-image-tools
timestamp: Mon 2011-08-22 09:02:31 +0100
message:
  * All hardware that is available is shown on page 1
  * If you chose hardware that doesn't have a build type available (release or snapshot) that build type is greyed out on page 2 with some help text saying why.
modified:
  linaro-fetch-image-ui


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'linaro-fetch-image-ui'
--- linaro-fetch-image-ui	2011-08-19 15:11:02 +0000
+++ linaro-fetch-image-ui	2011-08-20 12:44:34 +0000
@@ -77,6 +77,7 @@ 
         self.width = width
         self.settings['image'] = None
         self.os_selected = True
+        self.width = width
 
         message = ("Would you like to use a Linaro release, or a more up to "
                    "date, but possibly unstable build?")
@@ -90,14 +91,16 @@ 
                             'snapshot': "I would like to run untested, but "
                                         "more up-to-date software."}
 
-        add_button(self, self.box1, self.button_text['release'],
-                   wx.RB_GROUP, self.event_radio_button_select, None, None)
+        self.rel_btn = add_button(self, self.box1, self.button_text['release'],
+                                  wx.RB_GROUP, self.event_radio_button_select,
+                                  None, None)
 
         # Save the setting for the default selected value
         self.settings['release_or_snapshot'] = "release"
 
-        add_button(self, self.box1, self.button_text['snapshot'], None,
-                   self.event_radio_button_select, None, None)
+        self.snap_btn = add_button(self, self.box1,
+                                   self.button_text['snapshot'], None,
+                                   self.event_radio_button_select, None, None)
 
         self.cp = wx.CollapsiblePane(self, label="Advanced Options",
                                      style=wx.CP_DEFAULT_STYLE |
@@ -107,10 +110,13 @@ 
         self.make_pane_content(self.cp.GetPane())
         self.box2 = wx.BoxSizer(wx.VERTICAL)
         self.box2.Add(self.cp)
-        
+
+        self.help_text_main = wx.StaticText(self, -1, "")
+
         self.sizer.Add(header)
         self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5)
         self.sizer.Add(self.box2, 0, wx.ALIGN_LEFT | wx.ALL, 5)
+        self.sizer.Add(self.help_text_main, 0, wx.ALIGN_LEFT | wx.ALL, 5)
         self.SetSizerAndFit(self.sizer)
         self.sizer.Fit(self)
         self.Move((50, 50))
@@ -390,6 +396,50 @@ 
         self.cb_image.SetValue(
                             self.get_human_os_name(self.settings['image'])[0])
 
+    def force_rel_snap_if_hw_requires(self):
+        """
+        If a hardware pack is only available on a release or snapshot build
+        then force self.settings['release_or_snapshot'] and grey out the
+        other radio button. Also display a helpful message.
+        """
+
+        snapshot_ok = False
+        release_ok = False
+
+        for hwpack in self.settings['compatable_hwpacks']:
+            if self.db.hardware_is_available_in_table("snapshot_hwpacks",
+                                                      hwpack):
+                snapshot_ok = True
+            if self.db.hardware_is_available_in_table("release_hwpacks",
+                                                         hwpack):
+                release_ok = True
+
+        assert release_ok or snapshot_ok, ("release or snapshot should have"
+                                           "a hardware pack available")
+
+        self.rel_btn.Enable()
+        self.snap_btn.Enable()
+        message = ""
+
+        if not release_ok:
+            self.settings['release_or_snapshot'] = "snapshot"
+            self.rel_btn.Disable()
+            self.rel_btn.SetValue(False)
+            self.snap_btn.SetValue(True)
+            message = ("The hardware you have chosen is only available for "
+                       "snapshot builds, so release builds have been disabled")
+
+        if not snapshot_ok:
+            self.settings['release_or_snapshot'] = "release"
+            self.snap_btn.Disable()
+            self.snap_btn.SetValue(False)
+            self.rel_btn.SetValue(True)
+            message = ("The hardware you have chosen is only available for "
+                       "release builds, so snapshot builds have been disabled")
+
+        self.help_text_main.SetLabel(message)
+        self.help_text_main.Wrap(self.width - 10)
+
     def GetNext(self):
         if self.settings['release_or_snapshot'] == "release":
             return self.pages['lmc_settings']
@@ -546,11 +596,12 @@ 
                                                                   .iteritems(),
                                        key=operator.itemgetter(1))
 
-        table = self.settings['release_or_snapshot'] + "_hwpacks"
-
         for device_name, human_readable_name in sorted_hardware_names:
             for hwpack in self.settings['choice']['hwpack'][device_name]:
-                if self.db.hardware_is_available_in_table(table, hwpack):
+                if(self.db.hardware_is_available_in_table("snapshot_hwpacks",
+                                                          hwpack)
+                   or self.db.hardware_is_available_in_table("release_hwpacks",
+                                                             hwpack)):
                     self.cb_hardware.Append(human_readable_name, device_name)
                     break
 
@@ -1570,6 +1621,7 @@ 
                                             self.config.settings['build_date'])
 
             if page == hw_details_pg:
+                rel_or_snap_pg.force_rel_snap_if_hw_requires()
                 rel_or_snap_pg.fill_os_list()
                 rel_or_snap_pg.update_release_and_build_boxes()