| Home | Trees | Indices | Help |
|
|---|
|
|
1 """
2 @deprecated: see L{driver} instead.
3 """
4
5 # Copyright (C) 2009, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
7
8 from zeroinstall import _
9 from logging import info
10
11 from zeroinstall import SafeException
12 from zeroinstall.injector import driver
13 from zeroinstall.injector.model import Interface, Implementation, network_offline
14 from zeroinstall.injector.config import load_config
17 """@deprecated: Use Driver instead."""
18 __slots__ = ['driver']
19
20 help_with_testing = property(lambda self: self.config.help_with_testing,
21 lambda self, value: setattr(self.config, 'help_with_testing', bool(value)))
22
23 network_use = property(lambda self: self.config.network_use,
24 lambda self, value: setattr(self.config, 'network_use', value))
25
26 freshness = property(lambda self: self.config.freshness,
27 lambda self, value: setattr(self.config, 'freshness', str(value)))
28
29 target_arch = property(lambda self: self.driver.target_arch,
30 lambda self, value: setattr(self.driver, 'target_arch', value))
31
32 implementation = property(lambda self: self.solver.selections)
33
34 ready = property(lambda self: self.solver.ready)
35 config = property(lambda self: self.driver.config)
36 requirements = property(lambda self: self.driver.requirements)
37
38 # (was used by 0test)
39 handler = property(lambda self: self.config.handler,
40 lambda self, value: setattr(self.config, 'handler', value))
41
42
43 - def __init__(self, root = None, handler = None, src = None, command = -1, config = None, requirements = None):
44 """
45 @param requirements: Details about the program we want to run
46 @type requirements: L{requirements.Requirements}
47 @param config: The configuration settings to use, or None to load from disk.
48 @type config: L{config.Config}
49 Note: all other arguments are deprecated (since 0launch 0.52)
50 """
51 #import warnings
52 #warnings.warn("Policy is deprecated; use a Driver instead", DeprecationWarning, 2)
53 if requirements is None:
54 from zeroinstall.injector.requirements import Requirements
55 requirements = Requirements(root)
56 requirements.source = bool(src) # Root impl must be a "src" machine type
57 if command == -1:
58 if src:
59 command = 'compile'
60 else:
61 command = 'run'
62 requirements.command = command
63 else:
64 assert root == src == None
65 assert command == -1
66
67 if config is None:
68 config = load_config(handler)
69 else:
70 assert handler is None, "can't pass a handler and a config"
71
72 self.driver = driver.Driver(config = config, requirements = requirements)
73
74 @property
77
78 @property
81
82 @property
85
88
90 """Generator for C{iface.feeds} that are valid for our architecture.
91 @rtype: generator
92 @see: L{arch}"""
93 a = self.driver.target_arch
94 if iface.uri != self.root:
95 # note: assumes that only the root arch may be different (e.g. if using --source)
96 a = a.child_arch
97 return self.config.iface_cache.usable_feeds(iface, a)
98
100 """@deprecated: use IfaceCache.is_stale"""
101 return self.config.iface_cache.is_stale(feed, self.config.freshness)
102
104 """Return the local path of impl.
105 @rtype: str
106 @raise zeroinstall.zerostore.NotStored: if it needs to be added to the cache first."""
107 assert isinstance(impl, Implementation)
108 return impl.local_path or self.config.stores.lookup_any(impl.digests)
109
111 """Get the chosen implementation.
112 @type interface: Interface
113 @rtype: L{model.Implementation}
114 @raise SafeException: if interface has not been fetched or no implementation could be
115 chosen."""
116 assert isinstance(interface, Interface)
117
118 try:
119 return self.implementation[interface]
120 except KeyError:
121 raise SafeException(_("No usable implementation found for '%s'.") % interface.uri)
122
124 """Check whether an implementation is available locally.
125 @type impl: model.Implementation
126 @rtype: bool
127 """
128 return impl.is_available(self.config.stores)
129
132
134 """Start downloading all feeds for all selected interfaces.
135 @param force: Whether to restart existing downloads."""
136 return self.solve_with_downloads(force = True)
137
139 """@deprecated: use IfaceCache.get_feed_targets"""
140 return self.config.iface_cache.get_feed_targets(feed)
141
144
147
150
153
155 """Download an icon for this interface and add it to the
156 icon cache. If the interface has no icon or we are offline, do nothing.
157 @return: the task doing the import, or None
158 @rtype: L{tasks.Task}"""
159 if self.network_use == network_offline:
160 info("Not downloading icon for %s as we are off-line", interface)
161 return
162
163 return self.fetcher.download_icon(interface, force)
164
166 """@deprecated: use L{iface_cache.IfaceCache.get_interface} instead"""
167 import warnings
168 warnings.warn("Policy.get_interface is deprecated!", DeprecationWarning, stacklevel = 2)
169 return self.config.iface_cache.get_interface(uri)
170
171 @property
174
175 @property
177 return self.requirements.interface_uri
178
179 _config = None
185
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Apr 13 17:38:11 2012 | http://epydoc.sourceforge.net |