コード例 #1
0
 def cache_path(self):
     """Return the directory used as a cache for the duration of the installation"""
     _cache_path = cache.get_cache_path()
     if not _cache_path:
         _cache_path = os.path.join(settings.CACHE_DIR, "installer")
     url_parts = urlparse(self.url)
     folder = "gog" if url_parts.netloc.endswith("gog.com") else self.id
     return os.path.join(_cache_path, self.game_slug, folder)
コード例 #2
0
ファイル: installer_file.py プロジェクト: xeddmc/lutris
 def cache_path(self):
     """Return the directory used as a cache for the duration of the installation"""
     _cache_path = get_cache_path()
     if not _cache_path:
         _cache_path = os.path.join(settings.CACHE_DIR, "installer")
     if "cdn.gog.com" in self.url or "cdn-hw.gog.com" in self.url:
         folder = "gog"
     else:
         folder = self.id
     return os.path.join(_cache_path, self.game_slug, folder)
コード例 #3
0
 def cache_path(self):
     """Return the directory used as a cache for the duration of the installation"""
     _cache_path = get_cache_path()
     if not _cache_path:
         _cache_path = os.path.join(settings.CACHE_DIR, "installer")
     if "cdn.gog.com" in self.url or "cdn-hw.gog.com" in self.url:
         folder = "gog"
     else:
         folder = self.id
     return os.path.join(_cache_path, self.game_slug, folder)
コード例 #4
0
 def _get_game_cache_box(self):
     box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
     label = Label("Cache path")
     box.pack_start(label, False, False, 0)
     cache_path = get_cache_path()
     path_chooser = FileChooserEntry(
         title="Set the folder for the cache path",
         action=Gtk.FileChooserAction.SELECT_FOLDER,
         path=cache_path)
     path_chooser.entry.connect("changed", self._on_cache_path_set)
     box.pack_start(path_chooser, True, True, 0)
     return box
コード例 #5
0
 def uses_pga_cache(self, create=False):
     cache_path = get_cache_path()
     if not cache_path:
         return False
     if not system.path_exists(cache_path):
         if create:
             try:
                 os.makedirs(self.cache_path)
             except OSError as ex:
                 logger.error("Failed to created cache path: %s", ex)
                 return False
             return True
         logger.warning("Cache path %s does not exist", cache_path)
         return False
     return True
コード例 #6
0
ファイル: installer_file.py プロジェクト: xordspar0/lutris
    def uses_pga_cache(self, create=False):
        """Determines whether the installer files are stored in a PGA cache

        Params:
            create (bool): If a cache is active, auto create directories if needed
        Returns:
            bool
        """
        cache_path = get_cache_path()
        if not cache_path:
            return False
        if system.path_exists(cache_path):
            return True
        if create:
            try:
                os.makedirs(self.cache_path)
            except OSError as ex:
                logger.error("Failed to created cache path: %s", ex)
                return False
            return True
        logger.warning("Cache path %s does not exist", cache_path)
        return False
コード例 #7
0
    def uses_pga_cache(self, create=False):
        """Determines whether the installer files are stored in a PGA cache

        Params:
            create (bool): If a cache is active, auto create directories if needed
        Returns:
            bool
        """
        cache_path = get_cache_path()
        if not cache_path:
            return False
        if system.path_exists(cache_path):
            return True
        if create:
            try:
                os.makedirs(self.cache_path)
            except OSError as ex:
                logger.error("Failed to created cache path: %s", ex)
                return False
            return True
        logger.warning("Cache path %s does not exist", cache_path)
        return False
コード例 #8
0
ファイル: cache.py プロジェクト: zsh-754207424/lutris
    def get_cache_config(self):
        """Return the widgets for the cache configuration"""
        prefs_box = Gtk.VBox()

        box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
        label = Gtk.Label(_("Cache path"))
        box.pack_start(label, False, False, 0)
        cache_path = get_cache_path()
        path_chooser = FileChooserEntry(
            title=_("Set the folder for the cache path"),
            action=Gtk.FileChooserAction.SELECT_FOLDER,
            path=cache_path)
        path_chooser.entry.connect("changed", self._on_cache_path_set)
        box.pack_start(path_chooser, True, True, 0)

        prefs_box.pack_start(box, False, False, 6)
        cache_help_label = Gtk.Label(visible=True)
        cache_help_label.set_size_request(400, -1)
        cache_help_label.set_markup(
            _("If provided, this location will be used by installers to cache "
              "downloaded files locally for future re-use. \nIf left empty, the "
              "installer files are discarded after the install completion."))
        prefs_box.pack_start(cache_help_label, False, False, 6)
        return prefs_box
コード例 #9
0
 def _is_cached_file(file_path):
     """Return whether a file referenced by file_id is stored in the cache"""
     pga_cache_path = get_cache_path()
     if not pga_cache_path:
         return False
     return file_path.startswith(pga_cache_path)
コード例 #10
0
 def _is_cached_file(self, file_path):
     """Return whether a file referenced by file_id is stored in the cache"""
     pga_cache_path = get_cache_path()
     if not pga_cache_path:
         return False
     return file_path.startswith(pga_cache_path)