Merge lp://qastaging/~dooferlad/linaro-image-tools/fetch_image_cli into lp://qastaging/linaro-image-tools/11.11

Proposed by James Tunnicliffe
Status: Merged
Approved by: James Westby
Approved revision: 358
Merged at revision: 359
Proposed branch: lp://qastaging/~dooferlad/linaro-image-tools/fetch_image_cli
Merge into: lp://qastaging/linaro-image-tools/11.11
Prerequisite: lp://qastaging/~dooferlad/linaro-image-tools/fetch_image_server_indexer
Diff against target: 83 lines (+79/-0)
1 file modified
fetch_image.py (+79/-0)
To merge this branch: bzr merge lp://qastaging/~dooferlad/linaro-image-tools/fetch_image_cli
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+64710@code.qastaging.launchpad.net

Description of the change

A simple CLI tool that drives the FetchImage library.

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

 some comments from the other reviews apply ;-)

On Wed, Jun 15, 2011, James Tunnicliffe wrote:
> +import linaro_image_tools.FetchImage as FetchImage
> +import logging
> +
> +if __name__ == '__main__':

 From there, I would only call into a
    def main():
 function as to help testing and code reuse

> + file_handler = FetchImage.FileHandler()
> + config = FetchImage.Config()
> +
> + # 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 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"

 Instead of release_or_snapshot, "archive"? or "source"?

> + # 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):
> + file_handler.create_media(image_url, hwpack_url, config.args)
> + else:
> + logging.error("Unable to find files that match the parameters specified")
>

--
Loïc Minier

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

On 15 June 2011 18:22, Loïc Minier <email address hidden> wrote:
>  some comments from the other reviews apply   ;-)
>
> On Wed, Jun 15, 2011, James Tunnicliffe wrote:
>> +import linaro_image_tools.FetchImage as FetchImage
>> +import logging
>> +
>> +if __name__ == '__main__':
>
>  From there, I would only call into a
>    def main():
>  function as to help testing and code reuse

Noted. Will do.
<snip>
>> +    if config.args['platform'] == "snapshot":
>> +        config.args['release_or_snapshot'] = "snapshot"
>> +    else:
>> +        config.args['release_or_snapshot'] = "release"
>
>  Instead of release_or_snapshot, "archive"?  or "source"?

Release points to official Linaro releases, as currently hosted on
releases.linaro.org and shapshot the daily builds on
snapshots.linaro.org.

--
James Tunnicliffe

Revision history for this message
Loïc Minier (lool) wrote :

On Thu, Jun 16, 2011, James Tunnicliffe wrote:
> >> +    if config.args['platform'] == "snapshot":
> >> +        config.args['release_or_snapshot'] = "snapshot"
> >> +    else:
> >> +        config.args['release_or_snapshot'] = "release"
> >
> >  Instead of release_or_snapshot, "archive"?  or "source"?
>
> Release points to official Linaro releases, as currently hosted on
> releases.linaro.org and shapshot the daily builds on
> snapshots.linaro.org.

 Yup; I understood the reference, but in a way it seemed to hardcode
 that there would only be these two sources and their names in the
 variable name. It seemed like we could possibly change this over time,
 perhaps dropping one, or adding one like a ci.linaro.org download
 archive and using "release_or_snapshot" seemed a bit heavily biased
 towards exactly 2 sources of downloads.

--
Loïc Minier

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

On 16 June 2011 14:31, Loïc Minier <email address hidden> wrote:
> On Thu, Jun 16, 2011, James Tunnicliffe wrote:
>> >> +    if config.args['platform'] == "snapshot":
>> >> +        config.args['release_or_snapshot'] = "snapshot"
>> >> +    else:
>> >> +        config.args['release_or_snapshot'] = "release"
>> >
>> >  Instead of release_or_snapshot, "archive"?  or "source"?
>>
>> Release points to official Linaro releases, as currently hosted on
>> releases.linaro.org and shapshot the daily builds on
>> snapshots.linaro.org.
>
>  Yup; I understood the reference, but in a way it seemed to hardcode
>  that there would only be these two sources and their names in the
>  variable name.  It seemed like we could possibly change this over time,
>  perhaps dropping one, or adding one like a ci.linaro.org download
>  archive and using "release_or_snapshot" seemed a bit heavily biased
>  towards exactly 2 sources of downloads.

Ah, I see what you mean. Currently it is an indicator of the route
that the user took through the UI, which needs to be emulated for the
CLI. It is a bit hacky and I have ended up using it to build a table
name sometimes for database lookups, which I am sure I shouldn't! I
will see if I can restrict it to just the UI code where its meaning
should be more clear and think about a better name and usage.

--
James Tunnicliffe

358. By James Tunnicliffe

Modified according to changes proposed by code review.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Just a heads up that I hove committed a change in response to your feedback. I hope it covers everything.

Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches