Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def run(self):
- #while xbmc is running
- self._scrobbler = Scrobbler()
- self._scrobbler.start()
- while not (self._abortRequested or xbmc.abortRequested):
- try:
- #try to connect, catch errors and retry every 5 seconds
- telnet = telnetlib.Telnet(self.TELNET_ADDRESS, self.TELNET_PORT)
- #if connection succeeds
- while not (self._abortRequested or xbmc.abortRequested):
- try:
- #read notification data
- data = self._readNotification(telnet)
- Debug("[Notification Service] message: " + str(data))
- self._forward(data)
- except EOFError:
- #if we end up here, it means the connection was lost or reset,
- # so we empty out the buffer, and exit this loop, which retries
- # the connection in the outer loop
- self._notificationBuffer = ""
- break
- except:
- time.sleep(5)
- continue
- telnet.close()
- self._scrobbler.abortRequested = True
- Debug("Notification service stopping")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement