当前位置: 首页>>代码示例>>Python>>正文


Python GrowlNotifier.register方法代码示例

本文整理汇总了Python中gntp.notifier.GrowlNotifier.register方法的典型用法代码示例。如果您正苦于以下问题:Python GrowlNotifier.register方法的具体用法?Python GrowlNotifier.register怎么用?Python GrowlNotifier.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gntp.notifier.GrowlNotifier的用法示例。


在下文中一共展示了GrowlNotifier.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def main():
    '''Sets up WeeChat Growl notifications.'''
    # Initialize options.
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value)
    # Initialize Growl.
    name = "WeeChat"
    hostname = weechat.config_get_plugin('hostname')
    password = weechat.config_get_plugin('password')
    icon_path = os.path.join(weechat.info_get("weechat_dir", ""),
            weechat.config_get_plugin('icon'))
    try:
        icon = open(icon_path, "rb").read()
    except IOError:
        weechat.prnt('',
                'Weechat-Growl: {0} could not be opened. '.format(icon_path) +
                'Please make sure it exists.')
        icon = None

    notifications = [
        'Public',
        'Private',
        'Action',
        'Notice',
        'Invite',
        'Highlight',
        'Server',
        'Channel',
        'DCC',
        'WeeChat'
    ]
    if len(hostname) == 0:
        hostname = ''
    if len(password) == 0:
        password = ''
    growl = GrowlNotifier(
        applicationName=name,
        hostname=hostname,
        password=password,
        notifications=notifications,
        applicationIcon=icon)
    try:
        growl.register()
    except Exception as error:
        weechat.prnt('', 'growl: {0}'.format(error))
    STATE['growl'] = growl
    STATE['icon'] = icon
    # Register hooks.
    weechat.hook_signal(
        'irc_server_connected',
        'cb_irc_server_connected',
        '')
    weechat.hook_signal(
        'irc_server_disconnected',
        'cb_irc_server_disconnected',
        '')
    weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '')
    weechat.hook_print('', '', '', 1, 'cb_process_message', '')
开发者ID:sorin-ionescu,项目名称:weechat-growl,代码行数:61,代码来源:growl.py

示例2: TestHash

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
class TestHash(unittest.TestCase):
    def setUp(self):
        self.growl = GrowlNotifier("GNTP unittest", ["Testing"])
        self.growl.register()

    def test_lines(self):
        for priority in [2, 1, 0, -1, -2]:
            msg = "Priority %s" % priority
            self.growl.notify("Testing", msg, msg, priority=priority)
开发者ID:obmarg,项目名称:gntp,代码行数:11,代码来源:test_priority.py

示例3: Notifier

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
class Notifier(object):
    def __init__(self, app_name="autocheck"):
        self.growl = GrowlNotifier(
            applicationName=app_name, notifications=["New Message"], defaultNotifications=["New Message"]
        )
        self.growl.register()

    def notify(self, title, description, kind="pass", sticky=False):
        icon = open(join(dirname(__file__), "images", kind + ".png"), "rb").read()
        self.growl.notify(noteType="New Message", title=title, description=description, icon=icon, sticky=sticky)
开发者ID:htmue,项目名称:python-autocheck,代码行数:12,代码来源:growler.py

示例4: TestHash

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
class TestHash(unittest.TestCase):
	def setUp(self):
		self.growl = GrowlNotifier('GNTP unittest', ['Testing'])
		self.growl.register()
	def test_english(self):
		self.growl.notify('Testing','Testing','Hello')
	def test_extra(self):
		self.growl.notify('Testing','Testing','allô')
	def test_japanese(self):
		self.growl.notify('Testing','Testing',u'おはおう')
开发者ID:obmarg,项目名称:gntp,代码行数:12,代码来源:test_utf8.py

示例5: TestHash

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
class TestHash(unittest.TestCase):
	def setUp(self):
		self.growl = GrowlNotifier('GNTP unittest', ['Testing'])
		self.growl.register()
		self.dir = os.path.dirname(__file__)
		self.file = os.path.join(self.dir, 'test_lines.txt')

	def test_lines(self):
		for line in open(self.file):
			self.growl.notify('Testing', 'Line', line)
开发者ID:obmarg,项目名称:gntp,代码行数:12,代码来源:test_lines.py

示例6: ConfigTests

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
class ConfigTests(GNTPTestCase):
	def setUp(self):
		if os.path.exists(ORIGINAL_CONFIG):
			os.rename(ORIGINAL_CONFIG, BACKUP_CONFIG)
		self.growl = GrowlNotifier(self.application, [self.notification_name])
		self.growl.register()

	def test_missing_config(self):
		self.assertIsTrue(self._notify(description='No config file test'))

	def tearDown(self):
		if os.path.exists(BACKUP_CONFIG):
			os.rename(BACKUP_CONFIG, ORIGINAL_CONFIG)
开发者ID:Mondego,项目名称:pyreco,代码行数:15,代码来源:allPythonContent.py

