<s> import sys <EOL> import time <EOL> import datetime <EOL> import Adafruit_BMP . BMP085 as BMP085 <EOL> import gspread <EOL> GDOCS_EMAIL = '<STR_LIT>' <EOL> GDOCS_PASSWORD = '<STR_LIT>' <EOL> GDOCS_SPREADSHEET_NAME = '<STR_LIT>' <EOL> FREQUENCY_SECONDS = <NUM_LIT:30> <EOL> def login_open_sheet ( email , password , spreadsheet ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> gc = gspread . login ( email , password ) <EOL> worksheet = gc . open ( spreadsheet ) . sheet1 <EOL> return worksheet <EOL> except : <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> bmp = BMP085 . BMP085 ( ) <EOL> print '<STR_LIT>' . format ( GDOCS_SPREADSHEET_NAME , FREQUENCY_SECONDS ) <EOL> print '<STR_LIT>' <EOL> worksheet = None <EOL> while True : <EOL> if worksheet is None : <EOL> worksheet = login_open_sheet ( GDOCS_EMAIL , GDOCS_PASSWORD , GDOCS_SPREADSHEET_NAME ) <EOL> temp = bmp . read_temperature ( ) <EOL> pressure = bmp . read_pressure ( ) <EOL> altitude = bmp . read_altitude ( ) <EOL> print '<STR_LIT>' . format ( temp ) <EOL> print '<STR_LIT>' . format ( pressure ) <EOL> print '<STR_LIT>' . format ( altitude ) <EOL> try : <EOL> worksheet . append_row ( ( datetime . datetime . now ( ) , temp , pressure , altitude ) ) <EOL> except : <EOL> print '<STR_LIT>' <EOL> worksheet = None <EOL> time . sleep ( FREQUENCY_SECONDS ) <EOL> continue <EOL> print '<STR_LIT>' . format ( GDOCS_SPREADSHEET_NAME ) <EOL> time . sleep ( FREQUENCY_SECONDS ) </s>
