Esempio n. 1
0
	def __init__(self, url, filename, device=None, mountpoint="/"):
		Job.__init__(self, _("Download .NFI-files for USB-flasher"))
		if device:
			if isMount(mountpoint):
				UmountTask(self, mountpoint)
			MountTask(self, device, mountpoint)
		ImageDownloadTask(self, url, mountpoint+filename)
		ImageDownloadTask(self, url[:-4]+".nfo", mountpoint+filename[:-4]+".nfo")
Esempio n. 2
0
	def __init__(self, project):
		Job.__init__(self, "Data DVD Burn")
		self.project = project
		from time import strftime
		from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
		new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S") + "/dvd/"
		createDir(new_workspace, True)
		self.workspace = new_workspace
		self.project.workspace = self.workspace
		self.conduct()
Esempio n. 3
0
	def __init__(self, project):
		Job.__init__(self, "Bludisc Burn")
		self.project = project
		new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("bludisc_%Y%m%d%H%M/")
		createDir(new_workspace, True)
		self.workspace = new_workspace
		self.project.workspace = self.workspace
		self.titles = []
		for title in self.project.titles:
			self.titles.append(BludiscTitle(title))	# wrap original DVD-Title into new BludiscTitle objects
		self.conduct()
Esempio n. 4
0
	def __init__(self, project, menupreview=False):
		Job.__init__(self, "DVDBurn Job")
		self.project = project
		from time import strftime
		from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
		new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S")
		createDir(new_workspace, True)
		self.workspace = new_workspace
		self.project.workspace = self.workspace
		self.menupreview = menupreview
		self.conduct()
Esempio n. 5
0
	def __init__(self, project, imagepath):
		Job.__init__(self, _("Burn DVD"))
		self.project = project
		self.menupreview = False
		if imagepath.endswith(".iso"):
			PreviewTask(self, imagepath)
			burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD() + '='+imagepath, "-dvd-compat" ]
		else:
			PreviewTask(self, imagepath + "/VIDEO_TS/")
			volName = self.project.settings.name.getValue()
			burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ]
			burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, imagepath ]
		tool = "/bin/growisofs"
		BurnTask(self, burnargs, tool)
Esempio n. 6
0
	def __init__(self, path):
		Job.__init__(self, _("USB stick wizard"))
		self.path = path
		self.device = path
		while self.device[-1:] == "/" or self.device[-1:].isdigit():
			self.device = self.device[:-1]

		box = HardwareInfo().get_device_name()
		url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s.tar.bz2" % box
		self.downloadfilename = "/tmp/dreambox-nfiflasher-%s.tar.bz2" % box
		self.imagefilename = "/tmp/nfiflash_%s.img" % box
		#UmountTask(self, device)
		PartitionTask(self)
		ImageDownloadTask(self, url, self.downloadfilename)
		UnpackTask(self)
		CopyTask(self)
Esempio n. 7
0
	def __init__(self, project, imagepath):
		Job.__init__(self, _("Burn DVD"))
		self.project = project
		self.menupreview = False
		from Tools.Directories import getSize
		if imagepath.endswith(".iso"):
			PreviewTask(self, imagepath)
			burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD() + '='+imagepath, "-dvd-compat" ]
			if getSize(imagepath)/(1024*1024) > self.project.MAX_SL:
				burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
		else:
			PreviewTask(self, imagepath + "/VIDEO_TS/")
			volName = self.project.settings.name.value
			burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ]
			if getSize(imagepath)/(1024*1024) > self.project.MAX_SL:
				burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
			burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, imagepath ]
		tool = "growisofs"
		BurnTask(self, burnargs, tool)
Esempio n. 8
0
	def createJob(self):
		self.job = Job("Image flashing job")
		param = [self.nfifile]
		writeNAND(self.job,param,self.box)
		#writeNAND2(self.job,param)
		#writeNAND3(self.job,param)
		self.job.state_changed.append(self.update_job)
		self.job.end = 540
		self.cwd = self["filelist"].getCurrentDirectory()
		self["job_progressbar"].range = self.job.end
		self.startJob()
Esempio n. 9
0
	def __init__(self, toolbox, cmdline, filename, filetitle):
		Job.__init__(self, _("Downloading"))
		self.toolbox = toolbox
		self.retrycount = 0
		
                downloadTask(self, cmdline, filename, filetitle)
