Commit 8767d4d2 authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

Improve is info command

Add image format display
Add new options
Fix bad handling of changelog with version which are not number.
parent da0cb12b
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -289,10 +289,14 @@ def c_info(args):
    '''
    Display info about packaged images
    '''
    if args.all:
        args.payloads = True
        args.files = True
        args.changelog = True
    repoman = load_repositories(args)
    for image, repo in get_images(args.pattern, repoman, min=1):
        image.show(o_verbose=args.verbose, o_changelog=args.changelog,
                   o_json=args.json)
        image.show(o_files=args.files, o_payloads=args.payloads,
                   o_changelog=args.changelog, o_json=args.json)

def c_init(args):
    '''
@@ -613,12 +617,16 @@ def arg_parser_init():
    p.set_defaults(func=c_help, parser=parser, subparser=subparser)
    # info command parser
    p = subparser.add_parser("info", help=c_info.__doc__.lower())
    p.add_argument("-a", "--all", action="store_true",
                   help="display all information")
    p.add_argument("-j", "--json", action="store_true",
                   help="display all information formated in json")
    p.add_argument("-c", "--changelog", action="store_true",
                   help="display image changelog")
    p.add_argument("-j", "--json", action="store_true",
                   help="output is formated in json")
    p.add_argument("-v", "--verbose", action="store_true",
                   help="verbose output")
    p.add_argument("-f", "--files", action="store_true",
                   help="display image files")
    p.add_argument("-p", "--payloads", action="store_true",
                   help="display image payloads")
    p.add_argument("pattern", nargs="+",
                   help="path|[repository/][image][:version]")
    p.set_defaults(func=c_info)
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ _is() {
         (( args == 2 )) && _opt "${cmds[@]}"
      ;;
      info)
         [[ "$cur" == -* ]] && _opt '-v --verbose -c --changelog' && return 0
         [[ "$cur" == -* ]] && _opt '-a --all -j --json -c --changelog -f --files -p --payloads' && return 0
         _image
      ;;
      init)
+4 −2
Original line number Diff line number Diff line
@@ -227,9 +227,11 @@ _is() {
                        ;;
                    (info)
                        args+=(
                        '(-c --changelog)'{-c,--changelog}'[display image changelog]'
                        '(-a --all)'{-a,--all}'[display all information]'
                        '(-j, --json)'{-j,--json}'[output is formated in json]'
                        '(-v --verbose)'{-v,--verbose}'[verbose output]'
                        '(-c --changelog)'{-c,--changelog}'[display image changelog]'
                        '(-f --files)'{-f,--files}'[display image files]'
                        '(-p --payloads)'{-p,--payloads}'[display image payloads]'
                        '*:image:_installsystems_images'
                        )
                        ;;
+13 −7
Original line number Diff line number Diff line
@@ -203,17 +203,23 @@ help [-h]
    Show help.


info [-h] [-c] [-j] [-v] <image>...
    Display info about one *image* (or more).
info [-h] [-a] [-j] [-c] [-f] [-p] <image>...
    Display information about one *image* (or more).

    -c, --changelog
        display *image* changelog
    -a, --all
        display all information available

    -j, --json
        output is formated in json
        display all information formated in json

    -c, --changelog
        display image changelog

    -f, --files
        display image files

    -v, --verbose
        verbose output
    -p, --payloads
        display image payloads


init [-h] *repository*...
+15 −12
Original line number Diff line number Diff line
@@ -903,7 +903,7 @@ class PackageImage(Image):
            warn(u"Invalid changelog: %s" % e)
        return desc

    def show(self, o_verbose=False, o_changelog=False, o_json=False):
    def show(self, o_payloads=False, o_files=False, o_changelog=False, o_json=False):
        '''
        Display image content
        '''
@@ -915,15 +915,17 @@ class PackageImage(Image):
            out(u'#yellow#Date:#reset# %s' % istools.time_rfc2822(self.date))
            out(u'#yellow#Description:#reset# %s' % self.description)
            out(u'#yellow#Author:#reset# %s' % self.author)
            if o_verbose:
            # field is_build_version is new in version 5. I can be absent.
            try: out(u'#yellow#IS build version:#reset# %s' % self.is_build_version)
            except AttributeError: pass
            # field is_min_version is new in version 5. I can be absent.
            try: out(u'#yellow#IS minimum version:#reset# %s' % self.is_min_version)
            except AttributeError: pass
            out(u'#yellow#Format:#reset# %s' % self.format)
            out(u'#yellow#MD5:#reset# %s' % self.md5)
            if o_verbose:
            out(u'#yellow#Payload count:#reset# %s' % len(self.payload))
            # display payloads
            if o_payloads:
                payloads = self.payload
                for payload_name in payloads:
                    payload = payloads[payload_name]
@@ -932,11 +934,12 @@ class PackageImage(Image):
                    out(u'  #yellow#Size:#reset# %s' % (istools.human_size(payload.size)))
                    out(u'  #yellow#MD5:#reset# %s' % payload.md5)
            # display image content
            out('#light##yellow#Content:#reset#')
            self._tarball.list(o_verbose)
            if o_files:
                out('#light##yellow#Files:#reset#')
                self._tarball.list(True)
            # display changelog
            if o_changelog:
                self.changelog.show(int(self.version), o_verbose)
                self.changelog.show(self.version)

    def check(self, message="Check MD5"):
        '''