Esempio n. 1
0
 def __init__(self, session, cmdList = None):
     if not cmdList:
         cmdList = []
     Screen.__init__(self, session)
     self.cmdList = cmdList
     self.sliderPackages = {}
     self.slider = Slider(0, len(cmdList))
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = Label(_('Preparing... Please wait'))
     self['status'] = self.status
     self.package = Label()
     self['package'] = self.package
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.doActivityTimer)
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.runningCmd = None
     self.runNextCmd()
     self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
      'back': self.exit}, -1)
     return
Esempio n. 2
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        ProtectedScreen.__init__(self)
        Screen.setTitle(self, _("Software update"))

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)
        self['actions'].csel = self
        self["actions"].setEnabled(False)

        self.slider = Slider(0, 100)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False
        self.updating = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.onFirstExecBegin.append(self.checkNetworkState)
Esempio n. 3
0
 def __init__(self, session, args = None):
     Screen.__init__(self, session)
     self.sliderPackages = {'ini-dvb-modules': 1,
      'enigma2': 2,
      'egami-version-info': 3}
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Verifying your internet connection...'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.doActivityTimer)
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.updating = False
     self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
      'back': self.exit}, -1)
     iNetwork.checkNetworkState(self.checkNetworkCB)
     self.onClose.append(self.cleanup)
Esempio n. 4
0
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		Screen.setTitle(self, _("Software Update"))

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.checkNetworkState()
Esempio n. 5
0
	def __init__(self, session, args = None):
		Screen.__init__(self, session)
		
		self.sliderPackages = { "Settop Box-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }
		
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Upgrading Settop Box... Please wait"))
		self["status"] = self.status
		self.package = StaticText()
		self["package"] = self.package
		
		self.packages = 0
		self.error = 0
		
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.firsttime = True
		self.onShown.append(self.confirmUpdate)
    def __init__(self, session, args=None):
        Screen.__init__(self, session)

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Upgrading Dreambox... Please wait"))
        self["status"] = self.status
        self.package = StaticText()
        self["package"] = self.package

        self.packages = 0
        self.error = 0

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)

        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

        self.firsttime = True
        self.onShown.append(self.confirmUpdate)
Esempio n. 7
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     ProtectedScreen.__init__(self)
     Screen.setTitle(self, _('Software Update'))
     self.sliderPackages = {'ini-dvb-modules': 1,
      'enigma2': 2,
      'tuxbox-image-info': 3}
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Package list update'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self['tl_off'] = Pixmap()
     self['tl_red'] = Pixmap()
     self['tl_yellow'] = Pixmap()
     self['tl_green'] = Pixmap()
     self['feedStatusMSG'] = Label()
     self.channellist_only = 0
     self.channellist_name = ''
     self.SettingsBackupDone = False
     self.ImageBackupDone = False
     self.autobackuprunning = False
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.total_packages = None
     self.onFirstExecBegin.append(self.checkNetworkState)
Esempio n. 8
0
    def __init__(self, session, cmdList=[]):
        Screen.__init__(self, session)

        self.cmdList = cmdList

        self.sliderPackages = {}

        self.slider = Slider(0, len(cmdList))
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = Label(_("Preparing... Please wait"))
        self["status"] = self.status
        self.package = Label()
        self["package"] = self.package

        self.packages = 0
        self.error = 0
        self.processed_packages = []

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)
        #self.activityTimer.start(100, False)

        self.opkg = OpkgComponent()
        self.opkg.addCallback(self.opkgCallback)

        self.runningCmd = None
        self.runNextCmd()

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)
Esempio n. 9
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))
        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()
Esempio n. 10
0
 def __init__(self, session, cmdList=None):
     if not cmdList:
         cmdList = []
     Screen.__init__(self, session)
     self.cmdList = cmdList
     self.sliderPackages = {}
     self.slider = Slider(0, len(cmdList))
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = Label(_('Preparing... Please wait'))
     self['status'] = self.status
     self.package = Label()
     self['package'] = self.package
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.doActivityTimer)
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.runningCmd = None
     self.runNextCmd()
     self['actions'] = ActionMap(['WizardActions'], {
         'ok': self.exit,
         'back': self.exit
     }, -1)
     return
Esempio n. 11
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     self.sliderPackages = {'dreambox-dvb-modules': 1,
      'enigma2': 2,
      'tuxbox-image-info': 3}
     self.setTitle(_('Software update'))
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Package list update'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.total_packages = None
     self.channellist_only = 0
     self.channellist_name = ''
     self.updating = False
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.onClose.append(self.__close)
     self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
      'back': self.exit}, -1)
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.checkTraficLight)
     self.activityTimer.callback.append(self.doActivityTimer)
     self.activityTimer.start(100, True)
Esempio n. 12
0
    def __init__(self, session, parent, timeout=20):
        Screen.__init__(self, session)
        self.session = session

        self["actions"] = ActionMap(["OkCancelActions"], {
            "ok": self.keyExit,
        }, -2)

        self.is_done = 0
        self.exit_count = 0
        self.timeout = 20
        self.title_str = "FPGA Upgrade"

        #self["name"] = Label(_("Upgrade status"))
        self["name"] = Label(" ")
        self["info"] = StaticText(_("Can't cancel during upgrade!!"))

        self["status"] = Label(_("Status : 0%"))
        self.status_bar = self["status"]

        self.slider = Slider(0, 100)
        self["slider"] = self.slider

        self.parent = parent
        self.timer_check_progress = eTimer()
        self.timer_check_progress.callback.append(self.callbackDoCheckProgress)
        interval = self.parent.FPGA.get_interval()
        self.timer_check_progress.start(interval)
        self.need_restart = False
Esempio n. 13
0
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		Screen.setTitle(self, _("Software Update"))

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		if self.isProtected() and config.ParentalControl.servicepin[0].value:
			self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList=[x.value for x in config.ParentalControl.servicepin], triesEntry=config.ParentalControl.retries.servicepin, title=_("Please enter the correct pin code"), windowTitle=_("Enter pin code")))
		else:
                        self.checkNetworkState()
Esempio n. 14
0
File: Ipkg.py Progetto: TitanNit/tdt
	def __init__(self, session, cmdList = []):
		Screen.__init__(self, session)
		
		self.cmdList = cmdList

		self.sliderPackages = {}
		
		self.slider = Slider(0, len(cmdList))
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = Label(_("Preparing... Please wait"))
		self["status"] = self.status
		self.package = Label()
		self["package"] = self.package
		
		self.packages = 0
		self.error = 0
		
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)
		#self.activityTimer.start(100, False)
				
		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)
		
		self.runningCmd = None
		self.runNextCmd()
		
		self["actions"] = ActionMap(["WizardActions"], 
		{
			"ok": self.exit, 
			"back": self.exit
		}, -1)
Esempio n. 15
0
    def __init__(self, session, parent, firmware, datafile, device):
        Screen.__init__(self, session)
        self.session = session

        self["actions"] = ActionMap(["OkCancelActions"], {
            "ok": self.keyExit,
        }, -1)

        self.firmware = firmware
        self.datafile = datafile
        #print "[FirmwareUpgrade] - [%s][%s][%s]" % (self.datafile, firmware, device)

        self["name"] = Label(_(" "))
        self["info"] = StaticText(_("Can't cancel during upgrade!!"))

        self["status"] = Label(_("Status : 0%"))

        self.slider = Slider(0, 100)
        self["slider"] = self.slider

        self.callback = None

        self.setTitle(firmware.upper() + " Upgrade Status")

        self.FU = FirmwareUpgradeManager()

        self.old_status = 0
        self.status_exit = None
        self.check_status = eTimer()
        self.check_status.callback.append(self.cbCheckStatus)
        self.check_status.start(self.FU.getInterval())

        self.exitTimerCallCount = 0
        self.upgradeLock = True
        self.FU.startUpgrade(self.datafile, device, firmware)
Esempio n. 16
0
 def __init__(self, session, args=None):
     Screen.__init__(self, session)
     self.sliderPackages = {
         'ceryon-dvb-modules': 1,
         'broadmedia-dvb-modules': 2,
         'ini-dvb-modules': 3,
         'enigma2': 4,
         'egami-version-info': 5
     }
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Verifying your internet connection...'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.doActivityTimer)
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.updating = False
     self['actions'] = ActionMap(['WizardActions'], {
         'ok': self.exit,
         'back': self.exit
     }, -1)
     self['actions'].csel = self
     self['actions'].setEnabled(False)
     iNetwork.checkNetworkState(self.checkNetworkCB)
     self.onClose.append(self.cleanup)
 def __init__(self, session, args=None):
     Screen.__init__(self, session)
     self.sliderPackages = {
         'dreambox-dvb-modules': 1,
         'enigma2': 2,
         'tuxbox-image-info': 3
     }
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Upgrading Dreambox... Please wait'))
     self['status'] = self.status
     self.package = StaticText()
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.doActivityTimer)
     self.activityTimer.start(100, False)
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.updating = True
     self.package.setText(_('Package list update'))
     self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
     self['actions'] = ActionMap(['WizardActions'], {
         'ok': self.exit,
         'back': self.exit
     }, -1)
 def __init__(self, session, backend, message, lastservice=None):
     self.backend = backend
     backend.MusicWindow = self
     self.session = session
     self.skinName = 'AirPlayMusicPlayer'
     print '[AirPlayMusicPlayer] starting AirTunesPlayer'
     Screen.__init__(self, session)
     self['actions'] = ActionMap(['OkCancelActions', 'MoviePlayerActions'],
                                 {
                                     'cancel': self.Exit,
                                     'leavePlayer': self.Exit
                                 }, -1)
     self['label_update'] = StaticText('')
     self['label_message'] = Label()
     self['label_message'].setText(message)
     self['label_title'] = Label()
     self['label_album'] = Label()
     self['label_interpret'] = Label()
     self['label_title'].setText('No')
     self['label_album'].setText('Metadata')
     self['label_interpret'].setText('')
     self.progress = Slider(0, 100)
     self.progress.setValue(0)
     self['progress'] = self.progress
     self['progress'].setValue(0)
     self.runtime = None
     self.seconds = None
     self.libairtunes = None
     self.lastservice = lastservice or self.session.nav.getCurrentlyPlayingServiceReference(
     )
     self.session.nav.stopService()
     if config.plugins.airplayer.audioBackend.value == 'proxy':
         if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
             self.session.nav.stopService()
             open('/proc/player', 'w').write('0')
             open('/proc/player', 'w').write('2')
         sref = eServiceReference(self.backend.ENIGMA_SERVICE_ID, 0,
                                  'http://127.0.0.1:7098/stream.wav')
         sref.setName('AirTunes')
         self.session.nav.playService(sref)
     start_new_thread(self.checkForUpdate, (self, ))
     self.x_pos = None
     self.y_pos = None
     self.x_dir = 5
     self.y_dir = 5
     self.WindowMoveTimer = eTimer()
     self.WindowMoveTimer.timeout.get().append(self.moveWindow)
     if config.plugins.airplayer.screensaverEnabled.value:
         self.WindowMoveTimer.start(10000, True)
     self['cover'] = Pixmap()
     self.picload = ePicLoad()
     self.picload.PictureData.get().append(self.finish_decode)
     self.onLayoutFinish.append(self.setPicloadConf)
     self.bgcolor = '#00000000'
     self.progressTimer = eTimer()
     self.progressTimer.timeout.get().append(self.progressCallback)
     self.parseMetadata()
Esempio n. 19
0
	def __init__(self, session, parent, timeout = 20):
		Screen.__init__(self,session)
		self.session = session

		self["actions"] = ActionMap(["OkCancelActions"],
                {
			"ok": self.keyExit,
                }, -2)

		self.is_done = 0
		self.exit_count = 0
		self.timeout = 20
		self.title_str = "FPGA Upgrade"

		#self["name"] = Label(_("Upgrade status"))
		self["name"] = Label(" ")
		self["info"] = StaticText(_("Can't cancel during upgrade!!"))

		self["status"] = Label(_("Status : 0%"))
		self.status_bar = self["status"]

		self.slider = Slider(0, 100)
		self["slider"] = self.slider

		self.parent = parent
		self.timer_check_progress = eTimer()
		self.timer_check_progress.callback.append(self.callbackDoCheckProgress)
		interval = self.parent.FPGA.get_interval()
		self.timer_check_progress.start(interval)
		self.need_restart = False
	def __init__(self, session, updateurl, version):
		from Components.Slider import Slider

		self.session = session
		Screen.__init__(self, session)
		self.target = updateurl
		self.version = version
		self.file_name = "/tmp/%s" % self.target.split('/')[-1]
		self.fileSize = 5 * 1024
		self.downloadDone = False
		self.container = eConsoleAppContainer()
		self.appClosed_conn = None
		self.stdoutAvail_conn = None

		self['srlog'] = Label()

		self.status = Label(_("Preparing... Please wait"))
		self['status'] = self.status
		self.activityslider = Slider(0, 100)
		self['activityslider'] = self.activityslider
		self.activity = 0
		self.activityTimer = eTimer()
		if isDreamboxOS:
			self.activityTimerConnection = self.activityTimer.timeout.connect(self.doActivityTimer)
		else:
			self.activityTimer.callback.append(self.doActivityTimer)

		self.onLayoutFinish.append(self.__onLayoutFinished)
Esempio n. 21
0
    def __init__(self, session):
        self.session = session
        self.session.qPips = None
        Screen.__init__(self, session)
        FocusShowHide.__init__(self)
        HelpableScreen.__init__(self)
        self.setTitle(_("Quad PiP Screen"))

        self["actions"] = HelpableActionMap(
            self, "QuadPipSetupActions", {
                "cancel": (self.keyExit, _("Exit quad PiP")),
                "ok": (self.keyOk, _("Zap focused channel on full screen")),
                "left": (self.keyLeft, _("Select channel audio")),
                "right": (self.keyRight, _("Select channel audio")),
                "up": (self.keyUp, _("Select channel audio")),
                "down": (self.keyDown, _("Select channel audio")),
                "channelup": (self.KeyChannel, _("Show channel selection")),
                "channeldown": (self.KeyChannel, _("Show channel selection")),
                "menu": (self.KeyChannel, _("Show channel selection")),
                "channelPrev": (self.KeyPrev, _("Prev quad PiP channel")),
                "channelNext": (self.KeyNext, _("Next quad PiP channel")),
                "red": (self.KeyRed, _("Show/Hide focus bar")),
            }, -1)

        self["ch1"] = Label(_(" "))
        self["ch2"] = Label(_(" "))
        self["ch3"] = Label(_(" "))
        self["ch4"] = Label(_(" "))
        self["text1"] = Label(_("  Red key : Show/Hide channel name"))
        self["text2"] = Label(_("  Menu key : Select quad channel"))
        self["focus"] = Slider(-1, -1)

        self.currentPosition = 1  # 1~4
        self.updatePositionList()

        self.skin = QuadPipScreen.skin % (self.session.desktop.size().width(), self.session.desktop.size().height(), \
                  self.fontSize, self.fontSize, self.fontSize, self.fontSize, \
                  self.text1Pos[0], self.text1Pos[1], self.text1Pos[2], self.text1Pos[3], self.fontSize, \
                  self.text2Pos[0], self.text2Pos[1], self.text2Pos[2], self.text2Pos[3], self.fontSize)
        self.oldService = None
        self.curChannel = None
        self.curPlayAudio = -1

        global quad_pip_channel_list_instance
        self.qpipChannelList = quad_pip_channel_list_instance

        self.oldFccEnable = False
        self.oldMinitvEanble = False

        self.onLayoutFinish.append(self.layoutFinishedCB)

        self.notSupportTimer = eTimer()
        self.notSupportTimer.callback.append(self.showNotSupport)

        self.noChannelTimer = eTimer()
        self.noChannelTimer.callback.append(self.noChannelTimerCB)

        self.forceToExitTimer = eTimer()
        self.forceToExitTimer.callback.append(self.forceToExitTimerCB)
Esempio n. 22
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        status_msgs = {
            'stable': _('Feeds status:   Stable'),
            'unstable': _('Feeds status:   Unstable'),
            'updating': _('Feeds status:   Updating'),
            'unknown': _('No connection')
        }
        self['tl_off'] = Pixmap()
        self['tl_red'] = Pixmap()
        self['tl_yellow'] = Pixmap()
        self['tl_green'] = Pixmap()
        self.feedsStatus()
        self['feedStatusMSG'] = Label(status_msgs[self.trafficLight])

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()
Esempio n. 23
0
    def __init__(self, session, parent=None):
        Screen.__init__(self, session, parent=parent)
        ProtectedScreen.__init__(self)
        self.setTitle(_("Software update"))

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)
        self['actions'].csel = self
        self["actions"].setEnabled(False)

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }
        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self['tl_off'] = Pixmap()
        self['tl_red'] = Pixmap()
        self['tl_yellow'] = Pixmap()
        self['tl_green'] = Pixmap()
        self['feedStatusMSG'] = Label()

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False
        self.updating = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.onFirstExecBegin.append(self.checkNetworkState)
Esempio n. 24
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))
        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        if self.isProtected() and config.ParentalControl.servicepin[0].value:
            self.onFirstExecBegin.append(
                boundFunction(
                    self.session.openWithCallback,
                    self.pinEntered,
                    PinInput,
                    pinList=[
                        x.value for x in config.ParentalControl.servicepin
                    ],
                    triesEntry=config.ParentalControl.retries.servicepin,
                    title=_("Please enter the correct pin code"),
                    windowTitle=_("Enter pin code")))
        else:
            self.checkNetworkState()
Esempio n. 25
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        ProtectedScreen.__init__(self)

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))
        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None

        self.channellist_only = 0
        self.channellist_name = ''
        self.updating = False
        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)
        self.onClose.append(self.__close)
        self.Console = Console()

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.checkTraficLight1)
        self.activityTimer.callback.append(self.doActivityTimer)
        self.activityTimer.start(20, True)
Esempio n. 26
0
    def __init__(self, session, args=None):
        Screen.__init__(self, session)

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Verifying your internet connection..."))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.modified_packages = []

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer_conn = self.activityTimer.timeout.connect(
            self.doActivityTimer)

        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)

        self.updating = False
        self.rebootRequired = False
        self.device_name = iSoftwareTools.hardware_info.device_name

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

        self.checkNetwork()
        self.onClose.append(self.cleanup)
Esempio n. 27
0
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)
		Screen.setTitle(self, _("Software Update"))

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)
		self['actions'].csel = self
		self["actions"].setEnabled(False)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self['tl_off'] = Pixmap()
		self['tl_red'] = Pixmap()
		self['tl_yellow'] = Pixmap()
		self['tl_green'] = Pixmap()
		self['feedStatusMSG'] = Label()

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False
		self.updating = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.onFirstExecBegin.append(self.checkNetworkState)
Esempio n. 28
0
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {"dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3}

        self.setTitle(_("Software update"))

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        status_msgs = {
            "stable": _("Feeds status:   Stable"),
            "unstable": _("Feeds status:   Unstable"),
            "updating": _("Feeds status:   Updating"),
            "unknown": _("No connection"),
        }
        self["tl_off"] = Pixmap()
        self["tl_red"] = Pixmap()
        self["tl_yellow"] = Pixmap()
        self["tl_green"] = Pixmap()
        self.feedsStatus()
        self["feedStatusMSG"] = Label(status_msgs[self.trafficLight])

        self.channellist_only = 0
        self.channellist_name = ""
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()
Esempio n. 29
0
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None

		self.channellist_only = 0
		self.channellist_name = ''
		self.updating = False
		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)
		self.onClose.append(self.__close)
		self.Console = Console()

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.checkTraficLight1)
		self.activityTimer.callback.append(self.doActivityTimer)
		self.activityTimer.start(20, True)