Esempio n. 10
0
 def __init__(self, toolbox, cmdline, srcfile, destfile, eventname):
     Job.__init__(self, _("Merging Timeshift files"))
     self.toolbox = toolbox
     AddMergeTimeshiftTask(self, cmdline, srcfile, destfile, eventname)
Esempio n. 11
0
 def __init__(self, srcfile, destfile, name):
     Job.__init__(self, _("Moving files"))
     cmdline = "mv -f \"%s\" \"%s\"" % (srcfile, destfile)
     AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 12
0
	def __init__(self, src_file, dst_file, src_isDir, do_copy, title):
		Job.__init__(self, title)
		FileTransferTask(self, src_file, dst_file, src_isDir, do_copy)
Esempio n. 13
0
 def retry(self):
     self.tasks[0].args += self.tasks[0].retryargs
     Job.retry(self)
Esempio n. 14
0
def deleteFiles(fileList, name):
	job = Job(_("Deleting files"))
	task = DeleteFolderTask(job, name)
	task.openFiles(fileList)
	JobManager.AddJob(job)
Esempio n. 15
0
 def __init__(self, url, file, title):
     Job.__init__(self, title)
     downloadTask(self, url, file)
Esempio n. 16
0
 def __init__(self, toolbox, cmdline, srcfile, destfile, eventname):
     Job.__init__(self, _("Merging Timeshift files"))
     self.toolbox = toolbox
     AddMergeTimeshiftTask(self, cmdline, srcfile, destfile, eventname)
Esempio n. 17
0
 def __init__(self, url, file, title):
     Job.__init__(self, title)
     self.download_file = file
     self.download_job = downloadTask(self, url, self.download_file)
Esempio n. 18
0
 def __init__(self, cmdline, filename, filetitle):
     Job.__init__(self, 'Download: %s' % filetitle)
     self.filename = filename
     self.retrycount = 0
     print '63', filename
     downloadTaskrtmp(self, cmdline, filename)
Esempio n. 19
0
	def __init__(self, srcfile, destfile, name):
		Job.__init__(self, _("Moving files"))
		cmdline = ('mv', '-f', srcfile, destfile)
		AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 20
0
	def __init__(self, srcfile, destfile, name):
		Job.__init__(self, _("Copying files"))
		cmdline = ('cp', '-Rf', srcfile, destfile)
		AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 21
0
    def __init__(self, toolbox, cmdline, filename, filetitle):
        Job.__init__(self, _("Downloading"))
        self.toolbox = toolbox
        self.retrycount = 0

        downloadTask(self, cmdline, filename, filetitle)
Esempio n. 22
0
 def __init__(self, toolbox):
     Job.__init__(self, _("DVD media toolbox"))
     self.toolbox = toolbox
     DVDformatTask(self)
Esempio n. 23
0
 def __init__(self, url, file, title, agent=None):
     Job.__init__(self, title)
     DownloadTask(self, url, file, agent)
Esempio n. 24
0
	def __init__(self, url, file, title, agent=None):
		Job.__init__(self, title)
		DownloadTask(self, url, file, agent)
Esempio n. 25
0
	def __init__(self, url, filename, file, **kwargs):
		Job.__init__(self, _("%s") % file)
		DownloadTask(self, url, filename, **kwargs)
Esempio n. 26
0
 def __init__(self, toolbox):
     Job.__init__(self, _("DVD media toolbox"))
     self.toolbox = toolbox
     DVDformatTask(self)
Esempio n. 27
0
 def __init__(self, src_file, dst_file, src_isDir, do_copy, title):
     Job.__init__(self, title)
     FileTransferTask(self, src_file, dst_file, src_isDir, do_copy)
Esempio n. 28
0
 def __init__(self, url, filename, file):
     Job.__init__(self, _('Downloading %s' % file))
     ImageDownloadTask(self, url, filename)
Esempio n. 29
0
 def __init__(self, url, file, title):
     Job.__init__(self, title)
     self.download_file = file
     self.download_job = downloadTask(self, url, self.download_file)
Esempio n. 30
0
	def __init__(self, srcfile, destfile, name):
		Job.__init__(self, _("Copying files"))
		cmdline = 'cp -Rf "%s" "%s"' % (srcfile,destfile)
		AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 31
0
 def cut(self, name, inpath, outpath, inlen, outlen, clist):
     job = Job(_("Execute cuts"))
     CutTask(job, self.session, name, inpath, outpath, inlen, outlen,
             mcut_path, clist)
     JobManager.AddJob(job, onFail=self.noFail)
     self.close()
