Exemplo n.º 1
0
def init_scheduler():
    global scheduler, bg_scheduler
    scheduler = BlockingScheduler()
    bg_scheduler = BackgroundScheduler()
    scheduler.daemonic = False
Exemplo n.º 2
0
    r.encoding = 'utf-8'
    #print r.json()['weatherinfo']['city'], r.json()['weatherinfo']['WD'], r.json()['weatherinfo']['temp']
    print r.json()

    client = MongoClient('share2i.com', 27017)
    db = client.admin
    db.authenticate("root", "root")
    weathers = db.weathers
    weathers.save(r.json())  # add a record


def aps_test(x):
    print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), x


if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.daemonic = False
    #scheduler.add_job(func=aps_test, args=('定时任务',), trigger='cron', second='*/5')
    #scheduler.add_job(func=aps_test, args=('一次性任务',), next_run_time=datetime.datetime.now() + datetime.timedelta(seconds=12))
    scheduler.add_job(func=get_weather,
                      args=('循环任务', ),
                      trigger='interval',
                      seconds=60)
    scheduler.add_job(func=get_weather,
                      args=('循环任务', ),
                      trigger='interval',
                      hours=24)

    scheduler.start()
Exemplo n.º 3
0
def init_scheduler():
    global scheduler, bg_scheduler
    scheduler = BlockingScheduler()
    bg_scheduler = BackgroundScheduler()
    scheduler.daemonic = False
Exemplo n.º 4
0
# Power consumption meter
# Every hour add up the total Energy use from the past hour and post it to
# 'house/energy' on MQTT

import pandas as pd
from influxdb import DataFrameClient
from datetime import datetime
import time
import paho.mqtt.publish as publish
from apscheduler.schedulers.blocking import BlockingScheduler

#start the scheduler
sched = BlockingScheduler()
sched.daemonic = True


def report_energy_use():
    client = DataFrameClient('localhost', 8086, '', '', 'MulHomeAutomation')
    result = client.query(
        "select * from power where location='house' and time > now() - 1h limit 400"
    )
    db = result['power']
    db.reset_index(level=0, inplace=True)
    db = db.rename(columns={'index': 'date'})
    x1 = db['date']
    y1 = db['value']
    dataSet = []
    for i in range(0, len(x1)):
        dataPoint = []
        t0 = time.mktime(
            datetime.strptime(str(x1[i])[0:19],
Exemplo n.º 5
0
from apscheduler.schedulers.blocking import BlockingScheduler
import cx_Oracle
import datetime  
  
# Start the scheduler  
sched = BlockingScheduler()  

def OraRunPrc(v_prc):
    con = cx_Oracle.connect("xxxxxx/xxxxxx$@cd")
    cursor = con.cursor()
    query1 = cursor.callproc(v_prc)
    cursor.close()
    con.close()
    return None  
  
def job_function():  
    wx_post('开始自动执行存储过程')
#    OraRunPrc('ygl_week_job')
    wx_post('完成自动执行存储过程')
    print "Hello World"  , 'start job1 at: ', datetime.datetime.now()
 


print datetime.datetime.now()
sched.daemonic = False  

sched.add_job(job_function, 'cron', day_of_week='2', hour='9', minute='1',second='1')  

sched.start()