示例7: register_growl

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def register_growl(growl_server, growl_password):
    """ Register this app with Growl """
    error = None
    host, port = split_host(growl_server or '')

    sys_name = hostname(host)

    # Clean up persistent data in GNTP to make re-registration work
    GNTPRegister.notifications = []
    GNTPRegister.headers = {}

    growler = GrowlNotifier(
        applicationName='SABnzbd%s' % sys_name,
        applicationIcon=get_icon(),
        notifications=[Tx(NOTIFICATION[key]) for key in NOTIFY_KEYS],
        hostname=host or 'localhost',
        port=port or 23053,
        password=growl_password or None
    )

    try:
        ret = growler.register()
        if ret is None or isinstance(ret, bool):
            logging.info('Registered with Growl')
            ret = growler
        else:
            error = 'Cannot register with Growl %s' % str(ret)
            logging.debug(error)
            del growler
            ret = None
    except socket.error, err:
        error = 'Cannot register with Growl %s' % str(err)
        logging.debug(error)
        del growler
        ret = None
开发者ID:Hellowlol,项目名称:sabnzbd,代码行数:37,代码来源:notifier.py

示例8: bark

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def bark(message, host, password):
    growl = GrowlNotifier(
        applicationName = NAME,
        notifications = [NOTIFIER],
        defaultNotifications = [NOTIFIER],
        hostname = host,
        port = '23053',
        password = password
    )
    growl.register()

    growl.notify(
        noteType = NOTIFIER,
        title = TITLE,
        description = message,
        icon = ICON_URL,
        sticky = False,
        priority = 1,
    )
开发者ID:ghickman,项目名称:office-growl,代码行数:21,代码来源:main.py

示例9: main

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def main():
    """Sets up WeeChat Growl notifications."""
    # Initialize options.
    for option, value in SETTINGS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, value)
    # Initialize Growl.
    name = "WeeChat"
    hostname = weechat.config_get_plugin("hostname")
    password = weechat.config_get_plugin("password")
    icon = "file://{0}".format(os.path.join(weechat.info_get("weechat_dir", ""), weechat.config_get_plugin("icon")))
    notifications = [
        "Public",
        "Private",
        "Action",
        "Notice",
        "Invite",
        "Highlight",
        "Server",
        "Channel",
        "DCC",
        "WeeChat",
    ]
    if len(hostname) == 0:
        hostname = ""
    if len(password) == 0:
        password = ""
    growl = GrowlNotifier(
        applicationName=name, hostname=hostname, password=password, notifications=notifications, applicationIcon=icon
    )
    try:
        growl.register()
    except Exception as error:
        weechat.prnt("", "growl: {0}".format(error))
    STATE["growl"] = growl
    STATE["icon"] = icon
    # Register hooks.
    weechat.hook_signal("irc_server_connected", "cb_irc_server_connected", "")
    weechat.hook_signal("irc_server_disconnected", "cb_irc_server_disconnected", "")
    weechat.hook_signal("upgrade_ended", "cb_upgrade_ended", "")
    weechat.hook_print("", "", "", 1, "cb_process_message", "")
开发者ID:webvictim,项目名称:weechat-growl,代码行数:43,代码来源:growl.py

示例10: test_client

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def test_client(config, options):
    logging.basicConfig(level=options.verbose)
    notifier = GrowlNotifier(
        hostname=config.get('regrowl.server', 'hostname', '127.0.0.1'),
        port=config.getint('regrowl.server', 'port'),
        password=config.get('regrowl.server', 'password'),
        notifications=['Test']
    )
    if options.test in ['registration', 'all']:
        notifier.register()
    if options.test in ['notification', 'all']:
        notifier.notify(
            noteType='Test',
            title='Testing',
            description='ReGrowl Test',
        )
    if options.test in ['subscription', 'all']:
        notifier.subscribe(
            'TestId',
            'TestName',
            1337,
        )
开发者ID:kfdm,项目名称:gntp-regrowl,代码行数:24,代码来源:test.py

示例11: register_growl

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def register_growl(growl_server, growl_password):
    """ Register this app with Growl """
    error = None
    host, port = split_host(growl_server or '')

    sys_name = hostname(host)

    # Reduce logging of Growl in Debug/Info mode
    logging.getLogger('gntp').setLevel(logging.WARNING)

    # Clean up persistent data in GNTP to make re-registration work
    GNTPRegister.notifications = []
    GNTPRegister.headers = {}

    growler = GrowlNotifier(
        applicationName='SABnzbd%s' % sys_name,
        applicationIcon=get_icon(),
        notifications=[Tx(NOTIFICATION[key]) for key in NOTIFY_KEYS],
        hostname=host or 'localhost',
        port=port or 23053,
        password=growl_password or None
    )

    try:
        ret = growler.register()
        if ret is None or isinstance(ret, bool):
            logging.info('Registered with Growl')
            ret = growler
        else:
            error = 'Cannot register with Growl %s' % str(ret)
            logging.debug(error)
            del growler
            ret = None
    except (gntp.errors.NetworkError, gntp.errors.AuthError) as err:
        error = 'Cannot register with Growl %s' % str(err)
        logging.debug(error)
        del growler
        ret = None
    except:
        error = 'Unknown Growl registration error'
        logging.debug(error)
        logging.info("Traceback: ", exc_info=True)
        del growler
        ret = None

    return ret, error
