From: kos Date: Fri, 13 May 2011 05:43:54 +0000 (+0900) Subject: add FPGAUpgrade Plugin. X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=3634611e6260f2d0fd800752cd80af69d95bed04 add FPGAUpgrade Plugin. --- diff --git a/configure.ac b/configure.ac index c235888..38b66d3 100644 --- a/configure.ac +++ b/configure.ac @@ -203,6 +203,8 @@ lib/python/Plugins/SystemPlugins/WirelessLan/meta/Makefile lib/python/Plugins/SystemPlugins/FactoryTest/Makefile lib/python/Plugins/SystemPlugins/Fancontrol/Makefile lib/python/Plugins/SystemPlugins/Fancontrol/meta/Makefile +lib/python/Plugins/SystemPlugins/FPGAUpgrade/Makefile +lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/Makefile.am b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/Makefile.am new file mode 100755 index 0000000..36e60c8 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/Makefile.am @@ -0,0 +1,10 @@ +installdir = $(pkglibdir)/python/Plugins/SystemPlugins/FPGAUpgrade + +SUBDIRS = meta + +install_PYTHON = \ + __init__.py \ + plugin.py \ + fpga.py \ + fpga.conf \ + _fpga.so diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/__init__.py b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/_fpga.so b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/_fpga.so new file mode 100644 index 0000000..e932612 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/_fpga.so differ diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.conf b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.conf new file mode 100644 index 0000000..e7ec14e --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.conf @@ -0,0 +1 @@ +http://archive.vuplus.com/download/fpga/fpga.vuplus diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.py b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.py new file mode 100644 index 0000000..61e1209 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/fpga.py @@ -0,0 +1,87 @@ +# 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) + + + diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/Makefile.am new file mode 100755 index 0000000..31e3c0b --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(datadir)/meta + +dist_install_DATA = plugin_fpgaupgrade.xml diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/plugin_fpgaupgrade.xml b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/plugin_fpgaupgrade.xml new file mode 100755 index 0000000..d7c500a --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/meta/plugin_fpgaupgrade.xml @@ -0,0 +1,16 @@ + + + + + + oskwon + FPGAUpgrade + enigma2-plugin-systemplugins-fpgaupgrade + Upgrade your system FPGA + Upgrade your internal system FPGA. + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/FPGAUpgrade/plugin.py b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/plugin.py new file mode 100644 index 0000000..10f9e51 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FPGAUpgrade/plugin.py @@ -0,0 +1,164 @@ +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 = """ + + + + + + + + + + + + + + """ + + 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) + diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index db75abe..a2aa9e2 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \ DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \ CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \ - TempFanControl FactoryTest Fancontrol + TempFanControl FactoryTest Fancontrol FPGAUpgrade install_PYTHON = \ __init__.py