--- /dev/null
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.39
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+# This file is compatible with both classic and new-style classes.
+
+from sys import version_info
+if version_info >= (2,6,0):
+ def swig_import_helper():
+ from os.path import dirname
+ import imp
+ fp = None
+ try:
+ fp, pathname, description = imp.find_module('_fpga', [dirname(__file__)])
+ except ImportError:
+ import _fpga
+ return _fpga
+ if fp is not None:
+ try:
+ _mod = imp.load_module('_fpga', fp, pathname, description)
+ finally:
+ fp.close()
+ return _mod
+ _fpga = swig_import_helper()
+ del swig_import_helper
+else:
+ import _fpga
+del version_info
+try:
+ _swig_property = property
+except NameError:
+ pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+ if (name == "thisown"): return self.this.own(value)
+ if (name == "this"):
+ if type(value).__name__ == 'SwigPyObject':
+ self.__dict__[name] = value
+ return
+ method = class_type.__swig_setmethods__.get(name,None)
+ if method: return method(self,value)
+ if (not static) or hasattr(self,name):
+ self.__dict__[name] = value
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+ return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+ if (name == "thisown"): return self.this.own()
+ method = class_type.__swig_getmethods__.get(name,None)
+ if method: return method(self)
+ raise AttributeError(name)
+
+def _swig_repr(self):
+ try: strthis = "proxy of " + self.this.__repr__()
+ except: strthis = ""
+ return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+ _object = object
+ _newclass = 1
+except AttributeError:
+ class _object : pass
+ _newclass = 0
+
+
+class Fpga(_object):
+ __swig_setmethods__ = {}
+ __setattr__ = lambda self, name, value: _swig_setattr(self, Fpga, name, value)
+ __swig_getmethods__ = {}
+ __getattr__ = lambda self, name: _swig_getattr(self, Fpga, name)
+ __repr__ = _swig_repr
+ def __init__(self):
+ this = _fpga.new_Fpga()
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _fpga.delete_Fpga
+ __del__ = lambda self : None;
+ def get_error_msg(self, *args): return _fpga.Fpga_get_error_msg(self, *args)
+ def fpga_upgrade(self, *args): return _fpga.Fpga_fpga_upgrade(self, *args)
+Fpga_swigregister = _fpga.Fpga_swigregister
+Fpga_swigregister(Fpga)
+
+
+
--- /dev/null
+from urllib import urlretrieve
+
+from Screens.Screen import Screen
+from Screens.MessageBox import MessageBox
+
+from Plugins.Plugin import PluginDescriptor
+
+from Components.PluginComponent import plugins
+from Components.Pixmap import Pixmap
+from Components.ActionMap import ActionMap
+from Components.Sources.StaticText import StaticText
+from Components.FileList import FileList
+
+class FPGAUpgrade(Screen):
+ skin = """
+ <screen position="center,center" size="560,440" title="FPGA Upgrade" >
+ <ePixmap pixmap="Vu_HD/buttons/red.png" position="0,7" size="140,40" alphatest="blend" />
+ <ePixmap pixmap="Vu_HD/buttons/green.png" position="140,7" size="140,40" alphatest="blend" />
+ <ePixmap pixmap="Vu_HD/buttons/yellow.png" position="280,7" size="140,40" alphatest="blend" />
+ <ePixmap pixmap="Vu_HD/buttons/blue.png" position="420,7" size="140,40" alphatest="blend" />
+
+ <widget source="key_red" render="Label" position="20,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
+ <widget source="key_green" render="Label" position="160,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
+ <widget source="key_yellow" render="Label" position="300,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
+ <widget source="key_blue" render="Label" position="440,0" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
+
+ <widget source="status" render="Label" position="15,45" zPosition="1" size="540,40" font="Regular;18" halign="left" valign="center" backgroundColor="#a08500" transparent="1" />
+ <widget name="file_list" position="0,100" size="555,325" scrollbarMode="showOnDemand" />
+ </screen>"""
+
+ def __init__(self, session):
+ Screen.__init__(self, session)
+ self.session = session
+
+ self["key_red"] = StaticText(_("Close"))
+ self["key_green"] = StaticText(_("Ugrade"))
+ self["key_yellow"] = StaticText(_(" "))
+ self["key_blue"] = StaticText(_("Download"))
+ #self["key_blue"] = StaticText(_(" "))
+ self["status"] = StaticText(_(" "))
+ self["file_list"] = FileList("/", matchingPattern = "^.*")
+
+ self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", ],
+ {
+ "red": self.onClickRed,
+ "green": self.onClickGreen,
+ "blue": self.onClickBlue,
+ "back": self.onClickRed,
+ "ok": self.onClickOk,
+ "up": self.onClickUp,
+ "down": self.onClickDown,
+ "left": self.onClickLeft,
+ "right": self.onClickRight,
+ }, -1)
+ self.onLayoutFinish.append(self.doLayoutFinish)
+
+ self.ERROR_MSG = ''
+ self.ERROR_CODE = 0
+ self.SOURCELIST = self["file_list"]
+ self.STATUS_BAR = self["status"]
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+
+ self.DEVICE_PATH = 'a'
+ self.DOWNLOAD_TAR_PATH = '/tmp/'
+ self.DOWNLOAD_FILE_NAME = 'fpga.vuplus'
+ self.DOWNLOAD_URL = ''
+ self.doLoadConf()
+
+ print self.DEVICE_PATH
+ print self.DOWNLOAD_TAR_PATH
+ print self.DOWNLOAD_FILE_NAME
+ print self.DOWNLOAD_URL
+
+ def doLayoutFinish(self):
+ return
+
+ def doExit(self):
+ self.close()
+
+ def doLoadConf(self):
+ import os
+ f = open('/usr/lib/enigma2/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.conf')
+ self.DOWNLOAD_URL = str(f.readline())
+
+ def doHook(self, blockNumber, blockSize, totalSize) :
+ if blockNumber*blockSize > totalSize :
+ self.STATUS_BAR.setText(_("Downloaded " + self.DOWNLOAD_TAR_PATH + self.DOWNLOAD_FILE_NAME))
+ else :
+ self.STATUS_BAR.setText(_("Downloading..."))
+
+ def onCallbackHandler(self, confirmed):
+ if confirmed:
+ self.doExit()
+
+ def onClickRed(self):
+ self.doExit()
+
+ # run upgrade!!
+ def onClickGreen(self):
+ import fpga
+
+ FPGA = fpga.Fpga()
+
+ path = ''
+ try:
+ path = self.SOURCELIST.getCurrentDirectory() + self.SOURCELIST.getFilename()
+ except:
+ #self.session.open(MessageBox, _("Can't select directory."), MessageBox.TYPE_INFO, timeout = 5)
+ return
+
+ self.ERROR_CODE = FPGA.fpga_upgrade(path, self.DEVICE_PATH)
+ if self.ERROR_CODE > 0:
+ self.ERROR_MSG = FPGA.get_error_msg(self.ERROR_CODE, self.ERROR_MSG)
+ self.session.openWithCallback(self.onCallbackHandler, MessageBox, _("Fail to upgrade.\nCause : " + self.ERROR_MSG + "\nDo you want to exit?"), MessageBox.TYPE_YESNO, timeout = 10, default = True)
+
+ print "DEVICE_PATH : ", self.DEVICE_PATH
+ print "FILE_PATH : ", path
+ else:
+ self.session.open(MessageBox, _("Success!!"), MessageBox.TYPE_INFO, timeout = 5)
+
+ def onClickBlue(self):
+ fname = ''
+ header = ''
+
+ try :
+ fname, header = urlretrieve(self.DOWNLOAD_URL, self.DOWNLOAD_TAR_PATH + self.DOWNLOAD_FILE_NAME, self.doHook)
+ except IOError, msg:
+ self.session.open(MessageBox, _(str(msg)), MessageBox.TYPE_INFO, timeout = 5)
+ return
+
+ self.SOURCELIST.changeDir(self.DOWNLOAD_TAR_PATH)
+ while cmp(self.SOURCELIST.getFilename(), self.DOWNLOAD_FILE_NAME) != 0 :
+ self.SOURCELIST.down()
+
+ def onClickOk(self):
+ if self.SOURCELIST.canDescent() : # isDir
+ self.SOURCELIST.descent()
+ if self.SOURCELIST.getCurrentDirectory():
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+ else:
+ self.onClickGreen()
+
+ def onClickUp(self):
+ self.SOURCELIST.up()
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+
+ def onClickDown(self):
+ self.SOURCELIST.down()
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+
+ def onClickLeft(self):
+ self.SOURCELIST.pageUp()
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+
+ def onClickRight(self):
+ self.SOURCELIST.pageDown()
+ self.STATUS_BAR.setText(_(self.SOURCELIST.getCurrentDirectory()))
+
+def main(session, **kwargs):
+ session.open(FPGAUpgrade)
+
+def Plugins(**kwargs):
+ return PluginDescriptor(name=_("FPGA Upgrade"), description="Upgrade FPGA..", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
+