Esempio n. 1
0
    def _sendRegistration(self, host=None, password=None):
        opts = {}

        if host is None:
            hostParts = app.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 is None:
            opts['password'] = app.GROWL_PASSWORD
        else:
            opts['password'] = password

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

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

        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 as error:
            log.warning(
                u'GROWL: Unable to send growl to {host}:{port} - {msg!r}', {
                    'msg': ex(error),
                    'host': opts['host'],
                    'port': opts['port']
                })
            return False
Esempio n. 2
0
	def register(self):
		'''
		Send GNTP Registration
		'''
		register = gntp.GNTPRegister()
		register.add_header('Application-Name',self.applicationName)
		for notification in self.notifications:
			enabled = notification in self.defaultNotifications
			register.add_notification(notification,enabled)
		if self.applicationIcon:
			register.add_header('Application-Icon',self.applicationIcon)
		if self.password:
			register.set_password(self.password,self.passwordHash)
		response = self.send('register',register.encode())
		if isinstance(response,gntp.GNTPOK): return True
		return response.error()
Esempio n. 3
0
    def register(self):
        """Send GNTP Registration

		.. warning::
			Before sending notifications to Growl, you need to have
			sent a registration message at least once
		"""
        logger.info('Sending registration to %s:%s', self.hostname, self.port)
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', self.applicationName)
        for notification in self.notifications:
            enabled = notification in self.defaultNotifications
            register.add_notification(notification, enabled)
        if self.applicationIcon:
            register.add_header('Application-Icon', self.applicationIcon)
        if self.password:
            register.set_password(self.password, self.passwordHash)
        return self._send('register', register.encode())
Esempio n. 4
0
    def _sendRegistration(self, host=None, password=None, name='SickChill Notification'):
        opts = {}

        if host is 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 is None:
            opts['password'] = sickbeard.GROWL_PASSWORD
        else:
            opts['password'] = password

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

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

        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 as e:
            logger.log("GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e), logger.WARNING)
            return False
Esempio n. 5
0
    def register(self):
        """Send GNTP Registration

		.. warning::
			Before sending notifications to Growl, you need to have
			sent a registration message at least once
		"""
        logger.debug('Sending registration to %s:%s', self.hostname, self.port)
        register = gntp.GNTPRegister()
        register.add_header('Application-Name', self.applicationName)
        for notification in self.notifications:
            enabled = notification in self.defaultNotifications
            register.add_notification(notification, enabled)
        if self.applicationIcon:
            if self._checkIcon(self.applicationIcon):
                register.add_header('Application-Icon', self.applicationIcon)
            else:
                id = register.add_resource(self.applicationIcon)
                register.add_header('Application-Icon', id)
        if self.password:
            register.set_password(self.password, self.passwordHash)
        self.add_origin_info(register)
        self.register_hook(register)
        return self._send('register', register)