Skip to content

Commit

Permalink
Merge branch 'Developer' into Python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev0-BH committed Apr 16, 2024
2 parents 3cb4032 + af2caac commit ddcc385
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 158 deletions.
8 changes: 4 additions & 4 deletions lib/python/Components/Converter/CryptoInfo.py
Expand Up @@ -14,18 +14,18 @@ def __init__(self, type):

self.type = type
self.active = False
if int(config.usage.show_cryptoinfo.value) > 0:
self.visible = True
else:
if config.usage.show_cryptoinfo.value == "0":
self.visible = False
else:
self.visible = True
self.textvalue = ""
self.poll_interval = 1000
self.poll_enabled = True
self.ecmdata = GetEcmInfo()

@cached
def getText(self):
if int(config.usage.show_cryptoinfo.value) < 1:
if config.usage.show_cryptoinfo.value == "0":
self.visible = False
data = ''
else:
Expand Down
2 changes: 1 addition & 1 deletion lib/python/Components/UsageConfig.py
Expand Up @@ -422,7 +422,7 @@ def PreferredTunerChanged(configElement):

config.usage.hide_zap_errors = ConfigYesNo(default=True)
config.usage.hide_ci_messages = ConfigYesNo(default=False)
config.usage.show_cryptoinfo = ConfigSelection([("0", _("Off")), ("1", _("One line")), ("2", _("Two lines")), ("3", _("Two lines Alternative"))], "2")
config.usage.show_cryptoinfo = ConfigSelection([("0", _("Off")), ("1", _("One line")), ("2", _("One line Alt")), ("3", _("Two lines")), ("4", _("Two lines Alt"))], "3")
config.usage.show_eit_nownext = ConfigYesNo(default=True)
config.usage.show_vcr_scart = ConfigYesNo(default=False)
config.usage.pic_resolution = ConfigSelection(default=None, choices=[(None, _("Same resolution as skin")), ("(720, 576)", "720x576"), ("(1280, 720)", "1280x720"), ("(1920, 1080)", "1920x1080")])
Expand Down
244 changes: 91 additions & 153 deletions lib/python/Tools/GetEcmInfo.py
Expand Up @@ -20,9 +20,9 @@ def createCurrentDevice(self, current_device, isLong):
if not current_device:
return ""
if "/sci0" in current_device.lower():
return _("Card Reader 1") if isLong else "CARD1"
return _("Card Reader 1") if isLong else "CARD 1"
elif "/sci1" in current_device.lower():
return _("Card Reader 2") if isLong else "CARD2"
return _("Card Reader 2") if isLong else "CARD 2"
elif "/ttyusb0" in current_device.lower():
return _("USB Reader 1") if isLong else "USB 1"
elif "/ttyusb1" in current_device.lower():
Expand All @@ -38,7 +38,6 @@ def createCurrentDevice(self, current_device, isLong):
elif "const" in current_device.lower():
return _("Constcw") if isLong else "CCW"


def pollEcmData(self):
global data
global old_ecm_time
Expand Down Expand Up @@ -86,172 +85,111 @@ def getInfoRaw(self):

def getText(self):
global ecm
address = ""
device = ""
try:
# info is dictionary
using = info.get("using", "")
protocol = info.get("protocol", "")
device = ""
alt = config.usage.show_cryptoinfo.value in ("2", "4")
if using or protocol:
if config.usage.show_cryptoinfo.value == "0":
self.textvalue = " "
elif config.usage.show_cryptoinfo.value == "1":
self.textvalue = ""
elif using == "fta":
self.textvalue = _("Free To Air")
elif config.usage.show_cryptoinfo.value in ("1", "2"): # "One line" or "One line Alt"
# CCcam
if using == "fta":
self.textvalue = _("Free To Air")
elif protocol == "emu":
self.textvalue = "Emu (%ss)" % (info.get("ecm time", "?"))
if protocol == "emu":
self.textvalue = (x := info.get("ecm time", "")) and "Emu (%ss)" % x
elif protocol == "constcw":
self.textvalue = "Constcw (%ss)" % (info.get("ecm time", "?"))
self.textvalue = (x := info.get("ecm time", "")) and "Constcw (%ss)" % x
else:
if info.get("address", None):
address = info.get("address", "").capitalize()
elif info.get("from", None):
address = info.get("from", "").replace(":0", "").replace("cache", "cache ").capitalize()
if "Local" in address:
from_arr = address.split("-")
address = from_arr[0].strip()
if len(from_arr) > 1:
device = from_arr[1].strip()
else:
address = ""
device = ""
hops = info.get("hops", None)
if hops and hops != "0":
hops = " @" + hops
else:
hops = ""
device_str = self.createCurrentDevice(device, False)
self.textvalue = ((device_str) if device else (address)) + hops + " (%ss)" % info.get("ecm time", "?")

