def fetch_screenshot(self):
        screenshot_dir = os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name)
        screenshot_md5_path = os.path.join(screenshot_dir, "screenshot_md5.txt")
        remote_screenshot_md5_url = "%s/zh_CN/%s/screenshot_md5.txt" % (SCREENSHOT_HOST, self.pkg_name)
        remote_screenshot_zip_url = "%s/zh_CN/%s/screenshot.zip" % (SCREENSHOT_HOST, self.pkg_name)
        try:
            remote_md5 = urllib2.urlopen(remote_screenshot_md5_url).read()
            need_download = False

            if os.path.exists(screenshot_dir):
                if os.path.exists(screenshot_md5_path):
                    local_md5 = read_file(screenshot_md5_path)
                    if remote_md5 != local_md5:
                        need_download = True
                else:
                    need_download = True
            else:
                need_download = True

            if need_download:
                write_file(screenshot_md5_path, remote_md5, True)

                try:
                    urllib.urlretrieve(remote_screenshot_zip_url,
                                       os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name, "screenshot.zip")
                                       )
                    global_event.emit("download-screenshot-finish", self.pkg_name)
                except Exception, e:
                    global_logger.error("Download screenshot error: %s" % e)
        except Exception, e:
            global_logger.error("fetch_screenshot got error: %s" % e)
 def handle_pkg_status(self, status, success):
     if success:
         self.install_status= str(status)
         try:
             self.desktops = json.loads(self.install_status)
             self.desktops = self.data_manager.get_pkg_desktop_info(self.desktops)
         except:
             pass
         self.emit_redraw_request()
     else:
         global_logger.error("%s: get_pkg_installed handle_dbus_error" % self.pkg_name)
         global_logger.error(status)
Example #3
0
    def show_screenshot(self):
        container_remove_all(self.right_slide_box)
        screenshot_dir = os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name)

        if os.path.exists(screenshot_dir):
            screenshot_files = map(
                lambda filename: os.path.join(screenshot_dir, filename),
                filter(lambda file_name: file_name.endswith(".png"),
                       os.listdir(screenshot_dir)))

            if len(screenshot_files) > 0:
                slide_switcher = SlideSwitcher(
                    map(
                        lambda screenshot_file: get_resize_pixbuf_with_height(
                            screenshot_file, 290), screenshot_files),
                    pointer_offset_x=-370,
                    pointer_offset_y=-15,
                    horizontal_align=ALIGN_MIDDLE,
                    vertical_align=ALIGN_MIDDLE,
                    height_offset=60,
                    hover_switch=False,
                    auto_switch=False,
                    navigate_switch=True,
                )
                slide_align = gtk.Alignment()
                slide_align.set(0.5, 0.5, 1, 1)
                slide_align.add(slide_switcher)
                slide_align.connect("expose-event",
                                    self.expose_resizable_label_background)
                self.right_slide_box.pack_start(slide_align, True, True)

                powered_link = Label(
                    _("Powered by UpYun.com"),
                    text_color=app_theme.get_color("homepage"),
                    hover_color=app_theme.get_color("homepage_hover"),
                )
                powered_link.set_clickable()
                powered_link.connect(
                    "button-press-event", lambda w, e: run_command(
                        "xdg-open https://www.upyun.com/"))
                powered_link_align = gtk.Alignment()
                powered_link_align.set(1.0, 0.5, 0, 0)
                powered_link_align.set_padding(0, 0, 0, 100)
                powered_link_align.add(powered_link)
                self.right_slide_box.pack_start(powered_link_align, False,
                                                False)

                self.show_all()
            else:
                global_logger.error("%s haven't any screenshot from zip file" %
                                    self.pkg_name)
Example #4
0
 def handle_pkg_status(self, status, success):
     if success:
         self.install_status = str(status)
         try:
             self.desktops = json.loads(self.install_status)
             self.desktops = self.data_manager.get_pkg_desktop_info(
                 self.desktops)
         except:
             pass
         self.emit_redraw_request()
     else:
         global_logger.error("%s: get_pkg_installed handle_dbus_error" %
                             self.pkg_name)
         global_logger.error(status)