开发者ID:sabnzbd,项目名称:sabnzbd,代码行数:48,代码来源:notifier.py

示例12: register_growl

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def register_growl():
    """ Register this app with Growl
    """
    error = None
    host, port = sabnzbd.misc.split_host(sabnzbd.cfg.growl_server())

    if host:
        sys_name = '@' + sabnzbd.misc.hostname().lower()
    else:
        sys_name = ''

    # Clean up persistent data in GNTP to make re-registration work
    GNTPRegister.notifications = []
    GNTPRegister.headers = {}

    growler = GrowlNotifier(
        applicationName = 'SABnzbd%s' % sys_name,
        applicationIcon = get_icon(host or None),
        notifications = [Tx(_NOTIFICATION[key]) for key in _KEYS],
        hostname = host or None,
        port = port or 23053,
        password = sabnzbd.cfg.growl_password() or None
    )

    try:
        ret = growler.register()
        if ret is None or isinstance(ret, bool):
            logging.info('Registered with Growl')
            ret = growler
        else:
            error = 'Cannot register with Growl %s' % str(ret)
            logging.debug(error)
            del growler
            ret = None
    except socket.error, err:
        error = 'Cannot register with Growl %s' % str(err)
        logging.debug(error)
        del growler
        ret = None
开发者ID:Adrellias,项目名称:sabnzbd,代码行数:41,代码来源:growler.py

示例13: main

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def main():
	(options, message) = ClientParser().parse_args()
	logging.basicConfig(level=options.verbose)
	if not os.path.exists(DEFAULT_CONFIG):
		logging.info('No config read found at %s', DEFAULT_CONFIG)

	growl = GrowlNotifier(
		applicationName=options.app,
		notifications=[options.name],
		defaultNotifications=[options.name],
		hostname=options.host,
		password=options.password,
		port=options.port,
	)
	result = growl.register()
	if result is not True:
		exit(result)

	# This would likely be better placed within the growl notifier
	# class but until I make _checkIcon smarter this is "easier"
	if options.icon and growl._checkIcon(options.icon) is False:
		logging.info('Loading image %s', options.icon)
		f = open(options.icon, 'rb')
		options.icon = f.read()
		f.close()

	result = growl.notify(
		noteType=options.name,
		title=options.title,
		description=message,
		icon=options.icon,
		sticky=options.sticky,
		priority=options.priority,
		callback=options.callback,
		identifier=options.identifier,
	)
	if result is not True:
		exit(result)
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:40,代码来源:cli.py

示例14: send_gntp_notification

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
 def send_gntp_notification(self):
     growl_ips = self.growl_ips
     gntp_ips  = self.gntp_ips
     
     # don't send to gntp if we can use growl
     gntp_ips = [ip for ip in gntp_ips if (ip not in growl_ips)]
     
     for ip in gntp_ips:
         growl = GrowlNotifier(
             applicationName = 'Doorbell',
             notifications = ['doorbell'],
             defaultNotifications = ['doorbell'],
             hostname = ip,
             password = self.password,
         )
         result = growl.register()
         if not result:
             continue
         result = growl.notify(
             noteType = 'doorbell',
             title = self.title,
             description = self.description,
             sticky = True,
         )
开发者ID:keesnobel,项目名称:doorbell,代码行数:26,代码来源:doorbell.py

示例15: main

# 需要导入模块: from gntp.notifier import GrowlNotifier [as 别名]
# 或者: from gntp.notifier.GrowlNotifier import register [as 别名]
def main():
    (options, message) = ClientParser().parse_args()
    logging.basicConfig(level=options.verbose)

    growl = GrowlNotifier(
        applicationName=options.app,
        notifications=[options.name],
        defaultNotifications=[options.name],
        hostname=options.host,
        password=options.password,
        port=options.port,
    )
    result = growl.register()
    if result is not True:
        exit(result)

        # This would likely be better placed within the growl notifier
        # class but until I make _checkIcon smarter this is "easier"
    if options.icon is not None and not options.icon.startswith("http"):
        logging.info("Loading image %s", options.icon)
        f = open(options.icon)
        options.icon = f.read()
        f.close()

    result = growl.notify(
        noteType=options.name,
        title=options.title,
        description=message,
        icon=options.icon,
        sticky=options.sticky,
        priority=options.priority,
        callback=options.callback,
        identifier=options.identifier,
    )
    if result is not True:
        exit(result)
开发者ID:nagyistoce,项目名称:codeivate-st,代码行数:38,代码来源:cli.py


注:本文中的gntp.notifier.GrowlNotifier.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。