<commit_before>#!/usr/bin/python
##coding:utf-8
import RPi.GPIO as GPIO
import time
from chump import Application
from setmeup import *


# this is a function to write out to the log file
def SENDTOLOG(PassedText):
    print PassedText
    #open the file - defined in setmeup.py
    f = open(MyLogFile,"a")
    #create the string with the date and time at the start
    # ******* note time is one hour out *********
    WrittenText = time.strftime("%d/%m/%Y") + " " +  time.strftime("%H:%M:%S")  + " " + PassedText + "\n"
    # write the entry into the file
    f.write(WrittenText)
    # close the file
    f.close()
    return

# these functions are called by interupts generated on the GPIO lines
# variables are set up in setmeup.py to control actions
def MOTION_1():
    ActionSensed = "Motion Detected " + PIR_PIN_1_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_1_PRIORITY)

def MOTION_2():
    ActionSensed = "Motion Detected " + PIR_PIN_2_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_2_PRIORITY)

def MOTION_3():
    ActionSensed = "Motion Detected " + PIR_PIN_3_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_3_PRIORITY)

def MOTION_4():
    ActionSensed = "Motion Detected " + PIR_PIN_4_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_4_PRIORITY)


# log the startup 
SENDTOLOG("Watchman is starting up")

# setup GPIO pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR_PIN_1, GPIO.IN)
GPIO.setup(PIR_PIN_2, GPIO.IN)
GPIO.setup(PIR_PIN_3, GPIO.IN)
GPIO.setup(PIR_PIN_4, GPIO.IN)

# log GPIO pins set up
SENDTOLOG("GPIO pins set up")


# log starting to setup Pushover
SENDTOLOG("Setting up Pushover")

# Setup Pushover connection
# install APP API Key
app = Application(AppKey) 
AppKeyStatus = "%s - APP is authenticated" % app.is_authenticated
SENDTOLOG(AppKeyStatus)

# connect APP to user Key
user = app.get_user(UserKey)
UserKeyStatus =  "User is authenticated - %s the device is a %s" %  (user.is_authenticated, user.devices)
SENDTOLOG(UserKeyStatus)

#let everything (electronics) stabalise
time.sleep(2)

SENDTOLOG("Night Watchman is On Duty (CTRL+C to exit)"")


#main loop

try:
    GPIO.add_event_detect(PIR_PIN_1, GPIO.RISING, callback=MOTION_1)
    GPIO.add_event_detect(PIR_PIN_2, GPIO.RISING, callback=MOTION_2)
    while 1:
        time.sleep(100)
except KeyboardInterrupt:
    print " Quit"
    GPIO.cleanup()<commit_msg>PIR pins only setup for non 9 values in priority<commit_after>#!/usr/bin/python
##coding:utf-8
import RPi.GPIO as GPIO
import time
from chump import Application
from setmeup import *


# this is a function to write out to the log file
def SENDTOLOG(PassedText):
    print PassedText
    #open the file - defined in setmeup.py
    f = open(MyLogFile,"a")
    #create the string with the date and time at the start
    # ******* note time is one hour out *********
    WrittenText = time.strftime("%d/%m/%Y") + " " +  time.strftime("%H:%M:%S")  + " " + PassedText + "\n"
    # write the entry into the file
    f.write(WrittenText)
    # close the file
    f.close()
    return

# these functions are called by interupts generated on the GPIO lines
# variables are set up in setmeup.py to control actions
def MOTION_1():
    ActionSensed = "Motion Detected " + PIR_PIN_1_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_1_PRIORITY)

def MOTION_2():
    ActionSensed = "Motion Detected " + PIR_PIN_2_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_2_PRIORITY)

def MOTION_3():
    ActionSensed = "Motion Detected " + PIR_PIN_3_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_3_PRIORITY)

def MOTION_4():
    ActionSensed = "Motion Detected " + PIR_PIN_4_LOCATION
    SENDTOLOG(ActionSensed)
    message = user.send_message(ActionSensed,priority=PIR_PIN_4_PRIORITY)


# log the startup 
SENDTOLOG("Watchman is starting up")

# setup GPIO pins
GPIO.setmode(GPIO.BCM)
if PIR_PIN_1_PRIORITY != 9:
   GPIO.setup(PIR_PIN_1, GPIO.IN)
if PIR_PIN_2_PRIORITY != 9:
    GPIO.setup(PIR_PIN_2, GPIO.IN)
if PIR_PIN_2_PRIORITY != 9:
    GPIO.setup(PIR_PIN_3, GPIO.IN)
if PIR_PIN_2_PRIORITY != 9:
    GPIO.setup(PIR_PIN_4, GPIO.IN)

# log GPIO pins set up
SENDTOLOG("PIR GPIO pins set up: 1 = "str(PIR_PIN_1_PRIORITY) + " 2 = " + str(PIR_PIN_2_PRIORITY)+ " 3 = " + str(PIR_PIN_3_PRIORITY)+ " 4 = " + str(PIR_PIN_4_PRIORITY) )


# log starting to setup Pushover
SENDTOLOG("Setting up Pushover")

# Setup Pushover connection
# install APP API Key
app = Application(AppKey) 
AppKeyStatus = "%s - APP is authenticated" % app.is_authenticated
SENDTOLOG(AppKeyStatus)

# connect APP to user Key
user = app.get_user(UserKey)
UserKeyStatus =  "User is authenticated - %s the device is a %s" %  (user.is_authenticated, user.devices)
SENDTOLOG(UserKeyStatus)

#let everything (electronics) stabalise
time.sleep(2)

SENDTOLOG("Night Watchman is On Duty (CTRL+C to exit)"")


#main loop

try:
    GPIO.add_event_detect(PIR_PIN_1, GPIO.RISING, callback=MOTION_1)
    GPIO.add_event_detect(PIR_PIN_2, GPIO.RISING, callback=MOTION_2)
    while 1:
        time.sleep(100)
except KeyboardInterrupt:
    print " Quit"
    GPIO.cleanup()
{'fraction_non_alphanumeric': 0.10388888888888889, 'fraction_numerical': 0.012777777777777779, 'mean_word_length': 4.384845463609173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3343217', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1956, 'n_words': 489}