~ubuntu-branches/ubuntu/wily/system-image/wily

« back to all changes in this revision

Viewing changes to systemimage/main.py

  • Committer: Package Import Robot
  • Author(s): Barry Warsaw
  • Date: 2013-09-06 18:34:29 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130906183429-mwrrv52ooot0n3ut
Tags: 1.5-0ubuntu1
* New upstream release.
  - `system-image-cli --info` prints additional information:
     + last update time (i.e. the mtime of `/etc/system-image/channel.ini`
       falling back to the mtime of `/etc/ubuntu-build`).
     + version details for ubuntu, the device, and any custom version, if the
       `/etc/system-image/channel.ini` file contains these details.
  - `system-image-cli --dry-run -c <bad-channel>` no longer produces a
     traceback.  You get "Already up-to-date", but use `-v` for more info.
  - D-Bus API method `UpdateAvailableStatus` field `last_update_date`
    has changes its format.  It's still ISO 8601, but with a space
    instead of a 'T' separating the date from the time.
  - LP: #1221841 - Support the new channels.json file format with
    backward compatibility (for now) with the old format.
  - LP: #1215959 - New D-Bus .Info() method returns data similar to
    `system-image-cli --info`

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from systemimage.bindings import DBusClient
31
31
from systemimage.candidates import delta_filter, full_filter
32
32
from systemimage.config import config
33
 
from systemimage.helpers import makedirs
 
33
from systemimage.helpers import last_update_date, makedirs, version_detail
34
34
from systemimage.logging import initialize
35
35
from systemimage.state import State
36
36
from textwrap import dedent
139
139
        config.device = args.device
140
140
 
141
141
    if args.info:
142
 
        print(dedent("""
 
142
        print(dedent("""\
143
143
            current build number: {}
144
144
            device name: {}
145
 
            channel: {}""").format(config.build_number,
146
 
                                   config.device,
147
 
                                   config.channel))
 
145
            channel: {}
 
146
            last update: {}""").format(
 
147
                config.build_number,
 
148
                config.device,
 
149
                config.channel,
 
150
                last_update_date(),
 
151
                ))
 
152
        # If there's additional version details, print this out now too.  We
 
153
        # sort the keys in reverse order because we want 'ubuntu' to generally
 
154
        # come first.
 
155
        details = version_detail()
 
156
        for key in sorted(details, reverse=True):
 
157
            print('version {}: {}'.format(key, details[key]))
148
158
        return 0
149
159
 
150
160
    # We can either run the API directly or through DBus.
167
177
    state = State(candidate_filter=candidate_filter)
168
178
    if args.dry_run:
169
179
        state.run_thru('persist')
170
 
        if len(state.winner) > 0:
 
180
        # Say -c <no-such-channel> was given.  This will fail.
 
181
        if state.winner is None or len(state.winner) == 0:
 
182
            print('Already up-to-date')
 
183
        else:
171
184
            winning_path = [str(image.version) for image in state.winner]
172
185
            print('Upgrade path is {}'.format(COLON.join(winning_path)))
173
 
        else:
174
 
            print('Already up-to-date')
175
186
        return
176
187
    else:
177
188
        # Run the state machine to conclusion.  Suppress all exceptions, but