Ticket #3841: mythburn.patch

File mythburn.patch, 3.6 KB (added by lukas.kasprowicz@…, 17 years ago)
  • mythburn.py

     
    5656import MySQLdb, codecs
    5757import time, datetime, tempfile
    5858from fcntl import ioctl
    59 from CDROM import CDROMEJECT
    60 from CDROM import CDROMCLOSETRAY
     59import CDROM
    6160from shutil import copy
    6261
    6362# media types (should match the enum in mytharchivewizard.h)
     
    20882087    write( "Burning ISO image to %s" % dvddrivepath)
    20892088    checkCancelFlag()
    20902089
    2091     if mediatype == DVD_RW and erasedvdrw == True:
    2092         command = path_growisofs[0] + " -dvd-compat -use-the-force-luke -Z " + dvddrivepath + \
    2093                   " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
    2094     else:
    2095         command = path_growisofs[0] + " -dvd-compat -Z " + dvddrivepath + \
    2096                   " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
    2097 
    2098     if os.system(command) != 0:
    2099         write("ERROR: Retrying to start growisofs after reload.")
     2090    finished = False
     2091    while not finished:
    21002092        f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
    2101         r = ioctl(f,CDROMEJECT, 0)
    2102         os.close(f)
    2103         f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
    2104         r = ioctl(f,CDROMCLOSETRAY, 0)
    2105         os.close(f)
    2106         result = os.system(command)
    2107         if result != 0:
    2108             write("-"*60)
    2109             write("ERROR: Failed while running growisofs")
    2110             write("Result %d, Command was: %s" % (result, command))
    2111             write("Please check the troubleshooting section of the README for ways to fix this error")
    2112             write("-"*60)
    2113             write("")
    2114             sys.exit(1)
     2093        drivestatus = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0)
     2094        if drivestatus == CDROM.CDS_DISC_OK or drivestatus == CDROM.CDS_NO_INFO:
     2095            os.close(f);
     2096            if mediatype == DVD_RW and erasedvdrw == True:
     2097                command = path_growisofs[0] + " -dvd-compat -use-the-force-luke -Z " + dvddrivepath + \
     2098                          " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
     2099            else:
     2100                command = path_growisofs[0] + " -dvd-compat -Z " + dvddrivepath + \
     2101                          " -dvd-video -V 'MythTV DVD' " + os.path.join(getTempPath(),'dvd')
     2102            if os.system(command) != 0:
     2103                write("-"*60)
     2104                write("ERROR: Failed while running growisofs")
     2105                write("Result %d, Command was: %s" % (result, command))
     2106                write("Please check the troubleshooting section of the README for ways to fix this error")
     2107                write("-"*60)
     2108                write("")
     2109                sys.exit(1)
     2110            finished = True
    21152111
    2116     # eject the burned disc
    2117     f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
    2118     r = ioctl(f,CDROMEJECT, 0)
    2119     os.close(f)
     2112            # eject the burned disc
     2113            f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
     2114            r = ioctl(f,CDROMEJECT, 0)
     2115            os.close(f)
     2116        elif drivestatus == CDROM.CDS_TRAY_OPEN:
     2117            # Give the user 10secs to close the Tray
     2118            write("Waiting for tray to close.")
     2119            time.sleep(10)
     2120        elif drivestatus == CDROM.CDS_NO_DISC:
     2121            # Open the Tray, if there is one.
     2122            write("Opening tray to get it fed it with a DVD.")
     2123            ioctl(f,CDROM.CDROMEJECT, 0)
     2124        elif drivestatus == CDROM.CDS_DRIVE_NOT_READY:
     2125            # Try a hard reset
     2126            write("Trying a hard-reset of the device")
     2127            ioctl(f,CDROM.CDROMRESET, 0)
    21202128
    21212129    write("Finished burning ISO image")