コード例 #1
0
ファイル: detail_page.py プロジェクト: kissthink/deepin-store
    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.logerror("Download screenshot error: %s" % e)
        except Exception, e:
            global_logger.logerror("fetch_screenshot got error: %s" % e)
コード例 #2
0
 def add_no_notify_pkg(self, info):
     pkg_name, path = info
     no_notify_config = self.read_no_notify_config(path)
     
     if pkg_name not in no_notify_config:
         pkg_name = str(pkg_name)
         no_notify_config.append(pkg_name)
         write_file(path, str(no_notify_config))
コード例 #3
0
 def remove_no_notify_pkg(self, info):
     pkg_name, path = info
     pkg_name = str(pkg_name)
     path = str(path)
     no_notify_config = self.read_no_notify_config(path)
     
     if pkg_name in no_notify_config:
         write_file(path, str(filter(lambda config_pkg_name: config_pkg_name != pkg_name, no_notify_config)))
コード例 #4
0
ファイル: main.py プロジェクト: Tubbz-alt/deepin-store
    def add_no_notify_pkg(self, info):
        pkg_name, path = info
        no_notify_config = self.read_no_notify_config(path)

        if pkg_name not in no_notify_config:
            pkg_name = str(pkg_name)
            no_notify_config.append(pkg_name)
            write_file(path, str(no_notify_config))
コード例 #5
0
ファイル: main.py プロジェクト: Tubbz-alt/deepin-store
    def remove_no_notify_pkg(self, info):
        pkg_name, path = info
        pkg_name = str(pkg_name)
        path = str(path)
        no_notify_config = self.read_no_notify_config(path)

        if pkg_name in no_notify_config:
            write_file(
                path,
                str(
                    filter(lambda config_pkg_name: config_pkg_name != pkg_name,
                           no_notify_config)))
コード例 #6
0
def vote_send_success_callback(infos, window):
    pkg_name = infos[0]
    grade_config_path, grade_config = get_grade_config()

    global_event.emit("show-message", _("Rated successfully. Thanks for your involvement."), 5000)
    tool_tip.hide_all()
    current_time = time.time()

    grade_config[pkg_name] = current_time
    write_file(grade_config_path, str(grade_config))
    if infos[1] != None:
        obj = infos[1]
        star = float(infos[2][pkg_name][0])
        if isinstance(obj, StarView):
            obj.set_star_level(int(star))
        elif isinstance(obj, DscStarBuffer):
            obj.update_star(star)
コード例 #7
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)
コード例 #8
0
ファイル: utils.py プロジェクト: chenzhiwei/deepin-ui
def write_file(filepath, content, mkdir=False):
    print "Please import deepin_utils.file.write_file, this function will departed in next release version."
    return file.write_file(filepath, content, mkdir=False)
コード例 #9
0
def write_file(filepath, content, mkdir=False):
    print "Please import deepin_utils.file.write_file, this function will departed in next release version."
    return file.write_file(filepath, content, mkdir=False)