elif config.usage.show_cryptoinfo.value == "2":
# CCcam
if using == "fta":
self.textvalue = _("Free To Air")
else:
address = "Server: "
if info.get("address", None):
address += info.get("address", "").capitalize()
elif info.get("from", None):
address = info.get("from", "").replace(":0", "").replace("cache", "cache ").capitalize()
if "const" in protocol.lower():
device = "constcw"
if "const" in address.lower():
address = ""
if "Local" in address:
if x := (info.get("reader") if alt else info.get("address")) or info.get("from", None):
address = x.replace(":0", "").replace("cache", "cache ").capitalize()
if "local" in address.lower():
from_arr = address.split("-")
address = from_arr[0].strip().replace("Local", "")
if len(from_arr) > 1:
device = from_arr[1].strip()
protocol = _("Protocol:") + " "
if info.get("protocol", None):
protocol += info.get("protocol", "").capitalize().replace("-s2s", "-S2s").replace("ext", "Ext").replace("mcs", "Mcs").replace("Cccam", "CCcam")
elif info.get("using", None):
protocol += info.get("using", "").capitalize().replace("-s2s", "-S2s").replace("ext", "Ext").replace("mcs", "Mcs").replace("Cccam", "CCcam")

hops = _("Hops:") + " "
if info.get("hops", None):
hops += info.get("hops", "")
hops = (x := info.get("hops", "")) and x != "0" and "@" + x or ""
ecm = (x := info.get("ecm time", "")) and "(%ss)" % x
devtext = self.createCurrentDevice(device, False) if device else address
self.textvalue = " ".join([x for x in (devtext, hops, ecm) if x])

ecm = _("Ecm:") + " "
if info.get("ecm time", None):
ecm += info.get("ecm time", "")
device_str = self.createCurrentDevice(device, True)
self.textvalue = "Server: " + address + ((device_str) if device else "") + "\n" + protocol + " " + hops + " " + ecm

elif config.usage.show_cryptoinfo.value == "3":
elif config.usage.show_cryptoinfo.value in ("3", "4"): # "Two lines" or "Two lines Alt"
# CCcam
if using == "fta":
self.textvalue = _("Free To Air")
else:
address = "Reader: "
if info.get("reader", None):
address += info.get("reader", "").capitalize()
elif info.get("from", None):
address = info.get("from", "").replace(":0", "").replace("cache", "cache ").capitalize()
if "const" in protocol.lower():
device = "constcw"
if "const" in address.lower():
address = ""
if "Local" in address:
from_arr = address.split("-")
address = from_arr[0].strip().replace("Local", "")
if len(from_arr) > 1:
device = from_arr[1].strip()
protocol = _("Protocol:") + " "
if info.get("protocol", None):
protocol += info.get("protocol", "").capitalize().replace("-s2s", "-S2s").replace("ext", "Ext").replace("mcs", "Mcs").replace("Cccam", "CCcam")
elif info.get("using", None):
protocol += info.get("using", "").capitalize().replace("-s2s", "-S2s").replace("ext", "Ext").replace("mcs", "Mcs").replace("Cccam", "CCcam")

hops = _("Hops:") + " "
if info.get("hops", None):
hops += info.get("hops", "")

ecm = _("Ecm:") + " "
if info.get("ecm time", None):
ecm += info.get("ecm time", "")
device_str = self.createCurrentDevice(device, True)
self.textvalue = address + ((device_str) if device else "") + "\n" + protocol + " " + hops + " " + ecm
if x := (info.get("reader") if alt else info.get("address")) or info.get("from"):
address = (_("Reader:") if alt else _("Server:")) + " " + x.replace(":0", "").replace("cache", "cache ").capitalize()
if "const" in protocol.lower():
device = "constcw"
if "const" in address.lower():
address = ""
if "emu" in protocol.lower():
device = "emulator"
if "emu" in address.lower():
address = ""
if "local" in address.lower():
from_arr = address.split("-")
address = from_arr[0].strip().replace("Local", "")
if len(from_arr) > 1:
device = from_arr[1].strip()
protocol = (x := info.get("protocol", "")) and _("Protocol:") + " " + x.capitalize().replace("-s2s", "-S2s").replace("ext", "Ext").replace("mcs", "Mcs").replace("Cccam", "CCcam")
hops = (x := info.get("hops", "")) and _("Hops:") + " " + x
ecm = (x := info.get("ecm time", "")) and _("Ecm:") + " " + x
devtext = self.createCurrentDevice(device, True) if device else ""
self.textvalue = "".join([x for x in (address, devtext) if x]) + "\n" + " ".join([x for x in (protocol, hops, ecm) if x])

