def wait_pong(self): self.pong_count += 1 logger.warning("Tautulli WebSocket :: %s: Failed to receive pong from websocket, ping attempt %s." % (self.server.CONFIG.PMS_NAME, str(self.pong_count))) if self.pong_count >= plexpy.CONFIG.WEBSOCKET_CONNECTION_ATTEMPTS: self.pong_count = 0 self.close()
def notify(self, message, event): if not message or not event: return # Split host and port if self.host == "": host, port = "localhost", 23053 if ":" in self.host: host, port = self.host.split(':', 1) port = int(port) else: host, port = self.host, 23053 # If password is empty, assume none if self.password == "": password = None else: password = self.password # Register notification growl = gntp.notifier.GrowlNotifier( applicationName='PlexPy', notifications=['New Event'], defaultNotifications=['New Event'], hostname=host, port=port, password=password ) try: growl.register() except gntp.notifier.errors.NetworkError: logger.warning(u'Growl notification failed: network error') return except gntp.notifier.errors.AuthError: logger.warning(u'Growl notification failed: authentication error') return # Fix message message = message.encode(plexpy.SYS_ENCODING, "replace") # Send it, including an image image_file = os.path.join(str(plexpy.PROG_DIR), "data/images/plexpylogo.png") with open(image_file, 'rb') as f: image = f.read() try: growl.notify( noteType='New Event', title=event, description=message, icon=image ) except gntp.notifier.errors.NetworkError: logger.warning(u'Growl notification failed: network error') return logger.info(u"Growl notifications sent.")
def notify(self, message, event): if not message or not event: return # Split host and port if self.host == "": host, port = "localhost", 23053 if ":" in self.host: host, port = self.host.split(':', 1) port = int(port) else: host, port = self.host, 23053 # If password is empty, assume none if self.password == "": password = None else: password = self.password # Register notification growl = gntp.notifier.GrowlNotifier(applicationName='PlexPy', notifications=['New Event'], defaultNotifications=['New Event'], hostname=host, port=port, password=password) try: growl.register() except gntp.notifier.errors.NetworkError: logger.warning(u'Growl notification failed: network error') return except gntp.notifier.errors.AuthError: logger.warning(u'Growl notification failed: authentication error') return # Fix message message = message.encode(plexpy.SYS_ENCODING, "replace") # Send it, including an image image_file = os.path.join(str(plexpy.PROG_DIR), "data/images/plexpylogo.png") with open(image_file, 'rb') as f: image = f.read() try: growl.notify(noteType='New Event', title=event, description=message, icon=image) except gntp.notifier.errors.NetworkError: logger.warning(u'Growl notification failed: network error') return logger.info(u"Growl notifications sent.")
def push_nofitications(push_message=None, subject=None, status_message=None): if push_message: if not subject: subject = 'PlexPy' if plexpy.CONFIG.GROWL_ENABLED: logger.info(u"Growl request") growl = notifiers.GROWL() growl.notify(push_message, status_message) if plexpy.CONFIG.PROWL_ENABLED: logger.info(u"Prowl request") prowl = notifiers.PROWL() prowl.notify(push_message, status_message) if plexpy.CONFIG.XBMC_ENABLED: xbmc = notifiers.XBMC() if plexpy.CONFIG.XBMC_NOTIFY: xbmc.notify(subject, push_message) if plexpy.CONFIG.PLEX_ENABLED: plex = notifiers.Plex() if plexpy.CONFIG.PLEX_NOTIFY: plex.notify(subject, push_message) if plexpy.CONFIG.NMA_ENABLED: nma = notifiers.NMA() nma.notify(subject, push_message) if plexpy.CONFIG.PUSHALOT_ENABLED: logger.info(u"Pushalot request") pushalot = notifiers.PUSHALOT() pushalot.notify(push_message, status_message) if plexpy.CONFIG.PUSHOVER_ENABLED: logger.info(u"Pushover request") pushover = notifiers.PUSHOVER() pushover.notify(push_message, status_message) if plexpy.CONFIG.PUSHBULLET_ENABLED: logger.info(u"PushBullet request") pushbullet = notifiers.PUSHBULLET() pushbullet.notify(push_message, status_message) if plexpy.CONFIG.TWITTER_ENABLED: logger.info(u"Sending Twitter notification") twitter = notifiers.TwitterNotifier() twitter.notify_download(push_message) if plexpy.CONFIG.OSX_NOTIFY_ENABLED: # TODO: Get thumb in notification # from plexpy import cache # c = cache.Cache() # album_art = c.get_artwork_from_cache(None, release['AlbumID']) logger.info(u"Sending OS X notification") osx_notify = notifiers.OSX_NOTIFY() osx_notify.notify(subject, push_message) if plexpy.CONFIG.BOXCAR_ENABLED: logger.info(u"Sending Boxcar2 notification") boxcar = notifiers.BOXCAR() boxcar.notify(subject, push_message) if plexpy.CONFIG.EMAIL_ENABLED: logger.info(u"Sending Email notification") email = notifiers.Email() email.notify(subject=subject, message=push_message) else: logger.warning('Notification requested but no message received.')
def push_nofitications(push_message=None, subject=None, status_message=None): if push_message: if not subject: subject = "PlexPy" if plexpy.CONFIG.GROWL_ENABLED: logger.info(u"Growl request") growl = notifiers.GROWL() growl.notify(push_message, status_message) if plexpy.CONFIG.PROWL_ENABLED: logger.info(u"Prowl request") prowl = notifiers.PROWL() prowl.notify(push_message, status_message) if plexpy.CONFIG.XBMC_ENABLED: xbmc = notifiers.XBMC() if plexpy.CONFIG.XBMC_NOTIFY: xbmc.notify(subject, push_message) if plexpy.CONFIG.PLEX_ENABLED: plex = notifiers.Plex() if plexpy.CONFIG.PLEX_NOTIFY: plex.notify(subject, push_message) if plexpy.CONFIG.NMA_ENABLED: nma = notifiers.NMA() nma.notify(subject, push_message) if plexpy.CONFIG.PUSHALOT_ENABLED: logger.info(u"Pushalot request") pushalot = notifiers.PUSHALOT() pushalot.notify(push_message, status_message) if plexpy.CONFIG.PUSHOVER_ENABLED: logger.info(u"Pushover request") pushover = notifiers.PUSHOVER() pushover.notify(push_message, status_message) if plexpy.CONFIG.PUSHBULLET_ENABLED: logger.info(u"PushBullet request") pushbullet = notifiers.PUSHBULLET() pushbullet.notify(push_message, status_message) if plexpy.CONFIG.TWITTER_ENABLED: logger.info(u"Sending Twitter notification") twitter = notifiers.TwitterNotifier() twitter.notify_download(push_message) if plexpy.CONFIG.OSX_NOTIFY_ENABLED: # TODO: Get thumb in notification # from plexpy import cache # c = cache.Cache() # album_art = c.get_artwork_from_cache(None, release['AlbumID']) logger.info(u"Sending OS X notification") osx_notify = notifiers.OSX_NOTIFY() osx_notify.notify(subject, push_message) if plexpy.CONFIG.BOXCAR_ENABLED: logger.info(u"Sending Boxcar2 notification") boxcar = notifiers.BOXCAR() boxcar.notify(subject, push_message) if plexpy.CONFIG.EMAIL_ENABLED: logger.info(u"Sending Email notification") email = notifiers.Email() email.notify(subject=subject, message=push_message) else: logger.warning("Notification requested but no message received.")