From 7416bb955a8eee1764a969116a54e3996fec429d Mon Sep 17 00:00:00 2001 From: Andreas Frisch Date: Wed, 8 Oct 2008 15:36:49 +0000 Subject: [PATCH] get rid of hardcoded path to cdrom device --- lib/python/Components/Harddisk.py | 7 ++++++- lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py | 5 +++-- lib/python/Plugins/Extensions/DVDBurn/Process.py | 5 +++-- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 9 +++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index dfc262d8..a5727cf7 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -248,7 +248,7 @@ class Partition: class HarddiskManager: def __init__(self): self.hdd = [ ] - + self.cd = "" self.partitions = [ ] self.on_partition_list_change = CList() @@ -301,6 +301,8 @@ class HarddiskManager: if partition[0:len(blockdev)] != blockdev: continue partitions.append(partition) + else: + self.cd = "/dev/"+blockdev except IOError: error = True return error, blacklisted, removable, is_cdrom, partitions @@ -363,6 +365,9 @@ class HarddiskManager: list.append((hdd, hd)) return list + def getCD(self): + return self.cd + def getMountedPartitions(self, onlyhotplug = False): return [x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted()] diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py index c766ad52..30487b69 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py @@ -7,6 +7,7 @@ from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress from Components.Task import Task, Job, job_manager, Condition from Components.ScrollLabel import ScrollLabel +from Components.Harddisk import harddiskmanager class DVDToolbox(Screen): skin = """ @@ -161,7 +162,7 @@ class DVDformatTask(Task): self.toolbox = job.toolbox self.postconditions.append(DVDformatTaskPostcondition()) self.setTool("/bin/dvd+rw-format") - self.args += [ "/dev/cdroms/cdrom0" ] + self.args += [ harddiskmanager.getCD() ] self.end = 1100 def prepare(self): @@ -205,7 +206,7 @@ class DVDinfoTask(Task): self.toolbox = job.toolbox self.postconditions.append(DVDinfoTaskPostcondition()) self.setTool("/bin/dvd+rw-mediainfo") - self.args += [ "/dev/cdroms/cdrom0" ] + self.args += [ harddiskmanager.getCD() ] def prepare(self): self.error = None diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 74f23f15..71f7c998 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -1,4 +1,5 @@ from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition +from Components.Harddisk import harddiskmanager from Screens.MessageBox import MessageBox class png2yuvTask(Task): @@ -264,7 +265,7 @@ class BurnTask(Task): self.postconditions.append(BurnTaskPostcondition()) self.setTool("/bin/growisofs") volName = self.getASCIIname(job.project.settings.name.getValue()) - self.args += [ "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-publisher", "Dreambox", "-use-the-force-luke=dummy" ] + self.args += [ "-dvd-compat", "-Z", harddiskmanager.getCD(), "-V", volName, "-publisher", "Dreambox", "-use-the-force-luke=dummy" ] self.args += extra_args def getASCIIname(self, name): @@ -302,7 +303,7 @@ class BurnTask(Task): self.error = self.ERROR_SIZE elif line.find("write failed") != -1: self.error = self.ERROR_WRITE_FAILED - elif line.find("unable to open64(\"/dev/cdroms/cdrom0\",O_RDONLY): No such file or directory") != -1: # fixme + elif line.find("unable to open64(") != -1 and line.find(",O_RDONLY): No such file or directory") != -1: self.error = self.ERROR_DVDROM elif line.find("media is not recognized as recordable DVD") != -1: self.error = self.ERROR_NOTWRITEABLE diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index b9d9ce79..b201d2c6 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -12,6 +12,7 @@ from Components.MenuList import MenuList from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase from Components.config import config from Tools.Directories import pathExists, fileExists +from Components.Harddisk import harddiskmanager import servicedvd # load c++ part of dvd player plugin @@ -338,9 +339,9 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.dvd_device = dvd_device self.physicalDVD = True else: - if fileExists("/dev/cdroms/cdrom0"): - print "physical dvd found (/dev/cdroms/cdrom0)" - self.dvd_device = "/dev/cdroms/cdrom0" + if fileExists(harddiskmanager.getCD()): + print "physical dvd found:", harddiskmanager.getCD() + self.dvd_device = harddiskmanager.getCD() self.physicalDVD = True else: self.dvd_device = None @@ -541,7 +542,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP def showFileBrowser(self): if self.physicalDVD and len(self.dvd_filelist) == 0: - if self.dvd_device == "/dev/cdroms/cdrom0": + if self.dvd_device == harddiskmanager.getCD(): self.session.openWithCallback(self.DVDdriveCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 ) else: self.DVDdriveCB(True) -- 2.30.2