get rid of hardcoded path to cdrom device
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Wed, 8 Oct 2008 15:36:49 +0000 (15:36 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Wed, 8 Oct 2008 15:36:49 +0000 (15:36 +0000)
lib/python/Components/Harddisk.py
lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py
lib/python/Plugins/Extensions/DVDBurn/Process.py
lib/python/Plugins/Extensions/DVDPlayer/plugin.py

index dfc262d..a5727cf 100644 (file)
@@ -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()]
 
index c766ad5..30487b6 100644 (file)
@@ -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
index 74f23f1..71f7c99 100644 (file)
@@ -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
index b9d9ce7..b201d2c 100644 (file)
@@ -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)