Example #1
0
    def __init__(self,
                 host='127.0.0.1',
                 port=4445,
                 reconnectDelay=1.0,
                 connectionFunc=None,
                 maxBytes=1024,
                 start=True):
        self.host = host
        self.port = port

        self.reconnectDelay = 0.8
        self.connectionFunc = connectionFunc
        self.maxBytes = maxBytes
        self.threadHandle = None

        self.connectEvent = Event()
        self.disconnectEvent = Event()
        self.connectFailureEvent = Event()
        self.dataEvent = Event()

        self.activeSocket = None
        self.activeConnectionFunc = None
        self.running = False

        if start:
            self.running = True
            self.start()
Example #2
0
    def __init__(self, options={}):
        # config
        self.options = options

        # attributes
        self.player = None
        self.logger = logging.getLogger(__name__)
        if 'verbose' in options and options['verbose']:
            self.logger.setLevel(logging.DEBUG)

        # get video paths
        self.playlist = []
        self.playlist = options['playlist'] if 'playlist' in options else []
        self.logger.debug('playlist: {0}'.format(", ".join(self.playlist)))

        self.args = self.options['args'] if 'args' in self.options else [
            '--no-osd', '-b'
        ]
        self.event_manager = None
        # events
        self.loadEvent = Event()
        self.loadIndexEvent = Event()
        self.unloadEvent = Event()
        self.startEvent = Event()
        self.stopEvent = Event()
        self.playEvent = Event()
        self.pauseEvent = Event()
        self.toggleEvent = Event()
        self.seekEvent = Event()
        self.speedEvent = Event()
Example #3
0
    def __init__(self,
                 source,
                 args=[],
                 bus_address_finder=None,
                 Connection=None,
                 dbus_name=None,
                 pause=False):
        logger.debug('Instantiating OMXPlayer')

        self.args = args
        self._is_playing = True
        self._source = source
        self._dbus_name = dbus_name
        self._Connection = Connection if Connection else DBusConnection
        self._bus_address_finder = bus_address_finder if bus_address_finder else BusFinder(
        )

        #: Event called on pause ``callback(player)``
        self.pauseEvent = Event()
        #: Event called on play ``callback(player)``
        self.playEvent = Event()
        #: Event called on stop ``callback(player)``
        self.stopEvent = Event()
        #: Event called on seek ``callback(player, relative_position)``
        self.seekEvent = Event()
        #: Event called on setting position ``callback(player, absolute_position)``
        self.positionEvent = Event()

        self._process = None
        self._connection = None
        self.load(source, pause=pause)
Example #4
0
    def __init__(self):
        self.changeEvent = Event()
        self.schemaChangeEvent = Event()
        self.valueChangeEvent = Event()

        self.items_by_id = {}
        self.removers = {}
Example #5
0
    def __init__(self, path, options={}):
        # config
        self.path = path

        # attributes
        self.previous_data = None
        self.data = None

        # events
        self.dataLoadedEvent = Event()
        self.dataChangeEvent = Event()

        # config
        self.options = {}
        self.configure(options)
Example #6
0
    def getEventFrom(self, configName, eventName, dummy=True):
        if configName in self.options and eventName in self.options[
                configName] and self.event_manager:
            return self.event_manager.get(self.options[configName][eventName])

        # else
        return Event() if dummy else None
