Exemple #1
0
def CheckBinDay():

    message = None
    try:
        alerter = BinAlerter(gbConfig)
        alerter.GetNextBinDay()
    except Exception as e:
        message = str(e)
        alerter = None
        logging.exception("CheckBinDay(): " + message)

    if not gbConfig.pushover_userkey is None:
        Pushover.Initialise(gbConfig.pushover_userkey,
                            gbConfig.pushover_apptoken)

        if alerter is None:
            message = "Failed: " + message
        else:
            message = "Put \n"
            for bin in alerter.Collecting:
                message = message + bin + "\n"
            message = message + "out on " + alerter.NextCollection.strftime(
                '%d %B %Y') + "."
            logging.info(message)

        Pushover.Notify(message, "bugle")
Exemple #2
0
 def pushOver(self, message):
     try:
         po = Pushover(Coop.PUSHOVER_TOKEN)
         po.user(Coop.PUSHOVER_USER)
         msg = po.msg(message)
         msg.set("title", "Pips´s kleine Hühnerfarm")
         # po.send(msg)
     except Exception as e:
         logger.error(e)
class PushoverNotifier(object):

    def __init__(self, user, token):

        self._pushover = Pushover(user, token)

    def create(self, id, name=None):
        pass

    def die(self, id, name=None):
        if name:
            self._pushover.send("Container {0} exited.".format(name))
Exemple #4
0
    def execute(self, alarm_subject, alarm_message):
        # logger.debug(pi_ager_logging.me())
        cl_fact_logger.get_instance().debug(cl_fact_logger.get_instance().me())

        try:
            if self.it_pushover:
                user_key = str(self.it_pushover[0]['user_key'])
                api_token = str(self.it_pushover[0]['api_token'])
                cl_fact_logger.get_instance().debug('user_key  = ' + user_key)
                cl_fact_logger.get_instance().debug('api_token = ' + api_token)

                po = Pushover(api_token)
                po.user(user_key)

                self.send_pushover(po, alarm_subject, alarm_message)
        except Exception as cx_error:
            #TODO err undefined!
            fehler = 'Error: unable to send pushover: {err}'.format(
                err=cx_error)
            cl_fact_logger.get_instance().error(fehler)
Exemple #5
0
def main():
    pushover = Pushover(os.environ['PUSHOVER_SNAPRAID_TOKEN'], os.environ['PUSHOVER_USER_KEY'])

    if not obtain_lock(pushover):
        return False

    os.chdir(MOUNT_LOCATION)

    status = execute_snapraid_maintenance(pushover)

    if status:
        execute_duplicacy_backup(pushover)
Exemple #6
0
def main():
    """
    `pushover` command.
    """
    parser = setup_argparser('pushover')
    args = parser.parse_args()
    _ = setup_logger(args.verbosity)

    config_file = args.config_file
    if config_file:
        config_file = os.path.expanduser(config_file)
        if not os.path.isfile(config_file):
            log.error(u'Config file not found')
            sys.exit(1)
    else:
        config_file = os.path.expanduser(DEFAULT_CONFIG)
        if not os.path.isfile(config_file):
            config_file = None
            log.warning(u'Default config file not found')

    pushover = Pushover()

    if config_file:
        config = parse_config(config_file)
        users = config.get('users', {})
        apps = config.get('apps', {})

        for name, token in users.items():
            pushover.add_user(name, token)

        for name, token in apps.items():
            pushover.add_app(name, token)

    if args.message == '-':
        message = u''
        for line in sys.stdin:
            message += line
    else:
        message = args.message

    message_data = vars(args)

    if 'user_name' in message_data:
        message_data['user'] = message_data.pop('user_name')

    if 'app_name' in message_data:
        message_data['token'] = message_data.pop('app_name')

    message_data.pop('verbosity', None)
    message_data.pop('config_file', None)
    message_data.update(message=message)
    message_data = {k: v for k, v in message_data.items() if v}

    msg = pushover.message(**message_data)
    msg.validate_params()
    msg.send()
Exemple #7
0
	def __sendToPushover(text):
		try:
			po = Pushover(PUSHOVER_TOKEN)
			po.user(PUSHOVER_USER)
			msg = po.msg(text)
			msg.set("title", PUSHOVER_TITLE)
			po.send(msg)
			log.debug('Sent message to Pushover.')
		except:
			log.error('Pushover exception!')
