2016-05-11 05:12:43 +00:00
|
|
|
import os
|
2016-05-11 05:02:58 +00:00
|
|
|
import re
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_VOLUME_ID_REGEX = re.compile(b'^Volume id: (?P<volume_id>.+)$', re.MULTILINE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def GetVolumeID(path):
|
|
|
|
|
isoinfo = subprocess.check_output([
|
|
|
|
|
'isoinfo',
|
|
|
|
|
'-d',
|
|
|
|
|
'-i', path,
|
|
|
|
|
])
|
|
|
|
|
match = _VOLUME_ID_REGEX.search(isoinfo)
|
|
|
|
|
return match.group('volume_id').decode('ascii')
|
2016-05-11 05:12:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def GetCurrentImage(image_dir='/isodevice/iconograph'):
|
|
|
|
|
current_path = os.path.join(image_dir, 'current')
|
|
|
|
|
return os.path.basename(os.readlink(current_path))
|