def event_extraction(events_table, node, parent_verb):
    if verb_not_aux(node):
        events_table[node.id] = Event(node, None, None, parent_verb)
    for child in node.children:
        node_child = child[1]
        relation_child = child[0]
        if verb_not_aux(node):
            current_event = events_table[node.id]
            if relation_child == 'suj':
                current_event.subj = node_child
            elif relation_child == 'cd':
                current_event.obj = node_child
                augment_parent_object(parent_verb, events_table, node_child)
            elif relation_child in ('cpred', 'ci', 'cc', 'creg', 'atr', 'cag'):
                check_majority_obj = ancora.check_majority_rule_category(
                    node.form, node.lemma, SRL.OBJ, node_child.tag[0],
                    node_child.deprel)
                if check_majority_obj and not node.has_relation('cd'):
                    if current_event.obj is None or (
                            abs(current_event.verb.id - current_event.obj.id) >
                            abs(current_event.verb.id - node_child.id)):
                        current_event.obj = node_child
                else:
                    check_majority = ancora.check_majority_rule_category(
                        node.form, node.lemma, SRL.THIRD, node_child.tag[0],
                        node_child.deprel)
                    if is_location_or_time(node_child):
                        current_event.add_circumstance_complements(node_child)
                    elif check_majority or check_majority == None:
                        current_event.complement = node_child
                    augment_parent_complement(parent_verb, events_table,
                                              node_child)
        event_extraction(events_table, node_child,
                         node if node.tag[0] == 'V' else parent_verb)
Example #8
0
    def __init__(self, options={}):
        self.options = options
        self.event_manager = None
        self.output_events = None

        self.num_channels = self.options[
            'num_channels'] if 'num_channels' in self.options else 10
        self.channel_event_prefix = self.options[
            'channel_event_prefix'] if 'channel_event_prefix' in self.options else 'ch'
        self.deviceName = self.options[
            'deviceName'] if 'deviceName' in self.options else None
        self.deviceNumber = int(self.options['deviceNumber']
                                ) if 'deviceNumber' in self.options else None

        self.fps = self.getOption('fps', 4.0)
        self.frameTime = 1.0 / self.fps

        self.logger = logging.getLogger(__name__)
        if 'verbose' in options and options['verbose']:
            self.logger.setLevel(logging.DEBUG)

        # events
        self.messageEvent = Event()
        self.dirty = True
        self.nextFrameTime = 0.0
Example #9
0
    def __init__(self, type_, default=None, opts={}, getter=None, setter=None):
        self.type = type_
        self.value = None
        self.default = default
        self.opts = opts if opts else {}
        self.getter = self._makeSafe(getter) if getter else None
        self.setter = self._makeSafe(setter) if setter else None

        self.changeEvent = Event()
Example #10
0
    def __init__(self, port=8080, start=True):
        threading.Thread.__init__(self)
        self.http_server = None
        self.threading_event = None
        self.port = port
        self.isVerbose = False

        self.requestEvent = Event()

        if start:
            self.startServer()
Example #11
0
    def get(self, _id, create=True):
        _id = str(_id)

        # find existing
        if _id in self._events:
            return self._events[_id]

        # create new
        if create:
            new_event = Event()
            self._events[_id] = new_event
            self.eventAddedEvent(new_event)
            return new_event

        # don't create, return None
        return None
def event_extraction(events_table, node, parent_verb):
    ancora = Ancora("ancora.vbs")
    if verb_not_aux(node):
        events_table[node.id] = Event(node, None, None, parent_verb)
    for child in node.children:
        node_child = child[1]
        relation_child = child[0]
        if is_verb(node):
            current_event = events_table[node.id]
            if relation_child == 'suj':
                current_event.subj = node_child
            elif relation_child == 'cd':
                current_event.obj = node_child
                if parent_verb is not None and verb_not_gerunde_nor_participle(
                        parent_verb):
                    parent_event = events_table[parent_verb.id]
                    if parent_event.obj is None:
                        unanimity_valence_obj = ancora.unanimity_argument(
                            parent_verb.form, parent_verb.lemma, SRL.OBJ)
                        if unanimity_valence_obj:
                            parent_event.obj = node_child
                        elif unanimity_arg == None or (
                                unanimity_arg == False
                                and ancora.one_category_argument(
                                    parent_verb.form, parent_verb.lemma,
                                    SRL.OBJ)):
                            word_embeddings = WordEmbeddings()
                            if word_embeddings.similar_words(
                                    parent_verb.form, node_child.form):
                                parent_event.obj = node_child
            elif relation_child in ('cpred', 'ci', 'cc', 'creg'):
                check_majority = ancora.check_majority_rule_category(
                    node.form, node.lemma, SRL.THIRD, node_child.tag[0])
                if is_location_or_time(node_child):
                    current_event.add_circumstance_complements(node_child)
                elif check_majority or check_majority == None:
                    current_event.complement(node_child)
                if parent_verb is not None:
                    parent_event = events_table[parent_verb.id]
                    if parent_event.complement == None:
                        check_unanimity_complement = ancora.check_unanimity_categories_argument_rule(
                            parent_verb.form, parent_verb.lemma, SRL.THIRD,
                            node_child.tag[0])
                        if check_unanimity_complement:
                            parent_event.complement = node_child
        event_extraction(events_table, node_child,
                         node if node.tag[0] == 'V' else parent_verb)