Example #5
0
    def handle_pkg_status(self, reply, success):
        container_remove_all(self.left_action_box)
        if success:
            install_status = str(reply)
            if install_status == "uninstalled":
                action_button = ImageButton(
                    app_theme.get_pixbuf("button/install_normal.png"),
                    app_theme.get_pixbuf("button/install_hover.png"),
                    app_theme.get_pixbuf("button/install_press.png"),
                )
                action_button.connect(
                    "clicked", lambda w: global_event.emit(
                        "install-pkg", [self.pkg_name]))
                self.left_action_box.pack_start(action_button)
            elif install_status == "unknown":
                status_label = Label(_("Not found"))
                self.left_action_box.pack_start(status_label)
            else:
                try:
                    desktops = json.loads(install_status)
                    if not desktops:
                        status_label = Label(_("Successfully installed"))
                        self.left_action_box.pack_start(status_label)
                    else:
                        action_button = ImageButton(
                            app_theme.get_pixbuf("button/start_normal.png"),
                            app_theme.get_pixbuf("button/start_hover.png"),
                            app_theme.get_pixbuf("button/start_press.png"),
                        )
                        action_button.connect(
                            "button-press-event",
                            lambda w, e: self.button_press_start_button(
                                w, e, desktops))
                        self.left_action_box.pack_start(action_button)
                except:
                    logging.error("detail install status: %s = %s" %
                                  (self.pkg_name, install_status))

            self.left_action_box.show_all()
            global_event.emit('update-current-status-pkg-page', self)
        else:
            global_logger.error("get_pkg_installed handle_dbus_error")
            global_logger.error(reply)
    def show_screenshot(self):
        container_remove_all(self.right_slide_box)
        screenshot_dir = os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name)

        if os.path.exists(screenshot_dir):
            screenshot_files = map(lambda filename: os.path.join(screenshot_dir, filename),
                                   filter(lambda file_name: file_name.endswith(".png"), os.listdir(screenshot_dir)))

            if len(screenshot_files) > 0:
                slide_switcher = SlideSwitcher(
                    map(lambda screenshot_file: get_resize_pixbuf_with_height(screenshot_file, 290), screenshot_files),
                    pointer_offset_x=-370,
                    pointer_offset_y=-15,
                        horizontal_align=ALIGN_MIDDLE,
                        vertical_align=ALIGN_MIDDLE,
                        height_offset=60,
                        hover_switch=False,
                        auto_switch=False,
                        navigate_switch=True,
                        )
                slide_align = gtk.Alignment()
                slide_align.set(0.5, 0.5, 1, 1)
                slide_align.add(slide_switcher)
                slide_align.connect("expose-event", self.expose_resizable_label_background)
                self.right_slide_box.pack_start(slide_align, True, True)

                powered_link = Label(
                    _("Powered by UpYun.com"),
                    text_color=app_theme.get_color("homepage"),
                    hover_color=app_theme.get_color("homepage_hover"),
                    )
                powered_link.set_clickable()
                powered_link.connect("button-press-event", lambda w, e: run_command("xdg-open https://www.upyun.com/"))
                powered_link_align = gtk.Alignment()
                powered_link_align.set(1.0, 0.5, 0, 0)
                powered_link_align.set_padding(0, 0, 0, 100)
                powered_link_align.add(powered_link)
                self.right_slide_box.pack_start(powered_link_align, False, False)

                self.show_all()
            else:
                global_logger.error("%s haven't any screenshot from zip file" % self.pkg_name)
    def handle_pkg_status(self, reply, success):
        container_remove_all(self.left_action_box)
        if success:
            install_status = str(reply)
            if install_status == "uninstalled":
                action_button = ImageButton(
                    app_theme.get_pixbuf("button/install_normal.png"),
                    app_theme.get_pixbuf("button/install_hover.png"),
                    app_theme.get_pixbuf("button/install_press.png"),
                    )
                action_button.connect("clicked", lambda w: global_event.emit("install-pkg", [self.pkg_name]))
                self.left_action_box.pack_start(action_button)
            elif install_status == "unknown":
                status_label = Label(_("Not found"))
                self.left_action_box.pack_start(status_label)
            else:
                try:
                    desktops = json.loads(install_status)
                    if not desktops:
                        status_label = Label(_("Successfully installed"))
                        self.left_action_box.pack_start(status_label)
                    else:
                        action_button = ImageButton(
                            app_theme.get_pixbuf("button/start_normal.png"),
                            app_theme.get_pixbuf("button/start_hover.png"),
                            app_theme.get_pixbuf("button/start_press.png"),
                        )
                        action_button.connect("button-press-event", lambda w, e:self.button_press_start_button(w, e, desktops))
                        self.left_action_box.pack_start(action_button)
                except:
                    logging.error("detail install status: %s = %s" % (self.pkg_name, install_status))

            self.left_action_box.show_all()
            global_event.emit('update-current-status-pkg-page', self)
        else:
            global_logger.error("get_pkg_installed handle_dbus_error")
            global_logger.error(reply)
