コード例 #1
0
ファイル: test.py プロジェクト: laprice/pushover
def test_message_with_kwargs():
    """pushover.net updated their API to support a number of additional arguments
    see https://pushover.net/api
    """
    ps = PushoverClient()
    ps.send_message("Fancy Test Message",
                    title="fancy test",
                    url="https://pushover.net/api",
                    priority="1")
コード例 #2
0
def test_message_with_kwargs():
    """pushover.net updated their API to support a number of additional arguments
    see https://pushover.net/api
    """
    ps = PushoverClient()
    ps.send_message("Fancy Test Message",
                    title="fancy test",
                    url="https://pushover.net/api",
                    priority="1")
コード例 #3
0
    def setUp(self):
        self.APP_KEY = os.environ['PUSHOVER_APP_KEY']
        self.TEST_USER = os.environ['TEST_USER_KEY']
        if "PUSHOVER_MESSAGE" in os.environ:
            self.MESSAGE = os.environ["PUSHOVER_MESSAGE"]
        else:
            self.MESSAGE = "UNITESTING PUSHOVER CLIENT"

        assert (self.TEST_USER != "") and (self.APP_KEY != "")
        self.client = PushoverClient(self.APP_KEY)
コード例 #4
0
ファイル: test.py プロジェクト: laprice/pushover
def test_message_too_big():
    try:
        ps = PushoverClient()
        ps.send_message("""
Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world,

Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people,

Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law,

Whereas it is essential to promote the development of friendly relations between nations,""")
    except PushoverMessageTooBig as instance:
        assert(str(instance)=="The supplied message is bigger than 512 characters.")
    return
コード例 #5
0
ファイル: test.py プロジェクト: vaginessa/pushover-1
def test_message_too_big():
    try:
        ps = PushoverClient()
        ps.send_message("""
Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world,

Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people,

Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law,

Whereas it is essential to promote the development of friendly relations between nations,""")
    except PushoverMessageTooBig:
        cls, instance, traceback = sys.exc_info()
        assert(instance.message=="The supplied message is bigger than 512 characters.")
    return
コード例 #6
0
    def get_pushover_client(self):
        key = self.pushover_key

        if key is None:
            key = 'DUMMYKEY' # to return a valid client
        
        return PushoverClient(api_token=app.config.get('PUSHOVER_KEY'), user_key=key)
コード例 #7
0
def test_no_config():
    try:
        ps = PushoverClient(configfile="file_does_not_exist")
    except PushoverException:
        cls, instance, traceback = sys.exc_info()
        assert (instance.message == "No valid configuration found")
    return
コード例 #8
0
class TestPushoverClient(unittest.TestCase):
    def setUp(self):
        self.APP_KEY = os.environ['PUSHOVER_APP_KEY']
        self.TEST_USER = os.environ['TEST_USER_KEY']
        if "PUSHOVER_MESSAGE" in os.environ:
            self.MESSAGE = os.environ["PUSHOVER_MESSAGE"]
        else:
            self.MESSAGE = "UNITESTING PUSHOVER CLIENT"

        assert (self.TEST_USER != "") and (self.APP_KEY != "")
        self.client = PushoverClient(self.APP_KEY)

    def test_MessagePlain(self):
        assert (self.client.send_message(self.TEST_USER, self.MESSAGE) is True)

    def test_Message_With_Title(self):
        assert (self.client.send_message(self.TEST_USER, self.MESSAGE,
                                         "TEST TITLE") is True)

    def test_NOALERT_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.NOALERT) is
                True)

    def test_QUIET_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.QUIET) is
                True)

    def test_NORMAL_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.NORMAL) is
                True)

    def test_HIGH_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.HIGH) is
                True)

    def test_CONFIRM_NEEDED_Message(self):
        assert (self.client.send_message(
            self.TEST_USER,
            self.MESSAGE,
            priority=PushoverPriority.CONFIRM_NEEDED) is True)
コード例 #9
0
    #print "Path:"
    #print path 
    #print "___________"

    #Connecing to the specified host 
    client = mosquitto.Mosquitto("echo reactor")

    user = "******"
    password = "******"

    if user != None:
        client.username_pw_set(user,password)

    client.connect(args.host)

    PushClient = PushoverClient(path + "/" + "pushover.cfg")
    PushClient.send_message(args.message)

    keyword = args.topic.find("/send")

    #We need to be in the send path to send confirmation message. Avoids loops.
    if keyword == -1:
	exit(0)


    topic = args.topic[:keyword]


    #Echoing the message recived. 
    client.publish(topic, "Message sent!", 1)
    client.disconnect()
コード例 #10
0
ファイル: pushover.py プロジェクト: awikatchikaen/assa-search
   def execute(self, ad, name):
 
       po = PushoverClient("pushover.config")
       po.send_message("Hello, World : !"+name)
       
コード例 #11
0
ファイル: co2.py プロジェクト: wickedchicken/co2
#!/usr/bin/env python2

import sys, fcntl, time, os

from Adafruit_IO import Client
from pushover import Client as PushoverClient

AIO_USER = os.getenv('AIO_USER')
AIO_KEY = os.getenv('AIO_USER')

PUSHOVER_CLIENT = os.getenv('PUSHOVER_CLIENT')
PUSHOVER_TOKEN = os.getenv('PUSHOVER_TOKEN')

aio = Client(AIO_USER, AIO_KEY)
pushover = PushoverClient(PUSHOVER_CLIENT, api_token=PUSHOVER_TOKEN)

def decrypt(key,  data):
    cstate = [0x48,  0x74,  0x65,  0x6D,  0x70,  0x39,  0x39,  0x65]
    shuffle = [2, 4, 0, 7, 1, 6, 5, 3]

    phase1 = [0] * 8
    for i, o in enumerate(shuffle):
        phase1[o] = data[i]

    phase2 = [0] * 8
    for i in range(8):
        phase2[i] = phase1[i] ^ key[i]

    phase3 = [0] * 8
    for i in range(8):
        phase3[i] = ( (phase2[i] >> 3) | (phase2[ (i-1+8)%8 ] << 5) ) & 0xff
コード例 #12
0
ファイル: test.py プロジェクト: laprice/pushover
def test_send_message():
    ps = PushoverClient()
    ps.send_message("Test message from PushoverClient")
コード例 #13
0
def test_send_message():
    ps = PushoverClient()
    ps.send_message("Test message from PushoverClient")