<s> import os <EOL> import re <EOL> from oslo_config import cfg <EOL> from oslo_log import log as oslo_logging <EOL> from cloudbaseinit import exception <EOL> opts = [ <EOL> cfg . StrOpt ( '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> CONF = cfg . CONF <EOL> CONF . register_opts ( opts ) <EOL> CONFIG_DRIVE_LABEL = '<STR_LIT>' <EOL> LOG = oslo_logging . getLogger ( __name__ ) <EOL> VOLUME_LABEL_REGEX = re . compile ( "<STR_LIT>" ) <EOL> def _check_mtools_path ( ) : <EOL> if not CONF . mtools_path : <EOL> raise exception . CloudbaseInitException ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def is_vfat_drive ( osutils , drive_path ) : <EOL> """<STR_LIT>""" <EOL> _check_mtools_path ( ) <EOL> mlabel = os . path . join ( CONF . mtools_path , "<STR_LIT>" ) <EOL> args = [ mlabel , "<STR_LIT>" , drive_path , "<STR_LIT>" ] <EOL> out , err , exit_code = osutils . execute_process ( args , shell = False ) <EOL> if exit_code : <EOL> LOG . debug ( "<STR_LIT>" , <EOL> drive_path ) <EOL> LOG . debug ( "<STR_LIT>" , err ) <EOL> return False <EOL> LOG . debug ( "<STR_LIT>" , drive_path , out ) <EOL> out = out . decode ( ) . strip ( ) <EOL> match = VOLUME_LABEL_REGEX . search ( out ) <EOL> return match . group ( <NUM_LIT:1> ) == CONFIG_DRIVE_LABEL <EOL> def copy_from_vfat_drive ( osutils , drive_path , target_path ) : <EOL> """<STR_LIT>""" <EOL> _check_mtools_path ( ) <EOL> cwd = os . getcwd ( ) <EOL> try : <EOL> os . chdir ( target_path ) <EOL> mcopy = os . path . join ( CONF . mtools_path , "<STR_LIT>" ) <EOL> args = [ mcopy , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , drive_path , "<STR_LIT>" , "<STR_LIT:.>" ] <EOL> osutils . execute_process ( args , shell = False ) <EOL> finally : <EOL> os . chdir ( cwd ) </s>