Exemple #8
0
def main():
    try:
        pushover = Pushover(os.environ['PUSHOVER_SNAPRAID_TOKEN'], os.environ['PUSHOVER_USER_KEY'])

        message = f'Device: {os.environ["SMARTD_DEVICE"]}\n' \
                  f'Failure: {os.environ["SMARTD_FAILTYPE"]}\n' \
                  f'Error: {os.environ["SMARTD_MESSAGE"]}\n' \
                  f'First Reported: {os.environ["SMARTD_TFIRST"]}\n' \
                  f'Details: {os.environ["SMARTD_FULLMESSAGE"]}'

        pushover.send(title='SMART Status', message=message)
    except:
        pushover.send(title='SMART Notification Error!', message='Could not send notification!')
Exemple #9
0
	log.info('Starting up...')
	
	# iterate over configured devices in config file
	for section in config.sections():
		if (section[:7] == 'Device_'):
			newDevice = Device(config[section]['MacAddress'], section[7:], int(config[section]['Threshold']), config[section].getboolean('Twitter'), config[section].getboolean('Pushover'))
			log.info('Device configured: {0}'.format(newDevice.name))
			
	
	# send start up message to Pushover and Twitter
	timePrefix = '{0}: '.format(datetime.now().strftime("%d.%m.%Y %H:%M"))
	message = 'WiScanner started with configured devices: {0}'.format(Device.joinDeviceNames(Device.allDevices))

	try:
		po = Pushover(PUSHOVER_TOKEN)
		po.user(PUSHOVER_USER)
		msg = po.msg(timePrefix + message)
		msg.set("title", PUSHOVER_TITLE)
		po.send(msg)
		log.debug('Sent message to Pushover.')
	except:
		log.error('Pushover exception!')
		
	try:
		twitter = Twython(TWITTER_APP_KEY, TWITTER_APP_SECRET, TWITTER_OAUTH_TOKEN, TWITTER_OAUTH_TOKEN_SECRET)
		twitter.update_status(status=message)
		log.debug('Sent message to Twitter.')
	except:
		log.error('Twitter exception!')
		
Exemple #10
0
    return


if __name__ == "__main__":

    log = logging.getLogger(__name__)
    log.setLevel(logging.INFO)
    logging.basicConfig(format='%(asctime)s %(message)s',
                        datefmt='%d/%m/%Y %H:%M')

    # Start push notification
    # Read Pushover configuration
    with open('pushover.txt', 'r') as f:
        pushover_cfg = json.loads(f.read())
    f.close()
    po = Pushover(pushover_cfg["application_key"])
    po.user(pushover_cfg["user_key"])

    # Read SQL connection data
    with open('sqlinfo.txt', 'r') as f:
        sql = json.loads(f.read())
    f.close()

    # Read EUI list
    with open('sensors.txt', 'r') as f:
        euis = json.loads(f.read())
    f.close()

    # sql_conn = odbc.connect(        \
    #     'DRIVER={SQL Server};'
    #     + 'SERVER=' + sql["server"] + ';'
Exemple #11
0
def main():
    parser = ArgumentParser(
        description="Send a message to pushover.",
        formatter_class=RawDescriptionHelpFormatter,
        epilog="""
For more details and bug reports, see: https://github.com/Thibauth/python-pushover""",
    )
    parser.add_argument("--token", help="API token")
    parser.add_argument(
        "--user",
        "-u",
        help="User key or section name in the configuration",
        required=True,
    )
    parser.add_argument(
        "-c",
        "--config",
        help="configuration file\
                        (default: ~/.pushoverrc)",
        default="~/.pushoverrc",
    )
    parser.add_argument("message", help="message to send")
    parser.add_argument("--url", help="additional url")
    parser.add_argument("--url-title", help="url title")
    parser.add_argument("--title", "-t", help="message title")
    parser.add_argument("--priority",
                        "-p",
                        help="notification priority (-1, 0, 1 or 2)",
                        type=int)
    parser.add_argument(
        "--retry",
        "-r",
        help="resend interval in seconds (required for priority 2)",
        type=int,
    )
    parser.add_argument(
        "--expire",
        "-e",
        help="expiration time in seconds (required for priority 2)",
        type=int,
    )
    parser.add_argument(
        "--version",
        "-v",
        action="version",
        help="output version information and exit",
        version="""
%(prog)s 1.0
Copyright (C) 2013-2018 Thibaut Horel <*****@*****.**>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.""",
    )

    args = parser.parse_args()
    params = read_config(args.config)
    if args.priority == 2 and (args.retry is None or args.expire is None):
        parser.error("priority of 2 requires expire and retry")
    if args.user in params["users"]:
        user_key = params["users"][args.user]["user_key"]
        device = params["users"][args.user]["device"]
    else:
        user_key = args.user
        device = None
    token = args.token or params["token"]

    Pushover(token).message(
        user_key,
        args.message,
        device=device,
        title=args.title,
        priority=args.priority,
        url=args.url,
        url_title=args.url_title,
        timestamp=True,
        retry=args.retry,
        expire=args.expire,
    )
