예제 #1
0
def main():
    title = 'BW-Video-Keen-Hourly'
    keen_client = get_keen_client(
        '/home/robertdavidwest/keen-buzzworthy-aol.json')
    gdrive_client = get_gdrive_client(
                 '/home/robertdavidwest/gdrive-keen-buzzworthy-aol.json')

    tz_str = "US/Pacific"
    timezone_short = "PT"
    tz = timezone(tz_str)

    this_now = datetime.now(tz)
    local_now =  datetime.now()
    pacific_now = datetime.now(
            timezone("US/Pacific")) # keen reports are pacific
    display_now = this_now.ctime()

    if this_now.day != local_now.day:
        raise AssertionError("Changing timezone " \
                "in sheetname will show incorrect day")
    # Yesterday report
    report_name = "Today"
    timeframe = "this_day"
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short, report_name)
    report = get_keen_report(keen_client, gdrive_client, timeframe, tz_str)
    write_to_sheets(gdrive_client, report, title, sheetname)

    clean_sheets(gdrive_client, title, max_sheets=1)
예제 #2
0
def main():
    title = 'BW-Video-Keen-Hourly'
    keen_client = get_keen_client(
        '/home/robertdavidwest/keen-buzzworthy-aol.json')
    gdrive_client = get_gdrive_client(
        '/home/robertdavidwest/gdrive-keen-buzzworthy-aol.json')

    tz_str = "US/Pacific"
    timezone_short = "PT"
    tz = timezone(tz_str)

    this_now = datetime.now(tz)
    local_now = datetime.now()
    pacific_now = datetime.now(
        timezone("US/Pacific"))  # keen reports are pacific
    display_now = this_now.ctime()

    if this_now.day != local_now.day:
        raise AssertionError("Changing timezone " \
                "in sheetname will show incorrect day")
    # Yesterday report
    report_name = "Today"
    timeframe = "this_day"
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short,
                                                   report_name)
    report = get_keen_report(keen_client, gdrive_client, timeframe, tz_str)
    write_to_sheets(gdrive_client, report, title, sheetname)

    clean_sheets(gdrive_client, title, max_sheets=1)
예제 #3
0
def main():
    title = 'BW-Video-Keen-Data-Snapshots'
    keen_client = get_keen_client(
        '/home/robertdavidwest/keen-buzzworthy-aol.json')
    gdrive_client = get_gdrive_client(
        '/home/robertdavidwest/gdrive-keen-buzzworthy-aol.json')

    tz_str = "US/Pacific"
    timezone_short = "PT"
    tz = timezone(tz_str)

    this_now = datetime.now(tz)
    local_now = datetime.now()
    pacific_now = datetime.now(
        timezone("US/Pacific"))  # keen reports are pacific
    display_now = this_now.ctime()

    if this_now.day != local_now.day:
        raise AssertionError("Changing timezone " \
                "in sheetname will show incorrect day")

    # Yesterday report
    report_name = "Yesterday"
    timeframe = "previous_day"
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short,
                                                   report_name)
    report = get_keen_report(keen_client,
                             gdrive_client,
                             timeframe,
                             tz_str,
                             enclave_report_type=report_name)
    write_to_sheets(gdrive_client, report, title, sheetname)

    # Report Month to date excluding today
    report_name = 'MTD(not-today)'
    day = pacific_now.day
    n = day - 1
    if n == 0:
        timeframe = 'previous_month'
    else:
        timeframe = 'previous_{}_days'.format(n)
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short,
                                                   report_name)
    report = get_keen_report(keen_client,
                             gdrive_client,
                             timeframe,
                             tz_str,
                             enclave_report_type=report_name)
    write_to_sheets(gdrive_client, report, title, sheetname)

    # No more than 20 sheets in workbook. Older results are deleted.
    clean_sheets(gdrive_client, title, max_sheets=20)
예제 #4
0
def main():
    title = 'BW-Video-Keen-Data-Snapshots'
    keen_client = get_keen_client(
        '/home/robertdavidwest/keen-buzzworthy-aol.json')
    gdrive_client = get_gdrive_client(
                 '/home/robertdavidwest/gdrive-keen-buzzworthy-aol.json')

    tz_str = "US/Pacific"
    timezone_short = "PT"
    tz = timezone(tz_str)

    this_now = datetime.now(tz)
    local_now =  datetime.now()
    pacific_now = datetime.now(
            timezone("US/Pacific")) # keen reports are pacific
    display_now = this_now.ctime()

    if this_now.day != local_now.day:
        raise AssertionError("Changing timezone " \
                "in sheetname will show incorrect day")
    
    # Yesterday report
    report_name = "Yesterday"
    timeframe = "previous_day"
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short, report_name)
    report = get_keen_report(keen_client, gdrive_client, timeframe, tz_str, enclave_report_type=report_name)
    write_to_sheets(gdrive_client, report, title, sheetname)
    
    # Report Month to date excluding today
    report_name =  'MTD(not-today)'
    day = pacific_now.day
    n = day - 1
    if n == 0:
        timeframe = 'previous_month'
    else:
        timeframe = 'previous_{}_days'.format(n)
    sheetname = 'runtime: {} {} report: {}'.format(display_now, timezone_short, report_name)
    report = get_keen_report(keen_client, gdrive_client, timeframe, tz_str, enclave_report_type=report_name)
    write_to_sheets(gdrive_client, report, title, sheetname)

    # No more than 20 sheets in workbook. Older results are deleted.
    clean_sheets(gdrive_client, title, max_sheets=20)
