Ejemplo n.º 1
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.logerror("Download screenshot error: %s" % e)
        except Exception, e:
            global_logger.logerror("fetch_screenshot got error: %s" % e)
Ejemplo n.º 2
0
 def read_no_notify_config(self, no_notify_config_path):
     if os.path.exists(no_notify_config_path):
        no_notify_config_str = read_file(no_notify_config_path)
        try:
            no_notify_config = eval(no_notify_config_str)
            
            if type(no_notify_config).__name__ != "list":
                no_notify_config = []
        except Exception:
            no_notify_config = []
            
        return no_notify_config
     else:
         return []
Ejemplo n.º 3
0
    def read_no_notify_config(self, no_notify_config_path):
        if os.path.exists(no_notify_config_path):
            no_notify_config_str = read_file(no_notify_config_path)
            try:
                no_notify_config = eval(no_notify_config_str)

                if type(no_notify_config).__name__ != "list":
                    no_notify_config = []
            except Exception:
                no_notify_config = []

            return no_notify_config
        else:
            return []
Ejemplo n.º 4
0
def get_grade_config():
    grade_config_path = os.path.join(CONFIG_DIR, "grade_pkgs")
    if not os.path.exists(grade_config_path):
        touch_file(grade_config_path)

    grade_config_str = read_file(grade_config_path)
    try:
        grade_config = eval(grade_config_str)

        if type(grade_config).__name__ != "dict":
            grade_config = {}
    except Exception:
        grade_config = {}
    return (grade_config_path, grade_config)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def read_file(filepath, check_exists=False):
    print "Please import deepin_utils.file.read_file, this function will departed in next release version."
    return file.read_file(filepath, check_exists=False)
Ejemplo n.º 7
0
def read_file(filepath, check_exists=False):
    print "Please import deepin_utils.file.read_file, this function will departed in next release version."
    return file.read_file(filepath, check_exists=False)