Example #1
0
    def download_image_thread(self):

        if not os.path.exists(self.image_dir + self.image_info["image_id"]):

            header = {
                'User-Agent':
                'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'
            }

            try:

                self.image_info[
                    "image_path"] = self.image_dir + self.image_info["image_id"]
                req = urllib2.Request(self.image_info["image_url"],
                                      headers=header)
                res = urllib2.urlopen(req)
                f = open(self.image_dir + self.image_info["image_id"], "wb")
                f.write(res.read())
                f.close()

                if self.image_info["custom_frame"] or self.image_info[
                        "force_label"]:
                    ImageManager.create_banner(
                        self.image_dir + self.image_info["image_id"],
                        self.image_info["x"], self.image_info["y"],
                        self.image_info["name"],
                        self.image_info["custom_frame"],
                        self.image_info["image_path"])

            except Exception as e:

                output_file = self.image_info["image_path"]
                self.image_info[
                    "image_path"] = "/usr/share/icons/Vibrancy-Colors/status/96/image-missing.png"
                image = Gtk.Image.new_from_file(self.image_info["image_path"])

                if self.image_info["video_url"] != None:
                    self.image_info[
                        "image_path"] = "/usr/share/lliurex-store/lliurex-store-gui/rsrc/icons/clean_icons/video.svg"
                else:
                    self.image_info["custom_frame"] = True
                    self.image_info["force_label"] = True

                ret = ImageManager.create_banner(
                    self.image_info["image_path"], self.image_info["x"],
                    self.image_info["y"], self.image_info["name"],
                    self.image_info["custom_frame"])
                self.image_info["pixbuf"] = ret[1].get_pixbuf()
                self.set_from_pixbuf(self.image_info)

        else:
            self.image_info[
                "image_path"] = self.image_dir + self.image_info["image_id"]

        return True
Example #2
0
    def create_banner_from_file(self, image_info, output_file=None):

        file_name = image_info.setdefault("image_path")
        x = image_info.setdefault("x")
        y = image_info.setdefault("y")
        custom_frame = image_info.setdefault("custom_frame", False)
        txt = image_info.setdefault("name", None)

        ret = ImageManager.create_banner(file_name, x, y, txt, custom_frame,
                                         output_file)

        if output_file == None:
            image_info["pixbuf"] = ret[1].get_pixbuf()
            self.set_from_pixbuf(image_info)
        else:
            image_info["image_path"] = output_file
            self.set_from_file(image_info)