def register(self): if self.registered: return try: hostname = self.conf('hostname') password = self.conf('password') port = self.conf('port') self.growl = notifier.GrowlNotifier( applicationName=Env.get('appname'), notifications=["Updates"], defaultNotifications=["Updates"], applicationIcon='%s/static/images/couch.png' % fireEvent('app.api_url', single=True), hostname=hostname if hostname else 'localhost', password=password if password else None, port=port if port else 23053) self.growl.register() self.registered = True except Exception as e: if 'timed out' in str(e): self.registered = True else: log.error('Failed register of growl: %s', traceback.format_exc())
def send(message, hostname=None, sticky=True): try: from gntp import notifier import os if hostname == None: hostname = os.environ.get('SSH_CLIENT', '').split(' ')[0] growl = notifier.GrowlNotifier( applicationName="Cosmos", notifications=["New Updates", "New Messages"], defaultNotifications=["New Messages"], hostname=hostname, ) growl.register() # Send one message growl.notify( noteType="New Messages", title="Cosmos", description=message, sticky=sticky, priority=1, ) except Exception as e: print >> sys.stderr, '*** ERROR sending growl notification to %s: %s' % ( hostname, e)
def ownnotify(self): #notifications using growl growl = notifier.GrowlNotifier( applicationName="piRobot", notifications=["Speech", "New Updates", "New Messages"], defaultNotifications=["Speech"] # hostname = "computer.example.com", # Defaults to localhost # password = "******" # Defaults to a blank password ) growl.register() # Send one message growl.notify( noteType="New Messages", title="You have a new message", description="A longer message description", icon="http://www.baidu.com/img/bdlogo.gif", sticky=False, priority=1, ) growl.notify( noteType="New Updates", title="There is a new update to download", description="A longer message description", icon="http://www.baidu.com/img/bdlogo.gif", sticky=False, priority=-1, )
def _register_growl(self, hostname, port=23053, password='', force=False): """ Return a GrowlNotifier that's registered with the given hostname:port and the given password. If registration fails, return None unless force is True, in which case the unregistered GrowlNotifier is returned """ logging.debug("Registering with growl on %s:%s", hostname, port) growl_notifier = gntp_notifier.GrowlNotifier( applicationName="LPBS", notifications=self.growl_types, defaultNotifications=["Job Started"], hostname=hostname.strip(), port=port, password=password.strip()) try: if test_socket(hostname, port): growl_notifier.register() except socket.error as error: logging.warn("Can't connect to growl on %s:%s", growl_notifier.hostname, port) logging.debug("%s", error) if not force: return None except gntp.BaseError as error: logging.warn("GNTP Exception") logging.debug("%s", error) return None return growl_notifier
def init(self): self.growl = notifier.GrowlNotifier( applicationName = 'APP_NAME' , notifications = ['Message'] , defaultNotifications = ['Message'] , applicationIcon = None ) result = self.growl.register() if not result: raise ImportError
def notify(self, action): self.debugLog(u"notify") updateOnly = (action is None) notificationList = self.getNotificationList() if updateOnly: typeString = notificationList[0][1] substitutedTitle = "Indigo Plugin Update" substitutedDescription = "The list of notifications for the Indigo Plugin was updated." growlPriority = 0 growlSticky = False else: typeString = self.pluginPrefs[action.props["type"]] substitutedTitle = self.substitute(action.props.get("title", "")) substitutedDescription = self.substitute(action.props.get("descString", "")) try: growlPriority = int(action.props.get("priority", 0)) growlSticky = bool(action.props.get("sticky", False)) except: self.errorLog(u"Action is misconfigured") return if typeString != "": listToGrowl = [] for key in notificationList: if self.pluginPrefs[key[0]] != "": listToGrowl.append(key[1]) growlVersion = self.pluginPrefs.get("growlVersion", "1.3") if growlVersion == "1.2": try: theIcon = OldGrowl.Image.imageFromPath(kIconFileName) growl = OldGrowl.GrowlNotifier(applicationName=kApplicationName, notifications=listToGrowl, applicationIcon=theIcon) growl.register() growl.notify(noteType=typeString, title=substitutedTitle, description=substitutedDescription, priority=growlPriority, sticky=growlSticky) except Exception, e: self.errorLog(u"Unable to send Growl v1.2 Notification - make sure you have the correct version selected in the Growl plugin preferences\n%s" % str(e)) elif growlVersion == "1.3": try: growl = NewGrowl.GrowlNotifier(applicationName=kApplicationName, notifications=listToGrowl, applicationIcon="http://static.indigodomo.com/www/images/growlicon_64x64.png") growl.register() growl.notify(noteType=typeString, title=substitutedTitle, description=substitutedDescription, priority=growlPriority, sticky=growlSticky) except socket.error, e: if e.errno == 61: # Connection refused, very likely they don't have the Growl app running. self.errorLog(u"Unable to send Growl Notification - make sure the Growl application is running.") else: self.errorLog(u"Unable to send Growl Notification - make sure you have the correct version selected in the Growl plugin preferences\n" + str(e)) except Exception, e: self.errorLog(u"Unable to send Growl Notification - make sure you have the correct version selected in the Growl plugin preferences\n" + str(e))
def __init__(self, app_name, app_icon, hostname, password, port): """Initialize the service.""" from gntp import notifier self.gntp = notifier.GrowlNotifier( applicationName=app_name, notifications=["Notification"], applicationIcon=app_icon, hostname=hostname, password=password, port=port ) self.gntp.register()
def register(self): if self.registered: return try: hostname = self.conf('hostname') password = self.conf('password') port = self.conf('port') self.growl = notifier.GrowlNotifier( applicationName=Env.get('appname'), notifications=['Updates'], defaultNotifications=['Updates'], applicationIcon=self.getNotificationImage('medium'), hostname=hostname if hostname else 'localhost', password=password if password else None, port=port if port else 23053) self.growl.register() self.registered = True except Exception as e: if 'timed out' in str(e): self.registered = True else: log.error('Failed register of growl: %s', traceback.format_exc())
def connect(): global growl, grow_loaded, log_period, error_log_max, last_log_time, error_logged # Create grow object growl = notifier.GrowlNotifier( applicationName = "Weechat", notifications = ["irc message"], defaultNotifications = ["irc message"], ) try: grow_loaded = growl.register() except: grow_loaded = False if last_log_time is None: last_log_time = time.time() elapsed_time = time.time() - last_log_time if elapsed_time >= log_period: error_logged = 0 if error_logged < error_log_max: log("Cannot create notifier object, please make sure Growl has started") error_logged += 1 last_log_time = time.time() return grow_loaded
with open(image, "rb") as handle: return handle.read() try: import gntp.notifier as growl native_load_image = load_image_gntp logging.debug("Growl version: gntp") except ImportError: import Growl as growl native_load_image = load_image_legacy logging.debug("Growl version: legacy") logging.debug("Registering Growl notifier...") growler = growl.GrowlNotifier(applicationName="mpd-hiss", notifications=["Now Playing"]) growler.register() logging.debug("Registered.") def notify(title, description, icon): if icon and not is_string(icon): icon = growl_raw_image(icon) growler.notify(noteType="Now Playing", title=title, description=description, icon=icon)
PYAUDIO_INPUT = True PYAUDIO_FRAMES_PER_BUFFER = 1024 # Listener constants NUM_FRAMES = PYAUDIO_RATE / PYAUDIO_FRAMES_PER_BUFFER LAST_NOTIFICATION_TIME = None #logging constants LOG_FILE_NAME = 'decisions.log' LOG_FILE_FD = open(LOG_FILE_NAME, 'w') logging.basicConfig(level=logging.ERROR ) # this guy exists because Growl is angry about something #notifications using growl GROWL = notifier.GrowlNotifier(applicationName="Listener", notifications=["Speech"], defaultNotifications=["Speech"]) GROWL.register() def record(duration): '''Records Input From Microphone Using PyAudio''' in_stream = PYAUDIO_INSTANCE.open( format=pyaudio.paInt16, channels=PYAUDIO_CHANNELS, rate=PYAUDIO_RATE, input=PYAUDIO_INPUT, frames_per_buffer=PYAUDIO_FRAMES_PER_BUFFER)