From cd51d1c8a2ec341b4202689e693b7bf012610d0d Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:17:46 +0100 Subject: change hotplugNotifier to return correct state transition for cd-rom type and flash type devices --- lib/python/Plugins/SystemPlugins/Hotplug/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py index 97ddf4a1..e593e942 100644 --- a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py @@ -53,7 +53,7 @@ class Hotplug(Protocol): for callback in hotplugNotifier: try: - callback(dev, media_state) + callback(dev, action or media_state) except AttributeError: hotplugNotifier.remove(callback) -- cgit v1.2.3 From 53a9e8c65ffb3c83736be784c894c57beca5bde5 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:20:56 +0100 Subject: use new hotplugNotifier return value to clear playlist if audio CD was removed --- .../Plugins/Extensions/MediaPlayer/plugin.py | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 0d5305d7..babef3e7 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -863,17 +863,22 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.session.open(Subtitles) def hotplugCB(self, dev, media_state): - if dev == harddiskmanager.getCD(): - from Components.Scanner import scanDevice - devpath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) - self.cdAudioTrackFiles = [] - res = scanDevice(devpath) - list = [ (r.description, r, res[r], self.session) for r in res ] - if list: - (desc, scanner, files, session) = list[0] - for file in files: - if file.mimetype == "audio/x-cda": - self.cdAudioTrackFiles.append(file.path) + if dev == harddiskmanager.getCD(): + if media_state == "1": + from Components.Scanner import scanDevice + devpath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) + self.cdAudioTrackFiles = [] + res = scanDevice(devpath) + list = [ (r.description, r, res[r], self.session) for r in res ] + if list: + (desc, scanner, files, session) = list[0] + for file in files: + if file.mimetype == "audio/x-cda": + self.cdAudioTrackFiles.append(file.path) + else: + self.cdAudioTrackFiles = [] + if self.isAudioCD: + self.clear_playlist() class MediaPlayerLCDScreen(Screen): skin = """ -- cgit v1.2.3 From 95b10a03763a432c7d5940cc83d9e4fa9ed3cc7c Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:22:01 +0100 Subject: use hotplugNotifier to ease use of NFIFlash plugin. change some excess status bar translatables to static english. --- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 50 +++++++++------------- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 10 ++--- 2 files changed, 25 insertions(+), 35 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index c2046af7..7e34d2bb 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -18,6 +18,7 @@ import urllib from twisted.web import client from twisted.internet import reactor, defer from twisted.python import failure +from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier class UserRequestedCancel(Exception): pass @@ -335,7 +336,7 @@ class NFIDownload(Screen): self.download = self.nfo_download self.downloading(True) client.getPage(nfourl).addCallback(self.nfo_finished).addErrback(self.nfo_failed) - self["statusbar"].text = _("Downloading image description...") + self["statusbar"].text = ("Downloading image description...") def nfo_failed(self, failure_instance): print "[nfo_failed] " + str(failure_instance) @@ -400,7 +401,7 @@ class NFIDownload(Screen): pos = self.nfo.find("MD5:") if pos > 0 and len(self.nfo) >= pos+5+32: - self["statusbar"].text = _("Please wait for md5 signature verification...") + self["statusbar"].text = ("Please wait for md5 signature verification...") cmd = "md5sum -c -" md5 = self.nfo[pos+5:pos+5+32] + " " + self.nfilocal print cmd, md5 @@ -489,33 +490,22 @@ class NFIDownload(Screen): def umount_finished(self, retval): self.container.appClosed.remove(self.umount_finished) - self.session.openWithCallback(self.dmesg_clear, MessageBox, _("To make sure you intend to do this, please remove the target USB stick now and stick it back in upon prompt. Press OK when you have taken the stick out."), MessageBox.TYPE_INFO) - - def dmesg_clear(self, answer): self.container.appClosed.append(self.dmesg_cleared) self.taskstring = "" self.cmd = "dmesg -c" print "executing " + self.cmd self.container.execute(self.cmd) - def dmesg_cleared(self, retval): + def dmesg_cleared(self, answer): self.container.appClosed.remove(self.dmesg_cleared) - self.session.openWithCallback(self.stick_back_in, MessageBox, (_("Now please insert the USB stick (minimum size is 64 MB) that you want to format and use as .NFI image flasher. Press OK after you've put the stick back in.")), MessageBox.TYPE_INFO) - - def stick_back_in(self, answer): - self["statusbar"].text = _("Waiting for USB stick to settle...") - self.delayTimer = eTimer() - self.delayTimer.callback.append(self.waiting_for_stick) - self.delayCount = -1 - self.delayTimer.start(1000) - - def waiting_for_stick(self): - self.delayCount += 1 - self["job_progressbar"].range = 6 - self["job_progressbar"].value = self.delayCount - self["job_progresslabel"].text = "-%d s" % (6-self.delayCount) - if self.delayCount > 5: - self.delayTimer.stop() + self.msgbox = self.session.open(MessageBox, _("Please disconnect all USB devices from your Dreambox and (re-)attach the target USB stick (minimum size is 64 MB) now!"), MessageBox.TYPE_INFO) + hotplugNotifier.append(self.hotplugCB) + + def hotplugCB(self, dev, action): + print "[hotplugCB]", dev, action + if dev.startswith("sd") and action == "add": + self.msgbox.close() + hotplugNotifier.remove(self.hotplugCB) self.container.appClosed.append(self.dmesg_scanned) self.taskstring = "" self.cmd = "dmesg" @@ -539,8 +529,8 @@ class NFIDownload(Screen): self.session.openWithCallback(self.fdisk_query, MessageBox, (_("The following device was found:\n\n%s\n\nDo you want to write the USB flasher to this stick?") % self.devicetext), MessageBox.TYPE_YESNO) def fdisk_query(self, answer): - if answer == True: - self["statusbar"].text = _("Partitioning USB stick...") + if answer == True and self.stickdevice: + self["statusbar"].text = ("Partitioning USB stick...") self["job_progressbar"].range = 1000 self["job_progressbar"].value = 100 self["job_progresslabel"].text = "5.00%" @@ -562,7 +552,7 @@ class NFIDownload(Screen): self.tar_finished(0) self["job_progressbar"].value = 700 else: - self["statusbar"].text = _("Decompressing USB stick flasher boot image...") + self["statusbar"].text = ("Decompressing USB stick flasher boot image...") self.taskstring = "" self.container.appClosed.append(self.tar_finished) self.container.setCWD("/tmp") @@ -588,7 +578,7 @@ class NFIDownload(Screen): self.container.appClosed.remove(self.tar_finished) if retval == 0: self.imagefilename = "/tmp/nfiflash_" + self.box + ".img" - self["statusbar"].text = _("Copying USB flasher boot image to stick...") + self["statusbar"].text = ("Copying USB flasher boot image to stick...") self.taskstring = "" self.container.appClosed.append(self.dd_finished) self.cmd = "dd if=%s of=%s" % (self.imagefilename,self.stickdevice+"/part1") @@ -607,7 +597,7 @@ class NFIDownload(Screen): if retval == 0: self["job_progressbar"].value = 950 self["job_progresslabel"].text = "95.00%" - self["statusbar"].text = _("Remounting stick partition...") + self["statusbar"].text = ("Remounting stick partition...") self.taskstring = "" self.container.appClosed.append(self.mount_finished) self.cmd = "mount %s /mnt/usb -o rw,sync" % (self.stickdevice+"/part1") @@ -622,7 +612,7 @@ class NFIDownload(Screen): if retval == 0: self["job_progressbar"].value = 1000 self["job_progresslabel"].text = "100.00%" - self["statusbar"].text = _(".NFI Flasher bootable USB stick successfully created.") + self["statusbar"].text = (".NFI Flasher bootable USB stick successfully created.") self.session.openWithCallback(self.remove_img, MessageBox, _("The .NFI Image flasher USB stick is now ready to use. Please download an .NFI image file from the feed server and save it on the stick. Then reboot and hold the 'Down' key on the front panel to boot the .NFI flasher from the stick!"), MessageBox.TYPE_INFO) self["destlist"].changeDir("/mnt/usb") else: @@ -659,8 +649,8 @@ def filescan(**kwargs): Scanner(mimetypes = ["application/x-dream-image"], paths_to_scan = [ - ScanPath(path = "", with_subdirs = False), + ScanPath(path = "", with_subdirs = False), ], name = "NFI", - description = (_("Download .NFI-Files for USB-Flasher")+"..."), + description = (_("Download .NFI-Files for USB-Flasher")+"..."), openfnc = filescan_open, ) diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index 6a982c58..860efc02 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -17,7 +17,7 @@ import re class writeNAND(Task): def __init__(self,job,param,box): - Task.__init__(self,job, _("Writing image file to NAND Flash")) + Task.__init__(self,job, ("Writing image file to NAND Flash")) self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/mywritenand") if box == "dm7025": self.end = 256 @@ -26,7 +26,7 @@ class writeNAND(Task): if box == "dm8000": self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand") self.args += param - self.weighting = 1 + self.weighting = 1 def processOutput(self, data): print "[writeNand] " + data @@ -174,8 +174,8 @@ class NFIFlash(Screen): 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["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) @@ -252,7 +252,7 @@ class NFIFlash(Screen): def reboot(self): if self.job.status == self.job.FINISHED: - self["statusbar"].text = _("rebooting...") + self["statusbar"].text = ("rebooting...") TryQuitMainloop(self.session,2) def createSummary(self): -- cgit v1.2.3 From e7364f6c8cd59562884f895042980b88a962c945 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:24:20 +0100 Subject: show dvd burn jobs running in background in main menu and fix potential crash on aborting during CheckDiskspaceTask --- lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py index b88dbb3f..ce16259e 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py @@ -63,7 +63,7 @@ class DVDToolbox(Screen): def pageDown(self): self["details"].pageDown() - def update(self, dev="", media_state=""): + def update(self, dev="", action=""): self["space_label"].text = _("Please wait... Loading list...") self["info"].text = "" self["details"].setText("") -- cgit v1.2.3 From c2ec827d12f170cb4bee1a42be9e454c7174207b Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:29:31 +0100 Subject: show dvd burn jobs running in background in main menu and fix potential crash on aborting during CheckDiskspaceTask --- lib/python/Plugins/Extensions/DVDBurn/Process.py | 3 +++ lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 89ca90fd..946b44ad 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -368,6 +368,9 @@ class CheckDiskspaceTask(Task): self.global_preconditions.append(DiskspacePrecondition(diskSpaceNeeded)) self.weighting = 5 + def abort(self): + self.finish(aborted = True) + def run(self, callback): failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) if len(failed_preconditions): diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index 345af877..537da0dd 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -74,9 +74,22 @@ class TitleList(Screen, HelpableScreen): self["titles"] = List(list = [ ], enableWrapAround = True, item_height=30, fonts = [gFont("Regular", 20)]) self.updateTitleList() - + + def checkBackgroundJobs(self): + for job in job_manager.getPendingJobs(): + print "type(job):", type(job) + print "Process.DVDJob:", Process.DVDJob + if type(job) == Process.DVDJob: + self.backgroundJob = job + return + self.backgroundJob = None + def showMenu(self): menu = [] + self.checkBackgroundJobs() + if self.backgroundJob: + j = self.backgroundJob + menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob)) if self.project.settings.output.getValue() == "dvd": menu.append((_("Burn DVD"), self.burnProject)) elif self.project.settings.output.getValue() == "iso": @@ -97,6 +110,11 @@ class TitleList(Screen, HelpableScreen): if choice: choice[1]() + def showBackgroundJob(self): + job_manager.in_background = False + self.session.openWithCallback(self.JobViewCB, JobView, self.backgroundJob) + self.backgroundJob = None + def titleProperties(self): if self.getCurrentTitle(): self.session.openWithCallback(self.updateTitleList, TitleProperties.TitleProperties, self, self.project, self["titles"].getIndex()) @@ -217,7 +235,7 @@ class TitleList(Screen, HelpableScreen): totalsize += title.estimatedDiskspace self["titles"].list = res self.updateSize(totalsize) - + def updateSize(self, totalsize): size = int((totalsize/1024)/1024) max_SL = 4370 -- cgit v1.2.3 From a8e2ae086f201762677d9f926b75285d1c299ab2 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:29:39 +0100 Subject: remove superfluous import --- lib/python/Screens/InfoBarGenerics.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index cdaa2c1e..eb79c74e 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -1312,7 +1312,6 @@ class InfoBarJobman: self.session.openWithCallback(self.JobViewCB, JobView, job) def JobViewCB(self, in_background): - from Screens.TaskView import JobView job_manager.in_background = in_background # depends on InfoBarExtensions -- cgit v1.2.3 From f38670a4ea4d6dc6206e6bd99ad25943d0bf3602 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 17 Nov 2008 23:33:56 +0100 Subject: do remove elementary stream files... and do it correctly! --- lib/python/Plugins/Extensions/DVDBurn/Process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 946b44ad..750e9d9b 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -165,7 +165,7 @@ class DemuxTask(Task): def cleanup(self, failed): if failed: import os - for file in self.generated_files.itervalues(): + for file in self.generated_files: os.remove(file) class MplexTaskPostcondition(Condition): @@ -220,7 +220,7 @@ class RemoveESFiles(Task): def prepare(self): self.args += ["-f"] - self.args += self.demux_task.generated_files.values() + self.args += self.demux_task.generated_files self.args += [self.demux_task.cutfile] class DVDAuthorTask(Task): @@ -794,7 +794,7 @@ class DVDJob(Job): demux = DemuxTask(self, link_name) self.mplextask = MplexTask(self, outputfile=title_filename, demux_task=demux) self.mplextask.end = self.estimateddvdsize - #RemoveESFiles(self, demux) + RemoveESFiles(self, demux) WaitForResidentTasks(self) PreviewTask(self, self.workspace + "/dvd/VIDEO_TS/") output = self.project.settings.output.getValue() -- cgit v1.2.3