class Mirror(object):
    def __init__(self, ini_file):
        self.config = Config(ini_file)
        self.config.load()
        deepin_url = self.get_repo_urls()[1]
        _url_parse = urlparse(deepin_url)
        self._hostname = _url_parse.scheme + "://" + _url_parse.netloc
        self._priority = int(self.config.get("mirror", "priority")) if self.config.has_option("mirror", "priority") else 100
    
    @property
    def hostname(self):
        return self._hostname

    @property
    def name(self):
        if self.config.has_option('mirror', 'name[%s]' % LANGUAGE):
            return self.config.get('mirror', 'name[%s]' % LANGUAGE)
        else:
            return self.config.get('mirror', 'name[%s]' % 'en_US')

    @property
    def priority(self):
        return self._priority

    def get_repo_urls(self):
        return (self.config.get('mirror', 'ubuntu_url'), self.config.get('mirror', 'deepin_url'))
Ejemplo n.º 2
0
def is_mirror_disabled():
    if os.path.exists(deepin_version_path):
        config = Config(deepin_version_path)
        config.load()
        return config.has_option("Custom", "Mirror") and config.get("Custom", "Mirror") == "False"
    else:
        return True # not deepin os, disable mirror change
Ejemplo n.º 3
0
def is_mirror_disabled():
    if os.path.exists(deepin_version_path):
        config = Config(deepin_version_path)
        config.load()
        return config.has_option("Custom", "Mirror") and config.get(
            "Custom", "Mirror") == "False"
    else:
        return True  # not deepin os, disable mirror change
Ejemplo n.º 4
0
def get_last_update_time():
    config = Config(SYS_CONFIG_INFO_PATH)

    if os.path.exists(SYS_CONFIG_INFO_PATH):
        config.load()
        if config.has_option("update", "last_update_time"):
            return config.get("update", "last_update_time")
        else:
            return ""
    else:
        return ""