Exemple #12
0
 def __init__(self,
              data_source: DataSource = Snoo(),
              notifier: Notifier = Pushover()):
     self.data_source = data_source
     self.notifier = notifier
     self.session = data_source.session
Exemple #13
0
        season = ('0' + str(item['episode']['season']))[-2:]
        number = ('0' + str(item['episode']['number']))[-2:]

        lastCollectedEpisode = trakt.collectionProgress(id)['last_episode']
        collected = (lastCollectedEpisode['season'] == int(season)
                     and lastCollectedEpisode['number'] == int(number))

        if (collected == False):
            searchStr = '{title} S{season}E{episode}'.format(
                title=item['show']['title'], season=season, episode=number)
            torrents = torrentsearch.search(searchStr + ' 720p')
            if (len(torrents) > 0
                    and transmission.addTorrent(torrents[0]['magnet'])):
                info = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                info = info + '    Added: ' + torrents[0]['title']

                if (trakt.addToCollection(item['show']['ids']['trakt'],
                                          item['episode']['season'],
                                          item['episode']['number'])):
                    info = info + ' - Collected at Trakt.TV'

                print info
            else:
                Pushover.send(config.PUSHOVER_USER, config.PUSHOVER_APP,
                              'No torrents found for ' + searchStr,
                              'Trakt TV Downloader')
                print 'No torrents found for ' + searchStr

except Exception as e:
    print e
    return sid


def get_power():
    global sid
    main_url = FRITZBOX_BASE_URL + "webservices/homeautoswitch.lua?sid="
    url = main_url + sid + '&switchcmd=getswitchpower&ain=' + DEVICE_AIN
    fb = urlopen(url)
    power = str(fb.read())
    #cut off 'b' at start and '\n' on end of power
    power = power[2:-3]
    return power


po = Pushover(PUSHOVER_APP_KEY)
po.user(PUSHOVER_USER_KEY)
sid = get_sid()

while True:
    power = get_power()

    if is_running == False and int(power) > POWER_THRESHOLD:
        msg = po.msg(MESSAGE_TEXT_WASH_CYCLE_STARTED)
        msg.set("title", MESSAGE_TITLE_WASH_CYCLE_STARTED)
        po.send(msg)
        is_running = True

    if is_running == True and int(power) < POWER_THRESHOLD:
        counter += 1
Exemple #15
0
        print(f'{name} - {mk}')

    print("-----------------------------------------")
    return payment_book


def notify(payment_book: PaymentBook):
    for payment_sheet in payment_book.sheets:
        cats = payment_sheet.categories
        for category in cats:
            print(
                f"{payment_sheet.name}:{category} - {(category.payments[0])}")
            if category.payments[0].payable_within_2days:
                pu.notify(f"{category} - {(category.payments[0])}")


if __name__ == '__main__':
    pu = Pushover(config.pushover_apikey, config.pushover_user)
    dbx = DropboxClient(config.api_key)
    wpk = download_file()
    notify(wpk)
    getter = Ekartoteka(config.ekartoteka)
    getter.initialize()
    apartment_fee = getter.get_curret_fees_sum()
    print(apartment_fee)
    pu.notify(f'Mieszkanie: {apartment_fee:.2f}zł')
    wpk.update_current_payment_amount(config.ekartoteka_sheet[0],
                                      config.ekartoteka_sheet[1],
                                      apartment_fee)
    wpk.save_to_file(filename="Oplaty.xlsm")
Exemple #16
0
from pushover import Pushover
import requests, json

po_api_token = "aFERV6CYg8UQYjgGm1bMAfU9TurQYf"
po_user_kay = "uYCpaffsy7YGQDTiqPFd88Cu1sRdh9"
wug_api_key = "4a079b9b1c39e4fc"

# Do a weather lookup
wx_url = 'http://api.wunderground.com/api/4a079b9b1c39e4fc/geolookup/conditions/q/MI/Ann_Arbor.json'
raw = requests.get(wx_url)
info = json.loads(raw.text)
location = info['location']['city']
temp_f = info['current_observation']['temp_f']

message = "Temp: %s" % (temp_f)
title = "Wx update for %s" % (location)

po = Pushover(po_api_token)
po.user(po_user_kay)

msg = po.msg(message)
msg.set("title", title)

po.send(msg)
Exemple #17
0
    def __init__(self, user, token):

        self._pushover = Pushover(user, token)