Check-in [c83b236a5a]
Overview
Comment: | Perform basic version dependency checks before displaying downloadable plugins. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c83b236a5ad18baa43c99d11bd5d7d59 |
User & Date: | mario on 2015-05-03 20:24:47 |
Other Links: | manifest | tags |
Context
2015-05-03
| ||
20:26 | Add some version: bumps and add a few versions to depends: references. check-in: beebec9c76 user: mario tags: trunk | |
20:24 | Perform basic version dependency checks before displaying downloadable plugins. check-in: c83b236a5a user: mario tags: trunk | |
20:23 | Disable iCast plugin for now. check-in: 9d1b6cc7f5 user: mario tags: trunk | |
Changes
Modified channels/pluginmanager2.py from [d1c55d3594] to [978f889bbd].
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | - + | # encoding: UTF-8 # api: streamtuner2 # title: User Plugin Manager Ⅱ # description: Downloads new plugins, or updates them. # version: 0.2 # type: hook # category: config |
︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + | from channels import __path__ as channels__path__ import os from config import * from uikit import * import ahttp import json import compat2and3 from xml.sax.saxutils import escape as html_escape # Plugin manager class pluginmanager2(object): module = "pluginmanager2" meta = plugin_meta() |
︙ | |||
121 122 123 124 125 126 127 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | - - + - - + + - + - - - + + + + + + + - - + + - + | for url in re.split("[\s,]+", conf.plugin_repos.strip()): if re.match("https?://", url): d = ahttp.get(url, encoding='utf-8') or [] meta += json.loads(d) self.parent.status() # Clean up placeholders in vbox |
︙ | |||
202 203 204 205 206 207 208 209 210 211 212 213 214 | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | log.WARN("Cannot disable feature plugin '{}'.".format(name)) p.status("Disabling feature plugins requires a restart.") # just let main load any new plugins p.load_plugin_channels() # Do minimal depends: probing class dependency(object): # prepare list of known plugins and versions def __init__(self): self.have = {name: plugin_meta(module=name) for name in module_list()} # dependencies on core modules are somewhat more interesting: self.have.update({ "streamtuner2": plugin_meta(module="st2", plugin_base=["config"]), "uikit": plugin_meta(module="uikit", plugin_base=["config"]), "config": plugin_meta(module="config", plugin_base=["config"]), "action": plugin_meta(module="action", plugin_base=["config"]), }) have = {} # depends: def depends(self, plugin): if plugin.get("depends"): d = self.deps(plugin["depends"]) if not self.cmp(d, self.have): return False return True # Split trivial "pkg, mod >= 1, uikit < 4.0" list def deps(self, dep_str): d = [] for dep in re.split(r"\s*[,;]+\s*", dep_str): # skip deb:pkg-name, rpm:name, bin:name etc. if not len(dep) or dep.find(":") >= 0: continue # find comparison and version num m = re.search(r"([\w.-]+)\s*([>=<!~]+)\s*([\d.]+([-~.]\w+)*)", dep + " >= 0") if m and m.group(2): d.append([m.group(i) for i in (1,2,3)]) return d # Do actual comparison def cmp(self, d, have): r = True for name, op, ver in d: # skip unknown plugins, might be python module references ("depends: re, json") if not have.get(name, {}).get("version"): continue curr = have[name]["version"] tbl = { ">=": curr >= ver, "<=": curr <= ver, "==": curr == ver, ">": curr > ver, "<": curr < ver, "!=": curr != ver, } r &= tbl.get(op, True) return r # Alternative to .format(), with keys possibly being absent from string import Template def safe_format(str, **kwargs): return Template(str).safe_substitute(**kwargs) |