Esempio n. 30
0
 def __init__(self, session, backend, message, lastservice = None):
     self.backend = backend
     backend.MusicWindow = self
     self.session = session
     self.skinName = 'AirPlayMusicPlayer'
     print '[AirPlayMusicPlayer] starting AirTunesPlayer'
     Screen.__init__(self, session)
     self['actions'] = ActionMap(['OkCancelActions', 'MoviePlayerActions'], {'cancel': self.Exit,
      'leavePlayer': self.Exit}, -1)
     self['label_update'] = StaticText('')
     self['label_message'] = Label()
     self['label_message'].setText(message)
     self['label_title'] = Label()
     self['label_album'] = Label()
     self['label_interpret'] = Label()
     self['label_title'].setText('No')
     self['label_album'].setText('Metadata')
     self['label_interpret'].setText('')
     self.progress = Slider(0, 100)
     self.progress.setValue(0)
     self['progress'] = self.progress
     self['progress'].setValue(0)
     self.runtime = None
     self.seconds = None
     self.libairtunes = None
     self.lastservice = lastservice or self.session.nav.getCurrentlyPlayingServiceReference()
     self.session.nav.stopService()
     if config.plugins.airplayer.audioBackend.value == 'proxy':
         if self.backend.ENIGMA_SERVICE_ID == self.backend.ENIGMA_SERVICEAZ_ID:
             self.session.nav.stopService()
             open('/proc/player', 'w').write('0')
             open('/proc/player', 'w').write('2')
         sref = eServiceReference(self.backend.ENIGMA_SERVICE_ID, 0, 'http://127.0.0.1:7098/stream.wav')
         sref.setName('AirTunes')
         self.session.nav.playService(sref)
     start_new_thread(self.checkForUpdate, (self,))
     self.x_pos = None
     self.y_pos = None
     self.x_dir = 5
     self.y_dir = 5
     self.WindowMoveTimer = eTimer()
     self.WindowMoveTimer.timeout.get().append(self.moveWindow)
     if config.plugins.airplayer.screensaverEnabled.value:
         self.WindowMoveTimer.start(10000, True)
     self['cover'] = Pixmap()
     self.picload = ePicLoad()
     self.picload.PictureData.get().append(self.finish_decode)
     self.onLayoutFinish.append(self.setPicloadConf)
     self.bgcolor = '#00000000'
     self.progressTimer = eTimer()
     self.progressTimer.timeout.get().append(self.progressCallback)
     self.parseMetadata()
Esempio n. 31
0
	def __init__(self, session, args = None):
		Screen.__init__(self, session)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Verifying your internet connection..."))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.modified_packages = []

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer_conn = self.activityTimer.timeout.connect(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self.updating = False
		self.rebootRequired = False
		self.device_name = iSoftwareTools.hardware_info.device_name

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.checkNetwork()
		self.onClose.append(self.cleanup)
Esempio n. 32
0
 def __init__(self, session, parent):
     ScreenSummary.__init__(self, session, parent=parent)
     self["entry"] = StaticText(
         ""
     )  # Use the same widget as the Setup Summary screen so the screens can be shared.
     self["value"] = StaticText(
         ""
     )  # Use the same widget as the Setup Summary screen so the screens can be shared.
     self["activity"] = Slider(0, 100)
     if self.addWatcher not in self.onShow:
         self.onShow.append(self.addWatcher)
     if self.removeWatcher not in self.onHide:
         self.onHide.append(self.removeWatcher)
Esempio n. 33
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     ProtectedScreen.__init__(self)
     self.sliderPackages = {
         'dreambox-dvb-modules': 1,
         'enigma2': 2,
         'tuxbox-image-info': 3
     }
     self.setTitle(_('Software update'))
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Package list update'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.total_packages = None
     self.channellist_only = 0
     self.channellist_name = ''
     self.updating = False
     self.ipkg = IpkgComponent()
     self.ipkg.addCallback(self.ipkgCallback)
     self.onClose.append(self.__close)
     self['actions'] = ActionMap(['WizardActions'], {
         'ok': self.exit,
         'back': self.exit
     }, -1)
     self.activity = 0
     self.activityTimer = eTimer()
     self.activityTimer.callback.append(self.checkTraficLight)
     self.activityTimer.callback.append(self.doActivityTimer)
     self.activityTimer.start(100, True)
Esempio n. 34
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     Screen.setTitle(self, _('Software Update'))
     self.sliderPackages = {'dreambox-dvb-modules': 1,
      'enigma2': 2,
      'tuxbox-image-info': 3}
     self.setTitle(_('Software update'))
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Package list update'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     status_msgs = {'stable': _('Feeds status:   Stable'),
      'unstable': _('Feeds status:   Unstable'),
      'updating': _('Feeds status:   Updating'),
      'unknown': _('No connection')}
     self['tl_off'] = Pixmap()
     self['tl_red'] = Pixmap()
     self['tl_yellow'] = Pixmap()
     self['tl_green'] = Pixmap()
     self.feedsStatus()
     self['feedStatusMSG'] = Label(status_msgs[self.trafficLight])
     self.channellist_only = 0
     self.channellist_name = ''
     self.SettingsBackupDone = False
     self.ImageBackupDone = False
     self.autobackuprunning = False
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.total_packages = None
     self.checkNetworkState()
     return
Esempio n. 35
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     ProtectedScreen.__init__(self)
     Screen.setTitle(self, _('Software Update'))
     self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
        'back': self.exit
        }, -1)
     self['actions'].csel = self
     self['actions'].setEnabled(False)
     self.sliderPackages = {'ini-dvb-modules': 1,'enigma2': 2,'tuxbox-image-info': 3}
     self.slider = Slider(0, 4)
     self['slider'] = self.slider
     self.activityslider = Slider(0, 100)
     self['activityslider'] = self.activityslider
     self.status = StaticText(_('Please wait...'))
     self['status'] = self.status
     self.package = StaticText(_('Package list update'))
     self['package'] = self.package
     self.oktext = _('Press OK on your remote control to continue.')
     self['tl_off'] = Pixmap()
     self['tl_red'] = Pixmap()
     self['tl_yellow'] = Pixmap()
     self['tl_green'] = Pixmap()
     self['feedStatusMSG'] = Label()
     self.channellist_only = 0
     self.channellist_name = ''
     self.SettingsBackupDone = False
     self.ImageBackupDone = False
     self.autobackuprunning = False
     self.updating = False
     self.packages = 0
     self.error = 0
     self.processed_packages = []
     self.total_packages = None
     self.onFirstExecBegin.append(self.checkNetworkState)
     return
Esempio n. 36
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     HelpableScreen.__init__(self)
     self.setTitle(_("Software Update"))
     self.onTimerTick = []
     self["update"] = ScrollLabel(
         _("Software update starting, please wait.\n\n"))
     self["activity"] = Slider(0, 100)
     self["actions"] = HelpableActionMap(
         self,
         ["OkCancelActions", "NavigationActions"],
         {
             "cancel":
             (self.keyCancel, _("Stop the update, if running, then exit")),
             "ok":
             (self.keyCancel, _("Stop the update, if running, then exit")),
             "top": (self.top, _("Move to first line / screen")),
             "pageUp": (self.pageUp, _("Move up a page / screen")),
             "up": (self.pageUp, _("Move up a page / screen")),
             # "first": (self.top, _("Move to first line / screen")),
             "left": (self.pageUp, _("Move up a page / screen")),
             "right": (self.pageDown, _("Move down a page / screen")),
             # "last": (self.bottom, _("Move to last line / screen")),
             "down": (self.pageDown, _("Move down a page / screen")),
             "pageDown": (self.pageDown, _("Move down a page / screen")),
             "bottom": (self.bottom, _("Move to last line / screen"))
         },
         prio=0,
         description=_("Software Update Actions"))
     self.activity = 0
     self.timer = eTimer()
     self.timer.callback.append(self.timeout)
     self.packageTotal = 0
     self.downloadCount = 0
     self.updateCount = 0
     self.installCount = 0
     self.removeCount = 0
     self.deselectCount = 0
     self.upgradeCount = 0
     self.configureCount = 0
     self.errorCount = 0
     self.updateFlag = True
     self.opkg = OpkgComponent()
     self.opkg.addCallback(self.opkgCallback)
     self.onLayoutFinish.append(self.layoutFinished)
Esempio n. 37
0
	def __init__(self, session, parent, firmware, datafile, device):
		Screen.__init__(self,session)
		self.session = session

		self["actions"] = ActionMap(["OkCancelActions"],
                {
			"ok": self.keyExit,
                }, -1)

		self.firmware = firmware
		self.datafile = datafile
		#print "[FirmwareUpgrade] - [%s][%s][%s]" % (self.datafile, firmware, device)

		self["name"] = Label(" ")
		self["info"] = StaticText(_("Can't cancel during upgrade!!"))

		self["status"] = Label(_("Status : 0%"))

		self.slider = Slider(0, 100)
		self["slider"] = self.slider

		self.callback = None

		self.setTitle(firmware.upper() + " Upgrade Status")

		self.FU = FirmwareUpgradeManager()

		self.old_status   = 0
		self.status_exit  = None
		self.check_status = eTimer()
		self.check_status.callback.append(self.cbCheckStatus)
		self.check_status.start(self.FU.getInterval())

		self.exitTimerCallCount = 0;
		self.upgradeLock = True
		self.FU.startUpgrade(self.datafile, device, firmware)
Esempio n. 38
0
def telaSkin():
    cores = [corCobra, corBorda]
    rect = rectPlayer[2] * 2, rectPlayer[3] * 2
    pos = resolucao[0] / 2.3, posCaixa[12]
    base = fonte.render("Base", True, branco)
    borda = fonte.render("Borda", True, branco)

    while (True):
        blitBg()
        eventos = event()

        titulo("Skin")

        tela.blit(base,
                  (resolucao[0] / 4 - base.get_size()[0] / 2, posCaixa[3]))

        tela.blit(borda,
                  (resolucao[0] / 1.3 - borda.get_size()[0] / 2, posCaixa[3]))

        cores[0][0] = Slider(resolucao[0] / 4, posCaixa[6], "r", cores[0][0])

        cores[0][1] = Slider(resolucao[0] / 4, posCaixa[8], "g", cores[0][1])

        cores[0][2] = Slider(resolucao[0] / 4, posCaixa[10], "b", cores[0][2])

        cores[1][0] = Slider(resolucao[0] / 1.3, posCaixa[6], "r", cores[1][0])

        cores[1][1] = Slider(resolucao[0] / 1.3, posCaixa[8], "g", cores[1][1])

        cores[1][2] = Slider(resolucao[0] / 1.3, posCaixa[10], "b",
                             cores[1][2])

        drawSkin(rect, pos, cores)

        Botao("Aplicar", eventos, resolucao[0] / 2, posCaixa[16],
              lambda: mudarSkin(cores[0], cores[1]))

        if Botao("<", eventos, resolucao[0] * 0.06, resolucao[1] * 0.962,
                 quebra):
            break

        engine.display.update()
Esempio n. 39
0
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)
		screentitle = _("Software Update")
		self.menu_path = args[0]
		if config.usage.show_menupath.value == 'large':
			self.menu_path += screentitle
			self.title = self.menu_path
			self.menu_path_compressed = ""
			self.menu_path += ' / '
		elif config.usage.show_menupath.value == 'small':
			self.title = screentitle
			condtext = ""
			if self.menu_path and not self.menu_path.endswith(' / '):
				condtext = self.menu_path + " >"
			elif self.menu_path:
				condtext = self.menu_path[:-3] + " >"
			self.menu_path_compressed = condtext
			self.menu_path += screentitle + ' / '
		else:
			self.title = screentitle
			self.menu_path_compressed = ""
		self["menu_path_compressed"] = StaticText(self.menu_path_compressed)
		Screen.setTitle(self, self.title)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)
		self['actions'].csel = self
		self["actions"].setEnabled(False)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self['tl_off'] = Pixmap()
		self['tl_red'] = Pixmap()
		self['tl_yellow'] = Pixmap()
		self['tl_green'] = Pixmap()
		self['feedStatusMSG'] = Label()

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False
		self.updating = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.onFirstExecBegin.append(self.checkNetworkState)
