Advertisement
sschocke

trakt plugin fix for notification service

Jan 13th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1.     def run(self):
  2.         #while xbmc is running
  3.         self._scrobbler = Scrobbler()
  4.         self._scrobbler.start()
  5.         while not (self._abortRequested or xbmc.abortRequested):
  6.             try:
  7.                 #try to connect, catch errors and retry every 5 seconds
  8.                 telnet = telnetlib.Telnet(self.TELNET_ADDRESS, self.TELNET_PORT)
  9.                
  10.                 #if connection succeeds
  11.                 while not (self._abortRequested or xbmc.abortRequested):
  12.                     try:
  13.                         #read notification data
  14.                         data = self._readNotification(telnet)
  15.                         Debug("[Notification Service] message: " + str(data))
  16.                         self._forward(data)
  17.                     except EOFError:
  18.                         #if we end up here, it means the connection was lost or reset,
  19.                         # so we empty out the buffer, and exit this loop, which retries
  20.                         # the connection in the outer loop
  21.                         self._notificationBuffer = ""
  22.                         break
  23.             except:
  24.                 time.sleep(5)
  25.                 continue
  26.  
  27.  
  28.         telnet.close()
  29.         self._scrobbler.abortRequested = True
  30.         Debug("Notification service stopping")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement