def test_that_lirc_remote_is_symmetric_with_lirc_remote_listen(self):
     lircd_socket = tempfile.mktemp()
     t = threading.Thread()
     t.run = lambda: FakeLircd(lircd_socket)
     t.start()
     time.sleep(0.01)  # Give it a chance to start listening (sorry)
     listener = LircRemote.listen(lircd_socket, 'test', self._debugger)
     control = LircRemote(lircd_socket, 'test', self._debugger)
     for i in ['DOWN', 'DOWN', 'UP', 'GOODBYE']:
         control.press(i)
         assert listener.next() == i
     control.close()
     t.join()
 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)
Beispiel #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)
Beispiel #4
0
 def test_that_lirc_remote_is_symmetric_with_lirc_remote_listen(self):
     lircd_socket = tempfile.mktemp()
     t = threading.Thread()
     t.run = lambda: FakeLircd(lircd_socket)
     t.start()
     time.sleep(0.01)  # Give it a chance to start listening (sorry)
     listener = LircRemote.listen(lircd_socket, 'test', self._debugger)
     control = LircRemote(lircd_socket, 'test', self._debugger)
     for i in ['DOWN', 'DOWN', 'UP', 'GOODBYE']:
         control.press(i)
         assert listener.next() == i
     control.close()
     t.join()
 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)