Esempio n. 32
0
	def __init__(self, srcfile, destfile, name):
		Job.__init__(self, _("Moving files"))
		cmdline = "mv -f \"%s\" \"%s\"" % (srcfile,destfile)
		AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 33
0
 def __init__(self, srcfile, destfile, name):
     Job.__init__(self, _('Moving files'))
     cmdline = 'mv -f "%s" "%s"' % (srcfile, destfile)
     AddFileProcessTask(self, cmdline, srcfile, destfile, name)
	def __init__(self, url, outputfile, title, downloadStop):
		Job.__init__(self, title)
		downloadTask(self, url, outputfile, downloadStop)
Esempio n. 35
0
 def __init__(self, toolbox, cmdline, eventname):
     Job.__init__(self, _('Creating AP and SC Files'))
     self.toolbox = toolbox
     CreateAPSCFilesTask(self, cmdline, eventname)
Esempio n. 36
0
class NFIFlash(Screen):
    skin = """
		<screen name="NFIFlash" position="90,95" size="560,420" title="Image flash utility">
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
			<widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
			<widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="listlabel" render="Label" position="16,44" size="200,21" valign="center" font="Regular;18" />
			<widget name="filelist" position="0,68" size="260,260" scrollbarMode="showOnDemand" />
			<widget source="infolabel" render="Label" position="270,44" size="280,284" font="Regular;16" />
			<widget source="job_progressbar" render="Progress" position="10,374" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
			<widget source="job_progresslabel" render="Label" position="180,378" zPosition="2" font="Regular;18" halign="center" transparent="1" size="200,22" foregroundColor="#000000" />
			<widget source="statusbar" render="Label" position="10,404" size="540,16" font="Regular;16" foregroundColor="#cccccc" />
		</screen>"""

    def __init__(self, session, cancelable=True, close_on_finish=False):
        self.skin = NFIFlash.skin
        Screen.__init__(self, session)

        self["job_progressbar"] = Progress()
        self["job_progresslabel"] = StaticText("")

        self["finished"] = Boolean()

        self["infolabel"] = StaticText("")
        self["statusbar"] = StaticText(
            _("Please select .NFI flash image file from medium"))
        self["listlabel"] = StaticText(_("select .NFI flash file") + ":")

        self["key_green"] = StaticText()
        self["key_yellow"] = StaticText()
        self["key_blue"] = StaticText()

        self["actions"] = ActionMap(
            ["OkCancelActions", "ColorActions", "DirectionActions"], {
                "green": self.ok,
                "yellow": self.reboot,
                "ok": self.ok,
                "left": self.left,
                "right": self.right,
                "up": self.up,
                "down": self.down
            }, -1)

        currDir = "/media/usb/"
        self.filelist = FileList(currDir, matchingPattern="^.*\.(nfi|NFI)")
        self["filelist"] = self.filelist
        self.nfifile = ""
        self.md5sum = ""
        self.job = None
        self.box = HardwareInfo().get_device_name()

    def closeCB(self):
        if (self.job is None or self.job.status
                is not self.job.IN_PROGRESS) and not self.no_autostart:
            self.close()
        #else:
        #if self.cancelable:
        #self.cancel()

    def up(self):
        self["filelist"].up()
        self.check_for_NFO()

    def down(self):
        self["filelist"].down()
        self.check_for_NFO()

    def right(self):
        self["filelist"].pageDown()
        self.check_for_NFO()

    def left(self):
        self["filelist"].pageUp()
        self.check_for_NFO()

    def check_for_NFO(self):
        self.session.summary.setText(self["filelist"].getFilename())
        if self["filelist"].getFilename() is None:
            return
        if self["filelist"].getCurrentDirectory() is not None:
            self.nfifile = self["filelist"].getCurrentDirectory(
            ) + self["filelist"].getFilename()

        if self.nfifile.upper().endswith(".NFI"):
            self["key_green"].text = _("Flash")
            nfofilename = self.nfifile[0:-3] + "nfo"
            if fileExists(nfofilename):
                nfocontent = open(nfofilename, "r").read()
                self["infolabel"].text = nfocontent
                pos = nfocontent.find("MD5:")
                if pos > 0:
                    self.md5sum = nfocontent[pos + 5:pos + 5 +
                                             32] + "  " + self.nfifile
                else:
                    self.md5sum = ""
            else:
                self["infolabel"].text = _(
                    "No details for this image file"
                ) + ":\n" + self["filelist"].getFilename()
                self.md5sum = ""
        else:
            self["infolabel"].text = ""
            self["key_green"].text = ""

    def ok(self):
        if self.job is None or self.job.status is not self.job.IN_PROGRESS:
            if self["filelist"].canDescent():  # isDir
                self["filelist"].descent()
                self.session.summary.setText(self["filelist"].getFilename())
                self.check_for_NFO()
            else:
                self.queryFlash()

    def queryFlash(self):
        fd = open(self.nfifile, 'r')
        print fd
        sign = fd.read(11)
        print sign
        if sign.find("NFI1" + self.box + "\0") == 0:
            if self.md5sum != "":
                self["statusbar"].text = (
                    "Please wait for md5 signature verification...")
                self.session.summary.setText(
                    ("Please wait for md5 signature verification..."))
                self.container = eConsoleAppContainer()
                self.container.setCWD(self["filelist"].getCurrentDirectory())
                self.container.appClosed.append(self.md5finished)
                self.container.dataSent.append(self.md5ready)
                self.container.execute("md5sum -cw -")
                self.container.write(self.md5sum)
            else:
                self.session.openWithCallback(
                    self.queryCB, MessageBox,
                    _("This .NFI file does not have a md5sum signature and is not guaranteed to work. Do you really want to burn this image to flash memory?"
                      ), MessageBox.TYPE_YESNO)
        else:
            self.session.open(
                MessageBox,
                (_("This .NFI file does not contain a valid %s image!") %
                 (self.box.upper())), MessageBox.TYPE_ERROR)

    def md5ready(self, retval):
        self.container.sendEOF()

    def md5finished(self, retval):
        if retval == 0:
            self.session.openWithCallback(
                self.queryCB, MessageBox,
                _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"
                  ), MessageBox.TYPE_YESNO)
        else:
            self.session.openWithCallback(
                self.queryCB, MessageBox,
                _("The md5sum validation failed, the file may be corrupted! Are you sure that you want to burn this image to flash memory? You are doing this at your own risk!"
                  ), MessageBox.TYPE_YESNO)

    def queryCB(self, answer):
        if answer == True:
            self.createJob()
        else:
            self["statusbar"].text = _(
                "Please select .NFI flash image file from medium")

    def createJob(self):
        self.job = Job("Image flashing job")
        param = [self.nfifile]
        writeNAND(self.job, param, self.box)
        #writeNAND2(self.job,param)
        #writeNAND3(self.job,param)
        self.job.state_changed.append(self.update_job)
        self.job.end = 540
        self.cwd = self["filelist"].getCurrentDirectory()
        self["job_progressbar"].range = self.job.end
        self.startJob()

    def startJob(self):
        self["key_blue"].text = ""
        self["key_yellow"].text = ""
        self["key_green"].text = ""
        #self["progress0"].show()
        #self["progress1"].show()

        self.job.start(self.jobcb)

    def update_job(self):
        j = self.job
        #print "[job state_changed]"
        if j.status == j.IN_PROGRESS:
            self.session.summary["job_progressbar"].value = j.progress
            self.session.summary["job_progressbar"].range = j.end
            self.session.summary["job_progresslabel"].text = "%.2f%%" % (
                100 * j.progress / float(j.end))
            self["job_progressbar"].range = j.end
            self["job_progressbar"].value = j.progress
            #print "[update_job] j.progress=%f, j.getProgress()=%f, j.end=%d, text=%f" % (j.progress, j.getProgress(), j.end,  (100*j.progress/float(j.end)))
            self["job_progresslabel"].text = "%.2f%%" % (100 * j.progress /
                                                         float(j.end))
            self.session.summary.setText(j.tasks[j.current_task].name)
            self["statusbar"].text = (j.tasks[j.current_task].name)

        elif j.status == j.FINISHED:
            self["statusbar"].text = _(
                "Writing NFI image file to flash completed")
            self.session.summary.setText(
                _("NFI image flashing completed. Press Yellow to Reboot!"))
            self["key_yellow"].text = _("Reboot")

        elif j.status == j.FAILED:
            self["statusbar"].text = j.tasks[j.current_task].name + " " + _(
                "failed")
            self.session.open(
                MessageBox,
                (_("Flashing failed") + ":\n" + j.tasks[j.current_task].name +
                 ":\n" + j.tasks[j.current_task].output_line),
                MessageBox.TYPE_ERROR)

    def jobcb(self, jobref, fasel, blubber):
        print "[jobcb] %s %s %s" % (jobref, fasel, blubber)
        self["key_green"].text = _("Flash")

    def reboot(self):
        if self.job.status == self.job.FINISHED:
            self["statusbar"].text = ("rebooting...")
            TryQuitMainloop(self.session, 2)

    def createSummary(self):
        return NFISummary
