Package zeroinstall :: Package injector :: Module iface_cache :: Class IfaceCache
[frames] | no frames]

Class IfaceCache

source code

object --+
         |
        IfaceCache

The interface cache stores downloaded and verified interfaces in ~/.cache/0install.net/interfaces (by default).

There are methods to query the cache, add to it, check signatures, etc.

The cache is updated by fetch.Fetcher.

Confusingly, this class is really two caches combined: the in-memory cache of model.Interface objects, and an on-disk cache of model.ZeroInstallFeeds. It will probably be split into two in future.


See Also: iface_cache - the singleton IfaceCache instance.

Instance Methods
 
__init__(self, distro=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
stores(self) source code
 
update_interface_if_trusted(self, interface, sigs, xml) source code
bool
update_feed_if_trusted(self, feed_url, sigs, xml, dry_run=False)
Update a cached feed (using update_feed_from_network) if we trust the signatures.
source code
 
update_interface_from_network(self, interface, new_xml, modified_time) source code
 
update_feed_from_network(self, feed_url, new_xml, modified_time, dry_run=False)
Update a cached feed.
source code
model.ZeroInstallFeed
get_feed(self, url, force=False, selections_ok=False)
Get a feed from the cache.
source code
model.Interface
get_interface(self, uri)
Get the interface for uri, creating a new one if required.
source code
[str]
list_all_interfaces(self)
List all interfaces in the cache.
source code
str
get_icon_path(self, iface)
Get the path of a cached icon for an interface.
source code
[gpg.Signature] or None
get_cached_signatures(self, uri)
Verify the cached interface using GPG.
source code
 
mark_as_checking(self, url)
Touch a 'last-check-attempt' timestamp file for this feed.
source code
float | None
get_last_check_attempt(self, url)
Return the time of the most recent update attempt for a feed.
source code
Feed
get_feed_imports(self, iface)
Get all feeds that add to this interface.
source code
{str: ZeroInstallFeed | None}
get_feeds(self, iface)
Get all feeds for this interface.
source code
[Implementation]
get_implementations(self, iface)
Return all implementations from all of iface's feeds.
source code
[model.Interface]
get_feed_targets(self, feed)
Return a list of Interfaces for which feed can be a feed.
source code
bool
is_stale(self, feed_url, freshness_threshold)
Check whether feed needs updating, based on the configured config.Config.freshness.
source code
generator
usable_feeds(self, iface, arch)
Generator for iface.feeds that are valid for this architecture.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables
 
distro(self)
the native distribution proxy
source code
Properties

Inherited from object: __class__

Method Details

__init__(self, distro=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • distro (distro.Distribution, or None to use the host distribution) - distribution used to fetch "distribution:" feeds (since 0.49)
Overrides: object.__init__

stores(self)

source code 
Decorators:
  • @property

update_feed_if_trusted(self, feed_url, sigs, xml, dry_run=False)

source code 

Update a cached feed (using update_feed_from_network) if we trust the signatures. If we don't trust any of the signatures, do nothing.

Parameters:
  • feed_url (str) - the feed being updated
  • sigs ([gpg.Signature]) - signatures from gpg.check_stream
  • xml (str) - the downloaded replacement feed document
  • dry_run (bool)
Returns: bool
True if the feed was updated

Since: 0.48

update_feed_from_network(self, feed_url, new_xml, modified_time, dry_run=False)

source code 

Update a cached feed. Called by update_feed_if_trusted if we trust this data. After a successful update, writer is used to update the feed's last_checked time.

Parameters:
  • feed_url (model.Interface) - the feed being updated
  • new_xml (str) - the downloaded replacement feed document
  • modified_time (long) - the timestamp of the oldest trusted signature (used as an approximation to the feed's modification time)
  • dry_run (bool)
Raises:
  • ReplayAttack - if modified_time is older than the currently cached time

Since: 0.48

get_feed(self, url, force=False, selections_ok=False)

source code 

Get a feed from the cache.

Parameters:
  • url (str) - the URL of the feed
  • force (bool) - load the file from disk again
  • selections_ok (bool) - if url is a local selections file, return that instead
Returns: model.ZeroInstallFeed
the feed, or None if it isn't cached

get_interface(self, uri)

source code 

Get the interface for uri, creating a new one if required. New interfaces are initialised from the disk cache, but not from the network.

Parameters:
  • uri (str) - the URI of the interface to find
Returns: model.Interface

get_icon_path(self, iface)

source code 

Get the path of a cached icon for an interface.

Parameters:
  • iface (Interface) - interface whose icon we want
Returns: str
the path of the cached icon, or None if not cached.

get_cached_signatures(self, uri)

source code 

Verify the cached interface using GPG. Only new-style XML-signed interfaces retain their signatures in the cache.

Parameters:
  • uri (str) - the feed to check
Returns: [gpg.Signature] or None
a list of signatures, or None

Since: 0.25

mark_as_checking(self, url)

source code 

Touch a 'last-check-attempt' timestamp file for this feed. If url is a local path, nothing happens. This prevents us from repeatedly trying to download a failing feed many times in a short period.

Parameters:
  • url (str)

get_last_check_attempt(self, url)

source code 

Return the time of the most recent update attempt for a feed.

Parameters:
  • url (str)
Returns: float | None
The time, or None if none is recorded

See Also: mark_as_checking

get_feed_imports(self, iface)

source code 

Get all feeds that add to this interface. This is the feeds explicitly added by the user, feeds added by the distribution, and feeds imported by a <feed> in the main feed (but not recursively, at present).

Parameters:
Returns: Feed

Since: 0.48

get_feeds(self, iface)

source code 

Get all feeds for this interface. This is a mapping from feed URLs to ZeroInstallFeeds. It includes the interface's main feed, plus the resolution of every feed returned by get_feed_imports. Uncached feeds are indicated by a value of None.

Parameters:
Returns: {str: ZeroInstallFeed | None}

Since: 0.48

get_implementations(self, iface)

source code 

Return all implementations from all of iface's feeds.

Parameters:
Returns: [Implementation]

Since: 0.48

get_feed_targets(self, feed)

source code 

Return a list of Interfaces for which feed can be a feed. This is used by 0install add-feed.

Parameters:
Returns: [model.Interface]
Raises:

Since: 0.53

is_stale(self, feed_url, freshness_threshold)

source code 

Check whether feed needs updating, based on the configured config.Config.freshness. None is considered to be stale. If we already tried to update the feed within FAILED_CHECK_DELAY, returns false.

Parameters:
  • freshness_threshold (int)
  • feed_url (str)
Returns: bool
True if feed should be updated

Since: 0.53

usable_feeds(self, iface, arch)

source code 

Generator for iface.feeds that are valid for this architecture.

Parameters:
Returns: generator

See Also: arch

Since: 0.53


Instance Variable Details

distro(self)

source code 
the native distribution proxy
Decorators:
  • @property