elif info.get("decode"):
# gbox (untested)
if info["decode"] == "Network":
cardid = "id:" + info.get("prov", "")
try:
share = open("/tmp/share.info", "r").readlines()
for line in share:
if cardid in line:
self.textvalue = line.strip()
break
else:
self.textvalue = cardid
except:
self.textvalue = info["decode"]
else:
self.textvalue = info["decode"]
if ecm[1].startswith("SysID"):
info["prov"] = ecm[1].strip()[6:]
if "response" in info:
self.textvalue += " (0.%ss)" % info["response"]
info["caid"] = ecm[0][ecm[0].find("CaID 0x") + 7:ecm[0].find(",")]
info["pid"] = ecm[0][ecm[0].find("pid 0x") + 6:ecm[0].find(" =")]
info["provid"] = info.get("prov", "0")[:4]

elif info.get("source", None):
# wicardd - type 2 / mgcamd
caid = info.get("caid", None)
if caid:
info["caid"] = info["caid"][2:]
info["pid"] = info["pid"][2:]
info["provid"] = info["prov"][2:]
time = ""
for line in ecm:
if "msec" in line:
line = line.split(" ")
if line[0]:
time = " (%ss)" % (float(line[0]) / 1000)
break
self.textvalue = info["source"] + time

elif info.get("reader", ""):
hops = (x := info.get("hops", "")) and x != "0" and " @" + x or ""
ecm = (x := info.get("ecm time", "")) and " (%ss)" % x
self.textvalue = info["reader"] + hops + ecm

elif response := info.get("response time", None):
response = response.split(" ")
self.textvalue = "%s (%ss)" % (response[4], float(response[0]) / 1000)

else:
decode = info.get("decode", None)
if decode:
# gbox (untested)
if info["decode"] == "Network":
cardid = "id:" + info.get("prov", "")
try:
share = open("/tmp/share.info", "r").readlines()
for line in share:
if cardid in line:
self.textvalue = line.strip()
break
else:
self.textvalue = cardid
except:
self.textvalue = decode
else:
self.textvalue = decode
if ecm[1].startswith("SysID"):
info["prov"] = ecm[1].strip()[6:]
if "response" in info:
self.textvalue += " (0.%ss)" % info["response"]
info["caid"] = ecm[0][ecm[0].find("CaID 0x") + 7:ecm[0].find(",")]
info["pid"] = ecm[0][ecm[0].find("pid 0x") + 6:ecm[0].find(" =")]
info["provid"] = info.get("prov", "0")[:4]
else:
source = info.get("source", None)
if source:
# wicardd - type 2 / mgcamd
caid = info.get("caid", None)
if caid:
info["caid"] = info["caid"][2:]
info["pid"] = info["pid"][2:]
info["provid"] = info["prov"][2:]
time = ""
for line in ecm:
if "msec" in line:
line = line.split(" ")
if line[0]:
time = " (%ss)" % (float(line[0]) / 1000)
continue
self.textvalue = source + time
else:
reader = info.get("reader", "")
if reader:
hops = info.get("hops", None)
if hops and hops != "0":
hops = " @" + hops
else:
hops = ""
self.textvalue = reader + hops + " (%ss)" % info.get("ecm time", "?")
else:
response = info.get("response time", None)
if response:
# wicardd - type 1
response = response.split(" ")
self.textvalue = "%s (%ss)" % (response[4], float(response[0]) / 1000)
else:
self.textvalue = ""
self.textvalue = ""

decCI = info.get("caid", info.get("CAID", "0"))
provid = info.get("provid", info.get("prov", info.get("Provider", "0")))
ecmpid = info.get("pid", info.get("ECM PID", "0"))
Expand Down

0 comments on commit ddcc385

Please sign in to comment.