Esempio n. 40
0
class UpdatePlugin(Screen, ProtectedScreen):
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)
		screentitle = _("Software Update")
		self.menu_path = args[0]
		if config.usage.show_menupath.value == 'large':
			self.menu_path += screentitle
			self.title = self.menu_path
			self.menu_path_compressed = ""
			self.menu_path += ' / '
		elif config.usage.show_menupath.value == 'small':
			self.title = screentitle
			condtext = ""
			if self.menu_path and not self.menu_path.endswith(' / '):
				condtext = self.menu_path + " >"
			elif self.menu_path:
				condtext = self.menu_path[:-3] + " >"
			self.menu_path_compressed = condtext
			self.menu_path += screentitle + ' / '
		else:
			self.title = screentitle
			self.menu_path_compressed = ""
		self["menu_path_compressed"] = StaticText(self.menu_path_compressed)
		Screen.setTitle(self, self.title)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)
		self['actions'].csel = self
		self["actions"].setEnabled(False)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self['tl_off'] = Pixmap()
		self['tl_red'] = Pixmap()
		self['tl_yellow'] = Pixmap()
		self['tl_green'] = Pixmap()
		self['feedStatusMSG'] = Label()

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False
		self.updating = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.onFirstExecBegin.append(self.checkNetworkState)

	def checkNetworkState(self):
		self['tl_red'].hide()
		self['tl_yellow'].hide()
		self['tl_green'].hide()
		self['tl_off'].hide()
		self.trafficLight = feedsstatuscheck.getFeedsBool() 
		if self.trafficLight in feedsstatuscheck.feed_status_msgs:
			status_text = feedsstatuscheck.feed_status_msgs[self.trafficLight]
		else:
			status_text = _('Feeds status: Unexpected')
		if self.trafficLight:
			self['feedStatusMSG'].setText(status_text)
		if self.trafficLight == 'stable':
			self['tl_green'].show()
		elif self.trafficLight == 'unstable':
			self['tl_red'].show()
		elif self.trafficLight == 'updating':
			self['tl_yellow'].show()
		else:
			self['tl_off'].show()
		if (getImageType() != 'release' and self.trafficLight != 'unknown') or (getImageType() == 'release' and self.trafficLight not in ('stable', 'unstable')):
			self.session.openWithCallback(self.close, MessageBox, feedsstatuscheck.getFeedsErrorMessage(), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		else:
			if getImageType() != 'release' or (config.softwareupdate.updateisunstable.value == '1' and config.softwareupdate.updatebeta.value) or config.softwareupdate.updateisunstable.value == '0':
				self.startCheck()
			else:
				self.session.openWithCallback(self.close, MessageBox, _("Sorry the feeds seem to be in an unstable state, if you wish to use them please enable 'Allow unstable (experimental) updates' in \"Software update settings\"."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)

	def startCheck(self):
		self.updating = True
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self.activityTimer.start(100, False)
		self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

	def isProtected(self):
		return config.ParentalControl.setuppinactive.value and\
			(not config.ParentalControl.config_sections.main_menu.value and not config.ParentalControl.config_sections.configuration.value  or hasattr(self.session, 'infobar') and self.session.infobar is None) and\
			config.ParentalControl.config_sections.software_update.value

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
				self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
			else:
				self["actions"].setEnabled(True)
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % param
				)
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
			self.updating = False
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
			elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
				self.total_packages = None
				if getImageType() != 'release' or (config.softwareupdate.updateisunstable.value == '1' and config.softwareupdate.updatebeta.value):
					self.total_packages = len(self.ipkg.getFetchedList())
					message = _("The current update may be unstable") + "\n" + _("Are you sure you want to update your %s %s ?") % (getMachineBrand(), getMachineName()) + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
				elif config.softwareupdate.updateisunstable.value == '0':
					self.total_packages = len(self.ipkg.getFetchedList())
					message = _("Do you want to update your %s %s ?") % (getMachineBrand(), getMachineName()) + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
				if self.total_packages > 150:
					message += " " + _("Reflash recommended!")
				if self.total_packages:
					global ocram
					ocram = ''
					for package_tmp in self.ipkg.getFetchedList():
						if package_tmp[0].startswith('enigma2-plugin-picons-snp'):
							ocram = ocram + '[ocram-picons] ' + package_tmp[0].split('enigma2-plugin-picons-snp-')[1].replace('.',' ') + ' updated ' + package_tmp[2].replace('--',' ') + '\n'
						elif package_tmp[0].startswith('enigma2-plugin-picons-srp'):
							ocram = ocram + '[ocram-picons] ' + package_tmp[0].split('enigma2-plugin-picons-srp-')[1].replace('.',' ') + ' updated ' + package_tmp[2].replace('--',' ') + '\n'
					config.softwareupdate.updatefound.setValue(True)
					choices = [(_("View the changes"), "changes"),
						(_("Upgrade and reboot system"), "cold")]
					if path.exists("/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/BackupManager.pyo"):
						if not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
							choices.append((_("Perform a settings backup,") + '\n\t' + _("making a backup before updating") + '\n\t' +_("is strongly advised."), "backup"))
						if not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
							choices.append((_("Perform a full image backup"), "imagebackup"))
					choices.append((_("Update channel list only"), "channels"))
					choices.append((_("Cancel"), ""))
					self["actions"].setEnabled(True)
					upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name = "SoftwareUpdateChoices", var=self.trafficLight, menu_path=self.menu_path_compressed)
					upgrademessage.setTitle(self.title)
				else:
					self["actions"].setEnabled(True)
					upgrademessage = self.session.openWithCallback(self.close, MessageBox, _("Nothing to upgrade"), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
					upgrademessage.setTitle(_('Software update'))
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s.") % (getMachineBrand(), getMachineName(), getMachineBrand(), getMachineName())
				if self.packages == 0:
					error = _("A background update check is in progress,\nplease wait a few minutes and try again.")
				if self.updating:
					error = _("Update failed. Your %s %s does not have a working internet connection.") % (getMachineBrand(), getMachineName())
				self.status.setText(_("Error") +  " - " + error)
				self["actions"].setEnabled(True)
		elif event == IpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print event, "-", param
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return

		if answer[1] == "menu":
			if config.softwareupdate.updateisunstable.value == '1':
				message = _("The current update may be unstable") + "\n" + _("Are you sure you want to update your %s %s ?") % (getMachineBrand(), getMachineName()) + "\n(%s " % self.total_packages + _("Packages") + ")"
			elif config.softwareupdate.updateisunstable.value == '0':
				message = _("Do you want to update your %s %s ?") % (getMachineBrand(), getMachineName()) + "\n(%s " % self.total_packages + _("Packages") + ")"
			choices = [(_("View the changes"), "changes"),
				(_("Upgrade and reboot system"), "cold")]
			if not self.SettingsBackupDone and not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
				choices.append((_("Perform a settings backup, making a backup before updating is strongly advised."), "backup"))
			if not self.ImageBackupDone and not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
				choices.append((_("Perform a full image backup"), "imagebackup"))
			choices.append((_("Update channel list only"), "channels"))
			choices.append((_("Cancel"), ""))
			self["actions"].setEnabled(True)
			upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name="SoftwareUpdateChoices", var=self.trafficLight, menu_path=self.menu_path_compressed)
			upgrademessage.setTitle(self.title)
		elif answer[1] == "changes":
			self.session.openWithCallback(self.startActualUpgrade,SoftwareUpdateChanges, self.menu_path)
		elif answer[1] == "backup":
			self.doSettingsBackup()
		elif answer[1] == "imagebackup":
			self.doImageBackup()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.ipkg.startCmd(IpkgComponent.CMD_LIST, args = {'installed_only': True})
		elif answer[1] == "cold":
			if (config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value) or (config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value):
				self.doAutoBackup()
			else:
				self.session.open(TryQuitMainloop,retvalue=42)
				self.close()

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def doSettingsBackup(self):
		backup = None
		from Plugins.SystemPlugins.ViX.BackupManager import BackupFiles
		self.BackupFiles = BackupFiles(self.session, True)
		Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
		Components.Task.job_manager.in_background = False
		for job in Components.Task.job_manager.getPendingJobs():
			if job.name == dgettext('vix', 'Backup Manager'):
				break
		self.showJobView(job)

	def doImageBackup(self):
		backup = None
		from Plugins.SystemPlugins.ViX.ImageManager import ImageBackup
		self.ImageBackup = ImageBackup(self.session, True)
		Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
		Components.Task.job_manager.in_background = False
		for job in Components.Task.job_manager.getPendingJobs():
			if job.name == dgettext('vix', 'Image Manager'):
				break
		self.showJobView(job)

	def doAutoBackup(self, val = False):
		self.autobackuprunning = True
		if config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value and not self.SettingsBackupDone:
			self.doSettingsBackup()
		elif config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value and not self.ImageBackupDone:
			self.doImageBackup()
		else:
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()

	def showJobView(self, job):
		if job.name == dgettext('vix', 'Image Manager'):
			self.ImageBackupDone = True
		elif job.name == dgettext('vix', 'Backup Manager'):
			self.SettingsBackupDone = True
		from Screens.TaskView import JobView
		Components.Task.job_manager.in_background = False
		if not self.autobackuprunning:
			self.session.openWithCallback(self.startActualUpgrade(("menu", "menu")), JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")
		else:
			self.session.openWithCallback(self.doAutoBackup, JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your %s %s") % (getMachineBrand(), getMachineName()))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop, retvalue=2)
		self.close()
Esempio n. 41
0
class UpgradeStatus(Screen):
	skin = """
		<screen position="center,center" size="450,130" title=" ">
			<widget name="name" position="10,0" size="430,20" font="Regular;18" halign="left" valign="bottom"/>
			<widget name="slider" position="10,25" size="430,30" borderWidth="2" borderColor="#cccccc"/>
			<widget name="status" position="10,25" zPosition="1" size="430,30" font="Regular;18" halign="center" valign="center" foregroundColor="#9f1313" transparent="1"/>
			<widget source="info" render="Label" position="10,70" zPosition="1" size="430,60" font="Regular;22" halign="center" valign="center" transparent="1"/>
		</screen>
		"""

	def __init__(self, session, parent, firmware, datafile, device):
		Screen.__init__(self, session)
		self.session = session

		self["actions"] = ActionMap(["OkCancelActions"],
                {
			"ok": self.keyExit,
                }, -1)

		self.firmware = firmware
		self.datafile = datafile
		#print("[FirmwareUpgrade] - [%s][%s][%s]" % (self.datafile, firmware, device))

		self["name"] = Label(" ")
		self["info"] = StaticText(_("Can't cancel during upgrade!!"))

		self["status"] = Label(_("Status : 0%"))

		self.slider = Slider(0, 100)
		self["slider"] = self.slider

		self.callback = None

		self.setTitle(firmware.upper() + " Upgrade Status")

		self.FU = FirmwareUpgradeManager()

		self.old_status = 0
		self.status_exit = None
		self.check_status = eTimer()
		self.check_status.callback.append(self.cbCheckStatus)
		self.check_status.start(self.FU.getInterval())

		self.exitTimerCallCount = 0
		self.upgradeLock = True
		self.FU.startUpgrade(self.datafile, device, firmware)

	def cbCheckStatus(self):
		errmsg = ""
		errno = self.FU.checkError()
		if errno:
			self.check_status.stop()
			errmsg = self.FU.getErrorMessage(errno, errmsg)
			print("[FirmwareUpgrade] - ERROR : [%d][%s]" % (errno, errmsg))
			self.session.open(MessageBox, _(errmsg), MessageBox.TYPE_INFO, timeout=10)
			self.cbConfirmExit(False)
			return
		status = self.FU.getStatus()
		if self.old_status > status and status != -1:
			self.session.open(MessageBox, _("Fail to upgrade!! Retry!!"), MessageBox.TYPE_INFO, timeout=10)
		self.slider.setValue(status)
		self["status"].setText(_("%d / 100" % (status)))
		if status == 100:
			self.check_status.stop()
			self["status"].setText(_("Success. Press OK to exit."))
			self.status_exit = eTimer()
			self.status_exit.callback.append(self.cbTimerExit)
			self.status_exit.start(1000)
			self.upgradeLock = False
		self.old_status = status

	def setCallback(self, cb):
		self.callback = cb

	def cbTimerExit(self):
		if self.exitTimerCallCount < 10: # exit after 10 sec.
			self.exitTimerCallCount = self.exitTimerCallCount + 1
			self.setTitle("%s Upgrade Status (%d)" % (self.firmware.upper(), 10 - self.exitTimerCallCount))
			return
		if self.status_exit is not None:
			self.status_exit.stop()
		self.keyExit()

	def cbConfirmExit(self, ret):
		if ret:
			Console().ePopen("rm -f %s %s.md5" % (self.datafile, self.datafile))
		self.close()

	def keyExit(self):
		if self.upgradeLock:
			return
		if self.callback is not None:
			self.callback("Reboot now for a successful upgrade.", True)
		self.session.openWithCallback(self.cbConfirmExit, MessageBox, _("Do you want to remove binary data?"), MessageBox.TYPE_YESNO, timeout=10, default=False)
Esempio n. 42
0
class UpdatePlugin(Screen, ProtectedScreen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""

	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)

		self.sliderPackages = { "enigma2": 1, "openvision": 2 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None

		self.channellist_only = 0
		self.channellist_name = ''
		self.updating = False
		self.opkg = OpkgComponent()
		self.opkg.addCallback(self.opkgCallback)
		self.onClose.append(self.__close)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.checkTraficLight)
		self.activityTimer.callback.append(self.doActivityTimer)
		self.activityTimer.start(100, True)

	def isProtected(self):
		return config.ParentalControl.setuppinactive.value and\
			(not config.ParentalControl.config_sections.main_menu.value and not config.ParentalControl.config_sections.configuration.value  or hasattr(self.session, 'infobar') and self.session.infobar is None) and\
			config.ParentalControl.config_sections.software_update.value

	def checkTraficLight(self):
		self.activityTimer.callback.remove(self.checkTraficLight)
		self.activityTimer.start(100, False)
		status = None
		message = None
		abort = False
		picon = MessageBox.TYPE_ERROR
		url = "https://openvision.tech/trafficlight"

		# try to fetch the trafficlight json from the website
		try:
			status = dict(json.load(urlopen(url, timeout=5)))
			print("[SoftwareUpdate] status is: ", status)
		except:
			pass

		# process the status fetched
		if status is not None:

			try:
				# get image version and machine name
				machine = getBoxType()
				version = open("/etc/issue").readlines()[-2].split()[1]

				# do we have an entry for this version
				if version in status and machine in status[version]['machines']:
					if 'abort' in status[version]:
						abort = status[version]['abort']
					if 'from' in status[version]:
						starttime = datetime.datetime.strptime(status[version]['from'], '%Y%m%d%H%M%S')
					else:
						starttime = datetime.datetime.now()
					if 'to' in status[version]:
						endtime = datetime.datetime.strptime(status[version]['to'], '%Y%m%d%H%M%S')
					else:
						endtime = datetime.datetime.now()
					if (starttime <= datetime.datetime.now() and endtime >= datetime.datetime.now()):
						message = str(status[version]['message'])

				# check if we have per-language messages
				if type(message) is dict:
					lang = language.getLanguage()
					if lang in message:
						message = message[lang]
					elif 'en_EN' in message:
						message = message['en_EN']
					else:
						message =  _("The current image might not be stable.\nFor more information see %s.") % ("openvision.tech")

			except Exception as e:
				print("[SoftwareUpdate] status error: ", str(e))
				message =  _("The current image might not be stable.\nFor more information see %s.") % ("openvision.tech")

		# or display a generic warning if fetching failed
		else:
			message = _("The status of the current image could not be checked because %s can not be reached.") % ("openvision.tech")

		# show the user the message first
		if message is not None:
			if abort:
				self.session.openWithCallback(self.close, MessageBox, message, type=MessageBox.TYPE_ERROR, picon = picon)
			else:
				message += "\n\n" + _("Do you want to update your receiver?")
				self.session.openWithCallback(self.startActualUpdate, MessageBox, message, picon = picon)

		# no message, continue with the update
		else:
			self.startActualUpdate(True)

	def getLatestImageTimestamp(self):
		def gettime(url):
			try:
				return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(calendar.timegm(urlopen("%s/Packages.gz" % url).info().getdate('Last-Modified'))-time.altzone))
			except:
				return ""
		return sorted([gettime(open("/etc/opkg/%s" % file, "r").readlines()[0].split()[2]) for file in os.listdir("/etc/opkg") if not file.startswith("3rd-party") and file not in ("arch.conf", "opkg.conf", "picons-feed.conf")], reverse=True)[0]

	def startActualUpdate(self,answer):
		if answer:
			self.updating = True
			self.opkg.startCmd(OpkgComponent.CMD_UPDATE)
		else:
			self.close()

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def opkgCallback(self, event, param):
		if event == OpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == OpkgComponent.EVENT_UPGRADE:
			if param in self.sliderPackages:
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Updating") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == OpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == OpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == OpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == OpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
				self.opkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
			else:
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % (param)
				)
		elif event == OpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == OpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.opkg.startCmd(OpkgComponent.CMD_UPGRADE_LIST)
			elif self.opkg.currentCommand == OpkgComponent.CMD_UPGRADE_LIST:
				self.total_packages = len(self.opkg.getFetchedList())
				if self.total_packages:
					latestImageTimestamp = self.getLatestImageTimestamp()
					if latestImageTimestamp:
						message = _("Do you want to update your receiver to %s?") % latestImageTimestamp + "\n"
					else:
						message = _("Do you want to update your receiver?") + "\n"
					message += "(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
					if self.total_packages > 150:
						choices = [(_("Update and reboot"), "cold")]
						message += " " + _("Reflash recommended!")
					else:
						choices = [(_("Update and reboot (recommended)"), "cold"),
						(_("Update and ask to reboot"), "hot")]
					choices.append((_("Update channel list only"), "channels"))
					choices.append((_("Show packages to be updated"), "showlist"))
				else:
					message = _("No updates available")
					choices = []
				if fileExists("/home/root/opkgupgrade.log"):
					choices.append((_("Show latest update log"), "log"))
				choices.append((_("Show latest commits"), "commits"))
				choices.append((_("Cancel"), ""))
				self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, windowTitle=self.title)
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.opkg.startCmd(OpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.opkg.startCmd(OpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your receiver might be unusable now. Please consult the manual for further assistance before rebooting your receiver.")
				if self.packages == 0:
					error = _("No updates available. Please try again later.")
				if self.updating:
					error = _("Update failed. Your receiver does not have a working internet connection.")
				self.status.setText(_("Error") +  " - " + error)
		elif event == OpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print(event, "-", param)
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return
		if answer[1] == "cold":
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.opkg.startCmd(OpkgComponent.CMD_LIST, args = {'installed_only': True})
		elif answer[1] == "commits":
			self.session.openWithCallback(boundFunction(self.opkgCallback, OpkgComponent.EVENT_DONE, None), CommitInfo)
		elif answer[1] == "showlist":
			text = "\n".join([x[0] for x in sorted(self.opkg.getFetchedList(), key=lambda d: d[0])])
			self.session.openWithCallback(boundFunction(self.opkgCallback, OpkgComponent.EVENT_DONE, None), TextBox, text, _("Packages to update"), True)
		elif answer[1] == "log":
			text = open("/home/root/opkgupgrade.log", "r").read()
			self.session.openWithCallback(boundFunction(self.opkgCallback, OpkgComponent.EVENT_DONE, None), TextBox, text, _("Latest update log"), True)
		else:
			self.opkg.startCmd(OpkgComponent.CMD_UPGRADE, args = {'test_only': False})

	def modificationCallback(self, res):
		self.opkg.write(res and "N" or "Y")

	def exit(self):
		if not self.opkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Update completed. Do you want to reboot your receiver?"))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop, retvalue=2)
		self.close()

	def __close(self):
		self.opkg.removeCallback(self.opkgCallback)
Esempio n. 43
0
class UpdatePlugin(Screen):
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        status_msgs = {
            'stable': _('Feeds status:   Stable'),
            'unstable': _('Feeds status:   Unstable'),
            'updating': _('Feeds status:   Updating'),
            'unknown': _('No connection')
        }
        self['tl_off'] = Pixmap()
        self['tl_red'] = Pixmap()
        self['tl_yellow'] = Pixmap()
        self['tl_green'] = Pixmap()
        self.feedsStatus()
        self['feedStatusMSG'] = Label(status_msgs[self.trafficLight])

        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()

    def feedsStatus(self):
        from urllib import urlopen
        import socket
        self['tl_red'].hide()
        self['tl_yellow'].hide()
        self['tl_green'].hide()
        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        try:
            d = urlopen("http://openvix.co.uk/TrafficLightState.php")
            self.trafficLight = d.read()
            if self.trafficLight == 'unstable':
                self['tl_off'].hide()
                self['tl_red'].show()
            elif self.trafficLight == 'updating':
                self['tl_off'].hide()
                self['tl_yellow'].show()
            elif self.trafficLight == 'stable':
                self['tl_off'].hide()
                self['tl_green'].show()
            else:
                self.trafficLight = 'unknown'
                self['tl_off'].show()
        except:
            self.trafficLight = 'unknown'
            self['tl_off'].show()
        socket.setdefaulttimeout(currentTimeoutDefault)

    def checkNetworkState(self):
        cmd1 = "opkg update"
        self.CheckConsole = Console()
        self.CheckConsole.ePopen(cmd1, self.checkNetworkStateFinished)

    def checkNetworkStateFinished(self, result, retval, extra_args=None):
        if 'bad address' in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("Your %s %s is not connected to the internet, please check your network settings and try again."
                  ) % (getMachineBrand(), getMachineName()),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True)
        elif ('wget returned 1' or 'wget returned 255'
              or '404 Not Found') in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("Sorry feeds are down for maintenance, please try again later. If this issue persists please check www.openesi.eu"
                  ),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True)
        elif 'Collected errors' in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("A background update check is in progress, please wait a few minutes and try again."
                  ),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True)
        else:
            self.startCheck()

    def startCheck(self):
        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)

        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)

        self.updating = False

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

        self.updating = True
        self.activityTimer.start(100, False)
        self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

    def doActivityTimer(self):
        self.activity += 1
        if self.activity == 100:
            self.activity = 0
        self.activityslider.setValue(self.activity)

    def showUpdateCompletedMessage(self):
        self.setEndMessage(
            ngettext("Update completed, %d package was installed.",
                     "Update completed, %d packages were installed.",
                     self.packages) % self.packages)

    def ipkgCallback(self, event, param):
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_("Downloading"))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if self.sliderPackages.has_key(param):
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(
                _("Upgrading") + ": %s/%s" %
                (self.packages, self.total_packages))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_("Installing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_("Removing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_("Configuring"))

        elif event == IpkgComponent.EVENT_MODIFIED:
            if config.plugins.softwaremanager.overwriteConfigFiles.value in (
                    "N", "Y"):
                self.ipkg.write(
                    True and
                    config.plugins.softwaremanager.overwriteConfigFiles.value)
            else:
                self.session.openWithCallback(
                    self.modificationCallback, MessageBox,
                    _("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?"
                      ) % param)
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            if self.updating:
                self.updating = False
                self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
            elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
                from urllib import urlopen
                import socket
                currentTimeoutDefault = socket.getdefaulttimeout()
                socket.setdefaulttimeout(3)
                status = urlopen(
                    'http://www.openvix.co.uk/feeds/status').read()
                if '404 Not Found' in status:
                    status = '1'
                config.softwareupdate.updateisunstable.setValue(status)
                socket.setdefaulttimeout(currentTimeoutDefault)
                self.total_packages = None
                if config.softwareupdate.updateisunstable.value == '1' and config.softwareupdate.updatebeta.value:
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = _(
                        "The current update may be unstable") + "\n" + _(
                            "Are you sure you want to update your %s %s ?"
                        ) % (getMachineBrand(), getMachineName()) + "\n(" + (
                            ngettext("%s updated package available",
                                     "%s updated packages available",
                                     self.total_packages) %
                            self.total_packages) + ")"
                elif config.softwareupdate.updateisunstable.value == '0':
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = _("Do you want to update your %s %s ?") % (
                        getMachineBrand(), getMachineName()) + "\n(" + (
                            ngettext("%s updated package available",
                                     "%s updated packages available",
                                     self.total_packages) %
                            self.total_packages) + ")"
                if self.total_packages:
                    global ocram
                    for package_tmp in self.ipkg.getFetchedList():
                        if package_tmp[0].startswith(
                                'enigma2-plugin-picons-tv-ocram'):
                            ocram = ocram + '[ocram-picons] ' + package_tmp[
                                0].split('enigma2-plugin-picons-tv-ocram.')[
                                    1] + 'updated ' + package_tmp[2] + '\n'
                        elif package_tmp[0].startswith(
                                'enigma2-plugin-settings-ocram'):
                            ocram = ocram + '[ocram-settings] ' + package_tmp[
                                0].split('enigma2-plugin-picons-tv-ocram.')[
                                    1] + 'updated ' + package_tmp[2] + '\n'
                    config.softwareupdate.updatefound.setValue(True)
                    choices = [(_("View the changes"), "changes"),
                               (_("Upgrade and reboot system"), "cold")]
                    if path.exists(
                            "/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/BackupManager.pyo"
                    ):
                        if not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
                            choices.append(
                                (_("Perform a settings backup,") + '\n\t' +
                                 _("making a backup before updating") +
                                 '\n\t' + _("is strongly advised."), "backup"))
                        if not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                            choices.append((_("Perform a full image backup"),
                                            "imagebackup"))
                    choices.append((_("Update channel list only"), "channels"))
                    choices.append((_("Cancel"), ""))
                    upgrademessage = self.session.openWithCallback(
                        self.startActualUpgrade,
                        ChoiceBox,
                        title=message,
                        list=choices,
                        skin_name="SoftwareUpdateChoices",
                        var=self.trafficLight)
                    upgrademessage.setTitle(_('Software update'))
                else:
                    upgrademessage = self.session.openWithCallback(
                        self.close,
                        MessageBox,
                        _("Nothing to upgrade"),
                        type=MessageBox.TYPE_INFO,
                        timeout=10,
                        close_on_any_key=True)
                    upgrademessage.setTitle(_('Software update'))
            elif self.channellist_only > 0:
                if self.channellist_only == 1:
                    self.setEndMessage(
                        _("Could not find installed channel list."))
                elif self.channellist_only == 2:
                    self.slider.setValue(2)
                    self.ipkg.startCmd(IpkgComponent.CMD_REMOVE,
                                       {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 3:
                    self.slider.setValue(3)
                    self.ipkg.startCmd(IpkgComponent.CMD_INSTALL,
                                       {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 4:
                    self.showUpdateCompletedMessage()
                    eDVBDB.getInstance().reloadBouquets()
                    eDVBDB.getInstance().reloadServicelist()
            elif self.error == 0:
                self.showUpdateCompletedMessage()
            else:
                self.activityTimer.stop()
                self.activityslider.setValue(0)
                error = _(
                    "Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s."
                ) % (getMachineBrand(), getMachineName(), getMachineBrand(),
                     getMachineName())
                if self.packages == 0:
                    error = _("No updates available. Please try again later.")
                if self.updating:
                    error = _(
                        "Update failed. Your %s %s does not have a working internet connection."
                    ) % (getMachineBrand(), getMachineName())
                self.status.setText(_("Error") + " - " + error)
        elif event == IpkgComponent.EVENT_LISTITEM:
            if 'enigma2-plugin-settings-' in param[
                    0] and self.channellist_only > 0:
                self.channellist_name = param[0]
                self.channellist_only = 2
        #print event, "-", param
        pass

    def setEndMessage(self, txt):
        self.slider.setValue(4)
        self.activityTimer.stop()
        self.activityslider.setValue(0)
        self.package.setText(txt)
        self.status.setText(self.oktext)

    def startActualUpgrade(self, answer):
        if not answer or not answer[1]:
            self.close()
            return

        if answer[1] == "menu":
            if config.softwareupdate.updateisunstable.value == '1':
                message = _("The current update may be unstable") + "\n" + _(
                    "Are you sure you want to update your %s %s ?") % (
                        getMachineBrand(), getMachineName()
                    ) + "\n(%s " % self.total_packages + _("Packages") + ")"
            elif config.softwareupdate.updateisunstable.value == '0':
                message = _("Do you want to update your %s %s ?") % (
                    getMachineBrand(), getMachineName()
                ) + "\n(%s " % self.total_packages + _("Packages") + ")"
            choices = [(_("View the changes"), "changes"),
                       (_("Upgrade and reboot system"), "cold")]
            if not self.SettingsBackupDone and not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
                choices.append((_(
                    "Perform a settings backup, making a backup before updating is strongly advised."
                ), "backup"))
            if not self.ImageBackupDone and not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                choices.append(
                    (_("Perform a full image backup"), "imagebackup"))
            choices.append((_("Update channel list only"), "channels"))
            choices.append((_("Cancel"), ""))
            upgrademessage = self.session.openWithCallback(
                self.startActualUpgrade,
                ChoiceBox,
                title=message,
                list=choices,
                skin_name="SoftwareUpdateChoices",
                var=self.trafficLight)
            upgrademessage.setTitle(_('Software update'))
        elif answer[1] == "changes":
            self.session.openWithCallback(self.startActualUpgrade,
                                          SoftwareUpdateChanges)
        elif answer[1] == "backup":
            self.doSettingsBackup()
        elif answer[1] == "imagebackup":
            self.doImageBackup()
        elif answer[1] == "channels":
            self.channellist_only = 1
            self.slider.setValue(1)
            self.ipkg.startCmd(IpkgComponent.CMD_LIST,
                               args={'installed_only': True})
        elif answer[1] == "cold":
            if (config.softwareupdate.autosettingsbackup.value
                    and config.backupmanager.backuplocation.value) or (
                        config.softwareupdate.autoimagebackup.value
                        and config.imagemanager.backuplocation.value):
                self.doAutoBackup()
            else:
                self.session.open(TryQuitMainloop, retvalue=42)
                self.close()

    def modificationCallback(self, res):
        self.ipkg.write(res and "N" or "Y")

    def doSettingsBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.BackupManager import BackupFiles
        self.BackupFiles = BackupFiles(self.session, True)
        Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('vix', 'Backup Manager'):
                break
        self.showJobView(job)

    def doImageBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.ImageManager import ImageBackup
        self.ImageBackup = ImageBackup(self.session, True)
        Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('vix', 'Image Manager'):
                break
        self.showJobView(job)

    def doAutoBackup(self, val=False):
        self.autobackuprunning = True
        if config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value and not self.SettingsBackupDone:
            self.doSettingsBackup()
        elif config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value and not self.ImageBackupDone:
            self.doImageBackup()
        else:
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()

    def showJobView(self, job):
        if job.name == dgettext('vix', 'Image Manager'):
            self.ImageBackupDone = True
        elif job.name == dgettext('vix', 'Backup Manager'):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView
        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(self.startActualUpgrade(
                ("menu", "menu")),
                                          JobView,
                                          job,
                                          cancelable=False,
                                          backgroundable=False,
                                          afterEventChangeable=False,
                                          afterEvent="close")
        else:
            self.session.openWithCallback(self.doAutoBackup,
                                          JobView,
                                          job,
                                          cancelable=False,
                                          backgroundable=False,
                                          afterEventChangeable=False,
                                          afterEvent="close")

    def exit(self):
        if not self.ipkg.isRunning():
            if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
                self.session.openWithCallback(
                    self.exitAnswer, MessageBox,
                    _("Upgrade finished.") + " " +
                    _("Do you want to reboot your %s %s") %
                    (getMachineBrand(), getMachineName()))
            else:
                self.close()
        else:
            if not self.updating:
                self.close()

    def exitAnswer(self, result):
        if result is not None and result:
            self.session.open(TryQuitMainloop, retvalue=2)
        self.close()
Esempio n. 44
0
class UpdatePlugin(Screen):

    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _('Software Update'))
        self.sliderPackages = {'dreambox-dvb-modules': 1,
         'enigma2': 2,
         'tuxbox-image-info': 3}
        self.setTitle(_('Software update'))
        self.slider = Slider(0, 4)
        self['slider'] = self.slider
        self.activityslider = Slider(0, 100)
        self['activityslider'] = self.activityslider
        self.status = StaticText(_('Please wait...'))
        self['status'] = self.status
        self.package = StaticText(_('Package list update'))
        self['package'] = self.package
        self.oktext = _('Press OK on your remote control to continue.')
        status_msgs = {'stable': _('Feeds status:   Stable'),
         'unstable': _('Feeds status:   Unstable'),
         'updating': _('Feeds status:   Updating'),
         'unknown': _('No connection')}
        self['tl_off'] = Pixmap()
        self['tl_red'] = Pixmap()
        self['tl_yellow'] = Pixmap()
        self['tl_green'] = Pixmap()
        self.feedsStatus()
        self['feedStatusMSG'] = Label(status_msgs[self.trafficLight])
        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False
        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()
        return

    def feedsStatus(self):
        from urllib import urlopen
        import socket
        self['tl_red'].hide()
        self['tl_yellow'].hide()
        self['tl_green'].hide()
        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        try:
            d = urlopen('http://openvix.co.uk/TrafficLightState.php')
            self.trafficLight = d.read()
            if self.trafficLight == 'unstable':
                self['tl_off'].hide()
                self['tl_red'].show()
            elif self.trafficLight == 'updating':
                self['tl_off'].hide()
                self['tl_yellow'].show()
            elif self.trafficLight == 'stable':
                self['tl_off'].hide()
                self['tl_green'].show()
            else:
                self.trafficLight = 'unknown'
                self['tl_off'].show()
        except:
            self.trafficLight = 'unknown'
            self['tl_off'].show()

        socket.setdefaulttimeout(currentTimeoutDefault)

    def checkNetworkState(self):
        cmd1 = 'opkg update'
        self.CheckConsole = Console()
        self.CheckConsole.ePopen(cmd1, self.checkNetworkStateFinished)

    def checkNetworkStateFinished(self, result, retval, extra_args = None):
        if 'No space left on device' in result:
            self.session.openWithCallback(self.close, MessageBox, _('Your %s %s have a FULL flash memory, please free memory or expand in USB') % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
        elif 'bad address' in result:
            self.session.openWithCallback(self.close, MessageBox, _('Your %s %s is not connected to the internet, please check your network settings and try again.') % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
        elif ('wget returned 1' or 'wget returned 255' or '404 Not Found') in result:
            self.session.openWithCallback(self.close, MessageBox, _('Sorry feeds are down for maintenance, please try again later. If this issue persists please check www.italysat.eu'), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
        elif 'Collected errors' in result:
            self.session.openWithCallback(self.close, MessageBox, _('A background update check is in progress, please wait a few minutes and try again.'), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
        else:
            self.startCheck()

    def startCheck(self):
        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)
        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)
        self.updating = False
        self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
         'back': self.exit}, -1)
        self.updating = True
        self.activityTimer.start(100, False)
        self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

    def doActivityTimer(self):
        self.activity += 1
        if self.activity == 100:
            self.activity = 0
        self.activityslider.setValue(self.activity)

    def showUpdateCompletedMessage(self):
        self.setEndMessage(ngettext('Update completed, %d package was installed.', 'Update completed, %d packages were installed.', self.packages) % self.packages)

    def ipkgCallback(self, event, param):
        global ocram
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_('Downloading'))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if self.sliderPackages.has_key(param):
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(_('Upgrading') + ': %s/%s' % (self.packages, self.total_packages))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_('Installing'))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_('Removing'))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_('Configuring'))
        elif event == IpkgComponent.EVENT_MODIFIED:
            if config.plugins.softwaremanager.overwriteConfigFiles.value in ('N', 'Y'):
                self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
            else:
                self.session.openWithCallback(self.modificationCallback, MessageBox, _('A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?') % param)
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            if self.updating:
                self.updating = False
                self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
            elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
                from urllib import urlopen
                import socket
                currentTimeoutDefault = socket.getdefaulttimeout()
                socket.setdefaulttimeout(3)
                status = urlopen('http://feeds.italysat.eu/status').read()
                if '404 Not Found' in status:
                    status = '1'
                config.softwareupdate.updateisunstable.setValue(status)
                socket.setdefaulttimeout(currentTimeoutDefault)
                self.total_packages = None
                if config.softwareupdate.updateisunstable.value == '1' and config.softwareupdate.updatebeta.value:
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = _('The current update may be unstable') + '\n' + _('Are you sure you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(' + ngettext('%s updated package available', '%s updated packages available', self.total_packages) % self.total_packages + ')'
                elif config.softwareupdate.updateisunstable.value == '0':
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = _('Do you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(' + ngettext('%s updated package available', '%s updated packages available', self.total_packages) % self.total_packages + ')'
                if self.total_packages:
                    for package_tmp in self.ipkg.getFetchedList():
                        if package_tmp[0].startswith('enigma2-plugin-picons-tv-ocram'):
                            ocram = ocram + '[ocram-picons] ' + package_tmp[0].split('enigma2-plugin-picons-tv-ocram.')[1] + 'updated ' + package_tmp[2] + '\n'
                        elif package_tmp[0].startswith('enigma2-plugin-settings-ocram'):
                            ocram = ocram + '[ocram-settings] ' + package_tmp[0].split('enigma2-plugin-picons-tv-ocram.')[1] + 'updated ' + package_tmp[2] + '\n'

                    config.softwareupdate.updatefound.setValue(True)
                    choices = [(_('Upgrade and reboot system'), 'cold')]
                    if path.exists('/usr/lib/enigma2/python/ItalySat/ItalysatBackupManager.pyo'):
                        if not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
                            choices.append((_('Perform a settings backup,') + '\n\t' + _('making a backup before updating') + '\n\t' + _('is strongly advised.'), 'backup'))
                        if not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                            choices.append((_('Perform a full image backup'), 'imagebackup'))
                    choices.append((_('Cancel'), ''))
                    upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name='SoftwareUpdateChoices', var=self.trafficLight)
                    upgrademessage.setTitle(_('Software update'))
                else:
                    upgrademessage = self.session.openWithCallback(self.close, MessageBox, _('Nothing to upgrade'), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
                    upgrademessage.setTitle(_('Software update'))
            elif self.channellist_only > 0:
                if self.channellist_only == 1:
                    self.setEndMessage(_('Could not find installed channel list.'))
                elif self.channellist_only == 2:
                    self.slider.setValue(2)
                    self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 3:
                    self.slider.setValue(3)
                    self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 4:
                    self.showUpdateCompletedMessage()
                    eDVBDB.getInstance().reloadBouquets()
                    eDVBDB.getInstance().reloadServicelist()
            elif self.error == 0:
                self.showUpdateCompletedMessage()
            else:
                self.activityTimer.stop()
                self.activityslider.setValue(0)
                error = _('Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s.') % (getMachineBrand(),
                 getMachineName(),
                 getMachineBrand(),
                 getMachineName())
                if self.packages == 0:
                    error = _('No updates available. Please try again later.')
                if self.updating:
                    error = _('Update failed. Your %s %s does not have a working internet connection.') % (getMachineBrand(), getMachineName())
                self.status.setText(_('Error') + ' - ' + error)
        elif event == IpkgComponent.EVENT_LISTITEM:
            if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
                self.channellist_name = param[0]
                self.channellist_only = 2
        return

    def setEndMessage(self, txt):
        self.slider.setValue(4)
        self.activityTimer.stop()
        self.activityslider.setValue(0)
        self.package.setText(txt)
        self.status.setText(self.oktext)

    def startActualUpgrade(self, answer):
        if not answer or not answer[1]:
            self.close()
            return
        if answer[1] == 'menu':
            if config.softwareupdate.updateisunstable.value == '1':
                message = _('The current update may be unstable') + '\n' + _('Are you sure you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(%s ' % self.total_packages + _('Packages') + ')'
            elif config.softwareupdate.updateisunstable.value == '0':
                message = _('Do you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(%s ' % self.total_packages + _('Packages') + ')'
            choices = [(_('Upgrade and reboot system'), 'cold')]
            if not self.SettingsBackupDone and not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
                choices.append((_('Perform a settings backup, making a backup before updating is strongly advised.'), 'backup'))
            if not self.ImageBackupDone and not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                choices.append((_('Perform a full image backup'), 'imagebackup'))
            choices.append((_('Cancel'), ''))
            upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name='SoftwareUpdateChoices', var=self.trafficLight)
            upgrademessage.setTitle(_('Software update'))
        elif answer[1] == 'changes':
            self.session.openWithCallback(self.startActualUpgrade, SoftwareUpdateChanges)
        elif answer[1] == 'backup':
            self.doSettingsBackup()
        elif answer[1] == 'imagebackup':
            self.doImageBackup()
        elif answer[1] == 'channels':
            self.channellist_only = 1
            self.slider.setValue(1)
            self.ipkg.startCmd(IpkgComponent.CMD_LIST, args={'installed_only': True})
        elif answer[1] == 'cold':
            if config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value or config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                self.doAutoBackup()
            else:
                self.session.open(TryQuitMainloop, retvalue=42)
                self.close()

    def modificationCallback(self, res):
        self.ipkg.write(res and 'N' or 'Y')

    def doSettingsBackup(self):
        backup = None
        from ItalySat.ItalysatBackupManager import BackupFiles
        self.BackupFiles = BackupFiles(self.session, True)
        Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('italysat', 'Backup Manager'):
                break

        self.showJobView(job)
        return

    def doImageBackup(self):
        backup = None
        from ItalySat.ItalysatImageManager import ImageBackup
        self.ImageBackup = ImageBackup(self.session, True)
        Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('italysat', 'Image Manager'):
                break

        self.showJobView(job)
        return

    def doAutoBackup(self, val = False):
        self.autobackuprunning = True
        if config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value and not self.SettingsBackupDone:
            self.doSettingsBackup()
        elif config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value and not self.ImageBackupDone:
            self.doImageBackup()
        else:
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()

    def showJobView(self, job):
        if job.name == dgettext('italysat', 'Image Manager'):
            self.ImageBackupDone = True
        elif job.name == dgettext('italysat', 'Backup Manager'):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView
        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(self.startActualUpgrade(('menu', 'menu')), JobView, job, cancelable=False, backgroundable=False, afterEventChangeable=False, afterEvent='close')
        else:
            self.session.openWithCallback(self.doAutoBackup, JobView, job, cancelable=False, backgroundable=False, afterEventChangeable=False, afterEvent='close')

    def exit(self):
        if not self.ipkg.isRunning():
            if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
                self.session.openWithCallback(self.exitAnswer, MessageBox, _('Upgrade finished.') + ' ' + _('Do you want to reboot your %s %s') % (getMachineBrand(), getMachineName()))
            else:
                self.close()
        elif not self.updating:
            self.close()

    def exitAnswer(self, result):
        if result is not None and result:
            self.session.open(TryQuitMainloop, retvalue=2)
        self.close()
        return
Esempio n. 45
0
class Ipkg(Screen):
	def __init__(self, session, cmdList=None):
		if not cmdList: cmdList = []
		Screen.__init__(self, session)

		self.cmdList = cmdList

		self.sliderPackages = {}

		self.slider = Slider(0, len(cmdList))
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = Label(_("Preparing... Please wait"))
		self["status"] = self.status
		self.package = Label()
		self["package"] = self.package

		self.packages = 0
		self.error = 0
		self.processed_packages = []

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)
		#self.activityTimer.start(100, False)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self.runningCmd = None
		self.runNextCmd()

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

	def runNextCmd(self):
		if self.runningCmd is None:
			self.runningCmd = 0
		else:
			self.runningCmd += 1
		print len(self.cmdList), self.runningCmd
		if len(self.cmdList) - 1 < self.runningCmd:
			self.activityslider.setValue(0)
			self.slider.setValue(len(self.cmdList))

			self.package.setText("")
			self.status.setText(ngettext("Done - Installed, upgraded or removed %d package (%s)", "Done - Installed, upgraded or removed %d packages (%s)", self.packages) % (self.packages, ngettext("with %d error", "with %d errors", self.error) % self.error))
			return False
		else:
			cmd = self.cmdList[self.runningCmd]
			self.slider.setValue(self.runningCmd)
			self.ipkg.startCmd(cmd[0], args = cmd[1])
			self.startActivityTimer()

	def doActivityTimer(self):
		if not self.ipkg.isRunning():
			self.stopActivityTimer()
		else:
			self.activity += 1
			if self.activity == 100:
				self.activity = 0
			self.activityslider.setValue(self.activity)

	def startActivityTimer(self):
		self.activityTimer.start(100, False)

	def stopActivityTimer(self):
		self.activityTimer.stop()

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			self.runNextCmd()
		elif event == IpkgComponent.EVENT_MODIFIED:
			self.session.openWithCallback(
				self.modificationCallback,
				MessageBox,
				_("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % param
			)

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def exit(self):
		if not self.ipkg.isRunning():
			self.close()
Esempio n. 46
0
class UpdatePlugin(Screen):
    def __init__(self, session, *args):
        Screen.__init__(self, session)
        Screen.setTitle(self, _("Software Update"))

        self.sliderPackages = {"dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3}

        self.setTitle(_("Software update"))

        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        status_msgs = {
            "stable": _("Feeds status:   Stable"),
            "unstable": _("Feeds status:   Unstable"),
            "updating": _("Feeds status:   Updating"),
            "unknown": _("No connection"),
        }
        self["tl_off"] = Pixmap()
        self["tl_red"] = Pixmap()
        self["tl_yellow"] = Pixmap()
        self["tl_green"] = Pixmap()
        self.feedsStatus()
        self["feedStatusMSG"] = Label(status_msgs[self.trafficLight])

        self.channellist_only = 0
        self.channellist_name = ""
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.checkNetworkState()

    def feedsStatus(self):
        from urllib import urlopen
        import socket

        self["tl_red"].hide()
        self["tl_yellow"].hide()
        self["tl_green"].hide()
        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        try:
            d = urlopen("http://openvix.co.uk/TrafficLightState.php")
            self.trafficLight = d.read()
            if self.trafficLight == "unstable":
                self["tl_off"].hide()
                self["tl_red"].show()
            elif self.trafficLight == "updating":
                self["tl_off"].hide()
                self["tl_yellow"].show()
            elif self.trafficLight == "stable":
                self["tl_off"].hide()
                self["tl_green"].show()
            else:
                self.trafficLight = "unknown"
                self["tl_off"].show()
        except:
            self.trafficLight = "unknown"
            self["tl_off"].show()
        socket.setdefaulttimeout(currentTimeoutDefault)

    def checkNetworkState(self):
        cmd1 = "opkg update"
        self.CheckConsole = Console()
        self.CheckConsole.ePopen(cmd1, self.checkNetworkStateFinished)

    def checkNetworkStateFinished(self, result, retval, extra_args=None):
        if "bad address" in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("Your %s %s is not connected to the internet, please check your network settings and try again.")
                % (getMachineBrand(), getMachineName()),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True,
            )
        elif ("wget returned 1" or "wget returned 255" or "404 Not Found") in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _(
                    "Sorry feeds are down for maintenance, please try again later. If this issue persists please check openvix.co.uk or world-of-satellite.com."
                ),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True,
            )
        elif "Collected errors" in result:
            self.session.openWithCallback(
                self.close,
                MessageBox,
                _("A background update check is in progress, please wait a few minutes and try again."),
                type=MessageBox.TYPE_INFO,
                timeout=10,
                close_on_any_key=True,
            )
        else:
            self.startCheck()

    def startCheck(self):
        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)

        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)

        self.updating = False

        self["actions"] = ActionMap(["WizardActions"], {"ok": self.exit, "back": self.exit}, -1)

        self.updating = True
        self.activityTimer.start(100, False)
        self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

    def doActivityTimer(self):
        self.activity += 1
        if self.activity == 100:
            self.activity = 0
        self.activityslider.setValue(self.activity)

    def showUpdateCompletedMessage(self):
        self.setEndMessage(
            ngettext(
                "Update completed, %d package was installed.",
                "Update completed, %d packages were installed.",
                self.packages,
            )
            % self.packages
        )

    def ipkgCallback(self, event, param):
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_("Downloading"))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if self.sliderPackages.has_key(param):
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_("Installing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_("Removing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_("Configuring"))

        elif event == IpkgComponent.EVENT_MODIFIED:
            if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
                self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
            else:
                self.session.openWithCallback(
                    self.modificationCallback,
                    MessageBox,
                    _(
                        "A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?"
                    )
                    % param,
                )
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            if self.updating:
                self.updating = False
                self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
            elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
                from urllib import urlopen
                import socket

                currentTimeoutDefault = socket.getdefaulttimeout()
                socket.setdefaulttimeout(3)
                status = urlopen("http://www.openvix.co.uk/feeds/status").read()
                if "404 Not Found" in status:
                    status = "1"
                config.softwareupdate.updateisunstable.setValue(status)
                socket.setdefaulttimeout(currentTimeoutDefault)
                self.total_packages = None
                if config.softwareupdate.updateisunstable.value == "1" and config.softwareupdate.updatebeta.value:
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = (
                        _("The current update may be unstable")
                        + "\n"
                        + _("Are you sure you want to update your %s %s ?") % (getMachineBrand(), getMachineName())
                        + "\n("
                        + (
                            ngettext(
                                "%s updated package available", "%s updated packages available", self.total_packages
                            )
                            % self.total_packages
                        )
                        + ")"
                    )
                elif config.softwareupdate.updateisunstable.value == "0":
                    self.total_packages = len(self.ipkg.getFetchedList())
                    message = (
                        _("Do you want to update your %s %s ?") % (getMachineBrand(), getMachineName())
                        + "\n("
                        + (
                            ngettext(
                                "%s updated package available", "%s updated packages available", self.total_packages
                            )
                            % self.total_packages
                        )
                        + ")"
                    )
                if self.total_packages:
                    global ocram
                    for package_tmp in self.ipkg.getFetchedList():
                        if package_tmp[0].startswith("enigma2-plugin-picons-tv-ocram"):
                            ocram = (
                                ocram
                                + "[ocram-picons] "
                                + package_tmp[0].split("enigma2-plugin-picons-tv-ocram.")[1]
                                + "updated "
                                + package_tmp[2]
                                + "\n"
                            )
                        elif package_tmp[0].startswith("enigma2-plugin-settings-ocram"):
                            ocram = (
                                ocram
                                + "[ocram-settings] "
                                + package_tmp[0].split("enigma2-plugin-picons-tv-ocram.")[1]
                                + "updated "
                                + package_tmp[2]
                                + "\n"
                            )
                    config.softwareupdate.updatefound.setValue(True)
                    choices = [(_("View the changes"), "changes"), (_("Upgrade and reboot system"), "cold")]
                    if path.exists("/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/BackupManager.pyo"):
                        if (
                            not config.softwareupdate.autosettingsbackup.value
                            and config.backupmanager.backuplocation.value
                        ):
                            choices.append(
                                (
                                    _("Perform a settings backup,")
                                    + "\n\t"
                                    + _("making a backup before updating")
                                    + "\n\t"
                                    + _("is strongly advised."),
                                    "backup",
                                )
                            )
                        if not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                            choices.append((_("Perform a full image backup"), "imagebackup"))
                    choices.append((_("Update channel list only"), "channels"))
                    choices.append((_("Cancel"), ""))
                    upgrademessage = self.session.openWithCallback(
                        self.startActualUpgrade,
                        ChoiceBox,
                        title=message,
                        list=choices,
                        skin_name="SoftwareUpdateChoices",
                        var=self.trafficLight,
                    )
                    upgrademessage.setTitle(_("Software update"))
                else:
                    upgrademessage = self.session.openWithCallback(
                        self.close,
                        MessageBox,
                        _("Nothing to upgrade"),
                        type=MessageBox.TYPE_INFO,
                        timeout=10,
                        close_on_any_key=True,
                    )
                    upgrademessage.setTitle(_("Software update"))
            elif self.channellist_only > 0:
                if self.channellist_only == 1:
                    self.setEndMessage(_("Could not find installed channel list."))
                elif self.channellist_only == 2:
                    self.slider.setValue(2)
                    self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {"package": self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 3:
                    self.slider.setValue(3)
                    self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {"package": self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 4:
                    self.showUpdateCompletedMessage()
                    eDVBDB.getInstance().reloadBouquets()
                    eDVBDB.getInstance().reloadServicelist()
            elif self.error == 0:
                self.showUpdateCompletedMessage()
            else:
                self.activityTimer.stop()
                self.activityslider.setValue(0)
                error = _(
                    "Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s."
                ) % (getMachineBrand(), getMachineName(), getMachineBrand(), getMachineName())
                if self.packages == 0:
                    error = _("No updates available. Please try again later.")
                if self.updating:
                    error = _("Update failed. Your %s %s does not have a working internet connection.") % (
                        getMachineBrand(),
                        getMachineName(),
                    )
                self.status.setText(_("Error") + " - " + error)
        elif event == IpkgComponent.EVENT_LISTITEM:
            if "enigma2-plugin-settings-" in param[0] and self.channellist_only > 0:
                self.channellist_name = param[0]
                self.channellist_only = 2
                # print event, "-", param
        pass

    def setEndMessage(self, txt):
        self.slider.setValue(4)
        self.activityTimer.stop()
        self.activityslider.setValue(0)
        self.package.setText(txt)
        self.status.setText(self.oktext)

    def startActualUpgrade(self, answer):
        if not answer or not answer[1]:
            self.close()
            return

        if answer[1] == "menu":
            if config.softwareupdate.updateisunstable.value == "1":
                message = (
                    _("The current update may be unstable")
                    + "\n"
                    + _("Are you sure you want to update your %s %s ?") % (getMachineBrand(), getMachineName())
                    + "\n(%s " % self.total_packages
                    + _("Packages")
                    + ")"
                )
            elif config.softwareupdate.updateisunstable.value == "0":
                message = (
                    _("Do you want to update your %s %s ?") % (getMachineBrand(), getMachineName())
                    + "\n(%s " % self.total_packages
                    + _("Packages")
                    + ")"
                )
            choices = [(_("View the changes"), "changes"), (_("Upgrade and reboot system"), "cold")]
            if (
                not self.SettingsBackupDone
                and not config.softwareupdate.autosettingsbackup.value
                and config.backupmanager.backuplocation.value
            ):
                choices.append(
                    (_("Perform a settings backup, making a backup before updating is strongly advised."), "backup")
                )
            if (
                not self.ImageBackupDone
                and not config.softwareupdate.autoimagebackup.value
                and config.imagemanager.backuplocation.value
            ):
                choices.append((_("Perform a full image backup"), "imagebackup"))
            choices.append((_("Update channel list only"), "channels"))
            choices.append((_("Cancel"), ""))
            upgrademessage = self.session.openWithCallback(
                self.startActualUpgrade,
                ChoiceBox,
                title=message,
                list=choices,
                skin_name="SoftwareUpdateChoices",
                var=self.trafficLight,
            )
            upgrademessage.setTitle(_("Software update"))
        elif answer[1] == "changes":
            self.session.openWithCallback(self.startActualUpgrade, SoftwareUpdateChanges)
        elif answer[1] == "backup":
            self.doSettingsBackup()
        elif answer[1] == "imagebackup":
            self.doImageBackup()
        elif answer[1] == "channels":
            self.channellist_only = 1
            self.slider.setValue(1)
            self.ipkg.startCmd(IpkgComponent.CMD_LIST, args={"installed_only": True})
        elif answer[1] == "cold":
            if (config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value) or (
                config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value
            ):
                self.doAutoBackup()
            else:
                self.session.open(TryQuitMainloop, retvalue=42)
                self.close()

    def modificationCallback(self, res):
        self.ipkg.write(res and "N" or "Y")

    def doSettingsBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.BackupManager import BackupFiles

        self.BackupFiles = BackupFiles(self.session, True)
        Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext("vix", "Backup Manager"):
                break
        self.showJobView(job)

    def doImageBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.ImageManager import ImageBackup

        self.ImageBackup = ImageBackup(self.session, True)
        Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext("vix", "Image Manager"):
                break
        self.showJobView(job)

    def doAutoBackup(self, val=False):
        self.autobackuprunning = True
        if (
            config.softwareupdate.autosettingsbackup.value
            and config.backupmanager.backuplocation.value
            and not self.SettingsBackupDone
        ):
            self.doSettingsBackup()
        elif (
            config.softwareupdate.autoimagebackup.value
            and config.imagemanager.backuplocation.value
            and not self.ImageBackupDone
        ):
            self.doImageBackup()
        else:
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()

    def showJobView(self, job):
        if job.name == dgettext("vix", "Image Manager"):
            self.ImageBackupDone = True
        elif job.name == dgettext("vix", "Backup Manager"):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView

        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(
                self.startActualUpgrade(("menu", "menu")),
                JobView,
                job,
                cancelable=False,
                backgroundable=False,
                afterEventChangeable=False,
                afterEvent="close",
            )
        else:
            self.session.openWithCallback(
                self.doAutoBackup,
                JobView,
                job,
                cancelable=False,
                backgroundable=False,
                afterEventChangeable=False,
                afterEvent="close",
            )

    def exit(self):
        if not self.ipkg.isRunning():
            if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
                self.session.openWithCallback(
                    self.exitAnswer,
                    MessageBox,
                    _("Upgrade finished.")
                    + " "
                    + _("Do you want to reboot your %s %s") % (getMachineBrand(), getMachineName()),
                )
            else:
                self.close()
        else:
            if not self.updating:
                self.close()

    def exitAnswer(self, result):
        if result is not None and result:
            self.session.open(TryQuitMainloop, retvalue=2)
        self.close()
Esempio n. 47
0
    def __init__(self,
                 session,
                 showSteps=True,
                 showStepSlider=True,
                 showList=True,
                 showConfig=True):
        Screen.__init__(self, session)

        self.isLastWizard = False  # can be used to skip a "goodbye"-screen in a wizard

        self.stepHistory = []

        self.wizard = {}
        parser = make_parser()
        if not isinstance(self.xmlfile, list):
            self.xmlfile = [self.xmlfile]
        print "Reading ", self.xmlfile
        wizardHandler = self.parseWizard(self.wizard)
        parser.setContentHandler(wizardHandler)
        for xmlfile in self.xmlfile:
            if xmlfile[0] != '/':
                parser.parse(eEnv.resolve('${datadir}/enigma2/') + xmlfile)
            else:
                parser.parse(xmlfile)

        self.showSteps = showSteps
        self.showStepSlider = showStepSlider
        self.showList = showList
        self.showConfig = showConfig

        self.numSteps = len(self.wizard)
        self.currStep = self.getStepWithID("start") + 1

        self.timeoutTimer = eTimer()
        self.timeoutTimer.callback.append(self.timeoutCounterFired)

        self["text"] = Label()

        if showConfig:
            self["config"] = ConfigList([], session=session)

        if self.showSteps:
            self["step"] = Label()

        if self.showStepSlider:
            self["stepslider"] = Slider(1, self.numSteps)

        if self.showList:
            self.list = []
            self["list"] = List(self.list, enableWrapAround=True)
            self["list"].onSelectionChanged.append(self.selChanged)
            #self["list"] = MenuList(self.list, enableWrapAround = True)

        self.onShown.append(self.updateValues)

        self.configInstance = None
        self.currentConfigIndex = None

        Wizard.instance = self

        self.lcdCallbacks = []

        self.disableKeys = False

        self["actions"] = NumberActionMap(
            [
                "WizardActions", "NumberActions", "ColorActions",
                "SetupActions", "InputAsciiActions", "KeyboardInputActions"
            ], {
                "gotAsciiCode": self.keyGotAscii,
                "ok": self.ok,
                "back": self.back,
                "left": self.left,
                "right": self.right,
                "up": self.up,
                "down": self.down,
                "red": self.red,
                "green": self.green,
                "yellow": self.yellow,
                "blue": self.blue,
                "deleteBackward": self.deleteBackward,
                "deleteForward": self.deleteForward,
                "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
            }, -1)

        self["VirtualKB"] = NumberActionMap(
            ["VirtualKeyboardActions"], {
                "showVirtualKeyboard": self.KeyText,
            }, -2)

        self["VirtualKB"].setEnabled(False)
Esempio n. 48
0
class UpdatePlugin(Screen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""

	def __init__(self, session, *args):
		Screen.__init__(self, session)
		Screen.setTitle(self, _("Software Update"))

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.checkNetworkState()

	def checkNetworkState(self):
		cmd1 = "opkg update"
		self.CheckConsole = Console()
		self.CheckConsole.ePopen(cmd1, self.checkNetworkStateFinished)

	def checkNetworkStateFinished(self, result, retval,extra_args=None):
		if result.find('wget returned 1') != -1 or result.find('wget returned 255') != -1 or result.find('404 Not Found') != -1:
			self.session.openWithCallback(self.close, MessageBox, _("Sorry feeds are down for maintenance, please try again later."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		elif result.find('bad address') != -1:
			self.session.openWithCallback(self.close, MessageBox, _("Your STB_BOX is not connected to the internet, please check your network settings and try again."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		elif result.find('Collected errors') != -1:
			self.session.openWithCallback(self.close, MessageBox, _("A background update check is is progress, please wait a few minutes and try again."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		else:
			self.startCheck()

	def startCheck(self):
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self.updating = False

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.updating = True
		self.activityTimer.start(100, False)
		self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))

		elif event == IpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.getValue() in ("N", "Y"):
				self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.getValue())
			else:
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % (param)
				)
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
			elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
				from urllib import urlopen
				import socket
				currentTimeoutDefault = socket.getdefaulttimeout()
				socket.setdefaulttimeout(3)
				try:
					config.softwareupdate.updateisunstable.setValue(urlopen("http://enigma2.world-of-satellite.com/feeds/" + about.getImageVersionString() + "/status").read())
				except:
					config.softwareupdate.updateisunstable.setValue(1)
				socket.setdefaulttimeout(currentTimeoutDefault)
				self.total_packages = None
				if config.softwareupdate.updateisunstable.getValue() == '1' and config.softwareupdate.updatebeta.getValue():
					self.total_packages = len(self.ipkg.getFetchedList())
					message = _("The current update maybe unstable") + "\n" + _("Are you sure you want to update your STB_BOX?") + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
				elif config.softwareupdate.updateisunstable.getValue() == '0':
					self.total_packages = len(self.ipkg.getFetchedList())
					message = _("Do you want to update your STB_BOX?") + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
				if self.total_packages:
					config.softwareupdate.updatefound.setValue(True)
					choices = [(_("View the changes"), "changes"),
						(_("Upgrade and reboot system"), "cold")]
					if path.exists("/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/BackupManager.pyo"):
						if not config.softwareupdate.autosettingsbackup.getValue():
							choices.append((_("Perform a setting backup,") + '\n\t' + _("making a backup before updating") + '\n\t' +_("is strongly advised."), "backup"))
						if not config.softwareupdate.autoimagebackup.getValue():
							choices.append((_("Perform a full image backup"), "imagebackup"))
					choices.append((_("Update channel list only"), "channels"))
					choices.append((_("Cancel"), ""))
					upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name = "SoftwareUpdateChoices")
					upgrademessage.setTitle(_('Software update'))
				else:
					upgrademessage = self.session.openWithCallback(self.close, MessageBox, _("Nothing to upgrade"), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
					upgrademessage.setTitle(_('Software update'))
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your STB_BOX might be unusable now. Please consult the manual for further assistance before rebooting your STB_BOX.")
				if self.packages == 0:
					error = _("No updates available. Please try again later.")
				if self.updating:
					error = _("Update failed. Your STB_BOX does not have a working internet connection.")
				self.status.setText(_("Error") +  " - " + error)
		elif event == IpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print event, "-", param
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return

		if answer[1] == "menu":
			if config.softwareupdate.updateisunstable.getValue() == '1':
				message = _("The current update maybe unstable") + "\n" + _("Are you sure you want to update your STB_BOX?") + "\n(%s " % self.total_packages + _("Packages") + ")"
			elif config.softwareupdate.updateisunstable.getValue() == '0':
				message = _("Do you want to update your STB_BOX?") + "\n(%s " % self.total_packages + _("Packages") + ")"
			choices = [(_("View the changes"), "changes"),
				(_("Upgrade and reboot system"), "cold")]
			if not self.SettingsBackupDone and not config.softwareupdate.autosettingsbackup.getValue():
				choices.append((_("Perform a setting backup, making a backup before updating is strongly advised."), "backup"))
			if not self.ImageBackupDone and not config.softwareupdate.autoimagebackup.getValue():
				choices.append((_("Perform a full image backup"), "imagebackup"))
			choices.append((_("Update channel list only"), "channels"))
			choices.append((_("Cancel"), ""))
			upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name = "SoftwareUpdateChoices")
			upgrademessage.setTitle(_('Software update'))
		elif answer[1] == "changes":
			self.session.openWithCallback(self.startActualUpgrade,SoftwareUpdateChanges)
		elif answer[1] == "backup":
			self.doSettingsBackup()
		elif answer[1] == "imagebackup":
			self.doImageBackup()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.ipkg.startCmd(IpkgComponent.CMD_LIST, args = {'installed_only': True})
		elif answer[1] == "cold":
			if config.softwareupdate.autosettingsbackup.getValue() or config.softwareupdate.autoimagebackup.getValue():
				self.doAutoBackup()
			else:
				self.session.open(TryQuitMainloop,retvalue=42)
				self.close()

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def doSettingsBackup(self):
		backup = None
		from Plugins.SystemPlugins.ViX.BackupManager import BackupFiles
		self.BackupFiles = BackupFiles(self.session)
		Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
		Components.Task.job_manager.in_background = False
		for job in Components.Task.job_manager.getPendingJobs():
			if job.name == dgettext('ViX', 'Backup Manager'):
				break
		self.showJobView(job)

	def doImageBackup(self):
		backup = None
		from Plugins.SystemPlugins.ViX.ImageManager import ImageBackup
		self.ImageBackup = ImageBackup(self.session)
		Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
		Components.Task.job_manager.in_background = False
		for job in Components.Task.job_manager.getPendingJobs():
			if job.name == dgettext('ViX', 'Image Manager'):
				break
		self.showJobView(job)

	def doAutoBackup(self, val = False):
		self.autobackuprunning = True
		if config.softwareupdate.autosettingsbackup.getValue() and not self.SettingsBackupDone:
			self.doSettingsBackup()
		elif config.softwareupdate.autoimagebackup.getValue() and not self.ImageBackupDone:
			self.doImageBackup()
		else:
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()

	def showJobView(self, job):
		if job.name == dgettext('ViX', 'Image Manager'):
			self.ImageBackupDone = True
		elif job.name == dgettext('ViX', 'Backup Manager'):
			self.SettingsBackupDone = True
		from Screens.TaskView import JobView
		Components.Task.job_manager.in_background = False
		if not self.autobackuprunning:
			self.session.openWithCallback(self.startActualUpgrade(("menu", "menu")), JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")
		else:
			self.session.openWithCallback(self.doAutoBackup, JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your STB_BOX?"))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop, retvalue=2)
		self.close()
Esempio n. 49
0
class UpdatePlugin(Screen, ProtectedScreen):

    def __init__(self, session, *args):
        Screen.__init__(self, session)
        ProtectedScreen.__init__(self)
        Screen.setTitle(self, _('Software Update'))
        self.sliderPackages = {'ini-dvb-modules': 1,
         'enigma2': 2,
         'tuxbox-image-info': 3}
        self.slider = Slider(0, 4)
        self['slider'] = self.slider
        self.activityslider = Slider(0, 100)
        self['activityslider'] = self.activityslider
        self.status = StaticText(_('Please wait...'))
        self['status'] = self.status
        self.package = StaticText(_('Package list update'))
        self['package'] = self.package
        self.oktext = _('Press OK on your remote control to continue.')
        self['tl_off'] = Pixmap()
        self['tl_red'] = Pixmap()
        self['tl_yellow'] = Pixmap()
        self['tl_green'] = Pixmap()
        self['feedStatusMSG'] = Label()
        self.channellist_only = 0
        self.channellist_name = ''
        self.SettingsBackupDone = False
        self.ImageBackupDone = False
        self.autobackuprunning = False
        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None
        self.onFirstExecBegin.append(self.checkNetworkState)

    def checkNetworkState(self):
        self.trafficLight = feedsstatuscheck.getFeedsBool()
        status_msgs = {'stable': _('Feeds status:   Stable'),
         'unstable': _('Feeds status:   Unstable'),
         'updating': _('Feeds status:   Updating'),
         '-2': _('ERROR:   No network found'),
         '404': _('ERROR:   No internet found'),
         'inprogress': _('ERROR: Check is already running in background'),
         'unknown': _('No connection')}
        self['tl_red'].hide()
        self['tl_yellow'].hide()
        self['tl_green'].hide()
        self['tl_off'].hide()
        if self.trafficLight:
            self['feedStatusMSG'].setText(status_msgs[str(self.trafficLight)])
        if self.trafficLight == 'stable':
            self['tl_green'].show()
        elif self.trafficLight == 'unstable':
            self['tl_red'].show()
        elif self.trafficLight == 'updating':
            self['tl_yellow'].show()
        else:
            self['tl_off'].show()
        if self.trafficLight not in ('stable', 'unstable'):
            self.session.openWithCallback(self.close, MessageBox, feedsstatuscheck.getFeedsErrorMessage(), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
        elif config.softwareupdate.updateisunstable.value == '1' and config.softwareupdate.updatebeta.value or config.softwareupdate.updateisunstable.value == '0':
            self.startCheck()
        else:
            self.session.openWithCallback(self.close, MessageBox, _('Sorry feeds seem to be in an unstable state, if you wish to use them please enable \'Allow unstable (experimental) updates\' in "Software update settings".'), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)

    def startCheck(self):
        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)
        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)
        self.updating = False
        self['actions'] = ActionMap(['WizardActions'], {'ok': self.exit,
         'back': self.exit}, -1)
        self.updating = True
        self.activityTimer.start(100, False)
        self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

    def isProtected(self):
        return config.ParentalControl.setuppinactive.value and (not config.ParentalControl.config_sections.main_menu.value and not config.ParentalControl.config_sections.configuration.value or hasattr(self.session, 'infobar') and self.session.infobar is None) and config.ParentalControl.config_sections.software_update.value

    def doActivityTimer(self):
        self.activity += 1
        if self.activity == 100:
            self.activity = 0
        self.activityslider.setValue(self.activity)

    def showUpdateCompletedMessage(self):
        self.setEndMessage(ngettext('Update completed, %d package was installed.', 'Update completed, %d packages were installed.', self.packages) % self.packages)

    def ipkgCallback(self, event, param):
        global ocram
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_('Downloading'))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if self.sliderPackages.has_key(param):
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(_('Upgrading') + ': %s/%s' % (self.packages, self.total_packages))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_('Installing'))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_('Removing'))
            if param not in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_('Configuring'))
        elif event == IpkgComponent.EVENT_MODIFIED:
            if config.plugins.softwaremanager.overwriteConfigFiles.value in ('N', 'Y'):
                self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
            else:
                self.session.openWithCallback(self.modificationCallback, MessageBox, _('A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?') % param)
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            if self.updating:
                self.updating = False
                self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
            elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
                self.total_packages = None
                self.total_packages = len(self.ipkg.getFetchedList())
                message = _('Do you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(' + ngettext('%s updated package available', '%s updated packages available', self.total_packages) % self.total_packages + ')'
                if self.total_packages > 150:
                    message += ' ' + _('Reflash recommended!')
                if self.total_packages:
                    for package_tmp in self.ipkg.getFetchedList():
                        if package_tmp[0].startswith('enigma2-plugin-picons-tv-ocram'):
                            ocram = ocram + '[ocram-picons] ' + package_tmp[0].split('enigma2-plugin-picons-tv-ocram.')[1] + 'updated ' + package_tmp[2] + '\n'
                        elif package_tmp[0].startswith('enigma2-plugin-settings-ocram'):
                            ocram = ocram + '[ocram-settings] ' + package_tmp[0].split('enigma2-plugin-picons-tv-ocram.')[1] + 'updated ' + package_tmp[2] + '\n'

                    config.softwareupdate.updatefound.setValue(True)
                    choices = [(_('View the changes'), 'changes'), (_('Update and ask to reboot'), 'hot'), (_('Upgrade and reboot system'), 'cold')]
                    if path.exists('/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/BackupManager.pyo'):
                        if not config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value:
                            choices.append((_('Perform a settings backup,') + '\n\t' + _('making a backup before updating') + '\n\t' + _('is strongly advised.'), 'backup'))
                        if not config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value:
                            choices.append((_('Perform a full image backup'), 'imagebackup'))
                    choices.append((_('Update channel list only'), 'channels'))
                    choices.append((_('Cancel'), ''))
                    upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name='SoftwareUpdateChoices', var=self.trafficLight)
                    upgrademessage.setTitle(_('Software update'))
                else:
                    upgrademessage = self.session.openWithCallback(self.close, MessageBox, _('Nothing to upgrade'), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
                    upgrademessage.setTitle(_('Software update'))
            elif self.channellist_only > 0:
                if self.channellist_only == 1:
                    self.setEndMessage(_('Could not find installed channel list.'))
                elif self.channellist_only == 2:
                    self.slider.setValue(2)
                    self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 3:
                    self.slider.setValue(3)
                    self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 4:
                    self.showUpdateCompletedMessage()
                    eDVBDB.getInstance().reloadBouquets()
                    eDVBDB.getInstance().reloadServicelist()
            elif self.error == 0:
                self.showUpdateCompletedMessage()
            else:
                self.activityTimer.stop()
                self.activityslider.setValue(0)
                error = _('Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s.') % (getMachineBrand(),
                 getMachineName(),
                 getMachineBrand(),
                 getMachineName())
                if self.packages == 0:
                    error = _('A background update check is in progress,\nplease wait a few minutes and try again.')
                if self.updating:
                    error = _('Update failed. Your %s %s does not have a working internet connection.') % (getMachineBrand(), getMachineName())
                self.status.setText(_('Error') + ' - ' + error)
        elif event == IpkgComponent.EVENT_LISTITEM:
            if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
                self.channellist_name = param[0]
                self.channellist_only = 2

    def setEndMessage(self, txt):
        self.slider.setValue(4)
        self.activityTimer.stop()
        self.activityslider.setValue(0)
        self.package.setText(txt)
        self.status.setText(self.oktext)

    def startActualUpgrade(self, answer):
        if not answer or not answer[1]:
            self.close()
            return
        if answer[1] == 'menu':
            message = _('Do you want to update your %s %s ?') % (getMachineBrand(), getMachineName()) + '\n(%s ' % self.total_packages + _('Packages') + ')'
            choices = [(_('View the changes'), 'changes'), (_('Update and ask to reboot'), 'hot'), (_('Upgrade and reboot system'), 'cold')]
            choices.append((_('Update channel list only'), 'channels'))
            choices.append((_('Cancel'), ''))
            upgrademessage = self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices, skin_name='SoftwareUpdateChoices', var=self.trafficLight)
            upgrademessage.setTitle(_('Software update'))
        elif answer[1] == 'changes':
            from Plugins.Extensions.EGAMINews.plugin import EGAMIMainNews
            self.session.openWithCallback(self.startActualUpgrade, EGAMIMainNews)
        elif answer[1] == 'backup':
            self.doSettingsBackup()
        elif answer[1] == 'imagebackup':
            self.doImageBackup()
        elif answer[1] == 'channels':
            self.channellist_only = 1
            self.slider.setValue(1)
            self.ipkg.startCmd(IpkgComponent.CMD_LIST, args={'installed_only': True})
        elif answer[1] == 'cold':
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()
        else:
            self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args={'test_only': False})

    def modificationCallback(self, res):
        self.ipkg.write(res and 'N' or 'Y')

    def doSettingsBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.BackupManager import BackupFiles
        self.BackupFiles = BackupFiles(self.session, True)
        Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('vix', 'Backup Manager'):
                break

        self.showJobView(job)

    def doImageBackup(self):
        backup = None
        from Plugins.SystemPlugins.ViX.ImageManager import ImageBackup
        self.ImageBackup = ImageBackup(self.session, True)
        Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('vix', 'Image Manager'):
                break

        self.showJobView(job)

    def doAutoBackup(self, val = False):
        self.autobackuprunning = True
        if config.softwareupdate.autosettingsbackup.value and config.backupmanager.backuplocation.value and not self.SettingsBackupDone:
            self.doSettingsBackup()
        elif config.softwareupdate.autoimagebackup.value and config.imagemanager.backuplocation.value and not self.ImageBackupDone:
            self.doImageBackup()
        else:
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()

    def showJobView(self, job):
        if job.name == dgettext('vix', 'Image Manager'):
            self.ImageBackupDone = True
        elif job.name == dgettext('vix', 'Backup Manager'):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView
        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(self.startActualUpgrade(('menu', 'menu')), JobView, job, cancelable=False, backgroundable=False, afterEventChangeable=False, afterEvent='close')
        else:
            self.session.openWithCallback(self.doAutoBackup, JobView, job, cancelable=False, backgroundable=False, afterEventChangeable=False, afterEvent='close')

    def exit(self):
        if not self.ipkg.isRunning():
            if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
                self.session.openWithCallback(self.exitAnswer, MessageBox, _('Upgrade finished.') + ' ' + _('Do you want to reboot your %s %s') % (getMachineBrand(), getMachineName()))
            else:
                self.close()
        elif not self.updating:
            self.close()

    def exitAnswer(self, result):
        if result is not None and result:
            self.session.open(TryQuitMainloop, retvalue=2)
        self.close()
