#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright 2010 (C) Peter Gill # This file is part of DeVeDe # # DeVeDe is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # DeVeDe is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import os import sys import shutil import string from ctypes import windll import devede_executor class burn_generator(devede_executor.executor): """ This class generates the ISO image for DVDs """ def __init__(self,filename,filefolder,command, progresbar): devede_executor.executor.__init__(self,filename+".iso",filefolder, progresbar) self.driveTypes = ['DRIVE_UNKNOWN', 'DRIVE_NO_ROOT_DIR', 'DRIVE_REMOVABLE', 'DRIVE_FIXED', 'DRIVE_REMOTE', 'DRIVE_CDROM', 'DRIVE_RAMDISK'] self.print_error=_("Failed to burn the Disc") #ImgBurn.exe /MODE WRITE /SRC "C:\TEST123.ISO" /DEST G: /START /SPEED 1x /COPIES 1 /VERIFY YES if command == "ImgBurn.exe": self.launch_program([command, "/MODE", "WRITE", "/SRC", filefolder+filename+".iso", "/DEST", self.get_first_cdrom(), "/START", "/SPEED", "8x", "/COPIES", "1", "/VERIFY", "YES", "/close"], output=False) elif command == "brasero": pass def set_progress_bar(self): ''' set_progress_bar is defined in each subclass to fit the format ''' # As imageburn/brasero is being used wait for the process to end then return true. self.wait_end() return True def end_process(self,eraser=None,erase_temporal_files=None): ''' end_process is needed in each class ''' pass def __get_drives(self): drives = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in string.uppercase: if bitmask & 1: drives.append(letter) bitmask >>= 1 return drives def get_first_cdrom(self): for drive in self.__get_drives(): if not drive: continue #print "Drive:", drive try: typeIndex = windll.kernel32.GetDriveTypeW(u"%s:\\"%drive) #print "Type:",driveTypes[typeIndex] if self.driveTypes[typeIndex] == "DRIVE_CDROM": return drive + ":\\" except Exception,e: print "error:",e if __name__ == "__main__": dlg = burn_generator("somefile.iso","somefolder", "ImgBurn.exe") print dlg.get_first_cdrom()