1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/usr/bin/env python
# Copyright (C) 2010, 2011 Linaro
#
# Author: James Tunnicliffe <james.tunnicliffe@linaro.org>
#
# 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.fetch_image as fetch_image
import logging
def main():
file_handler = fetch_image.FileHandler()
config = fetch_image.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 = fetch_image.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()
|