Esempio n. 50
0
    def __init__(self, session, playerData, resume=False):
        '''
        '''
        printl("", self, "S")

        self.session = session

        self.startNewServiceOnPlay = False

        self.resume = resume
        self.resumeStamp = int(
            playerData['resumeStamp']) / 1000  #plex stores seconds * 1000
        self.server = str(playerData['server'])
        self.id = str(playerData['id'])
        self.url = str(playerData['playUrl'])

        printl("Checking for usable gstreamer service (built-in)... ", self,
               "I")

        if self.isValidServiceId(self.ENIGMA_SERVICEGS_ID):
            printl("found usable gstreamer service (builtin) ...", self, "I")
            self.ENIGMA_SERVICE_ID = self.ENIGMA_SERVICEGS_ID
            #STOP_BEFORE_UNPAUSE = False
        else:
            printl("no usable gstreamer service (built-in) found ...", self,
                   "I")
            #todo hier eine meldung mit dem hinweis auf systemcheck
            #session.open(MessageBox, _("Please try Systemcheck to install gstreamer!"), MessageBox.TYPE_INFO)

        #MoviePlayer.__init__(self, session, service)
        printl("self.ENIGMA_SERVICE_ID = " + str(self.ENIGMA_SERVICE_ID), self,
               "I")
        sref = eServiceReference(self.ENIGMA_SERVICE_ID, 0, self.url)
        sref.setName("DreamPlex")
        #MoviePlayer.__init__(self, session, service)
        MoviePlayer.__init__(self, session, sref)

        self.skinName = "DPS_PlexPlayer"

        self.service = sref
        self.bufferslider = Slider(0, 100)
        self["bufferslider"] = self.bufferslider
        self["bufferslider"].setValue(0)
        self["label_bitrate"] = StaticText("Bitrate: N/A")
        self["label_speed"] = StaticText("DL-Speed: N/A")
        self["label_buffer"] = StaticText("Buffer")
        self["label_update"] = StaticText("")
        self.bufferSeconds = 0
        self.bufferPercent = 0
        self.bufferSecondsLeft = 0
        self.bitrate = 0
        self.endReached = False
        self.buffersize = 1
        self.localCache = False
        self.dlactive = False
        self.url = self.service.getPath()
        self.localsize = 0

        self["actions"] = ActionMap(
            ["InfobarInstantRecord", "MoviePlayerActions"], {
                "instantRecord": self.keyStartLocalCache,
                "leavePlayer": self.leavePlayer,
            }, -2)

        self.useBufferControl = config.plugins.dreamplex.useBufferControl.value

        if config.plugins.dreamplex.setBufferSize.value:
            bufferSize = int(
                config.plugins.dreamplex.bufferSize.value) * 1024 * 1024
            session.nav.getCurrentService().streamed().setBufferSize(
                bufferSize)

        service1 = self.session.nav.getCurrentService()
        self.seek = service1 and service1.seek()

        if self.seek != None:
            rLen = self.getPlayLength()
            rPos = self.getPlayPosition()

        printl("rLen: " + str(rLen), self, "I")
        printl("rPos: " + str(rPos), self, "I")

        if self.resume == True and self.resumeStamp != None and self.resumeStamp > 0.0:
            start_new_thread(self.seekWatcher, (self, ))

        start_new_thread(self.bitRateWatcher, (self, ))
        #start_new_thread(self.checkForUpdate,(self,))

        self.__event_tracker = ServiceEventTracker(
            screen=self,
            eventmap={
                iPlayableService.evUser + 10: self.__evAudioDecodeError,
                iPlayableService.evUser + 11: self.__evVideoDecodeError,
                iPlayableService.evUser + 12: self.__evPluginError,
                iPlayableService.evBuffering: self.__evUpdatedBufferInfo,
                iPlayableService.evEOF: self.__evEOF,
            })

        printl("", self, "C")
