Exemplo n.º 1
0
 def check_cleanup(self):
     """
     Check if a cleanup should be run according to auto_clean_interval and process if required
     :return:
     :rtype:
     """
     cur_timestamp = CacheBase._get_timestamp()
     lastexecuted = g.get_float_runtime_setting(self._create_key("clean.lastexecuted"))
     if self._cleanup_required_check(lastexecuted, cur_timestamp):
         self.do_cleanup()
def update_provider_packages():
    """
    Perform checks for provider package updates
    :return: None
    :rtype: None
    """
    provider_check_stamp = g.get_float_runtime_setting(
        "provider.updateCheckTimeStamp", 0)
    automatic = g.get_bool_setting("providers.autoupdates")
    if time.time() > (provider_check_stamp + (24 * (60 * 60))):
        available_updates = ProviderInstallManager().check_for_updates(
            silent=True, automatic=automatic)
        if not automatic and len(available_updates) > 0:
            g.notification(g.ADDON_NAME, g.get_language_string(30268))
        g.set_runtime_setting("provider.updateCheckTimeStamp",
                              g.UNICODE(time.time()))
Exemplo n.º 3
0
def check_for_addon_update():
    """
    Perform checks for addon updates and notify user of any available updates
    :return: None
    :rtype: None
    """
    if not g.get_bool_setting("general.checkAddonUpdates"):
        return

    if "-" in g.VERSION:
        g.set_runtime_setting("addon.updateCheckTimeStamp",
                              g.UNICODE(time.time()))
        return

    update_timestamp = g.get_float_runtime_setting(
        "addon.updateCheckTimeStamp")

    if time.time() > (update_timestamp + (24 * (60 * 60))):
        repo_xml = requests.get(
            "https://github.com/nixgates/nixgates/raw/master/repo/zips/addons.xml"
        )
        if not repo_xml.status_code == 200:
            g.log(
                "Could not connect to repo XML, status: {}".format(
                    repo_xml.status_code),
                "error",
            )
            return
        try:
            xml = tools.ElementTree.fromstring(repo_xml.text)

            for dir_tag in xml.iterfind(
                    "./addon[@id='repository.nixgates']/extension/dir"):
                minversion = dir_tag.get('minversion')
                maxversion = dir_tag.get('maxversion')
                if ((minversion is None and maxversion is None) or
                    (minversion and maxversion
                     and tools.compare_version_numbers(
                         minversion, g.KODI_FULL_VERSION, include_same=True)
                     and tools.compare_version_numbers(
                         g.KODI_FULL_VERSION, maxversion, include_same=True))
                        or
                    (maxversion is None and minversion
                     and tools.compare_version_numbers(
                         minversion, g.KODI_FULL_VERSION, include_same=True))
                        or
                    (minversion is None and maxversion
                     and tools.compare_version_numbers(
                         g.KODI_FULL_VERSION, maxversion, include_same=True))):
                    repo_version = _get_latest_repo_version(
                        dir_tag.find('info').text)
                    if tools.compare_version_numbers(g.CLEAN_VERSION,
                                                     repo_version):
                        xbmcgui.Dialog().ok(
                            g.ADDON_NAME,
                            g.get_language_string(30199).format(repo_version))
        except tools.ElementTree.ParseError as pe:
            g.log("Could not parse repo XML", "error")
        finally:
            g.set_runtime_setting("addon.updateCheckTimeStamp",
                                  g.UNICODE(time.time()))