Coverage for appr/commands/channel.py: 23%

# Coverage for appr/commands/channel.py : 23%

## 48 statements 11 run 37 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

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 | from __future__ import absolute_import, division, print_function from appr.commands.command_base import CommandBase from appr.display import print_channels class ChannelCmd(CommandBase): name = 'channel' help_message = "Manage package channels" def __init__(self, options): super(ChannelCmd, self).__init__(options) self.package = options.package self.registry_host = options.registry_host self.delete = options.delete self.channel = options.channel self.remove = options.remove_release self.add = options.set_release self.version = options.version self.version_parts = options.version_parts self.status = None self.channels = {} self.ssl_verify = options.cacert or not options.insecure @classmethod def _add_arguments(cls, parser): cls._add_registryhost_option(parser) cls._add_packagename_option(parser) cls._add_packageversion_option(parser) parser.add_argument("-c", "--channel", default=None, help="channel name") parser.add_argument("--set-release", default=False, action='store_true', help="Add release to the channel") parser.add_argument("--delete", default=False, action='store_true', help="delete the channel") parser.add_argument("--remove-release", default=False, action='store_true', help="Remove a release from the channel") def _call(self): client = self.RegistryClient(self.registry_host, requests_verify=self.ssl_verify) package = self.package name = self.channel if self.delete is True: self.channels = client.delete_channel(package, name) self.status = ">>> Channel '%s' on '%s' deleted" % (name, package) elif self.add: self.channels = client.create_channel_release(package, name, self.version) self.status = ">>> Release '%s' added on '%s'" % (self.version, name) elif self.remove: self.channels = client.delete_channel_release(package, name, self.version) self.status = ">>> Release '%s' removed from '%s'" % (self.version, name) else: self.channels = client.show_channels(package, name) if name is not None: self.channels = [self.channels] self.status = print_channels(self.channels) def _render_dict(self): return self.channels def _render_console(self): return "%s" % self.status