Esempio n. 37
0
class NFIFlash(Screen):
	skin = """
		<screen name="NFIFlash" position="90,95" size="560,420" title="Image flash utility">
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
			<widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
			<widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
			<widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="listlabel" render="Label" position="16,44" size="200,21" valign="center" font="Regular;18" />
			<widget name="filelist" position="0,68" size="260,260" scrollbarMode="showOnDemand" />
			<widget source="infolabel" render="Label" position="270,44" size="280,284" font="Regular;16" />
			<widget source="job_progressbar" render="Progress" position="10,374" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
			<widget source="job_progresslabel" render="Label" position="180,378" zPosition="2" font="Regular;18" halign="center" transparent="1" size="200,22" foregroundColor="#000000" />
			<widget source="statusbar" render="Label" position="10,404" size="540,16" font="Regular;16" foregroundColor="#cccccc" />
		</screen>"""

	def __init__(self, session, cancelable = True, close_on_finish = False):
		self.skin = NFIFlash.skin
		Screen.__init__(self, session)
		
		self["job_progressbar"] = Progress()
		self["job_progresslabel"] = StaticText("")
		
		self["finished"] = Boolean()

		self["infolabel"] = StaticText("")
		self["statusbar"] = StaticText(_("Please select .NFI flash image file from medium"))
		self["listlabel"] = StaticText(_("select .NFI flash file")+":")
		
		self["key_green"] = StaticText()
		self["key_yellow"] = StaticText()
		self["key_blue"] = StaticText()

		self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"],
		{
			"green": self.ok,
			"yellow": self.reboot,
			"ok": self.ok,
			"left": self.left,
			"right": self.right,
			"up": self.up,
			"down": self.down
		}, -1)

		currDir = "/media/usb/"
		self.filelist = FileList(currDir, matchingPattern = "^.*\.(nfi|NFI)")
		self["filelist"] = self.filelist
		self.nfifile = ""
		self.md5sum = ""
		self.job = None
		self.box = HardwareInfo().get_device_name()

	def closeCB(self):
		if ( self.job is None or self.job.status is not self.job.IN_PROGRESS ) and not self.no_autostart:
			self.close()
		#else:
			#if self.cancelable:
				#self.cancel()

	def up(self):
		self["filelist"].up()
		self.check_for_NFO()

	def down(self):
		self["filelist"].down()
		self.check_for_NFO()
	
	def right(self):
		self["filelist"].pageDown()
		self.check_for_NFO()

	def left(self):
		self["filelist"].pageUp()
		self.check_for_NFO()

	def check_for_NFO(self):
		self.session.summary.setText(self["filelist"].getFilename())
		if self["filelist"].getFilename() is None:
			return
		if self["filelist"].getCurrentDirectory() is not None:
			self.nfifile = self["filelist"].getCurrentDirectory()+self["filelist"].getFilename()

		if self.nfifile.upper().endswith(".NFI"):
			self["key_green"].text = _("Flash")
			nfofilename = self.nfifile[0:-3]+"nfo"
			if fileExists(nfofilename):
				nfocontent = open(nfofilename, "r").read()
				self["infolabel"].text = nfocontent
				pos = nfocontent.find("MD5:")
				if pos > 0:
					self.md5sum = nfocontent[pos+5:pos+5+32] + "  " + self.nfifile
				else:
					self.md5sum = ""
			else:
				self["infolabel"].text = _("No details for this image file") + ":\n" + self["filelist"].getFilename()
				self.md5sum = ""
		else:
			self["infolabel"].text = ""
			self["key_green"].text = ""

	def ok(self):
		if self.job is None or self.job.status is not self.job.IN_PROGRESS:
			if self["filelist"].canDescent(): # isDir
				self["filelist"].descent()
				self.session.summary.setText(self["filelist"].getFilename())
				self.check_for_NFO()
			else:
				self.queryFlash()
	
	def queryFlash(self):
		fd = open(self.nfifile, 'r')
		print fd
		sign = fd.read(11)
		print sign
		if sign.find("NFI1" + self.box + "\0") == 0:
			if self.md5sum != "":
				self["statusbar"].text = ("Please wait for md5 signature verification...")
				self.session.summary.setText(("Please wait for md5 signature verification..."))
				self.container = eConsoleAppContainer()
				self.container.setCWD(self["filelist"].getCurrentDirectory())
				self.container.appClosed.append(self.md5finished)
				self.container.dataSent.append(self.md5ready)
				self.container.execute("md5sum -cw -")
				self.container.write(self.md5sum)
			else:
				self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file does not have a md5sum signature and is not guaranteed to work. Do you really want to burn this image to flash memory?"), MessageBox.TYPE_YESNO)
		else:
			self.session.open(MessageBox, (_("This .NFI file does not contain a valid %s image!") % (self.box.upper())), MessageBox.TYPE_ERROR)

	def md5ready(self, retval):
		self.container.sendEOF()

	def md5finished(self, retval):
		if retval==0:
			self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO)
		else:
			self.session.openWithCallback(self.queryCB, MessageBox, _("The md5sum validation failed, the file may be corrupted! Are you sure that you want to burn this image to flash memory? You are doing this at your own risk!"), MessageBox.TYPE_YESNO)

	def queryCB(self, answer):
		if answer == True:
			self.createJob()
		else:
			self["statusbar"].text = _("Please select .NFI flash image file from medium")

	def createJob(self):
		self.job = Job("Image flashing job")
		param = [self.nfifile]
		writeNAND(self.job,param,self.box)
		#writeNAND2(self.job,param)
		#writeNAND3(self.job,param)
		self.job.state_changed.append(self.update_job)
		self.job.end = 540
		self.cwd = self["filelist"].getCurrentDirectory()
		self["job_progressbar"].range = self.job.end
		self.startJob()

	def startJob(self):
		self["key_blue"].text = ""
		self["key_yellow"].text = ""
		self["key_green"].text = ""
		#self["progress0"].show()
		#self["progress1"].show()

		self.job.start(self.jobcb)

	def update_job(self):
		j = self.job
		#print "[job state_changed]"
		if j.status == j.IN_PROGRESS:
			self.session.summary["job_progressbar"].value = j.progress
			self.session.summary["job_progressbar"].range = j.end
			self.session.summary["job_progresslabel"].text = "%.2f%%" % (100*j.progress/float(j.end))
			self["job_progressbar"].range = j.end
			self["job_progressbar"].value = j.progress
			#print "[update_job] j.progress=%f, j.getProgress()=%f, j.end=%d, text=%f" % (j.progress, j.getProgress(), j.end,  (100*j.progress/float(j.end)))
			self["job_progresslabel"].text = "%.2f%%" % (100*j.progress/float(j.end))
			self.session.summary.setText(j.tasks[j.current_task].name)
			self["statusbar"].text = (j.tasks[j.current_task].name)

		elif j.status == j.FINISHED:
			self["statusbar"].text = _("Writing NFI image file to flash completed")
			self.session.summary.setText(_("NFI image flashing completed. Press Yellow to Reboot!"))
			self["key_yellow"].text = _("Reboot")

		elif j.status == j.FAILED:
			self["statusbar"].text = j.tasks[j.current_task].name + " " + _("failed")
			self.session.open(MessageBox, (_("Flashing failed") + ":\n" + j.tasks[j.current_task].name + ":\n" + j.tasks[j.current_task].output_line), MessageBox.TYPE_ERROR)

	def jobcb(self, jobref, fasel, blubber):
		print "[jobcb] %s %s %s" % (jobref, fasel, blubber)
		self["key_green"].text = _("Flash")

	def reboot(self):
		if self.job.status == self.job.FINISHED:
			self["statusbar"].text = ("rebooting...")
			TryQuitMainloop(self.session,2)
			
	def createSummary(self):
		return NFISummary