Example #8
0
    def fetch_screenshot(self):
        screenshot_dir = os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name)
        screenshot_md5_path = os.path.join(screenshot_dir,
                                           "screenshot_md5.txt")
        remote_screenshot_md5_url = "%s/zh_CN/%s/screenshot_md5.txt" % (
            SCREENSHOT_HOST, self.pkg_name)
        remote_screenshot_zip_url = "%s/zh_CN/%s/screenshot.zip" % (
            SCREENSHOT_HOST, self.pkg_name)
        try:
            remote_md5 = urllib2.urlopen(remote_screenshot_md5_url).read()
            need_download = False

            if os.path.exists(screenshot_dir):
                if os.path.exists(screenshot_md5_path):
                    local_md5 = read_file(screenshot_md5_path)
                    if remote_md5 != local_md5:
                        need_download = True
                else:
                    need_download = True
            else:
                need_download = True

            if need_download:
                write_file(screenshot_md5_path, remote_md5, True)

                try:
                    urllib.urlretrieve(
                        remote_screenshot_zip_url,
                        os.path.join(SCREENSHOT_DOWNLOAD_DIR, self.pkg_name,
                                     "screenshot.zip"))
                    global_event.emit("download-screenshot-finish",
                                      self.pkg_name)
                except Exception, e:
                    global_logger.error("Download screenshot error: %s" % e)
        except Exception, e:
            global_logger.error("fetch_screenshot got error: %s" % e)
 def handle_pkg_download_size(self, reply, success):
     # FIXME: download information display
     if success:
         if reply[0] == PKG_SIZE_OWN or reply[0] == PKG_SIZE_DOWNLOAD:
             self.left_size_label.set_text(_("Size: %s") % bit_to_human_str(reply[1]))
         elif reply[0] == PKG_SIZE_ERROR:
             self.left_size_label.set_text("")
             global_logger.error("Error for calculate pkg size!")
     else:
         global_logger.error("request_pkgs_install_status handle_dbus_error")
         global_logger.error(reply)
    def add_uninstall_items(self, data, success):
        if not success:
            global_logger.error("request_uninstall_pkgs failed: %s" % data)
            return
        pkg_infos = str(data)

        try:
            uninstall_pkg_infos = json.loads(pkg_infos)
        except Exception, e:
            global_logger.error("Parse uninstall package information failed: %s" % pkg_infos)
            global_logger.error("Error: %s" % str(e))
            uninstall_pkg_infos = []
    def add_uninstall_items(self, data, success):
        if not success:
            global_logger.error("request_uninstall_pkgs failed: %s" % data)
            return
        pkg_infos = str(data)

        try:
            uninstall_pkg_infos = json.loads(pkg_infos)
        except Exception, e:
            global_logger.error(
                "Parse uninstall package information failed: %s" % pkg_infos)
            global_logger.error("Error: %s" % str(e))
            uninstall_pkg_infos = []
Example #12
0
 def handle_pkg_download_size(self, reply, success):
     # FIXME: download information display
     if success:
         if reply[0] == PKG_SIZE_OWN or reply[0] == PKG_SIZE_DOWNLOAD:
             self.left_size_label.set_text(
                 _("Size: %s") % bit_to_human_str(reply[1]))
         elif reply[0] == PKG_SIZE_ERROR:
             self.left_size_label.set_text("")
             global_logger.error("Error for calculate pkg size!")
     else:
         global_logger.error(
             "request_pkgs_install_status handle_dbus_error")
         global_logger.error(reply)