Index: mythburn.py
===================================================================
--- mythburn.py (Revision 14205)
+++ mythburn.py (Arbeitskopie)
@@ -56,8 +56,7 @@
 import MySQLdb, codecs
 import time, datetime, tempfile
 from fcntl import ioctl
-from CDROM import CDROMEJECT
-from CDROM import CDROMCLOSETRAY
+import CDROM
 from shutil import copy

 # media types (should match the enum in mytharchivewizard.h)
@@ -2088,35 +2087,44 @@
     write( "Burning ISO image to %s" % dvddrivepath)
     checkCancelFlag()

-    if mediatype == DVD_RW and erasedvdrw == True:
-        command = path_growisofs[0] + " -dvd-compat -use-the-force-luke -Z " + dvddrivepath + \
-                  " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
-    else:
-        command = path_growisofs[0] + " -dvd-compat -Z " + dvddrivepath + \
-                  " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
-
-    if os.system(command) != 0:
-        write("ERROR: Retrying to start growisofs after reload.")
+    finished = False
+    while not finished:
         f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
-        r = ioctl(f,CDROMEJECT, 0)
-        os.close(f)
-        f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
-        r = ioctl(f,CDROMCLOSETRAY, 0)
-        os.close(f)
-        result = os.system(command)
-        if result != 0:
-            write("-"*60)
-            write("ERROR: Failed while running growisofs")
-            write("Result %d, Command was: %s" % (result, command))
-            write("Please check the troubleshooting section of the README for ways to fix this error")
-            write("-"*60)
-            write("")
-            sys.exit(1)
+        drivestatus = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0)
+        if drivestatus == CDROM.CDS_DISC_OK or drivestatus == CDROM.CDS_NO_INFO:
+            os.close(f);
+            if mediatype == DVD_RW and erasedvdrw == True:
+                command = path_growisofs[0] + " -dvd-compat -use-the-force-luke -Z " + dvddrivepath + \
+                          " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
+            else:
+                command = path_growisofs[0] + " -dvd-compat -Z " + dvddrivepath + \
+                          " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
+            if os.system(command) != 0:
+                write("-"*60)
+                write("ERROR: Failed while running growisofs")
+                write("Result %d, Command was: %s" % (result, command))
+                write("Please check the troubleshooting section of the README for ways to fix this error")
+                write("-"*60)
+                write("")
+                sys.exit(1)
+            finished = True

-    # eject the burned disc
-    f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
-    r = ioctl(f,CDROMEJECT, 0)
-    os.close(f)
+            # eject the burned disc
+            f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
+            r = ioctl(f,CDROM.CDROMEJECT, 0)
+            os.close(f)
+        elif drivestatus == CDROM.CDS_TRAY_OPEN:
+            # Give the user 10secs to close the Tray
+            write("Waiting for tray to close.")
+            time.sleep(10)
+        elif drivestatus == CDROM.CDS_NO_DISC:
+            # Open the Tray, if there is one.
+            write("Opening tray to get it fed it with a DVD.")
+            ioctl(f,CDROM.CDROMEJECT, 0)
+        elif drivestatus == CDROM.CDS_DRIVE_NOT_READY:
+            # Try a hard reset
+            write("Trying a hard-reset of the device")
+            ioctl(f,CDROM.CDROMRESET, 0)

     write("Finished burning ISO image")
