Exemplo n.º 1
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!')
Exemplo n.º 2
0
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))
Exemplo n.º 3
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!')
Exemplo n.º 4
0
	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!')
		
	
	while True:
		nm.scan(hosts= IP_RANGE + '/24', arguments='-n -sP -PE -T5')
		hostsList = [(nm[x]['addresses']) for x in nm.all_hosts()]
Exemplo n.º 5
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
    #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

    if is_running == True and int(power) > POWER_THRESHOLD:
        counter = 0

    if counter == POLL_TIMES:
        msg = po.msg(MESSAGE_TEXT_WASH_CYCLE_ENDED)
        msg.set("title", MESSAGE_TITLE_WASH_CYCLE_ENDED)
        po.send(msg)
        is_running = False
        counter = 0