diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 408: Improve error reporting when linaro-fetch-image is passed a set of options that don't match any a...

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

Commit Message

James Tunnicliffe Aug. 17, 2011, 12:48 p.m. UTC
Merge authors:
  James Tunnicliffe (dooferlad)
Related merge proposals:
  https://code.launchpad.net/~dooferlad/linaro-image-tools/improve_fetch_image_error_reporting/+merge/71393
  proposed by: James Tunnicliffe (dooferlad)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 408 [merge]
committer: James Tunnicliffe <james.tunnicliffe@linaro.org>
branch nick: linaro-image-tools
timestamp: Wed 2011-08-17 13:46:05 +0100
message:
  Improve error reporting when linaro-fetch-image is passed a set of options that don't match any available builds. User will now receive helpful information on what doesn't match up.
modified:
  linaro_image_tools/fetch_image.py


--
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_image_tools/fetch_image.py'
--- linaro_image_tools/fetch_image.py	2011-08-15 16:57:07 +0000
+++ linaro_image_tools/fetch_image.py	2011-08-17 12:46:05 +0000
@@ -1383,6 +1383,8 @@ 
                 HW Pack: platform, hardware, date, build"""
         image_url = None
         hwpack_url = None
+        old_image = args['image']
+        build_bits = None
 
         if(args['release_or_snapshot'] == "snapshot"):
             count = 0
@@ -1458,7 +1460,7 @@ 
                 else:
                     break  # Got a URL, go.
 
-        else:
+        elif args['release_or_snapshot'] == "release":
             image_url = self.get_url("release_binaries",
                             [
                              ("image", args['image']),
@@ -1471,14 +1473,86 @@ 
                              ("build", args['build']),
                              ("platform", args['platform'])])
 
+        else:
+            assert(0, "Unexpected args['release_or_snapshot']: {0}".format(
+                       args['release_or_snapshot']))
+
         if(not image_url):
             # If didn't get an image URL set up something so the return line
             # doesn't crash
             image_url = [None]
 
+            if args['release_or_snapshot'] == "snapshot":
+                table = "snapshot_binaries"
+            else:
+                table = "release_binaries"
+
+            if not (self.get_url(table, [("image", old_image)]) or
+                    self.get_url(table, [("image", args['image'])])):
+                msg = "{0} does not match any OS indexed".format(old_image)
+                logging.error(msg)
+
+            if args['release_or_snapshot'] == "snapshot":
+                if not self.get_url("snapshot_binaries",
+                                    [("date", build_bits[0])]):
+                    msg = "Can not find requested OS on date {0}".format(
+                           build_bits[0])
+                    logging.error(msg)
+
+                elif not self.get_url("snapshot_binaries",
+                                      [("build", build_bits[1])]):
+                    msg = "Can not find build {0} of requested OS".format(
+                           build_bits[1])
+                    logging.error(msg)
+
+            else:  # Release...
+                if not self.get_url("release_binaries",
+                                    [("build", args['build'])]):
+                    msg = "Can not find build {0} of selected OS".format(
+                           args['build'])
+                    logging.error(msg)
+
+                if not self.get_url("release_binaries",
+                                    [("platform", args['platform'])]):
+                    msg = "Can not find OS for platform {0}".format(
+                           args['platform'])
+                    logging.error(msg)
+
         if(not hwpack_url):
             # If didn't get a hardware pack URL set up something so the return
             # line doesn't crash
             hwpack_url = [None]
 
+            table = None
+            if args['release_or_snapshot'] == "snapshot":
+                table = "snapshot_hwpacks"
+                build = build_bits[1]
+
+            elif args['release_or_snapshot'] == "release":
+                table = "release_hwpacks"
+                build = args['build']
+
+            if not self.get_url(table, [("hardware", args['hwpack'])]):
+                msg = "{0} does not match any hardware pack indexed".format(
+                       args['hwpack'])
+                logging.error(msg)
+
+            if args['release_or_snapshot'] == "snapshot":
+                if not self.get_url("snapshot_hwpacks",
+                                    [("date", build_bits[0])]):
+                    msg = "Hardware pack does not exist on date {0}".format(
+                           build_bits[0])
+                    logging.error(msg)
+
+            else:  # Release...
+                if not self.get_url("release_hwpacks",
+                                    [("platform", args['platform'])]):
+                    msg = "Hardware pack unavailable for platform {0}".format(
+                           args['platform'])
+
+            if not self.get_url(table, [("build", build)]):
+                msg = ("Build {0} doesn't exist for any hardware "
+                       "pack indexed".format(build))
+                logging.error(msg)
+
         return(image_url[0], hwpack_url[0])