Skip to content

Commit

Permalink
Fix global var not working after cam switches
Browse files Browse the repository at this point in the history
  • Loading branch information
meo committed Dec 4, 2021
1 parent 71a7bba commit 37e3117
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions lib/python/Screens/OScamInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
NAMEBIN = "ncam"
NAMEBIN2 = "Ncam"

def check_NAMEBIN():
if fileExists("/tmp/.oscam/oscam.version"):
NAMEBIN = "oscam"
elif fileExists("/tmp/.ncam/ncam.version"):
NAMEBIN = "ncam"
return NAMEBIN


f = 1
sizeH = 700
HDSKIN = False
Expand Down Expand Up @@ -79,7 +87,7 @@ def confPath(self):
oport = None
opath = None
ipcompiled = False
global NAMEBIN
NAMEBIN = check_NAMEBIN()

# Find and parse running oscam/ncam
if fileExists("/tmp/.%s/%s.version" % (NAMEBIN, NAMEBIN)):
Expand Down Expand Up @@ -108,7 +116,7 @@ def confPath(self):
return owebif, oport, opath, ipcompiled

def getUserData(self):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
[webif, port, conf, ipcompiled] = self.confPath()
if conf == None:
conf = ""
Expand Down Expand Up @@ -150,7 +158,7 @@ def getUserData(self):
return ret

def openWebIF(self, part=None, reader=None):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
self.proto = "http"
if config.oscaminfo.userdatafromconf.value:
udata = self.getUserData()
Expand Down Expand Up @@ -407,7 +415,7 @@ def __init__(self, list, itemH=30):
class OscamInfoMenu(Screen):
def __init__(self, session):
Screen.__init__(self, session)
global NAMEBIN
NAMEBIN = check_NAMEBIN()
self.setTitle(_("%s Info - Main Menu" % NAMEBIN2))
self.menu = [_("Show Ecm info"), _("Show Clients"), _("Show Readers/Proxies"), _("Show Log"), _("Card info (CCcam-Reader)"), _("Ecm Statistics"), _("Setup")]
self.osc = OscamInfo()
Expand Down Expand Up @@ -477,7 +485,7 @@ def down(self):
pass

def goEntry(self, entry):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
if NAMEBIN:
print("[openWebIF] NAMEBIN=%s" % (NAMEBIN))
if entry in (1, 2, 3) and config.oscaminfo.userdatafromconf.value and self.osc.confPath()[0] is None:
Expand Down Expand Up @@ -569,7 +577,7 @@ def buildMenu(self, mlist):
return menuentries

def showMenu(self):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
entr = self.buildMenu(self.menu)
self["mainmenu"].l.setList(entr)
self["mainmenu"].moveToIndex(0)
Expand Down Expand Up @@ -798,7 +806,7 @@ def buildLogListEntry(self, listentry):
return res

def showData(self):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
if self.firstrun:
data = self.webif_data
self.firstrun = False
Expand Down Expand Up @@ -1210,12 +1218,12 @@ def elementChanged(self, instance):
pass

def layoutFinished(self):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
self.setTitle(_("%s Info - Configuration" % NAMEBIN2))
self["config"].l.setList(self.oscamconfig)

def createSetup(self):
global NAMEBIN
NAMEBIN = check_NAMEBIN()
self.oscamconfig = []
self.oscamconfig.append(getConfigListEntry(_("Read Userdata from %s.conf" % NAMEBIN), config.oscaminfo.userdatafromconf))
if not config.oscaminfo.userdatafromconf.value:
Expand Down

0 comments on commit 37e3117

Please sign in to comment.