Exemple #1
0
    def delete_image(self, image_name):
        ini_path = os.path.join(self.kindo_settings_path, "images.ini")
        if not os.path.isfile(ini_path):
            return False

        cf = ConfigParser(ini_path)
        infos = cf.get()

        if image_name not in infos:
            return True

        if "name" not in infos[image_name]:
            return True

        v = infos[image_name]["name"]
        kiname = v.replace("/", "-").replace(":", "-")

        if kiname[-3:] != ".ki":
            kiname = "%s.ki" % kiname

        target = os.path.join(self.kindo_images_path, kiname)
        if os.path.isfile(target):
            os.remove(target)

        cf.remove(image_name)
        cf.write()
        return True
Exemple #2
0
    def start(self):
        ini_path = os.path.join(self.kindo_settings_path, "kindo.ini")
        if not os.path.isfile(ini_path):
            self.logger.info("logout successfully")
            return

        try:
            cf = ConfigParser(ini_path)
            cf.remove("default", "username")
            cf.remove("default", "password")
            cf.write()

            self.logger.info("logout successfully")
        except Exception as e:
            self.logger.debug(traceback.format_exc())
            self.logger.error(e)
Exemple #3
0
    def delete_image(self, image_name):
        ini_path = os.path.join(self.kindo_settings_path, "images.ini")
        if not os.path.isfile(ini_path):
            return False

        cf = ConfigParser(ini_path)
        infos = cf.get()

        if image_name not in infos:
            return True

        if "path" in infos[image_name]:
            target = infos[image_name]["path"]
            if os.path.isfile(target):
                os.remove(target)

        cf.remove(image_name)
        cf.write()
        return True