Esempio n. 1
0
    def notify(self, message='', data={}, listener=None):
        if self.isDisabled(): return

        nma = pynma.PyNMA()
        keys = [x.strip() for x in self.conf('api_key').split(',')]
        nma.addkey(keys)
        nma.developerkey(self.conf('dev_key'))

        # hacky fix for the event type
        # as it seems to be part of the message now
        self.event = message.split(' ')[0]
        response = nma.push(application=self.default_title,
                            event=self.event,
                            description=message,
                            priority=self.conf('priority'),
                            batch_mode=len(keys) > 1)

        successful = 0
        for key in keys:
            if not response[str(key)]['code'] == u'200':
                log.error(
                    'Could not send notification to NotifyMyAndroid (%s). %s',
                    (key, response[key]['message']))
            else:
                successful += 1

        return successful == len(keys)
Esempio n. 2
0
 def _send_message(self, message, **kwargs):
     try:
         nma_instance = pynma.PyNMA(str(autosubliminal.NMAAPI))
         resp = nma_instance.push(application=self.application,
                                  event=self.title,
                                  description=message)
         if not resp[str(autosubliminal.NMAAPI)][u'code'] == u'200':
             log.error("%s notification failed" % self.name)
             return False
         else:
             log.info("%s notification sent" % self.name)
             return True
     except:
         log.error("%s notification failed" % self.name)
Esempio n. 3
0
    def pushGroupReport(self, sGroup, aGroupOfReport):

        if sGroup not in self.aNmaByGroup.keys():
            self.oLogger.debug('no nma action for group ' + sGroup)
            return

        sApplication = 'PyDrone'
        sEvent = 'Change'
        sMessage = 'in ' + sGroup + ' :'

        for aEachReport in aGroupOfReport:
            sMessage += aEachReport['server'] + ' is ' + str(
                aEachReport['lastCode']) + " - "

        aNmaToWarn = self.aNmaByGroup[sGroup]
        import pynma

        oNma = pynma.PyNMA(aNmaToWarn)
        oNma.push(sApplication, sEvent, sMessage)
Esempio n. 4
0
    def notify(self, message='', data={}):
        if self.isDisabled(): return

        nma = pynma.PyNMA()
        keys = self.conf('api_key').split(',')
        nma.addkey(keys)
        nma.developerkey(self.conf('dev_key'))

        response = nma.push(self.app_name,
                            'CouchPotato',
                            message,
                            priority=self.priority,
                            batch_mode=len(keys) > 1)

        for key in keys:
            if not response[str(key)]['code'] == u'200':
                log.error(
                    'Could not send notification to NotifyMyAndroid (%s). %s' %
                    (key, response[key]['message']))

        return response
Esempio n. 5
0
    def notify(self, message='', data=None, listener=None):
        if not data: data = {}

        nma = pynma.PyNMA()
        keys = splitString(self.conf('api_key'))
        nma.addkey(keys)
        nma.developerkey(self.conf('dev_key'))

        response = nma.push(application=self.default_title,
                            event=message.split(' ')[0],
                            description=message,
                            priority=self.conf('priority'),
                            batch_mode=len(keys) > 1)

        successful = 0
        for key in keys:
            if not response[str(key)]['code'] == six.u('200'):
                log.error(
                    'Could not send notification to NotifyMyAndroid (%s). %s',
                    (key, response[key]['message']))
            else:
                successful += 1

        return successful == len(keys)
Esempio n. 6
0
from pytrends.request import TrendReq
import time
import numpy
from random import randint
import pandas as pd
import pynma

print ("Imports complete")

# Add your Gmail username to the google_username variable and your Gmail password to the google_password variable.
# Be sure to amend the tz variable for your timezone.
# https://github.com/GeneralMills/pytrends
google_username = ""
google_password = ""
connector = TrendReq(google_username, google_password, tz='-360')
p = pynma.PyNMA("92a9e6e94e236a22d036f343d5aefa8578fff2f7d23d37e7")

# This script downloads a series of CSV files. Please specify your working directory.
path = "C:\\Users\\robfa\\Documents\\Python\\0.csv"

# Specify the filename of a CSV with a list of keywords in the variable, keywordcsv. The CSV should be one column, with header equal to Keywords (case sensitive).
keywordcsv = "keywords.csv"
keywords = pd.read_csv(keywordcsv)

# Downloads the new data, and compares this to the previous.
keywordlist = pd.DataFrame(columns=["keyword","slope","test"])
for index, row in keywords.iterrows():
    path = "C:\\Users\\robfa\\Documents\\Python\\" + row[0] + ".csv"
    print("Downloading Keyword #" + str(index))
    print("")
    print("====" + row[0] + "====")
import pynma
import os

if os.path.isfile("myapikey"):
    apikey = open("myapikey", 'r').readline().strip()
p = pynma.PyNMA(apikey)

p.push("System: Pi", "Event: tbd",
       "Hi! This is my first test to send a push message...")