diff --git a/lib/python/Screens/OScamInfo.py b/lib/python/Screens/OScamInfo.py
index db6a71dea..b970c6f18 100644
--- a/lib/python/Screens/OScamInfo.py
+++ b/lib/python/Screens/OScamInfo.py
@@ -27,20 +27,6 @@
# GLOBALS
MODULE_NAME = __name__.split(".")[-1]
-NAMEBIN = ""
-NAMEBIN2 = ""
-def check_NAMEBIN():
- NAMEBIN = "oscam"
- if fileExists("/tmp/.ncam/ncam.version"):
- NAMEBIN = "ncam"
- return NAMEBIN
-
-def check_NAMEBIN2():
- NAMEBIN2 = "OScam"
- if fileExists("/tmp/.ncam/ncam.version"):
- NAMEBIN2 = "Ncam"
- return NAMEBIN2
-
class OSCamGlobals():
def __init__(self):
@@ -54,12 +40,13 @@ def openWebIF(self, part="status", label="", fmt="json", log=False):
webifok, url, result = self.callApi(proto=proto, ip=ip, port=port, \
username=user, password=pwd, api=api, \
fmt=fmt, part=part, label=label, log=log)
- return webifok, url, signstatus, result
+ return webifok, api, url, signstatus, result
def confPath(self):
- conffile, owebif = ipv6compiled = found = "", False
+ conffile = ""
+ owebif = ipv6compiled = found = False
oport = opath = signstatus = data = error = file = url = None
- for filename in ["oscam.version"] if exists("/tmp/.oscam/oscam.version") else ["ncam.version"]:
+ for filename in ["oscam.version", "ncam.version"]:
conffile = filename.replace("version", "conf")
if config.oscaminfo.userDataFromConf.value: # Find and parse running oscam, ncam (auto)
file = "/tmp/.%s/%s" % (filename.split('.')[0], filename)
@@ -107,14 +94,14 @@ def confPath(self):
return owebif, oport, opath, ipv6compiled, signstatus, conffile, error
def getUserData(self):
- NAMEBIN2 = check_NAMEBIN2()
- webif, port, conf, ipv6compiled, signstatus, conffile, error = self.confPath() # (True, 'http', '127.0.0.1', '8080', '/etc/tuxbox/config/oscam-trunk/', True, 'CN=...', 'oscam/ncam.conf', None)
+ webif, port, conf, ipv6compiled, signstatus, conffile, error = self.confPath() # (True, 'http', '127.0.0.1', '8080', '/etc/tuxbox/config/oscam-trunk/', True, 'CN=...', 'oscam.conf', None)
conf = "%s%s" % ((conf or ""), (conffile or "oscam.conf"))
api = conffile.replace(".conf", "api")
- proto, blocked, user = pwd = "http", False, None # Assume that oscam/ncam webif is NOT blocking localhost, IPv6 is also configured if it is compiled in, and no user and password are required
- ret = _("%s webif disabled") % NAMEBIN2 if not error else error
- if webif and port is not None: # oscam/ncam reports it got webif support and webif is running (Port != 0)
- if config.oscaminfo.userDataFromConf.value: # Find and parse running oscam/ncam, ncam (auto)
+ proto, blocked = "http", False # Assume that oscam webif is NOT blocking localhost, IPv6 is also configured if it is compiled in, and no user and password are required
+ user = pwd = None
+ ret = _("OSCam webif disabled") if not error else error
+ if webif and port is not None: # oscam reports it got webif support and webif is running (Port != 0)
+ if config.oscaminfo.userDataFromConf.value: # Find and parse running oscam, ncam (auto)
if conf is not None and exists(conf): # If we have a config file, we need to investigate it further
with open(conf) as data:
for i in data:
@@ -128,7 +115,7 @@ def getUserData(self):
proto = "https"
port = port.replace("+", "")
elif "httpallowed" in i.lower():
- blocked = True # Once we encounter a httpallowed statement, we have to assume oscam/ncam webif is blocking us ...
+ blocked = True # Once we encounter a httpallowed statement, we have to assume oscam webif is blocking us ...
allowed = i.split("=")[1].strip()
if "::1" in allowed or "127.0.0.1" in allowed or "0.0.0.0-255.255.255.255" in allowed:
blocked = False # ... until we find either 127.0.0.1 or ::1 in allowed list
@@ -153,7 +140,7 @@ def callApi(self, proto="http", ip="127.0.0.1", port="83", username=None, passwo
elif part in ["restart", "shutdown"]:
url = "%s://%s:%s/shutdown.html?action=%s" % (proto, ip, port, part) # e.g. http://127.0.0.1:8080//shutdown.html?action=restart or ...?action=shutdown
elif label:
- key = "file" if part == "files" else "label" # e.g. http://127.0.0.1:8080/oscamapi.html?part=files&file=oscam/ncam.conf
+ key = "file" if part == "files" else "label" # e.g. http://127.0.0.1:8080/oscamapi.html?part=files&file=oscam.conf
url = "%s://%s:%s/%s.%s?part=%s&%s=%s" % (proto, ip, port, api, fmt, part, key, label) # e.g. http://127.0.0.1:8080/oscamapi.json?part=entitlement&label=MyReader
opener = build_opener(webhandler)
if username and password and url:
@@ -176,7 +163,7 @@ def callApi(self, proto="http", ip="127.0.0.1", port="83", username=None, passwo
return False, url, errmsg.encode(encoding="latin-1", errors="ignore")
def updateLog(self):
- webifok, url, signstatus, result = self.openWebIF(log=True)
+ webifok, api, url, signstatus, result = self.openWebIF(log=True)
result = result.decode(encoding="latin-1", errors="ignore")
if webifok:
log = search(r'(.*?)', result.replace("", ""), S)
@@ -333,10 +320,10 @@ class OSCamInfo(Screen, OSCamGlobals):
def __init__(self, session):
Screen.__init__(self, session)
- NAMEBIN = check_NAMEBIN()
- NAMEBIN2 = check_NAMEBIN2()
self.skinName = "OSCamInfo"
- self.setTitle(_("%sInfo: Information") % NAMEBIN2)
+ webifok, api, url, signstatus, result = self.openWebIF()
+ camname = {"oscamapi": ("OSCam"), "ncamapi": ("NCam")}.get(api)
+ self.setTitle(_("%sInfo: Information") % camname)
self.rulist = []
self["buildinfos"] = StaticText()
self["extrainfos"] = StaticText()
@@ -349,8 +336,8 @@ def __init__(self, session):
self["buffer"] = StaticText()
self["virtuell"] = StaticText()
self["resident"] = StaticText()
- self["key_red"] = StaticText(_("Shutdown %s") % NAMEBIN2)
- self["key_green"] = StaticText(_("Restart %s") % NAMEBIN2)
+ self["key_red"] = StaticText(_("Shutdown %s") % camname)
+ self["key_green"] = StaticText(_("Restart %s") % camname)
self["key_blue"] = StaticText(_("Show Log"))
self["key_OK"] = StaticText()
self["key_entitlements"] = StaticText()
@@ -360,10 +347,10 @@ def __init__(self, session):
"ok": (self.keyOk, _("Show details")),
"cancel": (self.exit, _("Close the screen")),
"menu": (self.keyMenu, _("Open Settings")),
- "red": (self.keyShutdown, _("Shutdown %s") % NAMEBIN2),
- "green": (self.keyRestart, _("Restart %s") % NAMEBIN2),
+ "red": (self.keyShutdown, _("Shutdown OSCam")),
+ "green": (self.keyRestart, _("Restart OSCam")),
"blue": (self.keyBlue, _("Open Log"))
- }, prio=1, description=_("%sInfo Actions") % NAMEBIN2)
+ }, prio=1, description=_("OSCamInfo Actions"))
self.loop = eTimer()
self.loop.callback.append(self.updateOScamData)
self.onLayoutFinish.append(self.onLayoutFinished)
@@ -375,36 +362,33 @@ def onLayoutFinished(self):
if config.oscaminfo.userDataFromConf.value and self.confPath()[0] is None:
config.oscaminfo.userDataFromConf.value = False
config.oscaminfo.userDataFromConf.save()
- self["extrainfos"].setText(_("File %s.conf not found.\nPlease enter username/password manually.") % NAMEBIN)
+ self["extrainfos"].setText(_("File oscam.conf not found.\nPlease enter username/password manually."))
else:
callInThread(self.updateOScamData)
if config.oscaminfo.autoUpdate.value:
self.loop.start(config.oscaminfo.autoUpdate.value * 1000, False)
def updateOScamData(self):
- NAMEBIN2 = check_NAMEBIN2()
- webifok, url, signstatus, result = self.openWebIF()
+ webifok, api, url, signstatus, result = self.openWebIF()
+ tag, camname = {"oscamapi": ("oscam", "OSCam"), "ncamapi": ("ncam", "NCam")}.get(api)
ctime = datetime.fromisoformat(datetime.now(timezone.utc).astimezone().isoformat())
currtime = "Protocol Time: %s - %s" % (ctime.strftime("%x"), ctime.strftime("%X"))
na = _("n/a")
if webifok and result:
- if fileExists("/tmp/.ncam/ncam.version"):
- oscam = loads(result).get("ncam", {})
- else:
- oscam = loads(result).get("oscam", {})
- sysinfo = oscam.get("sysinfo", {})
+ json = loads(result).get(tag, {})
+ sysinfo = json.get("sysinfo", {})
# GENERAL INFOS (timing, memory usage)
- stime_iso = oscam.get("starttime", None)
+ stime_iso = json.get("starttime", None)
starttime = "Start Time: %s - %s" % (datetime.fromisoformat(stime_iso).strftime("%x"), datetime.fromisoformat(stime_iso).strftime("%X")) if stime_iso else (na, na)
- runtime = "%s Run Time: %s" % (NAMEBIN2, oscam.get("runtime", na))
- version = "%s: %s" % (NAMEBIN2, oscam.get("version", na))
- srvidfile = "srvidfile: %s" % oscam.get("srvidfile", na)
+ runtime = "%s Run Time: %s" % (camname, json.get("runtime", na))
+ version = "%s: %s" % (camname, json.get("version", na))
+ srvidfile = "srvidfile: %s" % json.get("srvidfile", na)
url = "%s: %s//%s" % (_("Host"), url.split('/')[0], url.split('/')[2])
signed = "%s: %s" % (_("Signed by"), signstatus) if signstatus else ""
rulist = []
# MAIN INFOS {'s': 'server', 'h': 'http', 'p': 'proxy', 'r': 'reader', 'c': 'cccam_ext', 'x': 'cache exchange', 'm': 'monitor'}
outlist = []
- for client in oscam.get("status", {}).get("client", []):
+ for client in json.get("status", {}).get("client", []):
connection = client.get("connection", {})
request = client.get("request", {})
times = client.get("times", {})
@@ -412,15 +396,11 @@ def updateOScamData(self):
readeruser = unquote({"s": "root", "h": "root", "p": client.get("rname_enc", ""), "r": client.get("rname_enc", ""), "c": client.get("name_enc", "")}.get(currtype, na))
au = {"-1": "ON", "0": "OFF", "1": "ACTIVE"}.get(client.get("au", na), na)
ip = connection.get("ip", "")
- if ip and config.misc.softcam_hideServerName.value:
- ip = "\u2022" * len(ip)
port = connection.get("port", na)
protocol = "\n".join(client.get("protocol", "").split(" "))
srinfo = "%s:%s@%s" % (request.get("srvid", na), request.get("caid", na), request.get("provid", na))
chinfo = "%s\n%s" % (request.get("chname", na), request.get("chprovider", na))
answered = request.get("answered", "")
- if answered and config.misc.softcam_hideServerName.value:
- answered = "\u2022" * len(answered)
ecmtime = request.get("ecmtime", na)
lbvaluereader = "%s (%s ms)" % (answered, ecmtime) if answered and ecmtime else request.get("lbvalue", na)
login_iso = times.get("login")
@@ -457,12 +437,8 @@ def updateOScamData(self):
self["used"].setText("Used: %s" % sysinfo.get("mem_cur_used", na))
self["free"].setText("Free: %s" % sysinfo.get("mem_cur_free", na))
self["buffer"].setText("Buffer: %s" % sysinfo.get("mem_cur_buff", na))
- if fileExists("/tmp/.ncam/ncam.version"):
- self["virtuell"].setText("Virtuell memory: %s" % sysinfo.get("ncam_vmsize", na))
- self["resident"].setText("Resident Set: %s" % sysinfo.get("ncam_rsssize", na))
- else:
- self["virtuell"].setText("Virtuell memory: %s" % sysinfo.get("oscam_vmsize", na))
- self["resident"].setText("Resident Set: %s" % sysinfo.get("oscam_rsssize", na))
+ self["virtuell"].setText("Virtuell memory: %s" % sysinfo.get(tag + "_vmsize", na))
+ self["resident"].setText("Resident Set: %s" % sysinfo.get(tag + "_rsssize", na))
self["outlist"].updateList(outlist)
self.displayLog()
else:
@@ -513,10 +489,10 @@ def keyMenu(self):
self.session.openWithCallback(self.menuCallback, OSCamInfoSetup)
def keyShutdown(self):
- self.session.openWithCallback(boundFunction(self.msgboxCB, "shutdown"), MessageBox, _("Do you really want to shut down %s?\n\nATTENTION: To reactivate %s, a complete receiver restart must be carried out!" % (NAMEBIN2, NAMEBIN2)), MessageBox.TYPE_YESNO, timeout=10, default=False)
+ self.session.openWithCallback(boundFunction(self.msgboxCB, "shutdown"), MessageBox, _("Do you really want to shut down OSCam?\n\nATTENTION: To reactivate OSCam, a complete receiver restart must be carried out!"), MessageBox.TYPE_YESNO, timeout=10, default=False)
def keyRestart(self):
- self.session.openWithCallback(boundFunction(self.msgboxCB, "restart"), MessageBox, _("Do you really want to restart %s?\n\nHINT: This will take about 5 seconds!" % NAMEBIN2), MessageBox.TYPE_YESNO, timeout=10, default=False)
+ self.session.openWithCallback(boundFunction(self.msgboxCB, "restart"), MessageBox, _("Do you really want to restart OSCam?\n\nHINT: This will take about 5 seconds!"), MessageBox.TYPE_YESNO, timeout=10, default=False)
def keyBlue(self):
self.loop.stop()
@@ -525,7 +501,7 @@ def keyBlue(self):
def msgboxCB(self, action, answer):
if answer:
self.loop.stop()
- webifok, url, signstatus, result = self.openWebIF(part=action)
+ webifok, api, url, signstatus, result = self.openWebIF(part=action)
if not webifok:
print("[%s] ERROR in module 'msgboxCB': %s" % (MODULE_NAME, "Unexpected error accessing WebIF: %s" % result))
self.session.open(MessageBox, _("Unexpected error accessing WebIF: %s" % result), MessageBox.TYPE_ERROR, timeout=3, close_on_any_key=True)
@@ -729,11 +705,9 @@ class OSCamEntitlements(Screen, OSCamGlobals):
def __init__(self, session, readeruser):
self.readeruser = readeruser
- NAMEBIN = check_NAMEBIN()
- NAMEBIN2 = check_NAMEBIN2()
Screen.__init__(self, session)
self.skinName = "OSCamEntitlements"
- self.setTitle(_("%sInfo: Entitlements for '%s'") % (NAMEBIN2, self.readeruser))
+ self.setTitle(_("OSCamInfo: Entitlements for '%s'") % self.readeruser)
self.dheaders = ["type", "CAID", "Provid", "ID", "Class", "Start Date", "Expire Date", "Name"]
self.cheaders = ["CAID", "System", "Reshare", "Hop", "ShareID", "RemoteID", "ProvIDs", "Providers", "Nodes", "Locals", "Count", "Hop1", "Hop2", "Hopx", "Curr", "Res0", "Res1", "Res2", "Resx", "Reshare"]
self.showall = False
@@ -752,7 +726,7 @@ def __init__(self, session, readeruser):
"ok": (self.keyOk, _("Show all details")),
"cancel": (self.exit, _("Close the screen")),
"blue": (self.keyBlue, _("Show all"))
- }, prio=1, description=_("%sInfo Actions") % NAMEBIN2)
+ }, prio=1, description=_("OSCamInfo Actions"))
self.onLayoutFinish.append(self.onLayoutFinished)
self.bgColors = parameters.get("OSCamInfoBGcolors", (0x10fcfce1, 0x10f1f6e6, 0x10e2e0ef))
self.loop = eTimer()
@@ -772,6 +746,8 @@ def onLayoutFinished(self):
callInThread(self.updateEntitlements)
def updateEntitlements(self):
+ webifok, api, url, signstatus, result = self.openWebIF()
+ camname = {"oscamapi": ("OSCam"), "ncamapi": ("NCam")}.get(api)
entitleslist = self.getJSONentitlements()
if entitleslist:
self["entitleslist"].style = "default"
@@ -786,7 +762,7 @@ def updateEntitlements(self):
self["entitleslist"].style = "entitlements"
self.show_cheaders()
self["entitleslist"].updateList(entitleslist)
- self.setTitle(_("%sInfo: %s Entitlements for '%s'") % (NAMEBIN2, len(entitleslist), self.readeruser))
+ self.setTitle(_("%sInfo: %s Entitlements for '%s'") % (camname, len(entitleslist), self.readeruser))
self.entitleslist = entitleslist
self.showHideBlue()
self.showHideKeyOk()
@@ -795,12 +771,10 @@ def updateEntitlements(self):
def getJSONentitlements(self):
entitleslist = []
- webifok, url, signstatus, result = self.openWebIF(part="entitlement", label=self.readeruser) # read JSON-entitlements
+ webifok, api, url, signstatus, result = self.openWebIF(part="entitlement", label=self.readeruser) # read JSON-entitlements
+ tag = {"oscamapi": ("oscam"), "ncamapi": ("ncam")}.get(api)
if webifok and result:
- if fileExists("/tmp/.ncam/ncam.version"):
- entitlements = loads(result).get("ncam", {}).get("entitlements", [])
- else:
- entitlements = loads(result).get("oscam", {}).get("entitlements", [])
+ entitlements = loads(result).get(tag, {}).get("entitlements", [])
if entitlements:
bgcoloridx = 0
na = _("n/a")
@@ -820,12 +794,10 @@ def getJSONentitlements(self):
def getJSONstats(self):
entitleslist = []
- webifok, url, signstatus, result = self.openWebIF() # read JSON-status
+ webifok, api, url, signstatus, result = self.openWebIF() # read JSON-status
+ tag = {"oscamapi": ("oscam"), "ncamapi": ("ncam")}.get(api)
if webifok and result:
- if fileExists("/tmp/.ncam/ncam.version"):
- self.clients = loads(result).get("ncam", {}).get("status", {}).get("client", [])
- else:
- self.clients = loads(result).get("oscam", {}).get("status", {}).get("client", [])
+ self.clients = loads(result).get(tag, {}).get("status", {}).get("client", [])
bgcoloridx = 0
na = _("n/a")
for client in self.clients:
@@ -845,7 +817,7 @@ def getJSONstats(self):
def getXMLentitlements(self):
entitleslist = []
- webifok, url, signstatus, result = self.openWebIF(part="entitlement", label=self.readeruser, fmt="xml") # read XML-entitlements
+ webifok, api, url, signstatus, result = self.openWebIF(part="entitlement", label=self.readeruser, fmt="xml") # read XML-entitlements
if webifok and result:
reader = XML(result).find("reader")
bgcoloridx = 0
@@ -1011,45 +983,40 @@ def splitParts(slist, count):
return nlist
Screen.__init__(self, session)
- NAMEBIN = check_NAMEBIN()
- NAMEBIN2 = check_NAMEBIN2()
self.skinName = "OSCamEntitleDetails"
- if entitlement:
- self.setTitle(_("Entitlements for 'CAID %s'") % entitlement[1])
- entitlelen = len(entitlement)
- for idx in range(len(entitlement)):
- if (idx + 1) < entitlelen:
- self["label%s" % idx] = StaticText(entitlement[idx + 1])
- self["ProvIDlist"] = List((splitParts(entitlement[7].split(", "), 6)))
- self['ProvIDlist'].selectionEnabled(0)
- self["Providerlist"] = List((splitParts(entitlement[8].split(", "), 2)))
- self['Providerlist'].selectionEnabled(0)
- self["Nodelist"] = List((splitParts(entitlement[9].split(", "), 2)))
- self['Nodelist'].selectionEnabled(0)
- self["key_exit"] = StaticText(_("Exit"))
+ self.setTitle(_("Entitlements for 'CAID %s'") % entitlement[1])
+ entitlelen = len(entitlement)
+ for idx in range(len(entitlement)):
+ if (idx + 1) < entitlelen:
+ self["label%s" % idx] = StaticText(entitlement[idx + 1])
+ self["ProvIDlist"] = List((splitParts(entitlement[7].split(", "), 6)))
+ self['ProvIDlist'].selectionEnabled(0)
+ self["Providerlist"] = List((splitParts(entitlement[8].split(", "), 2)))
+ self['Providerlist'].selectionEnabled(0)
+ self["Nodelist"] = List((splitParts(entitlement[9].split(", "), 2)))
+ self['Nodelist'].selectionEnabled(0)
+ self["key_exit"] = StaticText(_("Exit"))
self["actions"] = HelpableActionMap(self, ["OkCancelActions"], {
"ok": (self.close, _("Close the screen")),
"cancel": (self.close, _("Close the screen")),
- }, prio=1, description=_("%sInfo Actions") % NAMEBIN2)
+ }, prio=1, description=_("OSCamInfo Actions"))
class OSCamInfoLog(Screen, OSCamGlobals):
skin = """
-
-
+
+
Format:%H:%M:%S
-
+
"""
def __init__(self, session):
Screen.__init__(self, session)
- NAMEBIN = check_NAMEBIN()
- NAMEBIN2 = check_NAMEBIN2()
self.skinName = "OSCamInfoLog"
- self.setTitle(_("%sInfo: Log") % NAMEBIN2)
+ self.setTitle(_("OSCamInfo: Log"))
self["logtext"] = ScrollLabel(_(""))
self["actions"] = HelpableActionMap(self, ["NavigationActions", "OkCancelActions"], {
"ok": (self.exit, _("Close the screen")),
@@ -1058,7 +1025,7 @@ def __init__(self, session):
"up": (self.keyPageUp, _("Move up a page")),
"down": (self.keyPageDown, _("Move down a page")),
"pageDown": (self.keyPageDown, _("Move down a page"))
- }, prio=1, description=_("%sInfo Log Actions") % NAMEBIN2)
+ }, prio=1, description=_("OSCamInfo Log Actions"))
self.loop = eTimer()
self.loop.callback.append(self.displayLog)
self.onLayoutFinish.append(self.onLayoutFinished)