Esempio n. 38
0
	def __init__(self, url, filename, file):
		Job.__init__(self, _("Downloading %s" %file))
		ImageDownloadTask(self, url, filename)
Esempio n. 39
0
    def do_run_script(self, answer):
        answer = answer and answer[1]
        if answer in ("YES", "PAR", "YES_BG", "PAR_BG"):
            if not os.access(self.commando, os.R_OK):
                self.session.open(
                    MessageBox,
                    _("Script '%s' must have read permission to be able to run it"
                      ) % self.commando,
                    type=MessageBox.TYPE_ERROR,
                    close_on_any_key=True,
                    simple=True)
                return
            nice = config.plugins.filecommander.script_priority_nice.getValue(
            ) or ''
            ionice = config.plugins.filecommander.script_priority_ionice.getValue(
            ) or ''
            if nice:
                nice = 'nice -n %d ' % nice
            if ionice:
                ionice = 'ionice -c %d ' % ionice
            priority = '%s%s' % (nice, ionice)
            if self.commando.endswith('.sh'):
                if os.access(self.commando, os.X_OK):
                    if 'PAR' in answer:
                        cmdline = "%s%s '%s'" % (priority, self.commando,
                                                 self.parameter)
                    else:
                        cmdline = "%s%s" % (priority, self.commando)
                else:
                    if 'PAR' in answer:
                        cmdline = "%s/bin/sh %s '%s'" % (
                            priority, self.commando, self.parameter)
                    else:
                        cmdline = "%s/bin/sh %s" % (priority, self.commando)
            else:
                if 'PAR' in answer:
                    cmdline = "%s/usr/bin/python %s '%s'" % (
                        priority, self.commando, self.parameter)
                else:
                    cmdline = "%s/usr/bin/python %s" % (priority,
                                                        self.commando)
        elif answer == "VIEW":
            try:
                yfile = os.stat(self.commando)
            except OSError as oe:
                self.session.open(MessageBox,
                                  _("%s: %s") % (self.commando, oe.strerror),
                                  type=MessageBox.TYPE_ERROR,
                                  simple=True)
                return
            if (yfile.st_size < 1000000):
                self.session.open(vEditor, self.commando)

        if answer and answer not in ("NO", "VIEW"):
            if answer.endswith('_BG'):
                global task_Stout, task_Sterr
                task_Stout = []
                task_Sterr = []
                if 'PAR' in answer:
                    name = '%s%s %s' % (priority, self.commando,
                                        self.parameter)
                else:
                    name = '%s%s' % (priority, self.commando)
                job = Job(_("Run script") + " ('%s')" % name)
                task = Task(job, name)
                task.postconditions.append(task_postconditions())
                task.processStdout = task_processStdout
                task.processStderr = task_processSterr
                task.setCmdline(cmdline)
                job_manager.AddJob(job,
                                   onSuccess=self.finishedCB,
                                   onFail=self.failCB)
                self.jobs += 1
                self.onLayout()
            else:
                self.session.open(Console, cmdlist=(cmdline, ))
