Cccam C Line Manager Role

Permalink

Join GitHub today

CCcam C Line Tester / Description This app provides a tool to test multiple cccam lines at once. Tags: cccam tester cccam controller cccam check tool cccam checker.

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Download ultraman ginga movie sub indo.

© 2008 Stephenie Meyer 1 1. First Sight This was the time of day when I wished I were able to sleep. Or was purgatory the right word? All about stephenie meyer.

Sign up
Find file Copy path
Cannot retrieve contributors at this time
Cccam C Line Manager Role

Cccam C Line Manager Rolex

# for localized messages
import re
from os import path, makedirs, remove, rename, symlink, mkdir, listdir
from datetime import datetime
from time import time, sleep
from enigma import eTimer
from . import _, PluginLanguageDomain
import Components.Task
from Components.ActionMap import ActionMap
from Components.Label import Label
from Components.Button import Button
from Components.ScrollLabel import ScrollLabel
from Components.Pixmap import MultiPixmap
from Components.config import configfile, config, ConfigSubsection, ConfigYesNo, ConfigNumber, ConfigLocations
from Components.Console import Console
from Components.FileList import MultiFileSelectList
from Components.PluginComponent import plugins
from Components.Sources.StaticText import StaticText
from Tools.Directories import resolveFilename, SCOPE_PLUGINS
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Components.SystemInfo import SystemInfo
config.softcammanager = ConfigSubsection()
config.softcammanager.softcams_autostart = ConfigLocations(default='')
config.softcammanager.softcamtimerenabled = ConfigYesNo(default=True)
config.softcammanager.softcamtimer = ConfigNumber(default=6)
config.softcammanager.showinextensions = ConfigYesNo(default=True)
softcamautopoller =None
defupdateExtensions(configElement):
plugins.clearPluginList()
plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
config.softcammanager.showinextensions.addNotifier(updateExtensions, initial_call=False)
defSoftcamAutostart(reason, session=None, **kwargs):
''called with reason=1 to during shutdown, with reason=0 at startup?''
global softcamautopoller
if reason 0:
print'[SoftcamManager] AutoStart Enabled'
if path.exists('/tmp/SoftcamsDisableCheck'):
remove('/tmp/SoftcamsDisableCheck')
softcamautopoller = SoftcamAutoPoller()
softcamautopoller.start()
elif reason 1:
# Stop Poller
if softcamautopoller isnotNone:
softcamautopoller.stop()
softcamautopoller =None
classVIXSoftcamManager(Screen):
skin =''
<screen name='VIXSoftcamManager' position='center,center' size='560,400'>
<ePixmap pixmap='buttons/red.png' position='0,0' size='140,40' alphatest='on'/>
<ePixmap pixmap='buttons/green.png' position='140,0' size='140,40' alphatest='on'/>
<ePixmap pixmap='buttons/yellow.png' position='280,0' size='140,40' alphatest='on'/>
<ePixmap pixmap='buttons/blue.png' position='420,0' size='140,40' alphatest='on'/>
<widget name='key_red' position='0,0' zPosition='1' size='140,40' font='Regular;20' halign='center' valign='center' backgroundColor='#9f1313' transparent='1'/>
<widget name='key_green' position='140,0' zPosition='1' size='140,40' font='Regular;20' halign='center' valign='center' backgroundColor='#1f771f' transparent='1'/>
<widget name='key_yellow' position='280,0' zPosition='1' size='140,40' font='Regular;20' halign='center' valign='center' backgroundColor='#a08500' transparent='1'/>
<widget name='key_blue' position='420,0' zPosition='1' size='140,40' font='Regular;20' halign='center' valign='center' backgroundColor='#a08500' transparent='1'/>
<widget name='lab1' position='40,60' size='170,20' font='Regular; 22' halign='right' zPosition='2' transparent='0'/>
<widget name='list' position='225,60' size='240,100' transparent='0' scrollbarMode='showOnDemand'/>
<widget name='lab2' position='40,165' size='170,30' font='Regular; 22' halign='right' zPosition='2' transparent='0'/>
<widget name='activecam' position='225,166' size='240,100' font='Regular; 20' halign='left' zPosition='2' transparent='0' noWrap='1'/>
<applet type='onLayoutFinish'>
self['list'].instance.setItemHeight(25)
</applet>
</screen>''
def__init__(self, session):
Screen.__init__(self, session)
screentitle = _('Softcam manager')
self.menu_path = _('Main menu')+' / '+_('Setup')+' / '+_('Softcam')+' / '
if config.usage.show_menupath.value 'large':
self.menu_path += screentitle
title =self.menu_path
self['menu_path_compressed'] = StaticText('')
self.menu_path +=' / '
elif config.usage.show_menupath.value 'small':
title = screentitle
self['menu_path_compressed'] = StaticText(self.menu_path +' >'ifnotself.menu_path.endswith(' / ') elseself.menu_path[:-3] +' >'or'')
self.menu_path +=' / '+ screentitle
else:
title = screentitle
self['menu_path_compressed'] = StaticText('')
Screen.setTitle(self, title)
self['lab1'] = Label(_('Select:'))
self['lab2'] = Label(_('Active:'))
self['activecam'] = Label()
self.onChangedEntry = []
self.sentsingle =''
self.selectedFiles = config.softcammanager.softcams_autostart.value
self.defaultDir ='/usr/softcams/'
self.emlist = MultiFileSelectList(self.selectedFiles, self.defaultDir, showDirectories=False)
self['list'] =self.emlist
self['myactions'] = ActionMap(['ColorActions', 'OkCancelActions', 'DirectionActions', 'TimerEditActions', 'MenuActions'],
{
'ok': self.keyStart,
'cancel': self.close,
'red': self.close,
'green': self.keyStart,
'yellow': self.getRestartPID,
'blue': self.changeSelectionState,
'log': self.showLog,
'menu': self.createSetup,
}, -1)
self['key_red'] = Button(_('Close'))
self['key_green'] = Button('')
self['key_yellow'] = Button('')
self['key_blue'] = Button(_('Autostart'))
self.currentactivecam =''
self.activityTimer = eTimer()
self.activityTimer.timeout.get().append(self.getActivecam)
self.Console = Console()
self.showActivecam()
ifnotself.selectionChanged inself['list'].onSelectionChanged:
self['list'].onSelectionChanged.append(self.selectionChanged)
defcreateSummary(self):
from Screens.PluginBrowser import PluginBrowserSummary
return PluginBrowserSummary
defcreateSetup(self):
from Screens.Setup import Setup
self.session.open(Setup, 'vixsoftcammanager', 'SystemPlugins/ViX', self.menu_path, PluginLanguageDomain)
defselectionChanged(self):
cams = []
if path.exists('/usr/softcams/'):
cams = listdir('/usr/softcams')
SystemInfo['CCcamInstalled'] =False
SystemInfo['OScamInstalled'] =False
for softcam in cams:
if softcam.lower().startswith('cccam'):
SystemInfo['CCcamInstalled'] =True
elif softcam.lower().startswith('oscam'):
SystemInfo['OScamInstalled'] =True
selcam =''
if cams:
current =self['list'].getCurrent()[0]
selcam = current[0]
print'[SoftcamManager] Selectedcam: '+str(selcam)
ifself.currentactivecam.find(selcam) <0:
self['key_green'].setText(_('Start'))
else:
self['key_green'].setText(_('Stop'))
ifself.currentactivecam.find(selcam) <0:
self['key_yellow'].setText('')
else:
self['key_yellow'].setText(_('Restart'))
if current[2] isTrue:
self['key_blue'].setText(_('Disable startup'))
else:
self['key_blue'].setText(_('Enable startup'))
self.saveSelection()
desc = _('Active:') +''+self['activecam'].text
for cb inself.onChangedEntry:
cb(selcam, desc)
defchangeSelectionState(self):
cams = []
if path.exists('/usr/softcams/'):
cams = listdir('/usr/softcams')
if cams:
self['list'].changeSelectionState()
self.selectedFiles =self['list'].getSelectedList()
defsaveSelection(self):
self.selectedFiles =self['list'].getSelectedList()
config.softcammanager.softcams_autostart.value =self.selectedFiles
config.softcammanager.softcams_autostart.save()
configfile.save()
defshowActivecam(self):
scanning = _('Wait please while scanningnfor softcam's..')
self['activecam'].setText(scanning)
self.activityTimer.start(10)
defgetActivecam(self):
self.activityTimer.stop()
active = []
for x inself['list'].list:
active.append(x[0][0])
activelist =','.join(active)
if activelist:
self.Console.ePopen('ps.procps -C '+ activelist +' | grep -v 'CMD' | sed 's/</ /g' | awk '{print $4}' | awk '{a[$1] = $0} END { for (x in a) { print a[x] } }'', self.showActivecam2)
else:
self['activecam'].setText('')
self['activecam'].show()
# self.Console.ePopen('ps.procps | grep softcams | grep -v 'grep' | sed 's/</ /g' | awk '{print $5}' | awk '{a[$1] = $0} END { for (x in a) { print a[x] } }' | awk -F'[/]' '{print $4}', self.showActivecam2)
defshowActivecam2(self, result, retval, extra_args):
if retval 0:
self.currentactivecamtemp = result
self.currentactivecam =''.join([s for s inself.currentactivecamtemp.splitlines(True) if s.strip('rn')])
self.currentactivecam =self.currentactivecam.replace('n', ', ')
print'[SoftcamManager] Active: '+self.currentactivecam.replace('n', ', ')
if path.exists('/tmp/SoftcamsScriptsRunning'):
file=open('/tmp/SoftcamsScriptsRunning')
SoftcamsScriptsRunning =file.read()
file.close()
SoftcamsScriptsRunning = SoftcamsScriptsRunning.replace('n', ', ')
self.currentactivecam += SoftcamsScriptsRunning
self['activecam'].setText(self.currentactivecam)
self['activecam'].show()
else:
print'[SoftcamManager] RESULT FAILED: '+str(result)
self.selectionChanged()
defkeyStart(self):
cams = []
if path.exists('/usr/softcams/'):
cams = listdir('/usr/softcams')
if cams:
self.sel =self['list'].getCurrent()[0]
selcam =self.sel[0]
ifself.currentactivecam.find(selcam) <0:
if selcam.lower().startswith('cccam'):
ifnot path.exists('/etc/CCcam.cfg'):
self.session.open(MessageBox, _('No config files found, please setup CCcam firstnin /etc/CCcam.cfg.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
ifself.currentactivecam.lower().find('mgcam') <0:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
else:
self.session.open(MessageBox, _('CCcam can't run whilst MGcamd is running'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
elif selcam.lower().startswith('hypercam'):
ifnot path.exists('/etc/hypercam.cfg'):
self.session.open(MessageBox, _('No config files found, please setup Hypercam firstnin /etc/hypercam.cfg.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elif selcam.lower().startswith('oscam'):
ifnot path.exists('/etc/tuxbox/config/oscam.conf'):
self.session.open(MessageBox, _('No config files found, please setup Oscam firstnin /etc/tuxbox/config'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elif selcam.lower().startswith('mgcam'):
ifnot path.exists('/var/keys/mg_cfg'):
ifself.currentactivecam.lower().find('cccam') <0:
self.session.open(MessageBox, _('No config files found, please setup MGcamd firstnin /usr/keys.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
self.session.open(MessageBox, _('MGcamd can't run whilst CCcam is running.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elif selcam.lower().startswith('scam'):
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
else:
self.session.open(MessageBox, _('Found non-standard softcam, trying to start, this may fail.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
else:
self.session.openWithCallback(self.showActivecam, VIXStopCam, self.sel[0])
defgetRestartPID(self):
cams = []
if path.exists('/usr/softcams/'):
cams = listdir('/usr/softcams')
if cams:
self.sel =self['list'].getCurrent()[0]
selectedcam =self.sel[0]
self.Console.ePopen('pidof '+ selectedcam, self.keyRestart, selectedcam)
defkeyRestart(self, result, retval, extra_args):
selectedcam = extra_args
strpos =self.currentactivecam.find(selectedcam)
if strpos <0:
return
else:
if retval 0:
stopcam =str(result)
print'[SoftcamManager] Stopping '+ selectedcam +' PID '+ stopcam.replace('n', '')
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Stopping: '+ selectedcam +'n')
output.close()
self.Console.ePopen('kill -9 '+ stopcam.replace('n', ''))
sleep(4)
else:
print'[SoftcamManager] RESULT FAILED: '+str(result)
if selectedcam.lower().startswith('cccam') and path.exists('/etc/CCcam.cfg') True:
ifself.currentactivecam.lower().find('mgcam') <0:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
else:
self.session.open(MessageBox, _('CCcam can't run whilst MGcamd is running.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
elif selectedcam.lower().startswith('cccam') and path.exists('/etc/CCcam.cfg') False:
self.session.open(MessageBox, _('No config files found, please setup CCcam firstnin /etc/CCcam.cfg.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
elif selectedcam.lower().startswith('oscam') and path.exists('/etc/tuxbox/config/oscam.conf') True:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elif selectedcam.lower().startswith('oscam') and path.exists('/etc/tuxbox/config/oscam.conf') False:
ifnot path.exists('/etc/tuxbox/config'):
makedirs('/etc/tuxbox/config')
self.session.open(MessageBox, _('No config files found, please setup Oscam firstnin /etc/tuxbox/config.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
elif selectedcam.lower().startswith('mgcam') and path.exists('/var/keys/mg_cfg') True:
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elif selectedcam.lower().startswith('mgcam') and path.exists('/var/keys/mg_cfg') False:
ifself.currentactivecam.lower().find('cccam') <0:
self.session.open(MessageBox, _('No config files found, please setup MGcamd firstnin /usr/keys.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
else:
self.session.open(MessageBox, _('MGcamd can't run whilst CCcam is running.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
elif selectedcam.lower().startswith('scam'):
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
elifnot selectedcam.lower().startswith('cccam') or selectedcam.lower().startswith('oscam') or selectedcam.lower().startswith('mgcamd'):
self.session.open(MessageBox, _('Found non-standard softcam, trying to start, this may fail.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
self.session.openWithCallback(self.showActivecam, VIXStartCam, self.sel[0])
defshowLog(self):
self.session.open(VIXSoftcamLog, self.menu_path)
defmyclose(self):
self.close()
classVIXStartCam(Screen):
skin =''
<screen name='VIXStartCam' position='center,center' size='484, 150'>
<widget name='connect' position='217, 0' size='64,64' zPosition='2' pixmaps='ViX_HD_Common/busy/busy1.png,ViX_HD_Common/busy/busy2.png,ViX_HD_Common/busy/busy3.png,ViX_HD_Common/busy/busy4.png,ViX_HD_Common/busy/busy5.png,ViX_HD_Common/busy/busy6.png,ViX_HD_Common/busy/busy7.png,ViX_HD_Common/busy/busy8.png,ViX_HD_Common/busy/busy9.png,ViX_HD_Common/busy/busy9.png,ViX_HD_Common/busy/busy10.png,ViX_HD_Common/busy/busy11.png,ViX_HD_Common/busy/busy12.png,ViX_HD_Common/busy/busy13.png,ViX_HD_Common/busy/busy14.png,ViX_HD_Common/busy/busy15.png,ViX_HD_Common/busy/busy17.png,ViX_HD_Common/busy/busy18.png,ViX_HD_Common/busy/busy19.png,ViX_HD_Common/busy/busy20.png,ViX_HD_Common/busy/busy21.png,ViX_HD_Common/busy/busy22.png,ViX_HD_Common/busy/busy23.png,ViX_HD_Common/busy/busy24.png' transparent='1' alphatest='blend'/>
<widget name='lab1' position='10, 80' halign='center' size='460, 60' zPosition='1' font='Regular;20' valign='top' transparent='1'/>
</screen>''
def__init__(self, session, selectedcam):
Screen.__init__(self, session)
Screen.setTitle(self, _('Softcam starting..'))
self['connect'] = MultiPixmap()
self['lab1'] = Label(_('Please wait while startingn') + selectedcam +'..')
global startselectedcam
startselectedcam = selectedcam
self.Console = Console()
self.activityTimer = eTimer()
self.activityTimer.timeout.get().append(self.updatepix)
self.onShow.append(self.startShow)
self.onClose.append(self.delTimer)
defstartShow(self):
self.curpix =0
self.count =0
self['connect'].setPixmapNum(0)
if startselectedcam.endswith('.sh'):
if path.exists('/tmp/SoftcamsScriptsRunning'):
file=open('/tmp/SoftcamsScriptsRunning')
data =file.read()
file.close()
if data.find(startselectedcam) >=0:
filewrite =open('/tmp/SoftcamsScriptsRunning.tmp', 'w')
fileread =open('/tmp/SoftcamsScriptsRunning')
filewrite.writelines([l for l in fileread.readlines() if startselectedcam notin l])
fileread.close()
filewrite.close()
rename('/tmp/SoftcamsScriptsRunning.tmp', '/tmp/SoftcamsScriptsRunning')
elif data.find(startselectedcam) <0:
fileout =open('/tmp/SoftcamsScriptsRunning', 'a')
line = startselectedcam +'n'
fileout.write(line)
fileout.close()
else:
fileout =open('/tmp/SoftcamsScriptsRunning', 'w')
line = startselectedcam +'n'
fileout.write(line)
fileout.close()
print'[SoftcamManager] Starting '+ startselectedcam
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Starting '+ startselectedcam +'n')
output.close()
self.Console.ePopen('/usr/softcams/'+ startselectedcam +' start')
else:
if path.exists('/tmp/SoftcamsDisableCheck'):
file=open('/tmp/SoftcamsDisableCheck')
data =file.read()
file.close()
if data.find(startselectedcam) >=0:
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Initialised timed check for '+ stopselectedcam +'n')
output.close()
fileread =open('/tmp/SoftcamsDisableCheck')
filewrite =open('/tmp/SoftcamsDisableCheck.tmp', 'w')
filewrite.writelines([l for l in fileread.readlines() if startselectedcam notin l])
fileread.close()
filewrite.close()
rename('/tmp/SoftcamsDisableCheck.tmp', '/tmp/SoftcamsDisableCheck')
print'[SoftcamManager] Starting '+ startselectedcam
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Starting '+ startselectedcam +'n')
output.close()
if startselectedcam.lower().startswith('hypercam'):
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ startselectedcam +' -c /etc/hypercam.cfg')
elif startselectedcam.lower().startswith('oscam'):
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ startselectedcam +' -b')
elif startselectedcam.lower().startswith('gbox'):
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ startselectedcam)
sleep(3)
self.Console.ePopen('start-stop-daemon --start --quiet --background --exec /usr/bin/gbox')
else:
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ startselectedcam)
self.activityTimer.start(1)
defupdatepix(self):
self.activityTimer.stop()
if startselectedcam.lower().startswith('cccam'):
ifself.curpix >23:
self.curpix =0
ifself.count >120:
self.curpix =23
self['connect'].setPixmapNum(self.curpix)
ifself.count 120: # timer on screen
self.hide()
self.close()
self.activityTimer.start(120) # cycle speed
self.curpix +=1
self.count +=1
else:
ifself.curpix >23:
self.curpix =0
ifself.count >23:
self.curpix =0
self['connect'].setPixmapNum(self.curpix)
ifself.count 25: # timer on screen
self.hide()
self.close()
self.activityTimer.start(120) # cycle speed
self.curpix +=1
self.count +=1
defdelTimer(self):
delself.activityTimer
classVIXStopCam(Screen):
skin =''
<screen name='VIXStopCam' position='center,center' size='484, 150'>
<widget name='connect' position='217, 0' size='64,64' zPosition='2' pixmaps='ViX_HD_Common/busy/busy1.png,ViX_HD_Common/busy/busy2.png,ViX_HD_Common/busy/busy3.png,ViX_HD_Common/busy/busy4.png,ViX_HD_Common/busy/busy5.png,ViX_HD_Common/busy/busy6.png,ViX_HD_Common/busy/busy7.png,ViX_HD_Common/busy/busy8.png,ViX_HD_Common/busy/busy9.png,ViX_HD_Common/busy/busy9.png,ViX_HD_Common/busy/busy10.png,ViX_HD_Common/busy/busy11.png,ViX_HD_Common/busy/busy12.png,ViX_HD_Common/busy/busy13.png,ViX_HD_Common/busy/busy14.png,ViX_HD_Common/busy/busy15.png,ViX_HD_Common/busy/busy17.png,ViX_HD_Common/busy/busy18.png,ViX_HD_Common/busy/busy19.png,ViX_HD_Common/busy/busy20.png,ViX_HD_Common/busy/busy21.png,ViX_HD_Common/busy/busy22.png,ViX_HD_Common/busy/busy23.png,ViX_HD_Common/busy/busy24.png' transparent='1' alphatest='blend'/>
<widget name='lab1' position='10, 80' halign='center' size='460, 60' zPosition='1' font='Regular;20' valign='top' transparent='1'/>
</screen>''
def__init__(self, session, selectedcam):
Screen.__init__(self, session)
global stopselectedcam
stopselectedcam = selectedcam
Screen.setTitle(self, _('Softcam stopping..'))
self['connect'] = MultiPixmap()
self['lab1'] = Label(_('Please wait while stoppingn') + selectedcam +'..')
self.Console = Console()
self.activityTimer = eTimer()
self.activityTimer.timeout.get().append(self.updatepix)
self.onShow.append(self.getStopPID)
self.onClose.append(self.delTimer)
defgetStopPID(self):
if stopselectedcam.endswith('.sh'):
self.curpix =0
self.count =0
self['connect'].setPixmapNum(0)
print'[SoftcamManager] Stopping '+ stopselectedcam
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Stopping '+ stopselectedcam +'n')
output.close()
self.Console.ePopen('/usr/softcams/'+ stopselectedcam +' stop')
if path.exists('/tmp/SoftcamsScriptsRunning'):
remove('/tmp/SoftcamsScriptsRunning')
if path.exists('/etc/SoftcamsAutostart'):
file=open('/etc/SoftcamsAutostart')
data =file.read()
file.close()
finddata = data.find(stopselectedcam)
if data.find(stopselectedcam) >=0:
print'[SoftcamManager] Temporarily disabled timed check for '+ stopselectedcam
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Temporarily disabled timed check for '+ stopselectedcam +'n')
output.close()
fileout =open('/tmp/SoftcamsDisableCheck', 'a')
line = stopselectedcam +'n'
fileout.write(line)
fileout.close()
self.activityTimer.start(1)
else:
self.Console.ePopen('pidof '+ stopselectedcam, self.startShow)
defstartShow(self, result, retval, extra_args):
if retval 0:
self.curpix =0
self.count =0
self['connect'].setPixmapNum(0)
stopcam =str(result)
if path.exists('/etc/SoftcamsAutostart'):
file=open('/etc/SoftcamsAutostart')
data =file.read()
file.close()
finddata = data.find(stopselectedcam)
if data.find(stopselectedcam) >=0:
print'[SoftcamManager] Temporarily disabled timed check for '+ stopselectedcam
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Temporarily disabled timed check for '+ stopselectedcam +'n')
output.close()
fileout =open('/tmp/SoftcamsDisableCheck', 'a')
line = stopselectedcam +'n'
fileout.write(line)
fileout.close()
print'[SoftcamManager] Stopping '+ stopselectedcam +' PID '+ stopcam.replace('n', '')
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Stopping '+ stopselectedcam +'n')
output.close()
self.Console.ePopen('kill -9 '+ stopcam.replace('n', ''))
self.activityTimer.start(1)
defupdatepix(self):
self.activityTimer.stop()
ifself.curpix >23:
self.curpix =0
ifself.count >23:
self.curpix =0
self['connect'].setPixmapNum(self.curpix)
ifself.count 25: # timer on screen
self.hide()
self.close()
self.activityTimer.start(120) # cycle speed
self.curpix +=1
self.count +=1
defdelTimer(self):
delself.activityTimer
classVIXSoftcamLog(Screen):
skin =''
<screen name='VIXSoftcamLog' position='center,center' size='560,400'>
<widget name='list' position='0,0' size='560,400' font='Regular;14'/>
</screen>''
def__init__(self, session, menu_path):
self.session = session
Screen.__init__(self, session)
screentitle = _('Logs')
if config.usage.show_menupath.value 'large':
menu_path += screentitle
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)
if path.exists('/var/volatile/tmp/cam.check.log'):
file=open('/var/volatile/tmp/cam.check.log')
softcamlog =file.read()
file.close()
else:
softcamlog =''
self['list'] = ScrollLabel(str(softcamlog))
self['setupActions'] = ActionMap(['SetupActions', 'ColorActions', 'DirectionActions'],
{
'cancel': self.cancel,
'ok': self.cancel,
'up': self['list'].pageUp,
'down': self['list'].pageDown
}, -2)
defcancel(self):
self.close()
classSoftcamAutoPoller:
''Automatically Poll SoftCam''
def__init__(self):
# Init Timer
ifnot path.exists('/usr/softcams'):
mkdir('/usr/softcams', 0755)
ifnot path.exists('/etc/scce'):
mkdir('/etc/scce', 0755)
ifnot path.exists('/etc/tuxbox/config'):
mkdir('/etc/tuxbox/config', 0755)
ifnot path.islink('/var/tuxbox'):
symlink('/etc/tuxbox', '/var/tuxbox')
ifnot path.exists('/usr/keys'):
mkdir('/usr/keys', 0755)
ifnot path.islink('/var/keys'):
symlink('/usr/keys', '/var/keys')
ifnot path.islink('/etc/keys'):
symlink('/usr/keys', '/etc/keys')
ifnot path.islink('/var/scce'):
symlink('/etc/scce', '/var/scce')
self.timer = eTimer()
defstart(self):
ifself.softcam_check notinself.timer.callback:
self.timer.callback.append(self.softcam_check)
self.timer.startLongTimer(10)
defstop(self):
ifself.softcam_check inself.timer.callback:
self.timer.callback.remove(self.softcam_check)
self.timer.stop()
defsoftcam_check(self):
now =int(time())
if path.exists('/tmp/SoftcamRuningCheck.tmp'):
remove('/tmp/SoftcamRuningCheck.tmp')
if config.softcammanager.softcams_autostart:
Components.Task.job_manager.AddJob(self.createCheckJob())
if config.softcammanager.softcamtimerenabled.value:
# print '[SoftcamManager] Timer Check Enabled'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Timer Check Enabledn')
output.close()
self.timer.startLongTimer(config.softcammanager.softcamtimer.value *60)
else:
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Timer Check Disabledn')
output.close()
# print '[SoftcamManager] Timer Check Disabled'
softcamautopoller.stop()
defcreateCheckJob(self):
job = Components.Task.Job(_('SoftcamCheck'))
task = Components.Task.PythonTask(job, _('Checking softcams..'))
task.work =self.JobStart
task.weighting =1
return job
defJobStart(self):
self.autostartcams = config.softcammanager.softcams_autostart.value
self.Console = Console()
if path.exists('/tmp/cam.check.log'):
if path.getsize('/tmp/cam.check.log') >40000:
fh =open('/tmp/cam.check.log', 'rb+')
fh.seek(-40000, 2)
data = fh.read()
fh.seek(0) # rewind
fh.write(data)
fh.truncate()
fh.close()
if path.exists('/etc/CCcam.cfg'):
f =open('/etc/CCcam.cfg', 'r')
logwarn =''
for line in f.readlines():
if line.find('LOG WARNINGS') !=-1:
parts = line.strip().split()
logwarn = parts[2]
if logwarn.find(':') >=0:
logwarn = logwarn.replace(':', '')
if logwarn '':
logwarn = parts[3]
else:
logwarn =''
if path.exists(logwarn):
if path.getsize(logwarn) >40000:
fh =open(logwarn, 'rb+')
fh.seek(-40000, 2)
data = fh.read()
fh.seek(0) # rewind
fh.write(data)
fh.truncate()
fh.close()
f.close()
for softcamcheck inself.autostartcams:
softcamcheck = softcamcheck.replace('/usr/softcams/', '')
softcamcheck = softcamcheck.replace('n', '')
if softcamcheck.endswith('.sh'):
if path.exists('/tmp/SoftcamsDisableCheck'):
file=open('/tmp/SoftcamsDisableCheck')
data =file.read()
file.close()
else:
data =''
if data.find(softcamcheck) <0:
if path.exists('/tmp/SoftcamsScriptsRunning'):
file=open('/tmp/SoftcamsScriptsRunning')
data =file.read()
file.close()
if data.find(softcamcheck) <0:
fileout =open('/tmp/SoftcamsScriptsRunning', 'a')
line = softcamcheck +'n'
fileout.write(line)
fileout.close()
print'[SoftcamManager] Starting '+ softcamcheck
self.Console.ePopen('/usr/softcams/'+ softcamcheck +' start')
else:
fileout =open('/tmp/SoftcamsScriptsRunning', 'w')
line = softcamcheck +'n'
fileout.write(line)
fileout.close()
print'[SoftcamManager] Starting '+ softcamcheck
self.Console.ePopen('/usr/softcams/'+ softcamcheck +' start')
else:
if path.exists('/tmp/SoftcamsDisableCheck'):
file=open('/tmp/SoftcamsDisableCheck')
data =file.read()
file.close()
else:
data =''
if data.find(softcamcheck) <0:
import process
p = process.ProcessList()
softcamcheck_process =str(p.named(softcamcheck)).strip('[]')
if softcamcheck_process !='':
if path.exists('/tmp/frozen'):
remove('/tmp/frozen')
if path.exists('/tmp/status.html'):
remove('/tmp/status.html')
if path.exists('/tmp/index.html'):
remove('/tmp/index.html')
print'[SoftcamManager] '+ softcamcheck +' already running'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': '+ softcamcheck +' running OKn')
output.close()
if softcamcheck.lower().startswith('oscam'):
if path.exists('/tmp/status.html'):
remove('/tmp/status.html')
port =''
if path.exists('/etc/tuxbox/config/oscam.conf'):
oscamconf ='/etc/tuxbox/config/oscam.conf'
f =open(oscamconf, 'r')
for line in f.readlines():
if line.find('httpport') !=-1:
port = re.sub('D', '', line)
f.close()
print'[SoftcamManager] Checking if '+ softcamcheck +' is frozen'
if port '':
port ='16000'
self.Console.ePopen('wget -T 1 http://127.0.0.1:'+ port +'/status.html -O /tmp/status.html &> /tmp/frozen')
sleep(2)
f =open('/tmp/frozen')
frozen = f.read()
f.close()
if frozen.find('Unauthorized') !=-1or frozen.find('Authorization Required') !=-1or frozen.find('Forbidden') !=-1or frozen.find('Connection refused') !=-1or frozen.find('100%') !=-1or path.exists('/tmp/status.html'):
print'[SoftcamManager] '+ softcamcheck +' is responding like it should'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': '+ softcamcheck +' is responding like it shouldn')
output.close()
else:
print'[SoftcamManager] '+ softcamcheck +' is frozen, Restarting..'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': '+ softcamcheck +' is frozen, Restarting..n')
output.close()
print'[SoftcamManager] Stopping '+ softcamcheck
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': AutoStopping: '+ softcamcheck +'n')
output.close()
self.Console.ePopen('killall -9 '+ softcamcheck)
sleep(1)
self.Console.ePopen('ps.procps | grep softcams | grep -v grep | awk 'NR1' | awk '{print $5}'| awk -F'[/]' '{print $4}' > /tmp/oscamRuningCheck.tmp')
sleep(2)
file=open('/tmp/oscamRuningCheck.tmp')
cccamcheck_process =file.read()
file.close()
cccamcheck_process = cccamcheck_process.replace('n', '')
if cccamcheck_process.lower().find('cccam') !=-1:
try:
print'[SoftcamManager] Stopping ', cccamcheck_process
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': AutoStopping: '+ cccamcheck_process +'n')
output.close()
self.Console.ePopen('killall -9 /usr/softcams/'+str(cccamcheck_process))
except:
pass
print'[SoftcamManager] Starting '+ softcamcheck
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': AutoStarting: '+ softcamcheck +'n')
output.close()
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck +' -b')
sleep(10)
elif softcamcheck.lower().startswith('cccam'):
if path.exists('/tmp/index.html'):
remove('/tmp/index.html')
allow ='no'
port =''
f =open('/etc/CCcam.cfg', 'r')
for line in f.readlines():
if line.find('ALLOW WEBINFO') !=-1:
ifnot line.startswith('#'):
parts = line.replace('ALLOW WEBINFO', '')
parts = parts.replace(':', '')
parts = parts.replace('', '')
parts = parts.strip().split()
if parts[0].startswith('yes'):
allow = parts[0]
if line.find('WEBINFO LISTEN PORT') !=-1:
port = re.sub('D', '', line)
f.close()
if allow.lower().find('yes') !=-1:
print'[SoftcamManager] Checking if '+ softcamcheck +' is frozen'
if port '':
port ='16001'
self.Console.ePopen('wget -T 1 http://127.0.0.1:'+ port +' -O /tmp/index.html &> /tmp/frozen')
sleep(2)
f =open('/tmp/frozen')
frozen = f.read()
f.close()
if frozen.find('Unauthorized') !=-1or frozen.find('Authorization Required') !=-1or frozen.find('Forbidden') !=-1or frozen.find('Connection refused') !=-1or frozen.find('100%') !=-1or path.exists('/tmp/index.html'):
print'[SoftcamManager] '+ softcamcheck +' is responding like it should'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': '+ softcamcheck +' is responding like it shouldn')
output.close()
else:
print'[SoftcamManager] '+ softcamcheck +' is frozen, Restarting..'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': '+ softcamcheck +' is frozen, Restarting..n')
output.close()
print'[SoftcamManager] Stopping '+ softcamcheck
self.Console.ePopen('killall -9 '+ softcamcheck)
sleep(1)
print'[SoftcamManager] Starting '+ softcamcheck
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck)
elif allow.lower().find('no') !=-1:
print'[SoftcamManager] Telnet info not allowed, can not check if frozen'
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Webinfo info not allowed, can not check if frozen,ntplease enable 'ALLOW WEBINFO: YES'n')
output.close()
else:
print'[SoftcamManager] Webinfo info not setup, please enable 'ALLOW WEBINFO= YES''
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Telnet info not setup, can not check if frozen,ntplease enable 'ALLOW WEBINFO: YES'n')
output.close()
elif softcamcheck_process '':
print'[SoftcamManager] Couldn't find '+ softcamcheck +' running, Starting '+ softcamcheck
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': Couldn't find '+ softcamcheck +' running, Starting '+ softcamcheck +'n')
output.close()
if softcamcheck.lower().startswith('oscam'):
self.Console.ePopen('ps.procps | grep softcams | grep -v grep | awk 'NR1' | awk '{print $5}'| awk -F'[/]' '{print $4}' > /tmp/softcamRuningCheck.tmp')
sleep(2)
file=open('/tmp/softcamRuningCheck.tmp')
cccamcheck_process =file.read()
cccamcheck_process = cccamcheck_process.replace('n', '')
file.close()
if cccamcheck_process.find('cccam') >=0or cccamcheck_process.find('CCcam') >=0:
try:
print'[SoftcamManager] Stopping ', cccamcheck_process
output =open('/tmp/cam.check.log', 'a')
now = datetime.now()
output.write(now.strftime('%Y-%m-%d %H:%M') +': AutoStopping: '+ cccamcheck_process +'n')
output.close()
self.Console.ePopen('killall -9 /usr/softcams/'+str(cccamcheck_process))
except:
pass
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck +' -b')
sleep(10)
remove('/tmp/softcamRuningCheck.tmp')
elif softcamcheck.lower().startswith('sbox'):
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck)
sleep(7)
elif softcamcheck.lower().startswith('gbox'):
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck)
sleep(3)
self.Console.ePopen('start-stop-daemon --start --quiet --background --exec /usr/bin/gbox')
else:
self.Console.ePopen('ulimit -s 512;/usr/softcams/'+ softcamcheck)

Cccam C Line Manager Role In Agile

  • Copy lines
  • Copy permalink

Comments are closed.