def cipher():
    pnconfig = PNConfiguration()

    pnconfig.publish_key = "my_pub_key"
    pnconfig.subscribe_key = "my_sub_key"
    pnconfig.cipher_key = "my_cipher_key"

    pubnub = PubNub(pnconfig)
Example #2
0
 def _pubnub_config(self):
     channel_config = self.client.channels.list()
     channels = [channel['name'] for channel in channel_config['channels']]
     pnconfig = PNConfiguration()
     pnconfig.subscribe_key = channel_config['subscribe_key']
     pnconfig.cipher_key = channel_config['cipher_key']
     pnconfig.auth_key = channel_config['auth_key']
     pnconfig.ssl = True
     pnconfig.reconnect_policy = PNReconnectionPolicy.LINEAR
     return pnconfig, channels
Example #3
0
def initPubNub(stdscr):
    """
    Ask for a pseudo if not in the path and init the pubnub.PubNub object.

    Parameters
    ----------
        stdscr: :class:curses._CursesWindow
            the screen initialised in main.py

    Returns
    -------
    :class:pubnub.PubNub
        with configuration
    """
    pseudo = os.getenv("PSEUDO")
    if pseudo == None:
        pseudo = ""
        while len(pseudo) < 2:
            stdscr.addstr(0, 0, "pseudo :")
            stdscr.refresh()
            editwin = curses.newwin(1, min(16, curses.COLS - 1), 1, 1)  # pylint: disable=no-member
            editwin.keypad(True)
            box = Textbox(editwin)
            box.edit()
            pseudo = " ".join(box.gather().split())
        alphabet = string.ascii_letters + string.digits
        pseudo += ''.join(secrets.choice(alphabet) for i in range(10))
        with open("assets/data/.env", "a") as file:
            file.write(f"\nPSEUDO=\"{pseudo}\"")
        editwin.erase()

    pnconfig = PNConfiguration()
    pnconfig.subscribe_key = os.getenv("SUB_KEY")
    pnconfig.publish_key = os.getenv("PUB_KEY")
    pnconfig.ssl = True
    pnconfig.cipher_key = os.getenv("CYPHER_KEY")
    pnconfig.uuid = pseudo
    pnconfig.reconnect_policy = PNReconnectionPolicy.EXPONENTIAL
    pnconfig.connect_timeout = 30

    return PubNub(pnconfig)
Example #4
0
pnconf = PNConfiguration()
pnconf.publish_key = pub_key
pnconf.subscribe_key = sub_key
pnconf.enable_subscribe = False
pnconf.uuid = uuid_mock

pnconf_sub = PNConfiguration()
pnconf_sub.publish_key = pub_key
pnconf_sub.subscribe_key = sub_key
pnconf_sub.uuid = uuid_mock

pnconf_enc = PNConfiguration()
pnconf_enc.publish_key = pub_key
pnconf_enc.subscribe_key = sub_key
pnconf_enc.cipher_key = "testKey"
pnconf_enc.enable_subscribe = False
pnconf_enc.uuid = uuid_mock

pnconf_enc_sub = PNConfiguration()
pnconf_enc_sub.publish_key = pub_key
pnconf_enc_sub.subscribe_key = sub_key
pnconf_enc_sub.cipher_key = "testKey"
pnconf_enc_sub.uuid = uuid_mock

pnconf_pam = PNConfiguration()
pnconf_pam.publish_key = pub_key_pam
pnconf_pam.subscribe_key = sub_key_pam
pnconf_pam.secret_key = sec_key_pam
pnconf_pam.enable_subscribe = False
pnconf_pam.uuid = uuid_mock
Example #5
0
import RPi.GPIO as GPIO
import Adafruit_DHT
import time, threading, spidev
from pubnub.callbacks import SubscribeCallback
from pubnub.enums import PNStatusCategory
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub

pnconfig = PNConfiguration()

pnconfig.subscribe_key = 'sub-c-c96cd480-3528-11e8-a218-f214888d2de6'
pnconfig.publish_key = 'pub-c-f141a42f-ae6d-4f11-bbaf-4bc7cb518b6c'
##########################
pnconfig.cipher_key = 'myCipherKey'
pnconfig.auth_key = 'raspberry-pi'
pnconfig.ssl = True
pubnub = PubNub(pnconfig)

myChannel = "RSPY"
PIR_pin = 23
Buzzer_pin = 24
LED = 18
dht11_pin = 5
sensorsList = ["buzzer"]
data = {}
# Define MCP3008 channels
light_channel = 0

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR_pin, GPIO.IN)
Example #6
0
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub

server_UUID = "df89d8b2-358e-11eb-adc1-0242ac120002"  # UUID Generated
cipherKey = "myCipherKey"  # Cipher Key
myChannel = "Homesafe"  # Channel Name

############################
pnconfig = PNConfiguration()

# Homesafe PubNub Connections - All members have access using these
pnconfig.subscribe_key = 'sub-c-12924b4c-2f48-11eb-9713-12bae088af96'
pnconfig.publish_key = 'pub-c-4c71c151-b075-498f-bfbc-c6f3221ed3b6'
pnconfig.secret_key = "sec-c-MTliZTg5YmItYjE3Zi00OGYxLTgwZDEtOTE5OGY5NDlmNWVk"
pnconfig.uuid = server_UUID
pnconfig.cipher_key = cipherKey
pubnub = PubNub(pnconfig)


def grant_access(auth_key, read, write):
    if read is True and write is True:
        grant_read_and_write_access(auth_key)
    elif read is True:
        grant_read_access(auth_key)
    elif write is True:
        grant_write_access(auth_key)
    else:
        revoke_access(auth_key)


def grant_read_and_write_access(auth_key):
Example #7
0
sub_key_pam = "sub-c-7ba2ac4c-4836-11e6-85a4-0619f8945a4f"
sec_key_pam = "sec-c-MGFkMjQxYjMtNTUxZC00YzE3LWFiZGYtNzUwMjdjNmM3NDhk"

pnconf = PNConfiguration()
pnconf.publish_key = pub_key
pnconf.subscribe_key = sub_key
pnconf.enable_subscribe = False

pnconf_sub = PNConfiguration()
pnconf_sub.publish_key = pub_key
pnconf_sub.subscribe_key = sub_key

pnconf_enc = PNConfiguration()
pnconf_enc.publish_key = pub_key
pnconf_enc.subscribe_key = sub_key
pnconf_enc.cipher_key = "testKey"
pnconf_enc.enable_subscribe = False

pnconf_enc_sub = PNConfiguration()
pnconf_enc_sub.publish_key = pub_key
pnconf_enc_sub.subscribe_key = sub_key
pnconf_enc_sub.cipher_key = "testKey"

pnconf_pam = PNConfiguration()
pnconf_pam.publish_key = pub_key_pam
pnconf_pam.subscribe_key = sub_key_pam
pnconf_pam.secret_key = sec_key_pam
pnconf_pam.enable_subscribe = False

pnconf_ssl = PNConfiguration()
pnconf_ssl.publish_key = pub_key