<commit_before>from abc import ABCMeta, abstractmethod

import guestfs

from xii import util


class NeedGuestFS():
    __metaclass__ = ABCMeta

    @abstractmethod
    def get_tmp_volume_path(self):
        pass

    def guest(self):
        def _start_guestfs():
            path = self.get_tmp_volume_path()
            guest = guestfs.GuestFS()

            guest.add_drive(path)
            guest.launch()
            guest.mount("/dev/sda1", "/")

            if guest.exists('/etc/sysconfig/selinux'):
                guest.get_selinux = lambda: 1<commit_msg>Add error handling to guestfs initializer<commit_after>from abc import ABCMeta, abstractmethod

import guestfs

from xii import util, error


class NeedGuestFS():
    __metaclass__ = ABCMeta

    @abstractmethod
    def get_tmp_volume_path(self):
        pass

    def guest(self):
        def _start_guestfs():
            try:
                path = self.get_tmp_volume_path()
                guest = guestfs.GuestFS()

                guest.add_drive(path)
                guest.launch()
                guest.mount("/dev/sda1", "/")

                if guest.exists('/etc/sysconfig/selinux'):
                    guest.get_selinux = lambda: 1
            except RuntimeError as e:
                raise error.ExecError("guestfs error: {}".format(e))
{'fraction_non_alphanumeric': 0.09401061410159212, 'fraction_numerical': 0.003032600454890068, 'mean_word_length': 1.9596412556053813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3194238', 'n_tokens_mistral': 400, 'n_tokens_neox': 380, 'n_words': 84}