Example #13
0
    def __init__(self, options={}):
        # params
        self.options = options
        # attributes
        self.port = self.options['port'] if 'port' in self.options else None
        self.midi = None
        # self.port_name = None
        self.limit = 10
        self.connected = False
        self.event_manager = None
        self.listeners = []

        self.logger = logging.getLogger(__name__)
        if 'verbose' in options and options['verbose']:
            self.logger.setLevel(logging.DEBUG)

        # events
        self.messageEvent = Event()
Example #14
0
    def __init__(self, path=None, loop=True, delimiter=',', verbose=False):
        self.path = path
        self.loop = loop
        self.delimiter = ','

        self.file = None

        # last read frame info
        self.currentFrame = None
        self.currentFrameTime = None
        self.currentFrameIndex = -1

        # events
        self.loopEvent = Event()

        self.logger = logging.getLogger(__name__)
        if verbose:
            self.logger.setLevel(logging.DEBUG)
Example #15
0
    def setup(self, event_manager=None):
        self.event_manager = event_manager

        self.cursor = float(self.options['cursorStart']
                            ) if 'cursorStart' in self.options else 0.0
        self.cursorSpeed = self.frequency * math.pi * 2.0

        if self.event_manager and 'output_events' in self.options and 'value' in self.options[
                'output_events']:
            # get the event to use for distributing the sine-value during update
            self.valueEvent = self.event_manager.get(
                self.options['output_events']['value'])
            self.logger.debug('sine outputting values to event: ' +
                              self.options['output_events']['value'])
        else:
            # dummy event
            self.valueEvent = Event()

        self.sleep = None
        if 'sleep' in self.options:
            self.sleep = self.options['sleep']

        self.lastUpdateTime = time.time()
Example #16
0
        class Outgoing:
            def __init__(self):
                # events notifying about server-to-remote communications
                self.sendValueEvent = Event()
                self.sendSchemaEvent = Event()
                self.sendConnectConfirmationEvent = Event()
                self.sendDisconnectEvent = Event()

            def send_connect_confirmation(self, schema_data=None):
                '''
        Use this method to send a connect confirmation
        to a connecting remote client
        '''
                self.sendConnectConfirmationEvent(schema_data)

            def send_schema(self, schema_data):
                '''
        Use this method to send schema data
        to a remote client
        '''
                self.sendSchemaEvent(schema_data)

            def send_disconnect(self):
                logger.debug(
                    '[Remote.outgoing.send_disconnect listeners={}]'.format(
                        self.sendDisconnectEvent.getSubscriberCount()))
                '''
        Use this notify/confirm disconnect to the Remote
        '''
                self.sendDisconnectEvent()

            def send_value(self, path, value):
                '''
        Use this method to notify the connected client about
        a single param value change
        '''
                self.sendValueEvent(path, value)
    def __init__(self,
                 source,
                 args=None,
                 bus_address_finder=None,
                 Connection=None,
                 dbus_name=None,
                 pause=False,
                 preload=True):
        logger.debug('Instantiating OMXPlayer')

        if args is None:
            self.args = []
        elif isinstance(args, str):
            import shlex
            self.args = shlex.split(args)
        else:
            self.args = list(map(str, args))
        self._is_playing = True
        self._source = Path(source)
        self._dbus_name = dbus_name
        self._Connection = Connection if Connection else DBusConnection
        self._bus_address_finder = bus_address_finder if bus_address_finder else BusFinder(
        )

        #: Event called on pause ``callback(player)``
        self.pauseEvent = Event()
        #: Event called on play ``callback(player)``
        self.playEvent = Event()
        #: Event called on stop ``callback(player)``
        self.stopEvent = Event()
        #: Event called on exit ``callback(player, exit_status)``
        self.exitEvent = Event()
        #: Event called on seek ``callback(player, relative_position)``
        self.seekEvent = Event()
        #: Event called on setting position ``callback(player, absolute_position)``
        self.positionEvent = Event()

        self._process = None
        self._connection = None
        if (preload):
            self.load(source, pause=pause)
