Beispiel #1
0
    def _send_registration(self, host=None, password=None):

        host_parts = self._choose(host, sickbeard.GROWL_HOST).split(':')
        port = 23053 if (2 != len(host_parts) or '' == host_parts[1]) else int(
            host_parts[1])
        password = self._choose(password, sickbeard.GROWL_PASSWORD)

        opts = dict(app='SickGear',
                    host=host_parts[0],
                    port=port,
                    password=password,
                    debug=False)

        # Send Registration
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', opts['app'])
        register.add_header('Application-Icon', self._sg_logo_url)

        register.add_notification('Test', True)
        register.add_notification(notify_strings['snatch'], True)
        register.add_notification(notify_strings['download'], True)
        register.add_notification(notify_strings['git_updated'], True)

        if opts['password']:
            register.set_password(opts['password'])

        try:
            return self._send(opts['host'], opts['port'], register.encode(),
                              opts['debug'])
        except Exception as e:
            self._log_warning(u'Unable to send growl to %s:%s - %s' %
                              (opts['host'], opts['port'], ex(e)))
            return False
Beispiel #2
0
 def _create_register(self):
     register = gntp.GNTPRegister()
     register.add_header('Application-Name', self.application)
     register.add_notification('Test', True)
     register.add_notification(self.title, True)
     if autosubliminal.GROWLPASS:
         register.set_password(autosubliminal.GROWLPASS)
     return register
Beispiel #3
0
    def _sendRegistration(self,
                          host=None,
                          password=None,
                          name='SickGear Notification'):
        opts = {}

        if host == None:
            hostParts = sickbeard.GROWL_HOST.split(':')
        else:
            hostParts = host.split(':')

        if len(hostParts) != 2 or hostParts[1] == '':
            port = 23053
        else:
            port = int(hostParts[1])

        opts['host'] = hostParts[0]
        opts['port'] = port

        if password == None:
            opts['password'] = sickbeard.GROWL_PASSWORD
        else:
            opts['password'] = password

        opts['app'] = 'SickGear'
        opts['debug'] = False

        #Send Registration
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', opts['app'])
        register.add_header(
            'Application-Icon',
            'https://raw.githubusercontent.com/SickGear/SickGear/master/gui/slick/images/ico/apple-touch-icon-72x72.png'
        )

        register.add_notification('Test', True)
        register.add_notification(common.notifyStrings[common.NOTIFY_SNATCH],
                                  True)
        register.add_notification(common.notifyStrings[common.NOTIFY_DOWNLOAD],
                                  True)
        register.add_notification(
            common.notifyStrings[common.NOTIFY_GIT_UPDATE], True)

        if opts['password']:
            register.set_password(opts['password'])

        try:
            return self._send(opts['host'], opts['port'], register.encode(),
                              opts['debug'])
        except Exception, e:
            logger.log(
                u"GROWL: Unable to send growl to " + opts['host'] + ":" +
                str(opts['port']) + " - " + ex(e), logger.WARNING)
            return False
Beispiel #4
0
    def _sendRegistration(self,
                          host=None,
                          password=None,
                          name='Sick Beard Notification'):
        opts = {}

        if host == None:
            hostParts = sickbeard.GROWL_HOST.split(':')
        else:
            hostParts = host.split(':')

        if len(hostParts) != 2 or hostParts[1] == '':
            port = 23053
        else:
            port = int(hostParts[1])

        opts['host'] = hostParts[0]
        opts['port'] = port

        if password == None:
            opts['password'] = sickbeard.GROWL_PASSWORD
        else:
            opts['password'] = password

        opts['app'] = 'SickBeard'
        opts['debug'] = False

        #Send Registration
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', opts['app'])
        register.add_header(
            'Application-Icon',
            'https://github.com/midgetspy/Sick-Beard/raw/master/data/images/sickbeard_touch_icon.png'
        )

        register.add_notification('Test', True)
        register.add_notification(common.notifyStrings[common.NOTIFY_SNATCH],
                                  True)
        register.add_notification(common.notifyStrings[common.NOTIFY_DOWNLOAD],
                                  True)
        register.add_notification(common.notifyStrings[common.NOTIFY_UPDATE],
                                  True)

        if opts['password']:
            register.set_password(opts['password'])

        try:
            return self._send(opts['host'], opts['port'], register.encode(),
                              opts['debug'])
        except socket.error, e:
            logger.log(u"Unable to send growl to " + opts['host'] + ":" +
                       str(opts['port']) + ": " + str(e).decode('utf-8'))
            return False
Beispiel #5
0
    def _sendRegistration(self, host=None, password=None, name="Sick Beard Notification"):
        opts = {}

        if not host:
            hostParts = sickbeard.GROWL_HOST.split(':')
        else:
            hostParts = host.split(':')

        if len(hostParts) != 2 or hostParts[1] == '':
            port = 23053
        else:
            port = int(hostParts[1])

        opts['host'] = hostParts[0]
        opts['port'] = port

        if not password:
            opts['password'] = sickbeard.GROWL_PASSWORD
        else:
            opts['password'] = password

        opts['app'] = 'SickBeard'
        opts['debug'] = False

        # send registration
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', opts['app'])
        register.add_header('Application-Icon', 'http://www.sickbeard.com/notify.png')

        register.add_notification('Test', True)
        register.add_notification(common.notifyStrings[common.NOTIFY_SNATCH], True)
        register.add_notification(common.notifyStrings[common.NOTIFY_DOWNLOAD], True)

        if opts['password']:
            register.set_password(opts['password'])

        try:
            return self._send(opts['host'], opts['port'], register.encode(), opts['debug'])
        except Exception, e:
            logger.log(u"GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e))
            return False
Beispiel #6
0
    def _send_growl(self, options, message=None):

        #Send Registration
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', options['app'])
        register.add_notification(options['name'], True)

        if options['password']:
            register.set_password(options['password'])

        self._send(options['host'], options['port'], register.encode(),
                   options['debug'])

        #Send Notification
        notice = gntp.GNTPNotice()

        #Required
        notice.add_header('Application-Name', options['app'])
        notice.add_header('Notification-Name', options['name'])
        notice.add_header('Notification-Title', options['title'])

        if options['password']:
            notice.set_password(options['password'])

        #Optional
        # determined by config option GROWL_STICKY
        if options['sticky']:
            notice.add_header('Notification-Sticky', options['sticky'])
        if options['priority']:
            notice.add_header('Notification-Priority', options['priority'])
        if options['icon']:
            notice.add_header('Notification-Icon', options['icon'])

        if message:
            notice.add_header('Notification-Text', message)

        response = self._send(options['host'], options['port'],
                              notice.encode(), options['debug'])
        if isinstance(response, gntp.GNTPOK): return True
        return False