예제 #1
0
async def main():
    init()
    app = App(appid='5972ed6da4c48a4118de80b2',
              secret='3acda6333f7422e45f24ecbc5aa971d5')
    print("loading webdriver...")
    drv = webdriver.PhantomJS()
    while True:
        print("fetching danawa...")
        l = drv.get("http://prod.danawa.com/info/?pcode=1795206&cate=1131401")
        result = drv.find_element_by_xpath('//*[@class="big_price"]')
        date = drv.find_element_by_xpath('//span[@class="product_date"]')
        t = result.text
        t = re.sub(',', '', t)
        date = date.text

        print(t)

        with db.get_conn():
            o = Price.select().order_by(Price.id.desc()).limit(3)
        p = []
        for i in o:
            with db.get_conn():
                p.append(i.price)

        if len(p) == 0:
            p.append('0')

        v = int(t) - int(p[-1])

        now = datetime.datetime.now().strftime('%Y%m%d-%H%M')
        d = {'date': date, 'localdate': now, 'title': 'Toshiba 3T', 'price': t}
        #with db.get_conn():
        with db.atomic():
            Price.insert_many([d]).execute()

        msg = "toshiba 3T: {} ( {})\n(<--{}won<---{}won)".format(
            t, v, p[-1], p[-2])

        # 가격변동이 있을 때만 InstaPushing 합니다
        if v != 0 or int(t) < 90000:
            print('price is different. instapushing!!!')
            app.notify(event_name='alarm', trackers={'msg': msg})
        #app.notify(event_name = 'alarm', trackers={'msg': msg})

        print('sleep {} secs'.format(INTERVAL))
        # cpu load를 없애기 위함입니다. danawa 페이지 왜저리 자원을 많이 먹죠? ㄷㄷㄷ
        drv.get('192.168.0.1:8888')
        await asyncio.sleep(INTERVAL)
예제 #2
0
    def save_data(self, trigger_id, **data):
        """
            let's save the data

            :param trigger_id: trigger ID from which to save data
            :param data: the data to check to be used and save
            :type trigger_id: int
            :type data:  dict
            :return: the status of the save statement
            :rtype: boolean
        """
        title, content = super(ServiceInstapush,
                               self).save_data(trigger_id, **data)
        instance = InstapushModel.objects.get(trigger_id=trigger_id)
        Instapush(user_token=self.token)
        app = App(appid=instance.app_id, secret=instance.app_secret)
        trackers = {instance.tracker_name: content}
        status = app.notify(event_name=instance.event_name, trackers=trackers)
        return status
    def send_push_notification(self, alarmMesssage):  # pip install instapush

        #insta = Instapush(user_token='57c5f710a4c48a6d45ee19ce')

        #insta.list_app()             #List all apps

        #insta.add_app(title='Home Surveillance') #Create a app named title

        app = App(appid='57c5f92aa4c48adc4dee19ce',
                  secret='2ed5c7b8941214510a94cfe4789ddb9f')

        #app.list_event()             #List all event

        #app.add_event(event_name='FaceDetected', trackers=['message'],
        #              message='{message} face detected.')

        app.notify(event_name='FaceDetected',
                   trackers={
                       'message':
                       "NOTIFICATION ALERT\n================\n" + alarmMesssage
                   })
예제 #4
0
 def initialize():
     if InstapushWrapper.app is None:
         InstapushWrapper.app = App(
             appid="58f89476a4c48af791967a04",
             secret="6a68c98f654efb6547d299c5ded84dbb")
예제 #5
0
import re
import datetime
import smtplib
import datetime
from instapush import Instapush, App

Config = ConfigParser.ConfigParser()
Config.read("config.ini")

log_file = open(
    Config.get('Logging', 'path') + "/pytorrent" +
    str(datetime.datetime.now().date().year) + "-" +
    str(datetime.datetime.now().date().month) + ".log", "a")
log_level = int(Config.get(
    'Logging', 'level'))  #0 = no log, 1 = normal, 2 = verbose, 3 = super
app = App(appid=Config.get('PushNotification', 'appid'),
          secret=Config.get('PushNotification', 'secret'))


def loG(level, s):
    if level <= log_level:
        msg = '[' + str(
            datetime.datetime.now()) + '][L' + str(level) + '] ' + str(s)
        log_file.write(msg + '\n')
        print msg
    return


def dim(s, toMatch, noMatch, needed):  #DoesItMatch?
    if toMatch not in s:
        loG(3, "[DiM] __" + s + "__")
        loG(3, "[Dim] nope! title doesn't match: " + toMatch)
import sys, time
from Queue import Queue
from ctypes import POINTER, c_ubyte, c_void_p, c_ulong, cast

# From https://github.com/Valodim/python-pulseaudio
from pulseaudio.lib_pulseaudio import *
from instapush import Instapush, App

APPID = ''
SECRET = ''

app = App(appid=APPID, secret=SECRET)

# edit to match your sink
SINK_NAME = ''
METER_RATE = 344
THRESHOLD = 40
EVENT_NAME = ''
TRACKERS = {}
WAIT_TIME = 300