def update_exclusions_in_sheets(gc, exclusions):
    title = "BW-Video-Keen-Key"
    sheet = "ALERT-EXCLUSIONS"
    delete_sheet(gc, title, sheet)
    write_to_sheets(gc, exclusions, title, sheet)
def write_encrave_report(gc, data, sheet):
    title = "Encrave Report Summaries"
    delete_sheet(gc, title, sheet)
    write_to_sheets(gc, data, title, sheet)
예제 #7
0
        IO.setwarnings(False)
        IO.setup(40,IO.OUT)
        IO.output(40,0)  
        time.sleep(0.28)  #sampling time
        
        #convert adc value to calcVoltage
        calcVoltage = adc.read_adc(3, gain=adc_gain) * (5.0 / 65535)
        
        # linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
        dustDensity = 170 * calcVoltage - 0.1
        #dust_level = "Dust     = " + str(round(dustDensity,2)) + "ug/m3\n"
        dust_level = str(round(dustDensity,2))
        time.sleep(0.04)  #delta time
        IO.output(40,1)
        time.sleep(0.9680)#sleep time
        
        #fileName = "/home/pi/Desktop/dataFolder/" + datetime.datetime.now().strftime('%Y%m%d%H') + ".txt"
        fileName = "/home/pi/Desktop/dataFolder/DATA.csv"
        #file1 = open( fileName ,"a")
        with open(fileName, mode = 'a') as data_file:
            data_writer = csv.writer(data_file, delimiter = ',', quotechar='"', quoting = csv.QUOTE_MINIMAL)
            text = [dateAndTime,gas1_String,gas2_String,gas3_String,dht_humidity,dht_temperature,bme_pressure,dust_level]
            data_writer.writerow(text)
            write_to_sheets(text)
        print(text)
        #file1.writelines(text)
        #file1.close()

if __name__=="__main__":
   main()
예제 #8
0
    aol_portal_json = '/home/robertdavidwest/aol-portal.json'
    d = json.load(open(aol_portal_json, 'r'))
    aol_df = get_aol_data(d['username'], d['password'])
    print aol_df

    '''
    tz = timezone('US/Eastern')
    eastern_now = datetime.now(tz)
    local_now = datetime.now()
    display_now = eastern_now.ctime()

    if eastern_now.day != local_now.day:
        raise AssertionError("Changing to Eastern time in sheetname will show"
                             "incorrect day")

    # see all timeframe options here:
    # https://keen.io/docs/api/#timeframe

    timeframe = 'previous_1_days'
    sheetname = '{} {}'.format(display_now, 'Yesterday')
    results = get_keen_data(keen_client, timeframe=timeframe)
    write_to_sheets(gdrive_client, results, title, sheetname)

    timeframe = 'this_month'
    sheetname = '{} {}'.format(display_now, timeframe)
    results = get_keen_data(keen_client, timeframe=timeframe)
    write_to_sheets(gdrive_client, results, title, sheetname)

    # No more than 20 sheets in workbook. Older results are deleted.
    clean_sheets(gdrive_client, title, max_sheets=20)
예제 #9
0
파일: run.py 프로젝트: robertdavidwest/keen
    aol_portal_json = '/home/robertdavidwest/aol-portal.json'
    d = json.load(open(aol_portal_json, 'r'))
    aol_df = get_aol_data(d['username'], d['password'])
    print aol_df

    '''
    tz = timezone('US/Eastern')
    eastern_now = datetime.now(tz)
    local_now =  datetime.now()
    display_now = eastern_now.ctime()

    if eastern_now.day != local_now.day:
        raise AssertionError("Changing to Eastern time in sheetname will show"
                             "incorrect day")

    # see all timeframe options here:
    # https://keen.io/docs/api/#timeframe

    timeframe = 'previous_1_days'
    sheetname = '{} {}'.format(display_now, 'Yesterday')
    results = get_keen_data(keen_client, timeframe=timeframe)
    write_to_sheets(gdrive_client, results, title, sheetname)

    timeframe = 'this_month'
    sheetname = '{} {}'.format(display_now, timeframe)
    results = get_keen_data(keen_client, timeframe=timeframe)
    write_to_sheets(gdrive_client, results, title, sheetname)

    # No more than 20 sheets in workbook. Older results are deleted.
    clean_sheets(gdrive_client, title, max_sheets=20)
예제 #10
0
def update_exclusions_in_sheets(gc, exclusions):
    title = "BW-Video-Keen-Key"
    sheet = "ALERT-EXCLUSIONS"
    delete_sheet(gc, title, sheet)
    write_to_sheets(gc, exclusions, title, sheet)