Esempio n. 51
0
 def __init__(self, session, *args):
     Screen.__init__(self, session)
     HelpableScreen.__init__(self)
     ProtectedScreen.__init__(self)
     Screen.setTitle(self, _("Software Update"))
     self.onCheckTrafficLight = []
     self.updateList = []
     self["list"] = List(self.updateList, enableWrapAround=True)
     self["key_red"] = StaticText(_("Cancel"))
     self["key_green"] = StaticText("")
     self["key_yellow"] = StaticText("")
     self["traffic_off"] = Pixmap()
     self["traffic_red"] = Pixmap()
     self["traffic_red"].hide()
     self["traffic_yellow"] = Pixmap()
     self["traffic_yellow"].hide()
     self["traffic_green"] = Pixmap()
     self["traffic_green"].hide()
     self["feedstatus_off"] = Label(_("Status unavailable!"))
     self["feedstatus_off"].hide()
     self["feedstatus_red"] = Label("< %s" % _("Feed disabled!"))
     self["feedstatus_red"].hide()
     self["feedstatus_yellow"] = Label("< %s" % _("Feed unstable!"))
     self["feedstatus_yellow"].hide()
     self["feedstatus_green"] = Label("< %s" % _("Feed stable."))
     self["feedstatus_green"].hide()
     self["feedmessage"] = Label()
     self["package_text"] = Label(_("Updates available:"))
     self["package_count"] = Label("?")
     self["activity"] = Slider(0, 100)
     cancelMsg = _("Cancel / Close the software update screen")
     updateMsg = _("Proceed with the update")
     self["actions"] = HelpableActionMap(
         self,
         ["OkCancelActions", "ColorActions", "NavigationActions"],
         {
             "cancel": (self.keyCancel, cancelMsg),
             "red": (self.keyCancel, cancelMsg),
             "top": (self.top, _("Move to first line / screen")),
             "pageUp": (self.pageUp, _("Move up a page / screen")),
             "up": (self.up, _("Move up a line")),
             # "first": (self.top, _("Move to first line / screen")),
             "left": (self.pageUp, _("Move up a page / screen")),
             "right": (self.pageDown, _("Move down a page / screen")),
             # "last": (self.bottom, _("Move to last line / screen")),
             "down": (self.down, _("Move down a line")),
             "pageDown": (self.pageDown, _("Move down a page / screen")),
             "bottom": (self.bottom, _("Move to last line / screen"))
         },
         prio=0,
         description=_("Software Update Actions"))
     self["updateActions"] = HelpableActionMap(
         self, ["OkCancelActions", "ColorActions"], {
             "ok": (self.keyUpdate, updateMsg),
             "green": (self.keyUpdate, updateMsg)
         },
         prio=0,
         description=_("Software Update Actions"))
     self["updateActions"].setEnabled(False)
     self["refreshActions"] = HelpableActionMap(
         self, ["ColorActions"], {
             "yellow":
             (self.keyRefresh, _("Refresh the update-able package list"))
         },
         prio=0,
         description=_("Software Update Actions"))
     self["refreshActions"].setEnabled(False)
     self.activity = 0
     self.feedState = self.FEED_UNKNOWN
     self.updateFlag = True
     self.packageCount = 0
     self.timer = eTimer()
     self.timer.callback.append(self.timeout)
     self.timer.callback.append(self.checkTrafficLight)
     self.opkg = OpkgComponent()
     self.opkg.addCallback(self.opkgCallback)
     self.onLayoutFinish.append(self.layoutFinished)
