Enigma2-plugin-skins-ramimaher-rm-10-m-mod-pli_0.1_mipsel.ipk Attached Files File Type: zip enigma2-plugin-skins-ramimaher-rm-10-m-mod-pli_0.1_mipsel.zip (1.46 MB, [You must be registered and logged in to see this link.]. Newnigma² » Plugins » CCcam Info v1.3c. CCcam Info v1.3c. -Show bigger ecm-info bar for hd-skins Credit to plugin creator.
Whenever you think about adding your stuff to github.com/opendreambox, you shouldthink about the license you want to apply to your code/resources.It is a common agreement in the open source world to put a file calledLICENSE or COPYING into the root directory of your project and/or to addthe license text to the head of all your sources.
Please always take care not to violate the license of code you didn'tactually write yourself but got somewhere else.
Everyone is welcome to publish their plugins and/or skins on github.com/opendreambox.Every plugin and skin added to github.com/opendreambox can be added to theofficial build system and will usually be available via the officialexperimental mirrors within a day.
Directory structures and paths
Before you start you should have a rough look at existing directorystructures and structure your things accordingly.Please do not use any absolute paths, neither in the Makefiles nor in a plugin.Both autotools and enigma2 provide proper mechanisms to locate a pathproperly using environment variables or helper-functions.In Makefiles you would use variables like $(sysconfdir) or $(prefix)instead of /etc and /usr.In enimga2 and any of its plugins you could use eEnv.resolve() to do the same.In addition you can use enigma2's Tools.Directories.resolveFilename()in conjunction with the according SCOPE_* constants.
Add your plugin to the build system
Basically everything on github.com/opendreambox will automatically be built on adaily basis. This is done using 'autotools' in an openembedded build environment.If you want to set up your own openembedded you can take a look athttp://opendreambox.org/ (you will need a Linux system for that).Whenever you have something new that you would like to be built properly, youhave to add a proper Makefile.am to every directory that contains filesthat have to be compiled and/or installed somewhere on the target system.In addition, you should always check that you properly extended thefiles 'configure.ac' and 'Makefile.am' in the root of the git you aregoing to commit your files to (no matter if it is a skin or a plugin).In the Makefile.am in the git-root just add your new plugin's directoryto the 'SUBDIRS' variable.In the configure.ac you have to add all directories containing aMakefile to the 'AC_CONFIG_FILES' call. Just have a look at the existing entries.Please try to keep the given alphabetical order in those files, it makesfinding and fixing things a lot easier.
If you are not familiar with Makefiles or configure.ac, just try to take a lookat existing content. You'll find lots of examples in enigma2-plugins.
Become the maintainer of what you created
If you're adding an enigma2-plugin, please also consider adding a propermaintainer.info for your plugin.A maintainer.info just contains two things: the mail address of the authorplus the name of the plugin.It enables users to send a crashlog to the actual maintainer of a pluginthat seems to have caused a crash.
Example:
Before changing anything in someone else's sources, please try to contacthim/her and discuss the things you want to change.Sometimes people have good reasons why they don't want particular things tobe in their plugin or maybe they have certain quality-standards they wouldlike the code to catch up to.Sometimes though, the original author doesn't maintain a plugin anymore.So if you have any fixes or enhancements for some existing plugin thatdoesn't seem to be maintained anymore or you cannot get any feedback fromthe original author, you can always go ahead and commit your changes.As github.com/opendreambox uses git, you can undo your changes at any time, if you wantor have to.But again, please check that whatever you're going to change doesn't violateany licenses!
Cccam Info Enigma2 Skins Pc
If you want to get in contact with some of the people that created andmaintain the projects on github.com/opendreambox you are always welcometo join us on #enigma2 in the freenode.net IRC network.
PermalinkJoin GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upCccam Info Enigma2 Skins Free
Find file Copy path
Cccam Info Enigma2 Skins 2017
Cannot retrieve contributors at this time
# -*- coding: UTF-8 -*- |
# CCcam Info by AliAbdul |
from base64 import encodestring |
from os import listdir, remove, rename, system, path |
from enigma import eListboxPythonMultiContent, eTimer, gFont, loadPNG, RT_HALIGN_RIGHT, getDesktop |
from Components.ActionMap import ActionMap, NumberActionMap |
from Components.config import config, getConfigListEntry |
from Components.ConfigList import ConfigListScreen |
from Components.Console import Console |
from Components.Label import Label |
from Components.MenuList import MenuList |
from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest, MultiContentEntryPixmapAlphaBlend |
from Components.ScrollLabel import ScrollLabel |
from Components.Sources.StaticText import StaticText |
from Screens.HelpMenu import HelpableScreen |
#from Screens.InfoBar import InfoBar |
from Screens.LocationBox import LocationBox |
from Screens.MessageBox import MessageBox |
from Screens.Screen import Screen |
from Screens.VirtualKeyBoard import VirtualKeyBoard |
from Tools.Directories import fileExists, SCOPE_ACTIVE_SKIN, resolveFilename |
from twisted.internet import reactor |
from twisted.web.client import HTTPClientFactory |
from urlparse import urlparse, urlunparse |
#TOGGLE_SHOW = InfoBar.toggleShow |
VERSION='v2' |
DATE='21.11.2014' |
CFG='/etc/CCcam.cfg' |
############################################################# |
def_parse(url): |
url = url.strip() |
parsed = urlparse(url) |
scheme = parsed[0] |
path = urlunparse(('','') + parsed[2:]) |
host, port = parsed[1], 80 |
if'@'in host: |
username, host = host.split('@') |
if':'in username: |
username, password = username.split(':') |
else: |
password ='' |
else: |
username ='' |
password ='' |
if':'in host: |
host, port = host.split(':') |
port =int(port) |
if path '': |
path ='/' |
return scheme, host, port, path, username, password |
defgetPage(url, contextFactory=None, *args, **kwargs): |
scheme, host, port, path, username, password = _parse(url) |
if username and password: |
url = scheme +'://'+ host +':'+str(port) + path |
basicAuth = encodestring('%s:%s'% (username, password)) |
authHeader ='Basic '+ basicAuth.strip() |
AuthHeaders = {'Authorization': authHeader} |
if kwargs.has_key('headers'): |
kwargs['headers'].update(AuthHeaders) |
else: |
kwargs['headers'] = AuthHeaders |
factory = HTTPClientFactory(url, *args, **kwargs) |
reactor.connectTCP(host, port, factory) |
return factory.deferred |
############################################################# |
classHelpableNumberActionMap(NumberActionMap): |
def__init__(self, parent, context, actions, prio): |
alist = [] |
adict = {} |
for (action, funchelp) in actions.iteritems(): |
alist.append((action, funchelp[1])) |
adict[action] = funchelp[0] |
NumberActionMap.__init__(self, [context], adict, prio) |
parent.helpList.append((self, context, alist)) |
############################################################# |
TranslationHelper = [ |
['Current time', _('Current time')], |
['NodeID', _('NodeID')], |
['Uptime', _('Uptime')], |
['Connected clients', _('Connected clients')], |
['Active clients', _('Active clients')], |
['Total handled client ecm's', _('Total handled client ecm's')], |
['Total handled client emm's', _('Total handled client emm's')], |
['Peak load (max queued requests per workerthread)', _('Peak load (max queued requests per workerthread)')], |
['card reader', _('card reader')], |
['no or unknown card inserted', _('no or unknown card inserted')], |
['system:', _('system:')], |
['caid:', _('caid:')], |
['provider:', _('provider:')], |
['provid:', _('provid:')], |
['using:', _('using:')], |
['address:', _('address:')], |
['hops:', _('hops:')], |
['pid:', _('pid:')], |
['share:', _('share:')], |
['handled', _('handled')], |
[' and', _(' and')], |
['card', _('card')], |
['Cardserial', _('Cardserial')], |
['ecm time:', _('ecm time:')]] |
deftranslateBlock(block): |
for x in TranslationHelper: |
if block.__contains__(x[0]): |
block = block.replace(x[0], x[1]) |
return block |
############################################################# |
defgetConfigValue(l): |
list= l.split(':') |
ret ='' |
iflen(list) >1: |
ret = (list[1]).replace('n', '').replace('r', '') |
if ret.__contains__('#'): |
idx = ret.index('#') |
ret = ret[:idx] |
while ret.startswith(''): |
ret = ret[1:] |
while ret.endswith(''): |
ret = ret[:-1] |
return ret |
############################################################# |
defnotBlackListed(entry): |
try: |
f =open(config.cccaminfo.blacklist.value, 'r') |
content = f.read().split('n') |
f.close() |
except: |
content = [] |
ret =True |
for x in content: |
if x entry: |
ret =False |
return ret |
############################################################# |
menu_list = [ |
_('General'), |
_('Clients'), |
_('Active clients'), |
_('Servers'), |
_('Shares'), |
_('Share View'), |
_('Extended Shares'), |
_('Providers'), |
_('Entitlements'), |
_('ecm.info'), |
_('Menu config'), |
_('Local box'), |
_('Remote box'), |
_('Free memory'), |
_('Switch config'), |
_('About')] |
############################################################# |
if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, 'icons/lock_on.png')): |
lock_on = loadPNG(resolveFilename(SCOPE_ACTIVE_SKIN, 'icons/lock_on.png')) |
else: |
lock_on = loadPNG('icons/lock_on.png') |
if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, 'icons/lock_off.png')): |
lock_off = loadPNG(resolveFilename(SCOPE_ACTIVE_SKIN, 'icons/lock_off.png')) |
else: |
lock_off = loadPNG('icons/lock_off.png') |
defgetConfigNameAndContent(fileName): |
try: |
f =open(fileName, 'r') |
content = f.read() |
f.close() |
except: |
content ='' |
if content.startswith('#CONFIGFILE NAME='): |
content = content.replace('r', 'n') |
name = content[17:] |
idx = name.index('n') |
name = name[:idx] |
else: |
name = fileName.replace('/var/etc/', '') |
return name, content |
############################################################# |
classCCcamList(MenuList): |
def__init__(self, list): |
MenuList.__init__(self, list, False, eListboxPythonMultiContent) |
self.l.setItemHeight(25) |
self.l.setFont(0, gFont('Regular', 20)) |
self.l.setFont(1, gFont('Regular', 32)) |
classCCcamShareList(MenuList): |
def__init__(self, list): |
MenuList.__init__(self, list, False, eListboxPythonMultiContent) |
self.l.setItemHeight(60) |
self.l.setFont(0, gFont('Regular', 18)) |
self.l.setFont(1, gFont('Regular', 32)) |
classCCcamConfigList(MenuList): |
def__init__(self, list): |
MenuList.__init__(self, list, False, eListboxPythonMultiContent) |
self.l.setItemHeight(30) |
self.l.setFont(0, gFont('Regular', 20)) |
self.l.setFont(1, gFont('Regular', 32)) |
classCCcamShareViewList(MenuList): |
def__init__(self, list): |
MenuList.__init__(self, list, False, eListboxPythonMultiContent) |
self.l.setItemHeight(20) |
self.l.setFont(0, gFont('Regular', 18)) |
self.l.setFont(1, gFont('Regular', 32)) |
defCCcamListEntry(name, idx): |
screenwidth = getDesktop(0).size().width() |
res = [name] |
if idx 10: |
idx ='red' |
elif idx 11: |
idx ='green' |
elif idx 12: |
idx ='yellow' |
elif idx 13: |
idx ='blue' |
elif idx 14: |
idx ='menu' |
elif idx 15: |
idx ='info' |
if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, 'buttons/key_%s.png'%str(idx))): |
png = resolveFilename(SCOPE_ACTIVE_SKIN, 'buttons/key_%s.png'%str(idx)) |
else: |
png ='buttons/key_%s.png'%str(idx) |
if screenwidth and screenwidth 1920: |
if fileExists(png): |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(10, 3), size=(67, 48), png=loadPNG(png))) |
res.append(MultiContentEntryText(pos=(90, 7), size=(900, 50), font=1, text=name)) |
else: |
if fileExists(png): |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(0, 0), size=(35, 25), png=loadPNG(png))) |
res.append(MultiContentEntryText(pos=(40, 3), size=(500, 25), font=0, text=name)) |
return res |
defCCcamServerListEntry(name, color): |
screenwidth = getDesktop(0).size().width() |
res = [name] |
if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, 'buttons/key_%s.png'% color)): |
png = resolveFilename(SCOPE_ACTIVE_SKIN, 'buttons/key_%s.png'% color) |
else: |
png ='buttons/key_%s.png'% color |
if screenwidth and screenwidth 1920: |
if fileExists(png): |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(10, 3), size=(67, 48), png=loadPNG(png))) |
res.append(MultiContentEntryText(pos=(90, 7), size=(900, 50), font=1, text=name)) |
else: |
if fileExists(png): |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(0, 0), size=(35, 25), png=loadPNG(png))) |
res.append(MultiContentEntryText(pos=(40, 3), size=(500, 25), font=0, text=name)) |
return res |
defCCcamShareListEntry(hostname, type, caid, system, uphops, maxdown): |
screenwidth = getDesktop(0).size().width() |
if screenwidth and screenwidth 1920: |
res = [(hostname, type, caid, system, uphops, maxdown), |
MultiContentEntryText(pos=(10, 0), size=(550, 35), font=1, text=hostname), |
MultiContentEntryText(pos=(650, 0), size=(500, 35), font=1, text=_('Type: ') +type, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(10, 40), size=(250, 35), font=1, text=_('CaID: ') + caid), |
MultiContentEntryText(pos=(230, 40), size=(250, 35), font=1, text=_('System: ') + system, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(520, 40), size=(250, 35), font=1, text=_('Uphops: ') + uphops, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(900, 40), size=(250, 35), font=1, text=_('Maxdown: ') + maxdown, flags=RT_HALIGN_RIGHT)] |
return res |
else: |
res = [(hostname, type, caid, system, uphops, maxdown), |
MultiContentEntryText(pos=(0, 0), size=(250, 20), font=0, text=hostname), |
MultiContentEntryText(pos=(250, 0), size=(250, 20), font=0, text=_('Type: ') +type, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(0, 20), size=(250, 20), font=0, text=_('CaID: ') + caid), |
MultiContentEntryText(pos=(250, 20), size=(250, 20), font=0, text=_('System: ') + system, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(0, 40), size=(250, 20), font=0, text=_('Uphops: ') + uphops), |
MultiContentEntryText(pos=(250, 40), size=(250, 20), font=0, text=_('Maxdown: ') + maxdown, flags=RT_HALIGN_RIGHT)] |
return res |
defCCcamShareViewListEntry(caidprovider, providername, numberofcards, numberofreshare): |
screenwidth = getDesktop(0).size().width() |
if screenwidth and screenwidth 1920: |
res = [(caidprovider, providername, numberofcards), |
MultiContentEntryText(pos=(10, 5), size=(800, 35), font=1, text=providername), |
MultiContentEntryText(pos=(1050, 5), size=(50, 35), font=1, text=numberofcards, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(1100, 5), size=(50, 35), font=1, text=numberofreshare, flags=RT_HALIGN_RIGHT)] |
return res |
else: |
res = [(caidprovider, providername, numberofcards), |
MultiContentEntryText(pos=(0, 0), size=(430, 20), font=0, text=providername), |
MultiContentEntryText(pos=(430, 0), size=(50, 20), font=0, text=numberofcards, flags=RT_HALIGN_RIGHT), |
MultiContentEntryText(pos=(480, 0), size=(50, 20), font=0, text=numberofreshare, flags=RT_HALIGN_RIGHT)] |
return res |
defCCcamConfigListEntry(file): |
screenwidth = getDesktop(0).size().width() |
res = [file] |
try: |
f =open(CFG, 'r') |
org = f.read() |
f.close() |
except: |
org ='' |
(name, content) = getConfigNameAndContent(file) |
if content org: |
png = lock_on |
else: |
png = lock_off |
if screenwidth and screenwidth 1920: |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(5, 5), size=(50, 50), png=png)) |
res.append(MultiContentEntryText(pos=(85, 5), size=(800, 35), font=1, text=name)) |
else: |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(2, 2), size=(25, 25), png=png)) |
res.append(MultiContentEntryText(pos=(35, 2), size=(550, 25), font=0, text=name)) |
return res |
defCCcamMenuConfigListEntry(name, blacklisted): |
screenwidth = getDesktop(0).size().width() |
res = [name] |
if blacklisted: |
png = lock_off |
else: |
png = lock_on |
if screenwidth and screenwidth 1920: |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(5, 5), size=(50, 50), png=png)) |
res.append(MultiContentEntryText(pos=(85, 5), size=(800, 35), font=1, text=name)) |
else: |
res.append(MultiContentEntryPixmapAlphaBlend(pos=(2, 2), size=(25, 25), png=png)) |
res.append(MultiContentEntryText(pos=(35, 2), size=(550, 25), font=0, text=name)) |
return res |
############################################################# |
classCCcamInfoMain(Screen): |
def__init__(self, session, menu_path=''): |
Screen.__init__(self, session) |
screentitle = _('CCcam Info') |
menu_path += screentitle |
if config.usage.show_menupath.value 'large': |
title = menu_path |
self['menu_path_compressed'] = StaticText('') |
elif config.usage.show_menupath.value 'small': |
title = screentitle |
self['menu_path_compressed'] = StaticText(menu_path +' >'ifnot menu_path.endswith(' / ') else menu_path[:-3] +' >'or'') |
else: |
title = screentitle |
self['menu_path_compressed'] = StaticText('') |
Screen.setTitle(self, title) |
self.session = session |
self['menu'] = CCcamList([]) |
self.working =False |
self.Console = Console() |
if config.cccaminfo.profile.value '': |
self.readConfig() |
else: |
self.url = config.cccaminfo.profile.value |
self['actions'] = NumberActionMap(['CCcamInfoActions'], |
{ |
'1': self.keyNumberGlobal, |
'2': self.keyNumberGlobal, |
'3': self.keyNumberGlobal, |
'4': self.keyNumberGlobal, |
'5': self.keyNumberGlobal, |
'6': self.keyNumberGlobal, |
'7': self.keyNumberGlobal, |
'8': self.keyNumberGlobal, |
'9': self.keyNumberGlobal, |
'0': self.keyNumberGlobal, |
'red': self.red, |
'green': self.green, |
'yellow': self.yellow, |
'blue': self.blue, |
'menu': self.menu, |
'info': self.info, |
'ok': self.okClicked, |
'cancel': self.close, |
'up': self.up, |
'down': self.down, |
'left': self.left, |
'right': self.right |
}, -2) |
self.onLayoutFinish.append(self.updateMenuList) |
defupdateMenuList(self): |
self.working =True |
self.menu_list = [] |
for x inself.menu_list: |
delself.menu_list[0] |
list= [] |
idx =0 |
for x in menu_list: |
if notBlackListed(x): |
list.append(CCcamListEntry(x, idx)) |
self.menu_list.append(x) |
idx +=1 |
self['menu'].setList(list) |
self.working =False |
defreadConfig(self): |
self.url ='http://127.0.0.1:16001' |
username =None |
password =None |
try: |
f =open(CFG, 'r') |
for l in f: |
if l.startswith('WEBINFO LISTEN PORT :'): |
port = getConfigValue(l) |
if port !='': |
self.url =self.url.replace('16001', port) |
elif l.startswith('WEBINFO USERNAME :'): |
username = getConfigValue(l) |
elif l.startswith('WEBINFO PASSWORD :'): |
password = getConfigValue(l) |
f.close() |
except: |
pass |
if (username isnotNone) and (password isnotNone) and (username !='') and (password !=''): |
self.url =self.url.replace('http://', ('http://%s:%s@'% (username, password))) |
config.cccaminfo.profile.value ='' |
config.cccaminfo.profile.save() |
defprofileSelected(self, url=None): |
if url isnotNone: |
self.url = url |
config.cccaminfo.profile.value =self.url |
config.cccaminfo.profile.save() |
self.showInfo(_('New profile: ') + url, _('Profile')) |
else: |
self.showInfo(_('Using old profile: ') +self.url, _('Profile')) |
defkeyNumberGlobal(self, idx): |
ifself.working Falseand (idx <len(self.menu_list)): |
self.working =True |
sel =self.menu_list[idx] |
if sel _('General'): |
getPage(self.url).addCallback(self.showCCcamGeneral).addErrback(self.getWebpageError) |
elif sel _('Clients'): |
getPage(self.url +'/clients').addCallback(self.showCCcamClients).addErrback(self.getWebpageError) |
elif sel _('Active clients'): |
getPage(self.url +'/activeclients').addCallback(self.showCCcamClients).addErrback(self.getWebpageError) |
elif sel _('Servers'): |
getPage(self.url +'/servers').addCallback(self.showCCcamServers).addErrback(self.getWebpageError) |
elif sel _('Shares'): |
getPage(self.url +'/shares').addCallback(self.showCCcamShares).addErrback(self.getWebpageError) |
elif sel _('Share View'): |
self.session.openWithCallback(self.workingFinished, CCcamShareViewMenu, self.url) |
elif sel _('Extended Shares'): |
self.session.openWithCallback(self.workingFinished, CCcamInfoShareInfo, 'None', self.url) |
elif sel _('Providers'): |
getPage(self.url +'/providers').addCallback(self.showCCcamProviders).addErrback(self.getWebpageError) |
elif sel _('Entitlements'): |
getPage(self.url +'/entitlements').addCallback(self.showCCcamEntitlements).addErrback(self.getWebpageError) |
elif sel _('ecm.info'): |
self.session.openWithCallback(self.showEcmInfoFile, CCcamInfoEcmInfoSelection) |
elif sel _('Menu config'): |
self.session.openWithCallback(self.updateMenuList, CCcamInfoMenuConfig) |
elif sel _('Local box'): |
self.readConfig() |
self.showInfo(_('Profile: Local box'), _('Local box')) |
elif sel _('Remote box'): |
self.session.openWithCallback(self.profileSelected, CCcamInfoRemoteBoxMenu) |
elif sel _('Free memory'): |
ifnotself.Console: |
self.Console = Console() |
self.working =True |
self.Console.ePopen('free', self.showFreeMemory) |
elif sel _('Switch config'): |
self.session.openWithCallback(self.workingFinished, CCcamInfoConfigSwitcher) |
else: |
self.showInfo(_('CCcam Info %snby AliAbdul %snnThis plugin shows you the status of your CCcam.') % (VERSION, DATE), _('About')) |
defred(self): |
self.keyNumberGlobal(10) |
defgreen(self): |
self.keyNumberGlobal(11) |
defyellow(self): |
self.keyNumberGlobal(12) |
defblue(self): |
self.keyNumberGlobal(13) |
defmenu(self): |
self.keyNumberGlobal(14) |
definfo(self): |
self.keyNumberGlobal(15) |
defokClicked(self): |
self.keyNumberGlobal(self['menu'].getSelectedIndex()) |
defup(self): |
ifnotself.working: |
self['menu'].up() |
defdown(self): |
ifnotself.working: |
self['menu'].down() |
defleft(self): |
ifnotself.working: |
self['menu'].pageUp() |
defright(self): |
ifnotself.working: |
self['menu'].pageDown() |
defgetWebpageError(self, error=''): |
printstr(error) |
self.session.openWithCallback(self.workingFinished, MessageBox, _('Error reading webpage!'), MessageBox.TYPE_ERROR) |
defshowFile(self, file): |
try: |
f =open(file, 'r') |
content = f.read() |
f.close() |
except: |
content = _('Could not open the file %s!') %file |
self.showInfo(translateBlock(content), '') |
defshowEcmInfoFile(self, file=None): |
iffileisnotNone: |
self.showFile('/tmp/'+file) |
self.workingFinished() |
defshowCCcamGeneral(self, html): |
if html.__contains__('<BR><BR>'): |
idx = html.index('<BR><BR>') |
idx2 = html.index('<BR></BODY>') |
html = html[idx+8:idx2].replace('<BR>', 'n').replace('nn', 'n') |
self.infoToShow = html |
getPage(self.url +'/shares').addCallback(self.showCCcamGeneral2).addErrback(self.getWebpageError) |
else: |
self.showInfo(_('Error reading webpage!'), _('Error')) |
defshowCCcamGeneral2(self, html): |
if html.__contains__('Welcome to CCcam'): |
idx = html.index('Welcome to CCcam') |
html = html[idx+17:] |
idx = html.index('') |
version = html[:idx] |
self.infoToShow ='%s%sn%s'% (_('Version: '), version, self.infoToShow) |
if html.__contains__('Available shares:'): |
idx = html.index('Available shares:') |
html = html[idx+18:] |
idx = html.index('n') |
html = html[:idx] |
self.showInfo(translateBlock('%s%sn%s'% (_('Available shares:'), html, self.infoToShow)), _('General')) |
else: |
self.showInfo(translateBlock(self.infoToShow), _('General')) |
defshowCCcamClients(self, html): |
firstLine =True |
clientList = [] |
infoList = [] |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >8: |
username = list[1].replace('', '') |
if username !='': |
hostname = list[2].replace('', '') |
connected = list[3].replace('', '') |
idleTime = list[4].replace('', '') |
ecm = list[5].replace('', '') |
emm = list[6].replace('', '') |
version = list[7].replace('', '') |
share = list[8].replace('', '') |
if version '': |
version ='N/A' |
ecmEmm ='ECM: '+ ecm +' - EMM: '+ emm |
infoList.append([username, _('Hostname: ') + hostname, _('Connected: ') + connected, _('Idle Time: ') + idleTime, _('Version: ') + version, _('Last used share: ') + share, ecmEmm]) |
clientList.append(username) |
self.set_title = _('CCcam Client Info') |
self.openSubMenu(clientList, infoList, self.set_title) |
defshowCCcamServers(self, html): |
firstLine =True |
infoList = [] |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >7: |
hostname = list[1].replace('', '') |
if hostname !='': |
connected = list[2].replace('', '') |
type= list[3].replace('', '') |
version = list[4].replace('', '') |
nodeid = list[5].replace('', '') |
cards = list[6].replace('', '') |
if version '': |
version ='N/A' |
if nodeid '': |
nodeid ='N/A' |
infoList.append([hostname, _('Cards: ') + cards, _('Type: ') +type, _('Version: ') + version, _('NodeID: ') + nodeid, _('Connected: ') + connected]) |
self.session.openWithCallback(self.workingFinished, CCcamInfoServerMenu, infoList, self.url) |
defshowCCcamShares(self, html): |
firstLine =True |
sharesList = [] |
infoList = [] |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >7: |
hostname = list[1].replace('', '') |
if hostname !='': |
type= list[2].replace('', '') |
caid = list[3].replace('', '') |
system = list[4].replace('', '') |
string = list[6] |
while string.startswith(''): |
string = string[1:] |
while string.endswith(''): |
string = string[:-1] |
idx = string.index('') |
uphops = string[:idx] |
string = string[idx+1:] |
while string.startswith(''): |
string = string[1:] |
maxdown = string |
iflen(caid) 3: |
caid ='0'+ caid |
infoList.append([hostname, _('Type: ') +type, _('CaID: ') + caid, _('System: ') + system, _('Uphops: ') + uphops, _('Maxdown: ') + maxdown]) |
sharesList.append(hostname +' - '+ _('CaID: ') + caid) |
self.set_title = _('CCcam Shares Info') |
self.openSubMenu(sharesList, infoList, self.set_title) |
defshowCCcamProviders(self, html): |
firstLine =True |
providersList = [] |
infoList = [] |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >5: |
caid = list[1].replace('', '') |
if caid !='': |
provider = list[2].replace('', '') |
providername = list[3].replace('', '') |
system = list[4].replace('', '') |
infoList.append([_('CaID: ') + caid, _('Provider: ') + provider, _('Provider Name: ') + providername, _('System: ') + system]) |
providersList.append(_('CaID: ') + caid +' - '+ _('Provider: ') + provider) |
self.set_title = _('CCcam Provider Info') |
self.openSubMenu(providersList, infoList, self.set_title) |
defshowCCcamEntitlements(self, html): |
if html.__contains__('<PRE>'): |
idx = html.index('<PRE>') |
idx2 = html.index('</PRE>') |
html = html[idx+5:idx2].replace('nn', 'n') |
if html '': |
html = _('No card inserted!') |
self.showInfo(translateBlock(html), _('Entitlements')) |
else: |
self.showInfo(_('Error reading webpage!'), _('Entitlements')) |
defshowInfo(self, info, set_title): |
self.session.openWithCallback(self.workingFinished, CCcamInfoInfoScreen, info, set_title) |
defopenSubMenu(self, list, infoList, set_title): |
self.session.openWithCallback(self.workingFinished, CCcamInfoSubMenu, list, infoList, set_title) |
defworkingFinished(self, callback=None): |
self.working =False |
defshowFreeMemory(self, result, retval, extra_args): |
if retval 0: |
if result.__contains__('Total:'): |
idx = result.index('Total:') |
result = result[idx+6:] |
tmpList = result.split('') |
list= [] |
for x in tmpList: |
if x !='': |
list.append(x) |
self.showInfo('%snn%s%sn%s%sn%s%s'% (_('Free memory:'), _('Total:'), list[0], _('Used:'), list[1], _('Free:'), list[2]), _('Free memory')) |
else: |
self.showInfo(result, _('Free memory')) |
else: |
self.showInfo(str(result), _('Free memory')) |
############################################################# |
classCCcamInfoEcmInfoSelection(Screen): |
def__init__(self, session): |
Screen.__init__(self, session) |
Screen.setTitle(self, _('CCcam ECM Info')) |
list= [] |
tmp = listdir('/tmp/') |
for x in tmp: |
if x.endswith('.info') and x.startswith('ecm'): |
list.append(x) |
self['list'] = MenuList(list) |
self['actions'] = ActionMap(['CCcamInfoActions'], {'ok': self.ok, 'cancel': self.close}, -1) |
defok(self): |
self.close(self['list'].getCurrent()) |
############################################################# |
classCCcamInfoInfoScreen(Screen): |
def__init__(self, session, info, set_title): |
Screen.__init__(self, session) |
Screen.setTitle(self, set_title) |
self['text'] = ScrollLabel(info) |
self['actions'] = ActionMap(['CCcamInfoActions'], |
{ |
'ok': self.close, |
'cancel': self.close, |
'up': self['text'].pageUp, |
'down': self['text'].pageDown, |
'left': self['text'].pageUp, |
'right': self['text'].pageDown, |
}, -1) |
self['key_red'] = Label(_('Cancel')) |
self['shortcuts'] = ActionMap(['ShortcutActions'], |
{ |
'red': self.close, |
}) |
############################################################# |
classCCcamShareViewMenu(Screen, HelpableScreen): |
def__init__(self, session, url): |
Screen.__init__(self, session) |
HelpableScreen.__init__(self) |
self.session = session |
Screen.setTitle(self, _('CCcam Share Info')) |
self.url = url |
self.list = [] |
self.providers = {} |
self.uphop =-1 |
self.working =True |
self['list'] = CCcamShareViewList([]) |
self['uphops'] = Label() |
self['cards'] = Label() |
self['providers'] = Label() |
self['reshare'] = Label() |
self['title'] = Label() |
self['actions'] = HelpableNumberActionMap(self, 'CCcamInfoActions', |
{ |
'cancel': (self.exit, _('close share view')), |
'0': (self.getUphop, _('show cards with uphop 0')), |
'1': (self.getUphop, _('show cards with uphop 1')), |
'2': (self.getUphop, _('show cards with uphop 2')), |
'3': (self.getUphop, _('show cards with uphop 3')), |
'4': (self.getUphop, _('show cards with uphop 4')), |
'5': (self.getUphop, _('show cards with uphop 5')), |
'6': (self.getUphop, _('show cards with uphop 6')), |
'7': (self.getUphop, _('show cards with uphop 7')), |
'8': (self.getUphop, _('show cards with uphop 8')), |
'9': (self.getUphop, _('show cards with uphop 9')), |
'green': (self.showAll, _('show all cards')), |
'incUphop': (self.incUphop, _('increase uphop by 1')), |
'decUphop': (self.decUphop, _('decrease uphop by 1')), |
'ok': (self.getServer, _('get the cards' server')), |
}, -1) |
self.onLayoutFinish.append(self.getProviders) |
self['key_red'] = Label(_('Cancel')) |
self['actions'] = ActionMap(['CCcamInfoActions'], {'cancel': self.close, 'red': self.close}, -1) |
defexit(self): |
ifnotself.working: |
self.close() |
defgetProviders(self): |
getPage(self.url +'/providers').addCallback(self.readProvidersCallback).addErrback(self.readError) |
defreadError(self, error=None): |
self.session.open(MessageBox, _('Error reading webpage!'), MessageBox.TYPE_ERROR) |
self.working =False |
defreadSharesCallback(self, html): |
firstLine =True |
providerList = [] |
countList = [] |
shareList = [] |
reshareList = [] |
self.hostList = [] |
self.caidList = [] |
count =0 |
totalcards =0 |
totalproviders =0 |
resharecards =0 |
numberofreshare =0 |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >7: |
hostname = list[1].replace('', '') |
if hostname !='': |
ifself.uphop -1: |
caid = list[3].replace('', '') |
provider = list[5].replace('', '') |
caidprovider =self.formatCaidProvider(caid, provider) |
string = list[6] |
while string.startswith(''): |
string = string[1:] |
while string.endswith(''): |
string = string[:-1] |
idx = string.index('') |
maxdown = string[idx+1:] |
while maxdown.startswith(''): |
maxdown = maxdown[1:] |
down = maxdown |
if caidprovider notin providerList: |
providerList.append(caidprovider) |
count =1 |
countList.append(count) |
numberofcards = count |
providername =self.providers.get(caidprovider, 'Multiple Providers given') |
#if providername 'Multiple Providers given': |
# print caidprovider |
numberofreshare =0 |
ifint(down)>0: |
resharecards +=1 |
numberofreshare =1 |
reshareList.append(numberofreshare) |
shareList.append(CCcamShareViewListEntry(caidprovider, providername, str(numberofcards), str(numberofreshare))) |
self.list.append([caidprovider, providername, numberofcards, numberofreshare]) |
totalproviders +=1 |
elif caidprovider in providerList: |
i = providerList.index(caidprovider) |
count = countList[i] |
count +=1 |
countList[i] = count |
numberofcards = count |
ifint(down)>0: |
reshare = reshareList[i] |
reshare +=1 |
reshareList[i] = reshare |
numberofreshare =0 |
numberofreshare = reshare |
resharecards +=1 |
elifint(down)0: |
numberofreshare = reshareList[i] |
providername =self.providers.get(caidprovider, 'Multiple Providers given') |
shareList[i] = CCcamShareViewListEntry(caidprovider, providername, str(numberofcards), str(numberofreshare)) |
self.hostList.append(hostname) |
self.caidList.append(caidprovider) |
totalcards +=1 |
ulevel = _('All') |
else: |
updown = list[6] |
while updown.startswith(''): |
updown = updown[1:] |
while updown.endswith(''): |
updown = updown[:-1] |
idx = updown.index('') |
up = updown[:idx] |
maxdown = updown[idx+1:] |
while maxdown.startswith(''): |
maxdown = maxdown[1:] |
down = maxdown |
ulevel =str(self.uphop) |
ifint(up) self.uphop: |
caid = list[3].replace('', '') |
provider = list[5].replace('', '') |
caidprovider =self.formatCaidProvider(caid, provider) |
if caidprovider notin providerList: |
providerList.append(caidprovider) |
count =1 |
countList.append(count) |
numberofcards = count |
providername =self.providers.get(caidprovider, 'Multiple Providers given') |
#if providername 'Multiple Providers given': |
# print caidprovider |
numberofreshare =0 |
ifint(down)>0: |
resharecards +=1 |
numberofreshare =1 |
reshareList.append(numberofreshare) |
shareList.append(CCcamShareViewListEntry(caidprovider, providername, str(numberofcards), str(numberofreshare))) |
self.list.append([caidprovider, providername, numberofcards, numberofreshare]) |
totalproviders +=1 |
elif caidprovider in providerList: |
i = providerList.index(caidprovider) |
count = countList[i] |
count +=1 |
countList[i] = count |
numberofcards = count |
ifint(down)>0: |
reshare = reshareList[i] |
reshare +=1 |
#if caidprovider '05021700': |
# print 're: %d' %(reshare) |
reshareList[i] = reshare |
numberofreshare =0 |
numberofreshare = reshare |
resharecards +=1 |
elifint(down)0: |
numberofreshare = reshareList[i] |
providername =self.providers.get(caidprovider, 'Multiple Providers given') |
shareList[i] = CCcamShareViewListEntry(caidprovider, providername, str(numberofcards), str(numberofreshare)) |
self.hostList.append(hostname) |
self.caidList.append(caidprovider) |
totalcards +=1 |
#maxdown = list[6] |
#while maxdown.startswith(' '): |
#maxdown = maxdown[1:] |
#down = maxdown |
#if int(down)>0: |
#resharecards +=1 |
self.instance.setTitle('%s (%s%d) %s%s'% (_('Share View'), _('Total cards:'), totalcards, _('Hops:'), ulevel)) |
self['title'].setText('%s (%s%d) %s%s'% (_('Share View'), _('Total cards:'), totalcards, _('Hops:'), ulevel)) |
self['list'].setList(shareList) |
self['uphops'].setText('%s%s'%(_('Hops:'), ulevel)) |
self['cards'].setText('%s%s'%(_('Total cards:'), totalcards)) |
self['providers'].setText('%s%s'%(_('Providers:'), totalproviders)) |
self['reshare'].setText('%s%d'%(_('Reshare:'), resharecards)) |
self.working =False |
defreadProvidersCallback(self, html): |
firstLine =True |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >5: |
caid = list[1].replace('', '') |
if caid !='': |
provider = list[2].replace('', '') |
providername = list[3] |
caidprovider =self.formatCaidProvider(caid, provider) |
self.providers.setdefault(caidprovider, providername) |
getPage(self.url +'/shares').addCallback(self.readSharesCallback).addErrback(self.readError) |
defformatCaidProvider(self, caid, provider): |
pos = provider.find(',') |
if pos !=-1: |
provider = provider[pos+1:] |
pos = provider.find(',') |
if pos !=-1: |
provider = provider[0:pos] |
iflen(provider) 0: |
provider ='0000' |
eliflen(provider) 1: |
provider ='000'+ provider |
eliflen(provider) 2: |
provider ='00'+ provider |
eliflen(provider) 3: |
provider ='0'+ provider |
iflen(caid) 3: |
caid ='0'+ caid |
if caid.startswith('0500') andlen(provider) 5: |
caid ='050' |
elif caid.startswith('0500') andlen(provider) 6: |
caid ='05' |
if caid.startswith('06'): |
caidprovider = caid |
elif caid.startswith('0d22'): |
caidprovider = caid |
elif caid.startswith('0d05'): |
caidprovider = caid |
elif caid.startswith('09'): |
caidprovider = caid |
elif caid.startswith('17'): |
caidprovider = caid |
elif caid.startswith('18'): |
caidprovider = caid |
elif caid.startswith('4a'): |
caidprovider = caid |
else: |
caidprovider = caid + provider |
return caidprovider |
defgetUphop(self, uphop): |
self.uphop = uphop |
self.getProviders() |
defshowAll(self): |
self.uphop =-1 |
self.getProviders() |
defincUphop(self): |
ifself.uphop <9: |
self.uphop +=1 |
self.getProviders() |
defdecUphop(self): |
ifself.uphop >-1: |
self.uphop -=1 |
self.getProviders() |
defgetServer(self): |
server = _('Servers:') +'n' |
sel =self['list'].getCurrent() |
if sel isnotNone: |
e =0 |
while e <len(self.caidList): |
if sel[0][0] self.caidList[e]: |
pos =self.hostList[e].find(':') |
if pos !=-1: |
server +=self.hostList[e][0:pos] +'n' |
else: |
server +=self.hostList[e] +'n' |
e +=1 |
self.session.open(CCcamInfoInfoScreen, server, _('Servers')) |
############################################################# |
classCCcamInfoSubMenu(Screen): |
def__init__(self, session, list, infoList, set_title): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _(set_title)) |
self.infoList = infoList |
self['list'] = MenuList(list) |
self['info'] = Label() |
self['key_green'] = Label(_('info')) |
self['key_red'] = Label(_('Cancel')) |
self['actions'] = ActionMap(['CCcamInfoActions'], {'ok': self.okClicked, 'cancel': self.close, 'red': self.close, 'green': self.okClicked}, -1) |
self['list'].onSelectionChanged.append(self.showInfo) |
self.onLayoutFinish.append(self.showInfo) |
defokClicked(self): |
info =self.getInfo() |
if info !='': |
self.session.open(MessageBox, info, MessageBox.TYPE_INFO) |
defshowInfo(self): |
info =self.getInfo() |
self['info'].setText(info) |
defgetInfo(self): |
try: |
idx =self['list'].getSelectedIndex() |
info ='' |
infoList =self.infoList[idx] |
for x in infoList: |
info += x +'n' |
return info |
except: |
return'' |
############################################################# |
classCCcamInfoServerMenu(Screen): |
def__init__(self, session, infoList, url): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _('CCcam Server Info')) |
self.infoList = infoList |
self.url = url |
list= [] |
for x inself.infoList: |
if x[5].replace(_('Connected: '), '') '': #offline - red |
list.append(CCcamServerListEntry(x[0], 'red')) |
elif x[1] _('Cards: 0'): #online with no card - blue |
list.append(CCcamServerListEntry(x[0], 'blue')) |
else: #online with cards - green |
list.append(CCcamServerListEntry(x[0], 'green')) |
self['list'] = CCcamList(list) |
self['info'] = Label() |
self['key_red'] = Label(_('Cancel')) |
self['actions'] = ActionMap(['CCcamInfoActions'], {'ok': self.okClicked, 'cancel': self.close, 'red': self.close, 'green': self.okClicked}, -1) |
self['list'].onSelectionChanged.append(self.showInfo) |
self.onLayoutFinish.append(self.showInfo) |
defshowInfo(self): |
info =self.getInfo() |
self['info'].setText(info) |
defgetInfo(self): |
try: |
idx =self['list'].getSelectedIndex() |
info ='' |
infoList =self.infoList[idx] |
for x in infoList: |
info += x +'n' |
return info |
except: |
return'' |
defokClicked(self): |
sel =self['list'].getCurrent() |
if sel isnotNone: |
self.session.open(CCcamInfoShareInfo, sel[0], self.url) |
############################################################# |
classCCcamInfoRemoteBox: |
def__init__(self, name, ip, username, password, port): |
self.name = name |
self.ip = ip |
self.username = username |
self.password = password |
self.port = port |
############################################################# |
classCCcamInfoConfigMenu(ConfigListScreen, Screen): |
def__init__(self, session, profile): |
Screen.__init__(self, session) |
Screen.setTitle(self, _('CCcam Info Setup')) |
config.cccaminfo.name.value = profile.name |
config.cccaminfo.ip.value = profile.ip |
config.cccaminfo.username.value = profile.username |
config.cccaminfo.password.value = profile.password |
config.cccaminfo.port.value = profile.port |
ConfigListScreen.__init__(self, [ |
getConfigListEntry(_('Name:'), config.cccaminfo.name), |
getConfigListEntry(_('IP:'), config.cccaminfo.ip), |
getConfigListEntry(_('Username:'), config.cccaminfo.username), |
getConfigListEntry(_('Password:'), config.cccaminfo.password), |
getConfigListEntry(_('Port:'), config.cccaminfo.port)]) |
self['actions'] = ActionMap(['CCcamInfoActions'], {'ok': self.okClicked, 'cancel': self.exit}, -2) |
defokClicked(self): |
self.close(CCcamInfoRemoteBox(config.cccaminfo.name.value, config.cccaminfo.ip.value, config.cccaminfo.username.value, config.cccaminfo.password.value, config.cccaminfo.port.value)) |
defexit(self): |
self.close(None) |
############################################################# |
classCCcamInfoRemoteBoxMenu(Screen): |
def__init__(self, session): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _('CCcam Remote Info')) |
self.list = [] |
self.profiles = [] |
self['key_red'] = Label(_('Delete')) |
self['key_green'] = Label(_('New')) |
self['key_yellow'] = Label(_('Location')) |
self['key_blue'] = Label(_('Edit')) |
self['list'] = MenuList([]) |
self['actions'] = ActionMap(['CCcamInfoActions'], |
{ |
'cancel': self.exit, |
'ok': self.profileSelected, |
'red': self.delete, |
'green': self.new, |
'yellow': self.location, |
'blue': self.edit |
}, -1) |
self.onLayoutFinish.append(self.readProfiles) |
defreadProfiles(self): |
try: |
f =open(config.cccaminfo.profiles.value, 'r') |
content = f.read() |
f.close() |
except: |
content ='' |
profiles = content.split('n') |
for profile in profiles: |
if profile.__contains__('|'): |
tmp = profile.split('|') |
iflen(tmp) 5: |
name = tmp[0] |
ip = tmp[1] |
username = tmp[2] |
password = tmp[3] |
port =int(tmp[4]) |
self.list.append(name) |
self.profiles.append(CCcamInfoRemoteBox(name, ip, username, password, port)) |
self['list'].setList(self.list) |
defsaveConfigs(self): |
content ='' |
for x inself.profiles: |
content ='%sn%s|%s|%s|%s|%d'% (content, x.name, x.ip, x.username, x.password, x.port) |
try: |
f =open(config.cccaminfo.profiles.value, 'w') |
f.write(content) |
f.close() |
except: |
pass |
defexit(self): |
self.saveConfigs() |
self.close(None) |
defprofileSelected(self): |
self.saveConfigs() |
iflen(self.list) >0: |
idx =self['list'].getSelectionIndex() |
cur =self.profiles[idx] |
if cur.ip '': |
url =None |
else: |
if cur.username !=''and cur.password !='': |
url ='http://%s:%s@%s:%d'% (cur.username, cur.password, cur.ip, cur.port) |
else: |
url ='http://%s:%d'% (cur.ip, cur.port) |
self.close(url) |
defdelete(self): |
iflen(self.list) >0: |
idx =self['list'].getSelectionIndex() |
delself.list[idx] |
delself.profiles[idx] |
self['list'].setList(self.list) |
defnew(self): |
self.session.openWithCallback(self.newCallback, CCcamInfoConfigMenu, CCcamInfoRemoteBox('Profile', '192.168.2.12', '', '', 16001)) |
defnewCallback(self, callback): |
if callback: |
self.list.append(callback.name) |
self.profiles.append(callback) |
self['list'].setList(self.list) |
deflocation(self): |
self.session.openWithCallback(self.locationCallback, LocationBox) |
deflocationCallback(self, callback): |
if callback: |
config.cccaminfo.profiles.value = ('%s/CCcamInfo.profiles'%callback).replace('//', '/') |
config.cccaminfo.profiles.save() |
delself.list |
self.list = [] |
delself.profiles |
self.profiles = [] |
self.readProfiles() |
defedit(self): |
iflen(self.list) >0: |
idx =self['list'].getSelectionIndex() |
self.session.openWithCallback(self.editCallback, CCcamInfoConfigMenu, self.profiles[idx]) |
defeditCallback(self, callback): |
if callback: |
idx =self['list'].getSelectionIndex() |
delself.list[idx] |
delself.profiles[idx] |
self.list.append(callback.name) |
self.profiles.append(callback) |
self['list'].setList(self.list) |
############################################################# |
classCCcamInfoShareInfo(Screen): |
def__init__(self, session, hostname, url): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _('CCcam Share Info')) |
self.hostname = hostname |
self.url = url |
self.list = [] |
self.uphops =-1 |
self.maxdown =-1 |
self.working =True |
self['key_red'] = Label(_('Uphops +')) |
self['key_green'] = Label(_('Uphops -')) |
self['key_yellow'] = Label(_('Maxdown +')) |
self['key_blue'] = Label(_('Maxdown -')) |
self['list'] = CCcamShareList([]) |
self['actions'] = ActionMap(['CCcamInfoActions'], |
{ |
'cancel': self.exit, |
'red': self.uhopsPlus, |
'green': self.uhopsMinus, |
'yellow': self.maxdownPlus, |
'blue': self.maxdownMinus |
}, -1) |
self.onLayoutFinish.append(self.readShares) |
defexit(self): |
ifnotself.working: |
self.close() |
defreadShares(self): |
getPage(self.url +'/shares').addCallback(self.readSharesCallback).addErrback(self.readSharesError) |
defreadSharesError(self, error=None): |
self.session.open(MessageBox, _('Error reading webpage!'), MessageBox.TYPE_ERROR) |
self.working =False |
defreadSharesCallback(self, html): |
firstLine =True |
shareList = [] |
count =0 |
lines = html.split('n') |
for l in lines: |
if l.__contains__('|'): |
if firstLine: |
firstLine =False |
else: |
list= l.split('|') |
iflen(list) >7: |
hostname = list[1].replace('', '') |
if (self.hostname 'None'orself.hostname hostname) and hostname !='': |
type= list[2].replace('', '') |
caid = list[3].replace('', '') |
system = list[4].replace('', '') |
string = list[6] |
while string.startswith(''): |
string = string[1:] |
while string.endswith(''): |
string = string[:-1] |
idx = string.index('') |
uphops = string[:idx] |
string = string[idx+1:] |
while string.startswith(''): |
string = string[1:] |
maxdown = string |
iflen(caid) 3: |
caid ='0'+ caid |
shareList.append(CCcamShareListEntry(hostname, type, caid, system, uphops, maxdown)) |
self.list.append([hostname, type, caid, system, uphops, maxdown]) |
count +=1 |
ifself.uphops <0: |
textUhops = _('All') |
else: |
textUhops =str(self.uphops) |
ifself.maxdown <0: |
textMaxdown = _('All') |
else: |
textMaxdown =str(self.maxdown) |
self.instance.setTitle('%s%d (%s%s / %s%s)'% (_('Available shares:'), count, _('Uphops: '), textUhops, _('Maxdown: '), textMaxdown)) |
self['list'].setList(shareList) |
self.working =False |
defuhopsPlus(self): |
ifnotself.working: |
self.uphops +=1 |
ifself.uphops >9: |
self.uphops =-1 |
self.refreshList() |
defuhopsMinus(self): |
ifnotself.working: |
self.uphops -=1 |
ifself.uphops <-1: |
self.uphops =9 |
self.refreshList() |
defmaxdownPlus(self): |
ifnotself.working: |
self.maxdown +=1 |
ifself.maxdown >9: |
self.maxdown =-1 |
self.refreshList() |
defmaxdownMinus(self): |
ifnotself.working: |
self.maxdown -=1 |
ifself.maxdown <-1: |
self.maxdown =9 |
self.refreshList() |
defrefreshList(self): |
shareList = [] |
count =0 |
self.working =True |
for x inself.list: |
(hostname, type, caid, system, uphops, maxdown) = x |
if (uphops str(self.uphops) orself.uphops -1) and (maxdown str(self.maxdown) orself.maxdown -1): |
shareList.append(CCcamShareListEntry(hostname, type, caid, system, uphops, maxdown)) |
count +=1 |
ifself.uphops <0: |
textUhops = _('All') |
else: |
textUhops =str(self.uphops) |
ifself.maxdown <0: |
textMaxdown = _('All') |
else: |
textMaxdown =str(self.maxdown) |
self.instance.setTitle('%s%d (%s%s / %s%s)'% (_('Available shares:'), count, _('Uphops: '), textUhops, _('Maxdown: '), textMaxdown)) |
self['list'].setList(shareList) |
self.working =False |
############################################################# |
classCCcamInfoConfigSwitcher(Screen): |
def__init__(self, session): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _('CCcam Config Switcher')) |
self['key_red'] = Label(_('Delete')) |
self['key_green'] = Label(_('Activate')) |
self['key_yellow'] = Label(_('Rename')) |
self['key_blue'] = Label(_('Content')) |
self['list'] = CCcamConfigList([]) |
self['actions'] = ActionMap(['CCcamInfoActions'], |
{ |
'ok': self.activate, |
'cancel': self.close, |
'red': self.delete, |
'green': self.activate, |
'yellow': self.rename, |
'blue': self.showContent |
}, -1) |
self.onLayoutFinish.append(self.showConfigs) |
defshowConfigs(self): |
list= [] |
try: |
files = listdir('/var/etc') |
except: |
files = [] |
forfilein files: |
iffile.startswith('CCcam_') andfile.endswith('.cfg'): |
list.append(CCcamConfigListEntry('/var/etc/'+file)) |
self['list'].setList(list) |
defdelete(self): |
fileName =self['list'].getCurrent() |
if fileName isnotNone: |
self.fileToDelete = fileName[0] |
self.session.openWithCallback(self.deleteConfirmed, MessageBox, (_('Delete %s?') %self.fileToDelete)) |
defdeleteConfirmed(self, yesno): |
if yesno: |
remove(self.fileToDelete) |
if fileExists(self.fileToDelete): |
self.session.open(MessageBox, _('Delete failed!'), MessageBox.TYPE_ERROR) |
else: |
self.session.open(MessageBox, _('Deleted %s!') %self.fileToDelete, MessageBox.TYPE_INFO) |
self.showConfigs() |
defactivate(self): |
fileName =self['list'].getCurrent() |
if fileName isnotNone: |
fileName = fileName[0] |
# Delete old backup |
backupFile ='%s.backup'%CFG |
if fileExists(backupFile): |
remove(backupFile) |
# Create a backup of the original /var/etc/CCcam.cfg file |
rename(CFG, backupFile) |
# Now copy the selected cfg file |
system('cp -f %s%s'% (fileName, CFG)) |
self.showConfigs() |
defrename(self): |
fileName =self['list'].getCurrent() |
if fileName isnotNone: |
self.fileToRename = fileName[0] |
(name, sel) = getConfigNameAndContent(self.fileToRename) |
self.session.openWithCallback(self.renameCallback, VirtualKeyBoard, title=_('Rename to:'), text=name) |
defrenameCallback(self, callback): |
if callback isnotNone: |
try: |
f =open(self.fileToRename, 'r') |
content = f.read() |
f.close() |
except: |
content =None |
if content isnotNone: |
content = content.replace('r', 'n') |
if content.startswith('#CONFIGFILE NAME=') and content.__contains__('n'): |
idx = content.index('n') |
content = content[:idx+2] |
content ='#CONFIGFILE NAME=%sn%s'% (callback, content) |
try: |
f =open(self.fileToRename, 'w') |
f.write(content) |
f.close() |
self.session.open(MessageBox, _('Renamed %s!') %self.fileToRename, MessageBox.TYPE_INFO) |
self.showConfigs() |
except: |
self.session.open(MessageBox, _('Rename failed!'), MessageBox.TYPE_ERROR) |
else: |
self.session.open(MessageBox, _('Rename failed!'), MessageBox.TYPE_ERROR) |
defshowContent(self): |
fileName =self['list'].getCurrent() |
if fileName isnotNone: |
try: |
f =open(fileName[0], 'r') |
content = f.read() |
f.close() |
except: |
content = _('Could not open the file %s!') % fileName[0] |
self.session.open(CCcamInfoInfoScreen, content, _('CCcam Config Switcher')) |
############################################################# |
classCCcamInfoMenuConfig(Screen): |
def__init__(self, session): |
Screen.__init__(self, session) |
self.session = session |
Screen.setTitle(self, _('CCcam Info Config')) |
self['key_red'] = Label(_('Cancel')) |
self['key_green'] = Label(_('Save')) |
self['key_yellow'] = Label(_('Location')) |
self['list'] = CCcamConfigList([]) |
self.getBlacklistedMenuEntries() |
self['actions'] = ActionMap(['CCcamInfoActions'], |
{ |
'ok': self.changeState, |
'cancel': self.close, |
'red': self.close, |
'green': self.save, |
'yellow': self.location |
}, -1) |
self.onLayoutFinish.append(self.showConfigs) |
defgetBlacklistedMenuEntries(self): |
try: |
f =open(config.cccaminfo.blacklist.value, 'r') |
content = f.read() |
f.close() |
self.blacklisted = content.split('n') |
except: |
self.blacklisted = [] |
defchangeState(self): |
cur =self['list'].getCurrent() |
if cur isnotNone: |
cur = cur[0] |
if cur inself.blacklisted: |
idx =0 |
for x inself.blacklisted: |
if x cur: |
delself.blacklisted[idx] |
break |
idx +=1 |
else: |
self.blacklisted.append(cur) |
self.showConfigs() |
defshowConfigs(self): |
list= [] |
for x in menu_list: |
if x != _('Menu config'): |
if x inself.blacklisted: |
list.append(CCcamMenuConfigListEntry(x, True)) |
else: |
list.append(CCcamMenuConfigListEntry(x, False)) |
self['list'].setList(list) |
defsave(self): |
content ='' |
for x inself.blacklisted: |
content = content + x +'n' |
content = content.replace('nn', 'n') |
try: |
f =open(config.cccaminfo.blacklist.value, 'w') |
f.write(content) |
f.close() |
self.session.open(MessageBox, _('Configfile %s saved.') % config.cccaminfo.blacklist.value, MessageBox.TYPE_INFO) |
except: |
self.session.open(MessageBox, _('Could not save configfile %s!') % config.cccaminfo.blacklist.value, MessageBox.TYPE_ERROR) |
deflocation(self): |
self.session.openWithCallback(self.locationCallback, LocationBox) |
deflocationCallback(self, callback): |
if callback: |
config.cccaminfo.blacklist.value = ('%s/CCcamInfo.blacklisted'%callback).replace('//', '/') |
config.cccaminfo.blacklist.save() |
Copy lines Copy permalink