Example #1
0
    def start(self):
        try:
            for option in self.options[2:]:
                self.logger.debug("searching %s" % option)

                isok, res = self.api.search(option)
                if not isok:
                    continue

                self.logger.debug("searched %s results" % len(res))

                table = PrettyTable(["number", "name", "version", "pusher", "size"])
                index = 0
                for ki in res:
                    index += 1
                    table.add_row([index, ki["name"], ki["version"], ki["pusher"], ki["size"]])

                if len(res) == 0:
                    continue

                self.logger.info(table)

                number = self.get_input_number(res)
                if number is not None and number > -1:
                    self.pull_image(res[number]["name"])
        except Exception as e:
            self.logger.debug(traceback.format_exc())
            self.logger.error(e)
Example #2
0
    def start(self):
        images = self.get_images_list()

        table = PrettyTable(["Name", "Version", "Pusher", "Size", "BuildTime"])
        table.padding_width = 1

        for section in images:
            image = images[section]

            table.add_row([
                image.get("name", ""),
                image.get("version", "1.0"),
                image.get("author", "anonymous"),
                image.get("size", 0),
                image.get("buildtime", "")
            ])

        self.logger.info(table)
Example #3
0
    def start(self):
        search_engine_url = "%s/v1/search" % self.configs.get("index", self.kindo_default_hub_host)

        if search_engine_url[:7].lower() != "http://" and search_engine_url[:8].lower() != "https://":
            search_engine_url = "http://%s" % search_engine_url

        try:
            for option in self.options[2:]:
                self.logger.debug("searching %s" % option)

                params = {"q": option}

                self.logger.debug("connecting %s" % search_engine_url)
                r = requests.get(search_engine_url, params=params)
                if r.status_code != 200:
                    self.logger.error("\"%s\" can't connect" % search_engine_url)
                    return

                response = r.json()

                if "code" in response:
                    raise Exception(response["msg"])

                self.logger.debug("searched %s results" % len(response))

                table = PrettyTable(["number", "name", "version", "pusher", "size"])
                index = 0
                for ki in response:
                    index += 1
                    table.add_row([index, ki["name"], ki["version"], ki["pusher"], ki["size"]])

                if len(response) == 0:
                    self.logger.error("image not found: %s" % option)
                    continue

                self.logger.info(table)

                number = self.get_input_number(response)
                if number > -1:
                    self.pull_image(response[number]["name"])
        except Exception as e:
            self.logger.debug(traceback.format_exc())
            self.logger.error(e)