def notify_on_change(): notifierLogPath = linux_utils.get_resource_path("cache", constants.__app_name__, "notifier.log") settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini") with open(notifierLogPath, "a") as file: file.write("Notification: %r\n" % (datetime.datetime.now(), )) config = ConfigParser.SafeConfigParser() config.read(settingsPath) backend = alarm_notify.create_backend(config) notifyUser = alarm_notify.is_changed(config, backend) if notifyUser: file.write("\tChange occurred\n")
def notify_on_change(): settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini") notifierSettingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "notifier.ini") config = ConfigParser.SafeConfigParser() config.read(settingsPath) backend = alarm_notify.create_backend(config) notifyUser = alarm_notify.is_changed(config, backend) config = ConfigParser.SafeConfigParser() config.read(notifierSettingsPath) soundFile = config.get("Sound Notifier", "soundfile") soundFile = "/usr/lib/gv-notifier/alert.mp3" if notifyUser: import subprocess import led_handler logging.info("Changed, playing %s" % soundFile) led = led_handler.LedHandler() led.on() soundOn = subprocess.call("/usr/bin/dbus-send --dest=com.nokia.osso_media_server --print-reply /com/nokia/osso_media_server com.nokia.osso_media_server.music.play_media string:file://%s",shell=True) else: logging.info("No Change")