Example #18
0
 def __init__(self):
     self._events = {}
     self.eventAddedEvent = Event()
Example #19
0
 def __init__(self):
     # events for remote-to-server communications
     self.valueEvent = Event()
     self.disconnectEvent = Event()
     self.confirmEvent = Event()
     self.requestSchemaEvent = Event()
Example #20
0
    res = -1

    # sanity rename
    v1 = evento_1.verb
    s1 = evento_1.subj
    o1 = evento_1.obj
    v2 = evento_2.verb
    s2 = evento_2.subj
    o2 = evento_2.obj

    # v1,v2,s1,s2,o1,o2
    res = max(res, dist_combinacion([v1,s1,o1],[v2,s2,o2]))
    # v1,v2,s1,o2,o1,s2
    res = max(res, dist_combinacion([v1,s1,o1],[v2,o2,s2]))
    # v1,s2,s1,v2,o1,o2
    res = max(res, dist_combinacion([v1,s1,o1],[s2,v2,o2]))
    # v1,o2,s1,v2,o1,s2
    res = max(res, dist_combinacion([v1,s1,o1],[o2,v2,s2]))
    # v1,s2,s1,o2,o1,v2
    res = max(res, dist_combinacion([v1,s1,o1],[s2,o2,v2]))
    # v1,o2,s1,s2,o1,v2
    res = max(res, dist_combinacion([v1,s1,o1],[o2,s2,v2]))

    return res



e1 = Event(Node(ID='1',DEPHEAD='1',FORM='causó',LEMMA='causar',TAG='verb'),Node(ID='1',DEPHEAD='1',FORM='lluvia',LEMMA='lluvia',TAG='noun'),Node(ID='1',DEPHEAD='1',FORM='destrozos',LEMMA='destrozo',TAG='noun'))
e2 = Event(Node(ID='1',DEPHEAD='1',FORM='provocó',LEMMA='provocar',TAG='verb'),Node(ID='1',DEPHEAD='1',FORM='guerra',LEMMA='guerra',TAG='noun'),Node(ID='1',DEPHEAD='1',FORM='muerte',LEMMA='muerte',TAG='noun'))
e3 = Event(Node(ID='1',DEPHEAD='1',FORM='produjo',LEMMA='producir',TAG='verb'),Node(ID='1',DEPHEAD='1',FORM='nieve',LEMMA='nieve',TAG='noun'),Node(ID='1',DEPHEAD='1',FORM='felicidad',LEMMA='felicidad',TAG='noun'))
Example #21
0
 def __init__(self):
     # events notifying about server-to-remote communications
     self.sendValueEvent = Event()
     self.sendSchemaEvent = Event()
     self.sendConnectConfirmationEvent = Event()
     self.sendDisconnectEvent = Event()