def hay(self, id, *args, **kwargs): if id not in self._hays: h = hay.stack(id, *args, **kwargs) self._hays[id] = h else: h = self._hays[id] return h
def __init__(self, w1, w2, header="", *args, **kwargs): xbmcgui.WindowDialog.__init__(self) self.setCoordinateResolution(0) self.wait = 0.1 # 1920x1080 self.__cw = 1920 self.__ch = 1080 self.__w1 = w1 self.__w2 = w2 self.__padx = 25 self.__rowh = 43 # changes depending on the selected skin :( self.__pady = self.__padx - 10 self.__elems = {} self.__cmap = {} self.__eid = 0 self.__numbtns = 0 self.__focus = None self.__etypes = { "label": ("setLabel", "getLabel", [], False), "edit": ("setText", "getText", [], True), "text": ("setText", "reset", [], False), "bool": ("setSelected", "isSelected", [], True), "button": ("setLabel", "getLabel", [], True), "list": ("getSelectedPosition", "selectItem", [], False), "image": ("setImage", "getId", [], False), } self.__pre = None self.__header = header with hay.stack(const.OPTIONHAY, write=False) as stack: ua = stack.find("useragent").data if ua == {}: ua = const.USERAGENT self.__useragent = ua addon.blockingloop.__init__(self, *args, **kwargs)
def __init__(self, tempdir, *args, **kwargs): self.tempdir = tempdir self.cfg = {} self.stack = hay.stack("anon", common=tempdir) self.nontors = [ "127.0.0.0/8", "10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12", "0.0.0.0/8", "100.64.0.0/10", "169.254.0.0/16", "192.0.0.0/24", "192.0.2.0/24", "192.88.99.0/24", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "240.0.0.0/4", "255.255.255.255/32" ] self.init(*args, **kwargs) for k, v in self.cfg.iteritems(): data = self.stack.find(k).data if not data == {}: self.cfg[k] = data for k, v in defs.defconfig.iteritems(): data = self.stack.find(k).data if data == {}: data = v self.cfg[k] = data self.defaultgw, self.interface = self.default_if_gw() self.ip, self.subnet = self.if_ip_subnet(self.interface) self.nontors.append(self.subnet)
def __init__(self, directory, maxrecords=5000): self.hay = hay.stack(directory, "null", 0, maxrecords, True, True)
def __init__(self): self.setting = addon.kodisetting(common.addon_id) self.hay = hay.stack(common.hay_chan, aid=common.addon_id) self.phay = hay.stack(common.hay_playlist, aid=common.addon_id)
def _openxhay(): global _xhay if not _xhay: _xhay = hay.stack(const.ADDONHAY, common=True) return _xhay
def patchsmu(smudir): # a very dirty hack to make smu work portable, not happy with this :( def getstr(content): r = re.search("<settings>(.*?)</settings>", content, re.DOTALL) if r: return r.group(1) else: return "" with hay.stack("smupatch") as smuhay: smupatch = smuhay.find("smupatch").data with open(os.path.join(smudir, "..", "script.module.resolveurl.json")) as vf: versioncommit = json.load(vf) versioncommit = versioncommit.get("latest") try: xmlstat = os.path.getsize(os.path.join(smudir, "settings.xml")) except Exception: xmlstat = None pldir = addon.get_addon("plugin.program.vods-players").getAddonInfo( "path") if not smupatch.get("versioncommit") == versioncommit: # first remove xbmcaddon referenced to script.module.urlresolver files = [ (["lib", "resolveurl", "lib", "log_utils.py"], 1), (["lib", "resolveurl", "lib", "kodi.py"], 1), (["lib", "resolveurl", "common.py"], 2), (["lib", "resolveurl", "lib", "CustomProgressDialog.py"], 1), ] for fpaths, patchtype in files: fpath = os.path.join(smudir, *fpaths) with open(fpath, "r") as f: contents = f.read() if patchtype == 1: pattern = "script\.module\.resolveurl" sub = "plugin.program.vods-players" elif patchtype == 2: pattern = "settings_file \= os\.path\.join\(addon_path, 'resources', 'settings.xml'\)" sub = "settings_file = os.path.join(os.path.dirname(__file__), '..', '..', 'settings.xml')" if re.search(pattern, contents): with open(fpath, "w") as f: f.write(re.sub(pattern, sub, contents)) # synchronize resources folder with xbmcvfs in case of permission problem for root, folders, files in os.walk( os.path.join(smudir, "resources")): relfolder = os.path.relpath(root, smudir) for folder in folders: tools.mkdirs(os.path.join(pldir, relfolder, folder)) for f in files: sfile = os.path.join(smudir, relfolder, f) tfile = os.path.join(pldir, relfolder, f) with tools.File(sfile) as sfileo: with tools.File(tfile, "w") as tfileo: tfileo.write(sfileo.readBytes()) smupatch["versioncommit"] = versioncommit smuhay.throw("smupatch", smupatch) tools.builtin("UpdateLocalAddons()") gui.ok( "URL Resolvers", "SMU has just been updated\nSome changes will be active on the next run" ) if not smupatch.get("xmlstat") == xmlstat: # merge smu settings.xml with current settings.xml smuxmlp = os.path.join(smudir, "settings.xml") plxmlop = os.path.join(pldir, "resources", "settings_orig.xml") plxmlp = os.path.join(pldir, "resources", "settings.xml") smupatch["xmlstat"] = xmlstat smuhay.throw("smupatch", smupatch) with tools.File(smuxmlp, "r") as smuxml: with tools.File(plxmlop, "r") as plxmlo: with tools.File(plxmlp, "w") as plxml: try: plxml.write( '<?xml version="1.0" ?><settings>%s%s</settings>' % (getstr(plxmlo.read()), getstr(smuxml.read()))) except Exception: print(traceback.format_exc()) shutil.copyfile(plxmlop, plxmlp)