Exemplo n.º 1
0
    def load(self, xml_file, max_depth=None, backup=None):
        """
        Load an xml file

        :param xml_file: str -- path of the xml file to load
        :param max_depth: int -- maximum depth for sequence creation
        :param backup: str -- path of the xml backup file
        """
        if self.loaded and self.started:
            if not self.interrupted:
                return
            self.wait()
        xml_sequence = parse_sequence_file(xml_file, max_depth, backup)
        self.sequence = RootSequenceThread(xml_sequence)
        self.loaded = True
        self.started = False
        self.interrupted = False
Exemplo n.º 2
0
    def load(self, xml_file, max_depth=None, backup=None):
        """
        Load an xml file

        :param xml_file: str -- path of the xml file to load
        :param max_depth: int -- maximum depth for sequence creation
        :param backup: str -- path of the xml backup file
        """
        if self.loaded and self.started:
            if not self.interrupted:
                return
            self.wait()
        xml_sequence = parse_sequence_file(xml_file, max_depth, backup)
        self.sequence = RootSequenceThread(xml_sequence)
        self.loaded = True
        self.started = False
        self.interrupted = False
Exemplo n.º 3
0
class SequenceEngine():
    """
    Main class of the sequence engine
    """
    is_loaded = lambda self: self.loaded
    is_started = lambda self: self.started
    is_interrupted = lambda self: self.interrupted

    def __init__(self):
        """
        Init method
        """
        self.sequence = None
        self.loaded = False
        self.started = False
        self.interrupted = False

    def load(self, xml_file, max_depth=None, backup=None):
        """
        Load an xml file

        :param xml_file: str -- path of the xml file to load
        :param max_depth: int -- maximum depth for sequence creation
        :param backup: str -- path of the xml backup file
        """
        if self.loaded and self.started:
            if not self.interrupted:
                return
            self.wait()
        xml_sequence = parse_sequence_file(xml_file, max_depth, backup)
        self.sequence = RootSequenceThread(xml_sequence)
        self.loaded = True
        self.started = False
        self.interrupted = False

    def start(self):
        """
        Start the sequence
        """
        if self.loaded and not self.started:
            self.sequence.start()
            self.started = True
            self.interrupted = False

    def wait(self, timeout=None):
        """
        Wait for the sequence to terminate
        Return False if the timeout is expired, True otherwise
        """
        if self.loaded and self.started:
            self.sequence.join(timeout)
            if self.sequence.is_alive():
                return False
            self.sequence = None
            self.interrupted = False
            self.started = False
            self.loaded = False
        return True

    def interrupt(self):
        """
        Interrupt the sequence execution
        """
        if self.loaded:
            if self.started:
                self.sequence.stop()
                self.interrupted = True
            else:
                self.sequence = None
                self.loaded = False
Exemplo n.º 4
0
class SequenceEngine:
    """
    Main class of the sequence engine
    """

    is_loaded = lambda self: self.loaded
    is_started = lambda self: self.started
    is_interrupted = lambda self: self.interrupted

    def __init__(self):
        """
        Init method
        """
        self.sequence = None
        self.loaded = False
        self.started = False
        self.interrupted = False

    def load(self, xml_file, max_depth=None, backup=None):
        """
        Load an xml file

        :param xml_file: str -- path of the xml file to load
        :param max_depth: int -- maximum depth for sequence creation
        :param backup: str -- path of the xml backup file
        """
        if self.loaded and self.started:
            if not self.interrupted:
                return
            self.wait()
        xml_sequence = parse_sequence_file(xml_file, max_depth, backup)
        self.sequence = RootSequenceThread(xml_sequence)
        self.loaded = True
        self.started = False
        self.interrupted = False

    def start(self):
        """
        Start the sequence
        """
        if self.loaded and not self.started:
            self.sequence.start()
            self.started = True
            self.interrupted = False

    def wait(self, timeout=None):
        """
        Wait for the sequence to terminate
        Return False if the timeout is expired, True otherwise
        """
        if self.loaded and self.started:
            self.sequence.join(timeout)
            if self.sequence.is_alive():
                return False
            self.sequence = None
            self.interrupted = False
            self.started = False
            self.loaded = False
        return True

    def interrupt(self):
        """
        Interrupt the sequence execution
        """
        if self.loaded:
            if self.started:
                self.sequence.stop()
                self.interrupted = True
            else:
                self.sequence = None
                self.loaded = False