Esempio n. 52
0
class UpdatePlugin(Screen, ProtectedScreen):
    skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""

    def __init__(self, session, *args):
        Screen.__init__(self, session)
        ProtectedScreen.__init__(self)

        self.sliderPackages = {
            "dreambox-dvb-modules": 1,
            "enigma2": 2,
            "tuxbox-image-info": 3
        }

        self.setTitle(_("Software update"))
        self.slider = Slider(0, 4)
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = StaticText(_("Please wait..."))
        self["status"] = self.status
        self.package = StaticText(_("Package list update"))
        self["package"] = self.package
        self.oktext = _("Press OK on your remote control to continue.")

        self.packages = 0
        self.error = 0
        self.processed_packages = []
        self.total_packages = None

        self.channellist_only = 0
        self.channellist_name = ''
        self.updating = False
        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)
        self.onClose.append(self.__close)

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.checkTraficLight)
        self.activityTimer.callback.append(self.doActivityTimer)
        self.activityTimer.start(100, True)

    def isProtected(self):
        return config.ParentalControl.setuppinactive.value and\
         (not config.ParentalControl.config_sections.main_menu.value and not config.ParentalControl.config_sections.configuration.value  or hasattr(self.session, 'infobar') and self.session.infobar is None) and\
         config.ParentalControl.config_sections.software_update.value

    def checkTraficLight(self):

        self.activityTimer.callback.remove(self.checkTraficLight)
        self.activityTimer.start(100, False)

        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        message = ""
        picon = None
        default = True
        try:
            # TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
            # run in parallel to the package update.
            status = urlopen("http://sfteam.es/status").read().split('!', 1)
            if getBoxType() in status[0].split(','):
                message = len(status) > 1 and status[1] or _(
                    "The current beta image might not be stable.\nFor more information see %s."
                ) % ("www.sfteam.es")
                picon = MessageBox.TYPE_ERROR
                default = False
        except:
            message = _(
                "The status of the current beta image could not be checked because %s can not be reached."
            ) % ("www.sfteam.es")
            picon = MessageBox.TYPE_ERROR
            default = False
        socket.setdefaulttimeout(currentTimeoutDefault)
        if default:
            self.showDisclaimer()
        else:
            message += "\n" + _("Do you want to update your receiver?")
            self.session.openWithCallback(self.startActualUpdate,
                                          MessageBox,
                                          message,
                                          default=default,
                                          picon=picon)

    def showDisclaimer(self, justShow=False):
        if config.usage.show_update_disclaimer.value or justShow:
            message = _(
                "The SFteam team would like to point out that upgrading to the latest nightly build comes not only with the latest features, but also with some risks. After the update, it is possible that your device no longer works as expected. We recommend you create backups with Autobackup or Backupsuite. This allows you to quickly and easily restore your device to its previous state, should you experience any problems. If you encounter a 'bug', please report the issue on www.sfteam.es.\n\nDo you understand this?"
            )
            list = not justShow and [
                (_("no"), False), (_("yes"), True),
                (_("yes") + " " + _("and never show this message again"),
                 "never")
            ] or []
            self.session.openWithCallback(boundFunction(
                self.disclaimerCallback, justShow),
                                          MessageBox,
                                          message,
                                          list=list)
        else:
            self.startActualUpdate(True)

    def disclaimerCallback(self, justShow, answer):
        if answer == "never":
            config.usage.show_update_disclaimer.value = False
            config.usage.show_update_disclaimer.save()
        if justShow and answer:
            self.ipkgCallback(IpkgComponent.EVENT_DONE, None)
        else:
            self.startActualUpdate(answer)

    def getLatestImageTimestamp(self):
        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        latestImageTimestamp = ""
        try:
            # TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
            # run in parallel to the package update.
            latestImageTimestamp = re.findall(
                '<dd>(.*?)</dd>',
                urlopen("http://sfteam.es/download/" + getBoxType() +
                        "/").read())[0][:16]
            latestImageTimestamp = time.strftime(
                _("%d-%b-%Y %-H:%M"),
                time.strptime(latestImageTimestamp, "%Y/%m/%d %H:%M"))
        except:
            pass
        socket.setdefaulttimeout(currentTimeoutDefault)
        return latestImageTimestamp

    def startActualUpdate(self, answer):
        if answer:
            self.updating = True
            self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
        else:
            self.close()

    def doActivityTimer(self):
        self.activity += 1
        if self.activity == 100:
            self.activity = 0
        self.activityslider.setValue(self.activity)

    def showUpdateCompletedMessage(self):
        self.setEndMessage(
            ngettext("Update completed, %d package was installed.",
                     "Update completed, %d packages were installed.",
                     self.packages) % self.packages)

    def ipkgCallback(self, event, param):
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_("Downloading"))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if self.sliderPackages.has_key(param):
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(
                _("Upgrading") + ": %s/%s" %
                (self.packages, self.total_packages))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_("Installing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_("Removing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_("Configuring"))
        elif event == IpkgComponent.EVENT_MODIFIED:
            if config.plugins.softwaremanager.overwriteConfigFiles.value in (
                    "N", "Y"):
                self.ipkg.write(
                    True and
                    config.plugins.softwaremanager.overwriteConfigFiles.value)
            else:
                self.session.openWithCallback(
                    self.modificationCallback, MessageBox,
                    _("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?"
                      ) % (param))
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            if self.updating:
                self.updating = False
                self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
            elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
                self.total_packages = len(self.ipkg.getFetchedList())
                if self.total_packages:
                    latestImageTimestamp = self.getLatestImageTimestamp()
                    if latestImageTimestamp:
                        message = _(
                            "Do you want to update your receiver to %s?"
                        ) % self.getLatestImageTimestamp() + "\n"
                    else:
                        message = _(
                            "Do you want to update your receiver?") + "\n"
                    message += "(" + (ngettext(
                        "%s updated package available",
                        "%s updated packages available", self.total_packages) %
                                      self.total_packages) + ")"
                    if self.total_packages > 150:
                        message += " " + _("Reflash recommended!")
                    choices = [(_("Update and reboot (recommended)"), "cold"),
                               (_("Update and ask to reboot"), "hot"),
                               (_("Update channel list only"), "channels"),
                               (_("Show packages to be upgraded"), "showlist")]
                else:
                    message = _("No updates available")
                    choices = []
                if fileExists("/home/root/ipkgupgrade.log"):
                    choices.append((_("Show latest upgrade log"), "log"))
                choices.append(
                    (_("Show latest commits on sourceforge"), "commits"))
                if not config.usage.show_update_disclaimer.value:
                    choices.append((_("Show disclaimer"), "disclaimer"))
                choices.append((_("Cancel"), ""))
                self.session.openWithCallback(self.startActualUpgrade,
                                              ChoiceBox,
                                              title=message,
                                              list=choices)
            elif self.channellist_only > 0:
                if self.channellist_only == 1:
                    self.setEndMessage(
                        _("Could not find installed channel list."))
                elif self.channellist_only == 2:
                    self.slider.setValue(2)
                    self.ipkg.startCmd(IpkgComponent.CMD_REMOVE,
                                       {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 3:
                    self.slider.setValue(3)
                    self.ipkg.startCmd(IpkgComponent.CMD_INSTALL,
                                       {'package': self.channellist_name})
                    self.channellist_only += 1
                elif self.channellist_only == 4:
                    self.showUpdateCompletedMessage()
                    eDVBDB.getInstance().reloadBouquets()
                    eDVBDB.getInstance().reloadServicelist()
            elif self.error == 0:
                self.showUpdateCompletedMessage()
            else:
                self.activityTimer.stop()
                self.activityslider.setValue(0)
                error = _(
                    "Your receiver might be unusable now. Please consult the manual for further assistance before rebooting your receiver."
                )
                if self.packages == 0:
                    error = _("No updates available. Please try again later.")
                if self.updating:
                    error = _(
                        "Update failed. Your receiver does not have a working internet connection."
                    )
                self.status.setText(_("Error") + " - " + error)
        elif event == IpkgComponent.EVENT_LISTITEM:
            if 'enigma2-plugin-settings-' in param[
                    0] and self.channellist_only > 0:
                self.channellist_name = param[0]
                self.channellist_only = 2
        #print event, "-", param
        pass

    def setEndMessage(self, txt):
        self.slider.setValue(4)
        self.activityTimer.stop()
        self.activityslider.setValue(0)
        self.package.setText(txt)
        self.status.setText(self.oktext)

    def startActualUpgrade(self, answer):
        if not answer or not answer[1]:
            self.close()
            return
        if answer[1] == "cold":
            self.session.open(TryQuitMainloop, retvalue=42)
            self.close()
        elif answer[1] == "channels":
            self.channellist_only = 1
            self.slider.setValue(1)
            self.ipkg.startCmd(IpkgComponent.CMD_LIST,
                               args={'installed_only': True})
        elif answer[1] == "commits":
            self.session.openWithCallback(
                boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE,
                              None), CommitInfo)
        elif answer[1] == "disclaimer":
            self.showDisclaimer(justShow=True)
        elif answer[1] == "showlist":
            text = ""
            for i in [
                    x[0] for x in sorted(self.ipkg.getFetchedList(),
                                         key=lambda d: d[0])
            ]:
                text = text and text + "\n" + i or i
            self.session.openWithCallback(
                boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE,
                              None), TextBox, text, _("Packages to update"))
        elif answer[1] == "log":
            text = ""
            for i in open("/home/root/ipkgupgrade.log", "r").readlines():
                text += i
            self.session.openWithCallback(
                boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE,
                              None), TextBox, text, _("Packages to update"))
        else:
            self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE,
                               args={'test_only': False})

    def modificationCallback(self, res):
        self.ipkg.write(res and "N" or "Y")

    def exit(self):
        if not self.ipkg.isRunning():
            if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
                self.session.openWithCallback(
                    self.exitAnswer, MessageBox,
                    _("Update completed. Do you want to reboot your receiver?")
                )
            else:
                self.close()
        else:
            if not self.updating:
                self.close()

    def exitAnswer(self, result):
        if result is not None and result:
            self.session.open(TryQuitMainloop, retvalue=2)
        self.close()

    def __close(self):
        self.ipkg.removeCallback(self.ipkgCallback)
