def cdload(path=None):
"""Load the ISO into the virtual CD-ROM device.
:param path: File path of ISO file to load if not sample.iso.
"""
path = path or 'sample.iso'
try:
run(['cdemu', 'load', '0', path])
except subprocess.CalledProcessError as exc:
if b'AlreadyLoaded' not in exc.stderr:
raise
loaded = cdstatus()
if not loaded or os.path.realpath(loaded) != os.path.realpath(path):
cdunload()
return cdload(path)
for _ in range(50):
if os.path.exists('/dev/cdrom'):
return
time.sleep(0.1)
if not os.path.exists('/dev/cdrom'):
raise IOError('Failed to load cdemu device!')
评论列表
文章目录