Esempio n. 40
0
 def retry(self):
     self.tasks[0].args += self.tasks[0].retryargs
     Job.retry(self)
Esempio n. 41
0
	def __init__(self, srcfile, destfile, name):
		Job.__init__(self, _("Copying files"))
		cmdline = 'cp -Rf "%s" "%s"' % (srcfile,destfile)
		AddFileProcessTask(self, cmdline, srcfile, destfile, name)
Esempio n. 42
0
 def __init__(self, toolbox, cmdline, srcfile, destfile, eventname):
     Job.__init__(self, _('Saving Timeshift files'))
     self.toolbox = toolbox
     AddCopyTimeshiftTask(self, cmdline, srcfile, destfile, eventname)
Esempio n. 43
0
 def __init__(self, url, filename, file):
     Job.__init__(self, _("%s") % file)
     DownloadTask(self, url, filename)
Esempio n. 44
0
 def __init__(self, toolbox, cmdline, srcfile, destfile, eventname):
     Job.__init__(self, _('Saving Timeshift files'))
     self.toolbox = toolbox
     AddCopyTimeshiftTask(self, cmdline, srcfile, destfile, eventname)
Esempio n. 45
0
 def __init__(self, toolbox, cmdline, eventname):
     Job.__init__(self, _('Creating AP and SC Files'))
     self.toolbox = toolbox
     CreateAPSCFilesTask(self, cmdline, eventname)
Esempio n. 46
0
 def __init__(self, srcfile, destfile, name):
     Job.__init__(self, _('Moving files'))
     cmdline = 'mv -f "%s" "%s"' % (srcfile, destfile)
     AddFileProcessTask(self, cmdline, srcfile, destfile, name)
	def __init__(self, url, outputfile, title, downloadStop):
		Job.__init__(self, title)
		downloadTask(self, url, outputfile, downloadStop)