def _extract_rpm_file(self, target_file, extract_path):
    """Extracts the rpm file.

    :param target_file: the firmware file to be extracted from
    :param extract_path: the path where extraction is supposed to happen
    :raises: ImageExtractionFailed, if any issue with extraction
    """
    if not os.path.exists(extract_path):
        os.makedirs(extract_path)
    os.chdir(extract_path)

    if find_executable('rpm2cpio') is None:
        raise exception.ImageExtractionFailed(
            image_ref=target_file, reason='Command `rpm2cpio` not found.')
    if find_executable('cpio') is None:
        raise exception.ImageExtractionFailed(
            image_ref=target_file, reason='Command `cpio` not found.')
    try:
        rpm2cpio = subprocess.Popen('rpm2cpio ' + target_file,
                                    shell=True,
                                    stdout=subprocess.PIPE)
        cpio = subprocess.Popen('cpio -idm', shell=True,
                                stdin=rpm2cpio.stdout)
        out, err = cpio.communicate()
    except (OSError, ValueError) as e:
        raise exception.ImageExtractionFailed(
            image_ref=target_file,
            reason='Unexpected error in extracting file. ' + str(e))
def _extract_rpm_file ( self , target_file , extract_path ) : if not os . path . exists ( extract_path ) : os . makedirs ( extract_path ) os . chdir ( extract_path ) if find_executable ( 'rpm2cpio' ) is None : raise exception . ImageExtractionFailed ( image_ref = target_file , reason = 'Command `rpm2cpio` not found.' ) if find_executable ( 'cpio' ) is None : raise exception . ImageExtractionFailed ( image_ref = target_file , reason = 'Command `cpio` not found.' ) try : rpm2cpio = subprocess . Popen ( 'rpm2cpio ' + target_file , shell = True , stdout = subprocess . PIPE ) cpio = subprocess . Popen ( 'cpio -idm' , shell = True , stdin = rpm2cpio . stdout ) out , err = cpio . communicate ( ) except ( OSError , ValueError ) as e : raise exception . ImageExtractionFailed ( image_ref = target_file , reason = 'Unexpected error in extracting file. ' + str ( e ) )
Extracts the rpm file.

    :param target_file: the firmware file to be extracted from
    :param extract_path: the path where extraction is supposed to happen
    :raises: ImageExtractionFailed, if any issue with extraction