Package zeroinstall :: Package injector :: Module policy :: Class Policy
[frames] | no frames]

Class Policy

source code

object --+
         |
        Policy

Chooses a set of implementations based on a policy. Typical use:

  1. Create a Policy object, giving it the URI of the program to be run and a handler.
  2. Call solve_with_downloads. If more information is needed, a fetch.Fetcher will be used to download it.
  3. When all downloads are complete, the solver contains the chosen versions.
  4. Use get_uncached_implementations to find where to get these versions and download them using download_uncached_implementations.
Instance Methods
 
__init__(self, root, handler=None, src=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
fetcher(self) source code
 
set_root(self, root)
Change the root interface URI.
source code
 
save_config(self)
Write global settings.
source code
 
recalculate(self, fetch_stale_interfaces=True) source code
generator
usable_feeds(self, iface)
Generator for iface.feeds that are valid for our architecture.
source code
 
is_stale(self, feed)
Check whether feed needs updating, based on the configured freshness.
source code
 
download_and_import_feed_if_online(self, feed_url)
If we're online, call fetch.Fetcher.download_and_import_feed.
source code
str
get_implementation_path(self, impl)
Return the local path of impl.
source code
model.Implementation
get_implementation(self, interface)
Get the chosen implementation.
source code
bool
get_cached(self, impl)
Check whether an implementation is available locally.
source code
[(str, model.Implementation)]
get_uncached_implementations(self)
List all chosen implementations which aren't yet available locally.
source code
 
refresh_all(self, force=True)
Start downloading all feeds for all selected interfaces.
source code
[model.Interface]
get_feed_targets(self, feed_iface_uri)
Return a list of Interfaces for which feed_iface can be a feed.
source code
 
solve_with_downloads(self, force=False)
Run the solver, then download any feeds that are missing or that need to be updated.
source code
bool
need_download(self)
Decide whether we need to download anything (but don't do it!)
source code
 
download_uncached_implementations(self)
Download all implementations chosen by the solver that are missing from the cache.
source code
tasks.Task
download_icon(self, interface, force=False)
Download an icon for this interface and add it to the icon cache.
source code
 
get_interface(self, uri) source code

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

Class Variables
  implementation = property(lambda self: self.solver.selections)
  ready = property(lambda self: self.solver.ready)
Instance Variables
bool help_with_testing = property(lambda self: self.solver.help_wit...
default stability policy
  network_use = property(lambda self: self.solver.network_use, l...
one of the model.network_* values
int freshness
seconds allowed since last update
handler.Handler handler
handler for main-loop integration
  root
URI of the root interface
solve.Solver solver
solver used to choose a set of implementations
bool src
whether we are looking for source code
set stale_feeds
set of feeds which are present but haven't been checked for a long time
  watchers
callbacks to invoke after recalculating
Properties

Inherited from object: __class__

Method Details

__init__(self, root, handler=None, src=False)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • root - The URI of the root interface (the program we want to run).
  • handler (zeroinstall.injector.handler.Handler) - A handler for main-loop integration.
  • src (bool) - Whether we are looking for source code.
Overrides: object.__init__

fetcher(self)

source code 
Decorators:
  • @property

recalculate(self, fetch_stale_interfaces=True)

source code 

Deprecated: see solve_with_downloads

usable_feeds(self, iface)

source code 

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

Returns: generator

See Also: arch

is_stale(self, feed)

source code 

Check whether feed needs updating, based on the configured freshness. None is considered to be stale.

Returns:
true if feed is stale or missing.

download_and_import_feed_if_online(self, feed_url)

source code 

If we're online, call fetch.Fetcher.download_and_import_feed. Otherwise, log a suitable warning.

get_implementation_path(self, impl)

source code 

Return the local path of impl.

Returns: str
Raises:

get_implementation(self, interface)

source code 

Get the chosen implementation.

Parameters:
  • interface (Interface)
Returns: model.Implementation
Raises:
  • SafeException - if interface has not been fetched or no implementation could be chosen.

get_cached(self, impl)

source code 

Check whether an implementation is available locally.

Parameters:
  • impl (model.Implementation)
Returns: bool

refresh_all(self, force=True)

source code 

Start downloading all feeds for all selected interfaces.

Parameters:
  • force - Whether to restart existing downloads.

get_feed_targets(self, feed_iface_uri)

source code 

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

Returns: [model.Interface]
Raises:
  • SafeException - If there are no known feeds.

solve_with_downloads(self, force=False)

source code 

Run the solver, then download any feeds that are missing or that need to be updated. Each time a new feed is imported into the cache, the solver is run again, possibly adding new downloads.

Parameters:
  • force - whether to download even if we're already ready to run.
Decorators:
  • @tasks.async

need_download(self)

source code 

Decide whether we need to download anything (but don't do it!)

Returns: bool
true if we MUST download something (feeds or implementations)

download_icon(self, interface, force=False)

source code 

Download an icon for this interface and add it to the icon cache. If the interface has no icon or we are offline, do nothing.

Returns: tasks.Task
the task doing the import, or None

get_interface(self, uri)

source code 

Deprecated: use iface_cache.IfaceCache.get_interface instead


Instance Variable Details

help_with_testing

default stability policy
Type:
bool
Value:
property(lambda self: self.solver.help_with_testing, lambda self, valu\
e: setattr(self.solver, 'help_with_testing', value))

network_use

one of the model.network_* values
Value:
property(lambda self: self.solver.network_use, lambda self, value: set\
attr(self.solver, 'network_use', value))