class PeakMonitor(object):

    def __init__(self, sink_name, rate):
        self.sink_name = sink_name
        self.rate = rate

        # Wrap callback methods in appropriate ctypefunc instances so
        # that the Pulseaudio C API can call them
        self._context_notify_cb = pa_context_notify_cb_t(self.context_notify_cb)
        self._sink_info_cb = pa_sink_info_cb_t(self.sink_info_cb)
예제 #7
0
        #print('pushed')
    except:
        pass


# pushbullet에 push명령을 내립니다
async def pushbulleting():
    try:
        cur = '9' + datetime.now().strftime('%H%M')
        push = pb.push_note(cur, "^^")

    except:
        pass


app = App(appid='595713a2a4c48ae3b8b70aa0',
          secret='78fbc7d58e750b37773b3dbd13c967c5')
pb = PushBullet("o.XnzDJuPVFyj0PuCpu5Ibxnzxy0rVqunh")
#message = 'Hello World!'
loop = asyncio.get_event_loop()

# pi3로 moving 메세지를 보냅니다
# octorpint 및 klipper 펌웨어 사용으로 임시로 제거해놓습니다. firefox-esr과 octoprint의 chromium이 충돌하는지
#문제가 생겨서리
#message = 'moving'
#loop.run_until_complete(tcp_echo_client(message, loop))

# pushbullet에 이벤트를 보냅니다
#loop.run_until_complete(instapushing())
loop.run_until_complete(pushbulleting())

# 102 데스크탑으로 coming 메세지를 보냅니다
예제 #8
0
 def notify():
     babyname, appid, secret = Notify.readcfg()
     app = App(appid=appid, secret=secret)
     app.notify(event_name='BabyCam', trackers={'Baby': babyname})
     time.sleep(600)
예제 #9
0
import RPi.GPIO as GPIO
import time
from time import sleep
import datetime
import Adafruit_DHT
import traceback
from threading import Thread, Event
import sys
from instapush import Instapush, App
import rrdtool
from rrdtool import update as rrd_update
import urllib2
import os

#Define Instapush App Details
app = App(appid='SOMESECRET', secret='SOMESECRET')

#Define GPIO Numbering
GPIO.setmode(GPIO.BCM)

#---------- GPIO SETUP------
#Define individual GPIO Pins
PIN_GARAGE_DOOR = 17
PIN_DOOR_BELL = 21
PIN_SHUT_DOWN = 18
PIN_WIFI_LED = 19
PIN_ALARM = 16
PIN_TEMP_HUMID = 4  #ONLY HERE AS A REMARK AS DHT Module sets GPIO as 4

#Setup GPIO Pins
GPIO.setup(PIN_GARAGE_DOOR, GPIO.IN,
예제 #10
0
 def __init__(self, config):
     self.config = config
     self.app = App(appid=self.config['APPID'],
                    secret=self.config['SECRET'])
예제 #11
0
파일: push.py 프로젝트: utylee/misc-3.6
def push():
    app = App(appid='595713a2a4c48ae3b8b70aa0',
              secret='78fbc7d58e750b37773b3dbd13c967c5')
    app.notify(event_name='alarm', trackers={'msg': '하핫'})
예제 #12
0
import RPi.GPIO as GPIO
import time
import os.path
from instapush import Instapush, App
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)

input_state = GPIO.input(4)
if input_state == False and os.path.isfile('active') == False:
    open('active', 'a')
    app = App(appid='xxxxxxxx', secret='xxxxxxxx')
    app.notify(event_name='Baby_Monitor', trackers={'Baby': 'Louis'})
    time.sleep(600)
    os.remove('active')
예제 #13
0
from pytz import utc
from apscheduler.jobstores.base import JobLookupError
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler import events
from instapush import Instapush, App
import logging
import dht11
import bluetooth
import subprocess
import io
import base64
from picamera import PiCamera
import glob
import os

appPush = App(appid='', secret='')

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'

device_folder1 = glob.glob(base_dir + '')[0]
device_file1 = device_folder1 + '/w1_slave'

device_folder2 = glob.glob(base_dir + '')[0]
device_file2 = device_folder2 + '/w1_slave'

service = Service()
#dbArr = service.getAllHeater()
scheduler = BackgroundScheduler()
예제 #14
0
def sendNotificationDeveloper(eventName, message):
  insta = Instapush(user_token=Environment.INSTAPUSH_USER_TOKEN)
  app = App(appid=Environment.INSTAPUSH_APPID, secret=Environment.INSTAPUSH_SECRET)
  # app.notify(event_name=eventName, trackers={'message': message})
  print 'Hipsografia Except:'+message
예제 #15
0
#!/usr/bin/env python3
import socket
import datetime
import time
import RPi.GPIO as GPIO


from instapush import Instapush, App
app = App(appid='*****', secret='*****')

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)

PinLDR = 27
T_NONE=11000
T_LIGHT=4000

def ReadLDR():
    LDRCount = 0 # Sets the count to 0
    GPIO.setup(PinLDR, GPIO.OUT)
    GPIO.output(PinLDR, GPIO.LOW)
    time.sleep(0.1) # Drains all charge from the capacitor
    GPIO.setup(PinLDR, GPIO.IN) # Sets the pin to be input
    # While the input pin reads ‘off’ or Low, count
    while (GPIO.input(PinLDR) == GPIO.LOW):
        LDRCount += 1 # Add one to the counter
    return LDRCount

def check_light():