Exemplo n.º 1
0
 def __init__(self):
     self.proc = childprocess.ChildProcess()
     if CONFIG.get(CONFIG_SECTION, CONFIG_PLAYER) is None:
         self.setup()
     self.player = CONFIG.get(CONFIG_SECTION, CONFIG_PLAYER)
     self.channels = []
     self.currentChannelId = -1
Exemplo n.º 2
0
 def readLoop(self):
     device = evdev.InputDevice(CONFIG.get(CONFIG_SECTION, CONFIG_DEVPATH))
     self.device = device
     logger.info(self.__class__.__name__ + " opening device: " +
                 str(device))
     device.grab()
     logger.info(self.__class__.__name__ + " opened device: " + str(device))
     try:
         for event in device.read_loop():
             if event.type == evdev.ecodes.EV_KEY:
                 if evdev.categorize(event) == None:
                     continue
                 logger.info(self.__class__.__name__ + " input: " +
                             str(evdev.categorize(event)))
                 keyevent = evdev.KeyEvent(event)
                 if keyevent.keystate in (
                         1, ):  #state: 0=up, 1=down, 2=hold
                     keycode = keyevent.keycode
                     self.keydispatcher.dispatch(keycode)
                     #print("scancode: ", evdev.KeyEvent(event).scancode, "keycode:", evdev.KeyEvent(event).keycode)
                     #print("event:", evdev.categorize(event))
     except:
         type, value, traceback = sys.exc_info()
         logger.info(self.__class__.__name__ + " Error: " + str(value) +
                     "\n" + str(traceback))
Exemplo n.º 3
0
 def setup(self):
     while True:
         i = 1
         options = ['mplayer --really-quiet']
         for option in options:
             print(i, option)
             i += 1
         print("Please setup the Radio Player app: ")
         try:
             n = sys.stdin.readline()
             n = int(n)
         except:
             n = 0
         i = 1
         for option in options:
             if i == n:
                 CONFIG.set(CONFIG_SECTION, CONFIG_PLAYER, option)
                 return
             i += 1
         print("Invalid option number " + str(n) + ", please try again")
Exemplo n.º 4
0
 def setup(self):
     devices = [evdev.InputDevice(fn) for fn in evdev.list_devices()]
     if len(devices) == 0:
         return None
     print("Please chose an Input Device")
     while True:
         i = 1
         for device in devices:
             print(i, device.fn, device.name, device.phys)
             i += 1
         print("Enter the device number: ")
         try:
             n = sys.stdin.readline()
             n = int(n)
         except:
             n = 0
         i = 1
         for device in devices:
             if i == n:
                 CONFIG.set(CONFIG_SECTION, CONFIG_DEVPATH, device.fn)
                 CONFIG.set(CONFIG_SECTION, CONFIG_DEVNAME, device.name)
                 CONFIG.set(CONFIG_SECTION, CONFIG_DEVPHYS, device.phys)
                 return
             i += 1
         print("Invalid device number " + str(n) + ", please try again")
Exemplo n.º 5
0
 def setup(self):
     while True:
         i = 1
         options = [
             'sudo openvt -f -s -c 1 -- sudo -u pi mplayer --really-quiet --hardframedrop -vo sdl'
         ]
         for option in options:
             print(i, option)
             i += 1
         print("Please setup the Player app: ")
         try:
             n = sys.stdin.readline()
             n = int(n)
         except:
             n = 0
         i = 1
         for option in options:
             if i == n:
                 CONFIG.set(CONFIG_SECTION, CONFIG_PLAYER, option)
                 return
             i += 1
         print("Invalid option number " + str(n) + ", please try again")
Exemplo n.º 6
0
 def __init__(self, keydispatcher):
     self.keydispatcher = keydispatcher
     if CONFIG.get(CONFIG_SECTION, 'devicepath') is None:
         self.setup()