From patchwork Wed Jul 6 14:18:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Tunnicliffe X-Patchwork-Id: 2480 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 066712413B for ; Wed, 6 Jul 2011 14:18:26 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id B5324A18269 for ; Wed, 6 Jul 2011 14:18:25 +0000 (UTC) Received: by qyk30 with SMTP id 30so4864001qyk.11 for ; Wed, 06 Jul 2011 07:18:25 -0700 (PDT) Received: by 10.229.54.12 with SMTP id o12mr2870022qcg.80.1309961905179; Wed, 06 Jul 2011 07:18:25 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.48.135 with SMTP id r7cs80339qcf; Wed, 6 Jul 2011 07:18:24 -0700 (PDT) Received: by 10.227.55.20 with SMTP id s20mr7613414wbg.15.1309961903564; Wed, 06 Jul 2011 07:18:23 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id en14si16668767wbb.4.2011.07.06.07.18.23; Wed, 06 Jul 2011 07:18:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QeSvm-00058n-Qo for ; Wed, 06 Jul 2011 14:18:22 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id C5E152E8910 for ; Wed, 6 Jul 2011 14:18:22 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 359 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 359: Merging in fetch_image.py Message-Id: <20110706141822.7642.25332.launchpad@loganberry.canonical.com> Date: Wed, 06 Jul 2011 14:18:22 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13376"; Instance="initZopeless config overlay" X-Launchpad-Hash: ee3a0153a889547f76d364c23f1935b26639bc21 Merge authors: James Tunnicliffe (dooferlad) Related merge proposals: https://code.launchpad.net/~dooferlad/linaro-image-tools/fetch_image_cli/+merge/64710 proposed by: James Tunnicliffe (dooferlad) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 359 [merge] committer: James Tunnicliffe branch nick: linaro-image-tools timestamp: Fri 2011-06-17 19:15:35 +0100 message: Merging in fetch_image.py This is a command line client that will download the required files from release.linaro.org and snapshots.linaro.org to build a specified OS image for your hardware, for example: fetch_image.py -w panda -a linaro-n -i nano -b final -p panda -t ~/Desktop/panda.bin This will create a nano image for a panda board based on the final linaro-n release from release.linaro.org and place it on the users desktop. added: 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 === added file 'fetch_image.py' --- fetch_image.py 1970-01-01 00:00:00 +0000 +++ fetch_image.py 2011-06-17 13:10:22 +0000 @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# Copyright (C) 2010, 2011 Linaro +# +# Author: James Tunnicliffe +# +# This file is part of Linaro Image Tools. +# +# Linaro Image Tools is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# Linaro Image Tools is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Linaro Image Tools; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +import sys +import os +import linaro_image_tools.FetchImage as FetchImage +import logging + + +def main(): + file_handler = FetchImage.FileHandler() + config = FetchImage.FetchImageConfig() + + # Unfortunately we need to do a bit of a hack here and look for some + # options before performing a full options parse. + clean_cache = ("--clean-cache" in sys.argv[1:] + or "-x" in sys.argv[1:]) + + force_download = ("--force-download" in sys.argv[1:] + or "-d" in sys.argv[1:]) + + if clean_cache: + file_handler.clean_cache() + + # If the settings file and server index need updating, grab them + file_handler.update_files_from_server(force_download) + + # Load settings YAML, which defines the parameters we ask for and + # acceptable responses from the user + config.read_config(file_handler.settings_file) + + # Using the settings that the YAML defines as what we need for a build, + # generate a command line parser and parse the command line + config.parse_args(sys.argv[1:]) + + if config.args['platform'] == "snapshot": + config.args['release_or_snapshot'] = "snapshot" + else: + config.args['release_or_snapshot'] = "release" + + # Using the config we have, look up URLs to download data from in the + # server index + db = FetchImage.DB(file_handler.index_file) + + image_url, hwpack_url = db.get_image_and_hwpack_urls(config.args) + + if(image_url and hwpack_url): + + tools_dir = os.path.dirname(__file__) + if tools_dir == '': + tools_dir = None + + file_handler.create_media(image_url, hwpack_url, + config.args, tools_dir) + else: + logging.error( + "Unable to find files that match the parameters specified") + +if __name__ == '__main__': + main()