Esempio n. 53
0
class UpdatePlugin(Screen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""
		
	def __init__(self, session, *args):
		Screen.__init__(self, session)
		Screen.setTitle(self, _("Software Update"))

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.channellist_only = 0
		self.channellist_name = ''
		self.SettingsBackupDone = False
		self.ImageBackupDone = False
		self.autobackuprunning = False

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None
		self.checkNetworkState()

	def checkNetworkState(self):
		cmd1 = "opkg update"
		self.CheckConsole = Console()
		self.CheckConsole.ePopen(cmd1, self.checkNetworkStateFinished)

	def checkNetworkStateFinished(self, result, retval,extra_args=None):
		if 'bad address' in result:
			self.session.openWithCallback(self.close, MessageBox, _("Your %s %s is not connected to the internet, please check your network settings and try again.") % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		elif ('wget returned 1' or 'wget returned 255' or '404 Not Found') in result:
			self.session.openWithCallback(self.close, MessageBox, _("Sorry feeds are down for maintenance, please try again later."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		elif 'Collected errors' in result:
			self.session.openWithCallback(self.close, MessageBox, _("A background update check is in progress, please wait a few minutes and try again."), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
		else:
			self.startCheck()

	def startCheck(self):
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)
		self.onClose.append(self.__close)

		self.updating = False

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.updating = True
		self.activityTimer.start(100, False)
		self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
				self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
			else:
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % (param)
				)
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
			elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
				self.total_packages = len(self.ipkg.getFetchedList())
				if self.total_packages:
					message = _("Do you want to update your %s %s ?") % (getMachineBrand(), getMachineName()) + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
					choices = [(_("Update and reboot (recommended)"), "cold"),
						(_("Update and ask to reboot"), "hot"),
						(_("Update channel list only"), "channels"),
						(_("Cancel"), "")]
					self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices)
				else:
					self.session.openWithCallback(self.close, MessageBox, _("No updates available"), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your %s %s might be unusable now. Please consult the manual for further assistance before rebooting your %s %s.") % (getMachineBrand(), getMachineName(), getMachineBrand(), getMachineName())
				if self.packages == 0:
					error = _("No updates available. Please try again later.")
				if self.updating:
					error = _("Update failed. Your %s %s does not have a working internet connection.") % (getMachineBrand(), getMachineName())
				self.status.setText(_("Error") +  " - " + error)
		elif event == IpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print event, "-", param
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return
		if answer[1] == "cold":
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.ipkg.startCmd(IpkgComponent.CMD_LIST, args = {'installed_only': True})
		else:
			self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False})

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your %s %s") % (getMachineBrand(), getMachineName()))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop,retvalue=2)
		self.close()

	def __close(self):
		self.ipkg.removeCallback(self.ipkgCallback)
Esempio n. 54
0
class UpdatePlugin(Screen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="620,160" title="Software update">
			<widget name="activityslider" position="10,10" size="600,10"  borderWidth="2" borderColor="#cccccc"/>
			<widget source="package" render="Label" position="10,40" size="600,25" font="Regular;22" />
			<widget source="status" render="Label" position="10,70" size="600,45" font="Regular;22" />
			<widget name="slider" position="10,140" size="600,12" borderWidth="2" borderColor="#cccccc" />
		</screen>"""

	def __init__(self, session, args = None):
		Screen.__init__(self, session)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Verifying your internet connection..."))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.modified_packages = []

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer_conn = self.activityTimer.timeout.connect(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self.updating = False
		self.rebootRequired = False
		self.device_name = iSoftwareTools.hardware_info.device_name

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.checkNetwork()
		self.onClose.append(self.cleanup)

	def cleanup(self):
		iSoftwareTools.cleanupSoftwareTools()

	def checkNetwork(self):
		if eNetworkManager.getInstance().online():
			self.updating = True
			self.activityTimer.start(100, False)
			self.package.setText(_("Package list update"))
			self.status.setText(_("Upgrading Dreambox... Please wait"))
			self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
		else:
			self.package.setText(_("Your network is not working. Please try again."))
			self.status.setText(self.oktext)

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				iSoftwareTools.listUpgradable(self.listUpgradableCB)
			elif self.error == 0:
				self.slider.setValue(4)
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				self.package.setText(_("Done - Installed or upgraded %d packages") % self.packages)
				self.status.setText(self.oktext)
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.")
				if self.packages == 0:
					error = _("No packages were upgraded yet. So you can check your network and try again.")
				if self.updating:
					error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.")
				self.status.setText(_("Error") +  " - " + error)
		#print event, "-", param
		pass

	def listUpgradableCB(self, res):
		if iSoftwareTools.upgradeAvailable is False:
			self.updating = False
			self.slider.setValue(4)
			self.activityTimer.stop()
			self.activityslider.setValue(0)
			self.package.setText(_("Done - No updates available."))
			self.status.setText(self.oktext)
		else:
			self.updating = False
			upgrade_args = {'use_maintainer' : True, 'test_only': False}
			if config.plugins.softwaremanager.overwriteConfigFiles.value == 'N':
				upgrade_args = {'use_maintainer' : False, 'test_only': False}
			self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = upgrade_args)

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0:
				self.session.openWithCallback(self.exitReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitReboot(self, result):
		if result:
			quitMainloop(2)
		self.close()

	def exitRestart(self, result):
		if result:
			quitMainloop(3)
		self.close()
Esempio n. 55
0
    def __init__(self, session, movieinfo, movietitle):
        self.skin = PlayRtmpMovie.skin
        Screen.__init__(self, session)

        self.url = movieinfo[0]
        self.filename = movieinfo[1]
        self.movietitle = movietitle
        self.movieinfo = movieinfo
        self.destination = config.mediaportal.storagepath.value
        #self.moviepath = self.destination + ASCIItranslit.legacyEncode(self.filename)
        self.moviepath = self.destination + ".rtmp_movie"

        self.streamactive = False
        self.isVisible = True

        self.container = eConsoleAppContainer()
        self.container.appClosed.append(self.copyfinished)
        self.container.stdoutAvail.append(self.progressUpdate)
        self.container.stderrAvail.append(self.progressUpdate)
        self.container.setCWD(self.destination)

        self.oldService = self.session.nav.getCurrentlyPlayingServiceReference(
        )

        self.BgFileEraser = eBackgroundFileEraser.getInstance()

        filesize = 0
        self.filesize = float(filesize)  # in bytes

        self.dummyfilesize = False
        self.lastcmddata = None
        self.lastlocalsize = 0
        self.localsize = 0
        self.isplaying = False
        self.autoplaythreshold = config.mediaportal.autoplayThreshold.value

        self["key_green"] = Button(_("Play"))
        self["key_red"] = Button(_("Cancel"))
        self["key_blue"] = Button(_("Show/Hide"))

        self["label_filename"] = StaticText("File: %s" % (self.filename))
        self["label_progress"] = StaticText("Progress: N/A")
        self["label_speed"] = StaticText("Speed: N/A")
        self["label_timeleft"] = StaticText("Time left: N/A")

        self["actions"] = ActionMap(
            ["OkCancelActions", "ColorActions"], {
                "cancel": self.exit,
                "ok": self.okbuttonClick,
                "red": self.exit,
                "green": self.playfile,
                "blue": self.visibility
            }, -1)

        self.StatusTimer = eTimer()
        self.StatusTimer.callback.append(self.UpdateStatus)

        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider

        self.onFirstExecBegin.append(self.firstExecBegin)
Esempio n. 56
0
class UpdatePlugin(Screen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,200" title="Software update" >
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,60" size="540,45" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""
		
	def __init__(self, session, args = None):
		Screen.__init__(self, session)
		
		self.sliderPackages = { "Settop Box-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }
		
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Upgrading Settop Box... Please wait"))
		self["status"] = self.status
		self.package = StaticText()
		self["package"] = self.package
		
		self.packages = 0
		self.error = 0
		
		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.doActivityTimer)

		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.firsttime = True
		self.onShown.append(self.confirmUpdate)

	def confirmUpdate(self):
		if self.firsttime:
			self.firsttime = False
			self.session.openWithCallback(self.confirmationResult, MessageBox, _("Do you want to upgrade?"))

	def confirmationResult(self, result):
		if not result:
			self.close()
		else:
			self.activityTimer.start(100, False)
			self.updating = True
			self.package.setText(_("Package list update"))
			self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)
		
	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading"))
			self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_MODIFIED:
			self.session.openWithCallback(
				self.modificationCallback,
				MessageBox,
				_("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param)
			)
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False})
			elif self.error == 0:
				self.slider.setValue(4)
				
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				
				self.package.setText("")
				self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages)
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("your Settop Box might be unusable now. Please consult the manual for further assistance before rebooting your Settop Box.")
				if self.packages == 0:
					error = _("No packages were upgraded yet. So you can check your network and try again.")
				if self.updating:
					error = _("Your Settop Box isn't connected to the internet properly. Please check it and try again.")
				self.status.setText(_("Error") +  " - " + error)
		#print event, "-", param
		pass

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished. Do you want to reboot your Settop Box?"))
			else:
				self.close()
			
	def exitAnswer(self, result):
		if result is not None and result:
			quitMainloop(2)
		self.close()
Esempio n. 57
0
class Ipkg(Screen):
    def __init__(self, session, cmdList=None):
        if not cmdList: cmdList = []
        Screen.__init__(self, session)

        self.cmdList = cmdList

        self.sliderPackages = {}

        self.slider = Slider(0, len(cmdList))
        self["slider"] = self.slider
        self.activityslider = Slider(0, 100)
        self["activityslider"] = self.activityslider
        self.status = Label(_("Preparing... Please wait"))
        self["status"] = self.status
        self.package = Label()
        self["package"] = self.package

        self.packages = 0
        self.error = 0
        self.processed_packages = []

        self.activity = 0
        self.activityTimer = eTimer()
        self.activityTimer.callback.append(self.doActivityTimer)
        #self.activityTimer.start(100, False)

        self.ipkg = IpkgComponent()
        self.ipkg.addCallback(self.ipkgCallback)

        self.runningCmd = None
        self.runNextCmd()

        self["actions"] = ActionMap(["WizardActions"], {
            "ok": self.exit,
            "back": self.exit
        }, -1)

    def runNextCmd(self):
        if self.runningCmd is None:
            self.runningCmd = 0
        else:
            self.runningCmd += 1
        print len(self.cmdList), self.runningCmd
        if len(self.cmdList) - 1 < self.runningCmd:
            self.activityslider.setValue(0)
            self.slider.setValue(len(self.cmdList))

            self.package.setText("")
            self.status.setText(
                ngettext(
                    "Done - Installed, upgraded or removed %d package (%s)",
                    "Done - Installed, upgraded or removed %d packages (%s)",
                    self.packages) %
                (self.packages,
                 ngettext("with %d error", "with %d errors", self.error) %
                 self.error))
            return False
        else:
            cmd = self.cmdList[self.runningCmd]
            self.slider.setValue(self.runningCmd)
            self.ipkg.startCmd(cmd[0], args=cmd[1])
            self.startActivityTimer()

    def doActivityTimer(self):
        if not self.ipkg.isRunning():
            self.stopActivityTimer()
        else:
            self.activity += 1
            if self.activity == 100:
                self.activity = 0
            self.activityslider.setValue(self.activity)

    def startActivityTimer(self):
        self.activityTimer.start(100, False)

    def stopActivityTimer(self):
        self.activityTimer.stop()

    def ipkgCallback(self, event, param):
        if event == IpkgComponent.EVENT_DOWNLOAD:
            self.status.setText(_("Downloading"))
        elif event == IpkgComponent.EVENT_UPGRADE:
            if param in self.sliderPackages:
                self.slider.setValue(self.sliderPackages[param])
            self.package.setText(param)
            self.status.setText(_("Upgrading"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_INSTALL:
            self.package.setText(param)
            self.status.setText(_("Installing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_REMOVE:
            self.package.setText(param)
            self.status.setText(_("Removing"))
            if not param in self.processed_packages:
                self.processed_packages.append(param)
                self.packages += 1
        elif event == IpkgComponent.EVENT_CONFIGURING:
            self.package.setText(param)
            self.status.setText(_("Configuring"))
        elif event == IpkgComponent.EVENT_ERROR:
            self.error += 1
        elif event == IpkgComponent.EVENT_DONE:
            self.runNextCmd()
        elif event == IpkgComponent.EVENT_MODIFIED:
            self.session.openWithCallback(
                self.modificationCallback, MessageBox,
                _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?"
                  ) % param)

    def modificationCallback(self, res):
        self.ipkg.write(res and "N" or "Y")

    def exit(self):
        if not self.ipkg.isRunning():
            self.close()
Esempio n. 58
0
class UpgradeStatus(Screen):
	skin = 	"""
		<screen position="center,center" size="450,100" title="FPGA Upgrade">
			<widget name="name" position="10,0" size="430,20" font="Regular;18" halign="left" valign="bottom"/>
			<widget name="slider" position="10,25" size="430,30" backgroundColor="white"/>
			<widget name="status" position="10,27" zPosition="1" size="430,30" font="Regular;18" halign="center" valign="center" foregroundColor="black" backgroundColor="white" transparent="1"/>
			<widget source="info" render="Label" position="10,70" zPosition="1" size="430,30" font="Regular;22" halign="center" valign="center" backgroundColor="black" transparent="1"/>
		</screen>
		"""
	def __init__(self, session, parent, timeout = 20):
		Screen.__init__(self,session)
		self.session = session

		self["actions"] = ActionMap(["OkCancelActions"],
                {
			"ok": self.keyExit,
                }, -2)

		self.is_done = 0
		self.exit_count = 0
		self.timeout = 20
		self.title_str = "FPGA Upgrade"

		#self["name"] = Label(_("Upgrade status"))
		self["name"] = Label(" ")
		self["info"] = StaticText(_("Can't cancel during upgrade!!"))

		self["status"] = Label(_("Status : 0%"))
		self.status_bar = self["status"]

		self.slider = Slider(0, 100)
		self["slider"] = self.slider

		self.parent = parent
		self.timer_check_progress = eTimer()
		self.timer_check_progress.callback.append(self.callbackDoCheckProgress)
		interval = self.parent.FPGA.get_interval()
		self.timer_check_progress.start(interval)
		self.need_restart = False

	def callbackDoCheckProgress(self):
		self.status = self.parent.FPGA.get_status()

		if self.status > 0:
			self.slider.setValue(self.status)

		if self.status == 100:
			#print "fpga-upgrade done!!"
			self.status_bar.setText(_("Succeed"))
			#self.status_bar.setText(_("%d / 100" % (self.status)))
			self.timer_check_progress.stop()
			self.is_done = 1
			self.timer_exit = eTimer()
			self.timer_exit.callback.append(self.callbackExit)
			self.timer_exit.start(1000)

		elif self.status < 0:#elif self.status == -1 or self.status == -2:
			#print "fpga-upgrade error >> errno : [%d]" % (self.status)
			ERROR_MSG = ''
			ERROR_CODE = int(self.status) * -1
			ERROR_MSG = self.parent.FPGA.get_error_msg(ERROR_CODE, ERROR_MSG)
			self.status_bar.setText("Fail to update!!")
			self["info"].setText(_("Error[%d] : %s.\nPress OK to exit." % (self.status, ERROR_MSG)))
			self.timer_check_progress.stop()
			self.is_done = 1

		else:
			#print "fpga-upgrade status : %d" % self.status
			self.status_bar.setText(_("%d / 100" % (self.status)))

	def callbackExit(self):
		self.need_restart = True
		if self.exit_count == self.timeout:
			self.timer_exit.stop()
			self.keyExit()
		self.exit_count = self.exit_count + 1
		#self.instance.setTitle("%s (%d)" % (self.title_str, (self.timeout-self.exit_count)))
		self["info"].setText("Reboot after %d seconds.\nPress the OK to reboot now." %(self.timeout-self.exit_count))

	def keyExit(self):
		if self.need_restart:
			from Screens.Standby import TryQuitMainloop
			self.session.open(TryQuitMainloop, 2)
		if self.is_done :
			self.close()
class UpdatePlugin(Screen, ProtectedScreen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""

	def __init__(self, session, *args):
		Screen.__init__(self, session)
		ProtectedScreen.__init__(self)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None

		self.channellist_only = 0
		self.channellist_name = ''
		self.updating = False
		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)
		self.onClose.append(self.__close)

		self["actions"] = ActionMap(["WizardActions"],
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)

		self.activity = 0
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.checkTraficLight1)
		self.activityTimer.callback.append(self.doActivityTimer)
		self.activityTimer.start(20, True)

	def checkTraficLight1(self):
		self.activityTimer.callback.remove(self.checkTraficLight1)
		self.activityTimer.start(100, False)
		self.showDisclaimer()

	def isProtected(self):
		return config.ParentalControl.setuppinactive.value and\
			(not config.ParentalControl.config_sections.main_menu.value and not config.ParentalControl.config_sections.configuration.value  or hasattr(self.session, 'infobar') and self.session.infobar is None) and\
			config.ParentalControl.config_sections.software_update.value

	def checkTraficLight(self):

		self.activityTimer.callback.remove(self.checkTraficLight)
		self.activityTimer.start(100, False)

		currentTimeoutDefault = socket.getdefaulttimeout()
		socket.setdefaulttimeout(3)
		message = ""
		picon = None
		default = True
		try:
			# TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
			# run in parallel to the package update.
			status = urlopen("http://openpli.org/status/").read().split('!', 1)
			if getBoxType() in status[0].split(','):
				message = len(status) > 1 and status[1] or _("The current beta image might not be stable.\nFor more information see %s.") % ("www.openpli.org")
				picon = MessageBox.TYPE_ERROR
				default = False
		except:
			message = _("The status of the current beta image could not be checked because %s can not be reached.") % ("www.openpli.org")
			picon = MessageBox.TYPE_ERROR
			default = False
		socket.setdefaulttimeout(currentTimeoutDefault)
		if default:
			self.showDisclaimer()
		else:
			message += "\n" + _("Do you want to update your receiver?")
			self.session.openWithCallback(self.startActualUpdate, MessageBox, message, default = default, picon = picon)

	def showDisclaimer(self, justShow=False):
		if config.usage.show_update_disclaimer.value or justShow:
			message = _("The OpenPLi team would like to point out that upgrading to the latest nightly build comes not only with the latest features, but also with some risks. After the update, it is possible that your device no longer works as expected. We recommend you create backups with Autobackup or Backupsuite. This allows you to quickly and easily restore your device to its previous state, should you experience any problems. If you encounter a 'bug', please report the issue on www.openpli.org.\n\nDo you understand this?")
			list = not justShow and [(_("no"), False), (_("yes"), True), (_("yes") + " " + _("and never show this message again"), "never")] or []
			self.session.openWithCallback(boundFunction(self.disclaimerCallback, justShow), MessageBox, message, list=list)
		else:
			self.startActualUpdate(True)

	def disclaimerCallback(self, justShow, answer):
		if answer == "never":
			config.usage.show_update_disclaimer.value = False
			config.usage.show_update_disclaimer.save()
		if justShow and answer:
			self.ipkgCallback(IpkgComponent.EVENT_DONE, None)
		else:
			self.startActualUpdate(answer)

	def getLatestImageTimestamp(self):
		# TODO: Impement own sh4 timestamp
		return ""
		
		currentTimeoutDefault = socket.getdefaulttimeout()
		socket.setdefaulttimeout(3)
		latestImageTimestamp = ""
		try:
			# TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
			# run in parallel to the package update.
			latestImageTimestamp = re.findall('<dd>(.*?)</dd>', urlopen("http://openpli.org/download/"+getBoxType()+"/").read())[0][:16]
			latestImageTimestamp = time.strftime(_("%d-%b-%Y %-H:%M"), time.strptime(latestImageTimestamp, "%Y/%m/%d %H:%M"))
		except:
			pass
		socket.setdefaulttimeout(currentTimeoutDefault)
		return latestImageTimestamp

	def startActualUpdate(self,answer):
		if answer:
			self.updating = True
			self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
		else:
			self.close()

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def ipkgCallback(self, event, param):
		if event is IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event is IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event is IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event is IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event is IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event is IpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
				self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
			else:
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % (param)
				)
		elif event is IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event is IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
			elif self.ipkg.currentCommand is IpkgComponent.CMD_UPGRADE_LIST and self.error == 0:
				self.total_packages = len(self.ipkg.getFetchedList())
				if self.total_packages:
					latestImageTimestamp = self.getLatestImageTimestamp()
					if latestImageTimestamp:
						message = _("Do you want to update your receiver to %s?") % self.getLatestImageTimestamp() + "\n"
					else:
						message = _("Do you want to update your receiver?") + "\n"
					message += "(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
					if self.total_packages > 150:
						message += " " + _("Reflash recommended!")
					choices = [(_("Update and reboot (recommended)"), "cold"),
						(_("Update and ask to reboot"), "hot"),
						(_("Update channel list only"), "channels"),
						(_("Show updated packages"), "showlist")]
				else:
					message = _("No updates available")
					choices = []
				if fileExists("/hdd/ipkgupgrade.log"):
					choices.append((_("Show latest upgrade log"), "log"))
				choices.append((_("Show latest commits"), "commits"))
				if not config.usage.show_update_disclaimer.value:
					choices.append((_("Show disclaimer"), "disclaimer"))
				choices.append((_("Cancel"), ""))
				self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices)
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your receiver might be unusable now. Please consult the manual for further assistance before rebooting your receiver.")
				if self.packages == 0:
					error = _("No updates available. Please try again later.")
				if self.updating:
					error = _("Update failed. Your receiver does not have a working internet connection.")
				self.status.setText(_("Error") +  " - " + error)
		elif event is IpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print event, "-", param
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return
		if answer[1] == "cold":
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.ipkg.startCmd(IpkgComponent.CMD_LIST, args = {'installed_only': True})
		elif answer[1] == "commits":
			self.session.openWithCallback(boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE, None), CommitInfo)
		elif answer[1] == "disclaimer":
			self.showDisclaimer(justShow=True)
		elif answer[1] == "showlist":
			text = ""
			for i in [x[0] for x in sorted(self.ipkg.getFetchedList(), key=lambda d: d[0])]:
				text = text and text + "\n" + i or i
			self.session.openWithCallback(boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE, None), TextBox, text, _("Packages to update"))
		elif answer[1] == "log":
			text = ""
			for i in open("/hdd/ipkgupgrade.log", "r").readlines():
				text += i
			self.session.openWithCallback(boundFunction(self.ipkgCallback, IpkgComponent.EVENT_DONE, None), TextBox, text, _("Packages to update"))
		else:
			self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False})

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Update completed. Do you want to reboot your receiver?"))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop,retvalue=2)
		self.close()

	def __close(self):
		self.ipkg.removeCallback(self.ipkgCallback)
Esempio n. 60
0
class UpdatePlugin(Screen):
	skin = """
		<screen name="UpdatePlugin" position="center,center" size="550,300">
			<widget name="activityslider" position="0,0" size="550,5"  />
			<widget name="slider" position="0,150" size="550,30"  />
			<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
			<widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
		</screen>"""

	def __init__(self, session, *args):
		Screen.__init__(self, session)

		self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 }

		self.setTitle(_("Software update"))
		self.slider = Slider(0, 4)
		self["slider"] = self.slider
		self.activityslider = Slider(0, 100)
		self["activityslider"] = self.activityslider
		self.status = StaticText(_("Please wait..."))
		self["status"] = self.status
		self.package = StaticText(_("Package list update"))
		self["package"] = self.package
		self.oktext = _("Press OK on your remote control to continue.")

		self.packages = 0
		self.error = 0
		self.processed_packages = []
		self.total_packages = None

		self.channellist_only = 0
		self.channellist_name = ''
		self.updating = False
		self.ipkg = IpkgComponent()
		self.ipkg.addCallback(self.ipkgCallback)
		self.onClose.append(self.__close)

		self["actions"] = ActionMap(["WizardActions"], 
		{
			"ok": self.exit,
			"back": self.exit
		}, -1)
		
		self.activity = 0 
		self.activityTimer = eTimer()
		self.activityTimer.callback.append(self.checkTraficLight)
		self.activityTimer.callback.append(self.doActivityTimer)
		self.activityTimer.start(100, True)

	def checkTraficLight(self):
	
		self.activityTimer.callback.remove(self.checkTraficLight)
		self.activityTimer.start(100, False)

		from urllib import urlopen
		import socket
		import os
		currentTimeoutDefault = socket.getdefaulttimeout()
		socket.setdefaulttimeout(3)
		message = ""
		picon = None
		default = True
		try:
			# TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
			# run in parallel to the package update.
			if getBoxType() in urlopen("http://openpli.org/status").read().split(','):
				message = _("The current beta image might not be stable.\nFor more information see www.openpli.org.")
				picon = MessageBox.TYPE_ERROR
				default = False
		except:
			message = _("The status of the current beta image could not be checked because www.openpli.org can not be reached.")
			picon = MessageBox.TYPE_ERROR
			default = False
		socket.setdefaulttimeout(currentTimeoutDefault)
		if default:
			self.startActualUpdate(True)
		else:
			message += "\n" + _("Do you want to update your receiver?")
			self.session.openWithCallback(self.startActualUpdate, MessageBox, message, default = default, picon = picon)

	def startActualUpdate(self,answer):
		if answer:
			self.updating = True
			self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
		else:
			self.close()

	def doActivityTimer(self):
		self.activity += 1
		if self.activity == 100:
			self.activity = 0
		self.activityslider.setValue(self.activity)

	def showUpdateCompletedMessage(self):
		self.setEndMessage(ngettext("Update completed, %d package was installed.", "Update completed, %d packages were installed.", self.packages) % self.packages)

	def ipkgCallback(self, event, param):
		if event == IpkgComponent.EVENT_DOWNLOAD:
			self.status.setText(_("Downloading"))
		elif event == IpkgComponent.EVENT_UPGRADE:
			if self.sliderPackages.has_key(param):
				self.slider.setValue(self.sliderPackages[param])
			self.package.setText(param)
			self.status.setText(_("Upgrading") + ": %s/%s" % (self.packages, self.total_packages))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_INSTALL:
			self.package.setText(param)
			self.status.setText(_("Installing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_REMOVE:
			self.package.setText(param)
			self.status.setText(_("Removing"))
			if not param in self.processed_packages:
				self.processed_packages.append(param)
				self.packages += 1
		elif event == IpkgComponent.EVENT_CONFIGURING:
			self.package.setText(param)
			self.status.setText(_("Configuring"))
		elif event == IpkgComponent.EVENT_MODIFIED:
			if config.plugins.softwaremanager.overwriteConfigFiles.value in ("N", "Y"):
				self.ipkg.write(True and config.plugins.softwaremanager.overwriteConfigFiles.value)
			else:
				self.session.openWithCallback(
					self.modificationCallback,
					MessageBox,
					_("A configuration file (%s) has been modified since it was installed.\nDo you want to keep your modifications?") % (param)
				)
		elif event == IpkgComponent.EVENT_ERROR:
			self.error += 1
		elif event == IpkgComponent.EVENT_DONE:
			if self.updating:
				self.updating = False
				self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
			elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
				self.total_packages = len(self.ipkg.getFetchedList())
				if self.total_packages:
					message = _("Do you want to update your receiver?") + "\n(" + (ngettext("%s updated package available", "%s updated packages available", self.total_packages) % self.total_packages) + ")"
					choices = [(_("Update and reboot (recommended)"), "cold"),
						(_("Update and ask to reboot"), "hot"),
						(_("Update channel list only"), "channels"),
						(_("Cancel"), "")]
					self.session.openWithCallback(self.startActualUpgrade, ChoiceBox, title=message, list=choices)
				else:
					self.session.openWithCallback(self.close, MessageBox, _("No updates available"), type=MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
			elif self.channellist_only > 0:
				if self.channellist_only == 1:
					self.setEndMessage(_("Could not find installed channel list."))
				elif self.channellist_only == 2:
					self.slider.setValue(2)
					self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 3:
					self.slider.setValue(3)
					self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': self.channellist_name})
					self.channellist_only += 1
				elif self.channellist_only == 4:
					self.showUpdateCompletedMessage()
					eDVBDB.getInstance().reloadBouquets()
					eDVBDB.getInstance().reloadServicelist()
			elif self.error == 0:
				self.showUpdateCompletedMessage()
			else:
				self.activityTimer.stop()
				self.activityslider.setValue(0)
				error = _("Your receiver might be unusable now. Please consult the manual for further assistance before rebooting your receiver.")
				if self.packages == 0:
					error = _("No updates available. Please try again later.")
				if self.updating:
					error = _("Update failed. Your receiver does not have a working internet connection.")
				self.status.setText(_("Error") +  " - " + error)
		elif event == IpkgComponent.EVENT_LISTITEM:
			if 'enigma2-plugin-settings-' in param[0] and self.channellist_only > 0:
				self.channellist_name = param[0]
				self.channellist_only = 2
		#print event, "-", param
		pass

	def setEndMessage(self, txt):
		self.slider.setValue(4)
		self.activityTimer.stop()
		self.activityslider.setValue(0)
		self.package.setText(txt)
		self.status.setText(self.oktext)

	def startActualUpgrade(self, answer):
		if not answer or not answer[1]:
			self.close()
			return
		if answer[1] == "cold":
			self.session.open(TryQuitMainloop,retvalue=42)
			self.close()
		elif answer[1] == "channels":
			self.channellist_only = 1
			self.slider.setValue(1)
			self.ipkg.startCmd(IpkgComponent.CMD_LIST, args = {'installed_only': True})
		else:
			self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False})

	def modificationCallback(self, res):
		self.ipkg.write(res and "N" or "Y")

	def exit(self):
		if not self.ipkg.isRunning():
			if self.packages != 0 and self.error == 0 and self.channellist_only == 0:
				self.session.openWithCallback(self.exitAnswer, MessageBox, _("Update completed. Do you want to reboot your receiver?"))
			else:
				self.close()
		else:
			if not self.updating:
				self.close()

	def exitAnswer(self, result):
		if result is not None and result:
			self.session.open(TryQuitMainloop,retvalue=2)
		self.close()

	def __close(self):
		self.ipkg.removeCallback(self.ipkgCallback)