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 dfc262d84b889407dcd81c41df5429f3a8980be1..a5727cf71aef725af0cdc178740b306c8384dace 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 c766ad522ce3e656bdfd756fb197f04aabcdf95f..30487b690ff1c88a1f3345d9fdde7f9c9cec0960 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 74f23f1512fdb24cc5f78f9c23a4e8acbb2a5c7b..71f7c99801bdf1676dbb8733351789ace5781389 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 b9d9ce7914e774e3e7fafc96d03dc390feb54d4f..b201d2c6df682a8a2e006e4dec01bdce6965525d 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)