Пример #1
0
 def test_that_virtual_remote_is_symmetric_with_virtual_remote_listen(self):
     received = []
     keys = ['DOWN', 'DOWN', 'UP', 'GOODBYE']
     def listener():
         #    "* 2" is once for VirtualRemote's __init__ and once for press.
         for _ in range(len(keys) * 2):
             for k in VirtualRemote.listen('localhost', 2033, self._debugger):
                 received.append(k)
     t = threading.Thread()
     t.run = listener
     t.start()
     for k in keys:
         time.sleep(0.01)  # Give listener a chance to start listening (sorry)
         vr = VirtualRemote('localhost', 2033, self._debugger)
         time.sleep(0.01)
         vr.press(k)
     t.join()
     assert received == keys
Пример #2
0
    def test_that_virtual_remote_is_symmetric_with_virtual_remote_listen(self):
        received = []
        keys = ['DOWN', 'DOWN', 'UP', 'GOODBYE']

        def listener():
            #    "* 2" is once for VirtualRemote's __init__ and once for press.
            for _ in range(len(keys) * 2):
                for k in VirtualRemote.listen('localhost', 2033,
                                              self._debugger):
                    received.append(k)

        t = threading.Thread()
        t.run = listener
        t.start()
        for k in keys:
            time.sleep(
                0.01)  # Give listener a chance to start listening (sorry)
            vr = VirtualRemote('localhost', 2033, self._debugger)
            time.sleep(0.01)
            vr.press(k)
        t.join()
        assert received == keys
Пример #3
0
 def __new__(cls, uri, debugger):
     vr = re.match(r'vr:(?P<hostname>[^:]*)(:(?P<port>\d+))?', uri)
     if vr:
         d = vr.groupdict()
         return VirtualRemote.listen(d['hostname'], int(d['port'] or 2033), debugger)
     lirc = re.match(r'lirc:(?P<lircd_socket>[^:]*):(?P<control_name>.*)', uri)
     if lirc:
         d = lirc.groupdict()
         return LircRemote.listen(d['lircd_socket'] or '/var/run/lirc/lircd',
                                   d['control_name'],
                                   debugger)
     f = re.match('file://(?P<filename>.+)', uri)
     if f:
         return FileRemote.listen(f.group('filename'), debugger)
     raise ConfigurationError('Invalid remote control recorder URI: "%s"' % uri)
Пример #4
0
 def __new__(cls, uri, debugger):
     vr = re.match(r'vr:(?P<hostname>[^:]*)(:(?P<port>\d+))?', uri)
     if vr:
         d = vr.groupdict()
         return VirtualRemote.listen(d['hostname'], int(d['port'] or 2033),
                                     debugger)
     lirc = re.match(r'lirc:(?P<lircd_socket>[^:]*):(?P<control_name>.*)',
                     uri)
     if lirc:
         d = lirc.groupdict()
         return LircRemote.listen(
             d['lircd_socket'] or '/var/run/lirc/lircd', d['control_name'],
             debugger)
     f = re.match('file://(?P<filename>.+)', uri)
     if f:
         return FileRemote.listen(f.group('filename'), debugger)
     raise ConfigurationError('Invalid remote control recorder URI: "%s"' %
                              uri)
Пример #5
0
 def __new__(cls, uri, display, debugger):
     if uri.lower() == 'none':
         return NullRemote()
     if uri.lower() == 'test':
         return TestRemote(display, debugger)
     vr = re.match(r'vr:(?P<hostname>[^:]*)(:(?P<port>\d+))?', uri)
     if vr:
         d = vr.groupdict()
         return VirtualRemote(d['hostname'], int(d['port'] or 2033), debugger)
     lirc = re.match(r'lirc:(?P<lircd_socket>[^:]*):(?P<control_name>.*)', uri)
     if lirc:
         d = lirc.groupdict()
         return LircRemote(d['lircd_socket'] or '/var/run/lirc/lircd',
                           d['control_name'],
                           debugger)
     irnb = re.match(
         r'irnetbox:(?P<hostname>[^:]+):(?P<output>\d+):(?P<config>.+)', uri)
     if irnb:
         d = irnb.groupdict()
         return IRNetBoxRemote(d['hostname'], d['output'], d['config'], debugger)
     raise ConfigurationError('Invalid remote control URI: "%s"'%uri)
Пример #6
0
 def listener():
     #    "* 2" is once for VirtualRemote's __init__ and once for press.
     for _ in range(len(keys) * 2):
         for k in VirtualRemote.listen('localhost', 2033,
                                       self._debugger):
             received.append(k)
Пример #7
0
 def listener():
     #    "* 2" is once for VirtualRemote's __init__ and once for press.
     for _ in range(len(keys) * 2):
         for k in VirtualRemote.listen('localhost', 2033, self._debugger):
             received.append(k)