#!/usr/bin/python
import os, fcntl

credentials_file = os.path.join(os.path.dirname(__file__),
                                "credentials.oracle")
if os.path.isfile(credentials_file):
    lock_file = "/var/lock/oracle.lock"
    f = open(lock_file, 'w')
    try:
        fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
        print("No other uploads in progress, proceeding...")
        import database  # requires MySQLdb python 2 library which is not ported to python 3 yet
        db = database.weather_database()
        db.upload()
    except IOError:
        print("Another upload is running exiting now")
    finally:
        f.close()
else:
    print("Credentials file not found")
예제 #2
0
#!/usr/bin/python
import interrupt_client, database, MCP342X, wind_direction, HTU21D, bmp085, tgs2600, ds18b20_therm

pressure = bmp085.BMP085()
temp_probe = ds18b20_therm.DS18B20()
air_qual = tgs2600.TGS2600(adc_channel = 1)
humidity = HTU21D.HTU21D()
wind_dir = wind_direction.wind_direction(adc_channel = 0, margin = 20)
interrupts = interrupt_client.interrupt_client(port = 49501)

db = database.weather_database() #Local MySQL db

wind_average = wind_dir.get_value(10) #ten seconds

print "Inserting..."
db.insert(humidity.read_tmperature(), temp_probe.read_temp(), air_qual.get_value(), pressure.get_pressure(), humidity.read_humidity(), wind_average, interrupts.get_wind(), interrupts.get_wind_gust(), interrupts.get_rain())
print "done"

interrupts.reset()
예제 #3
0
import time
import sys
from ISStreamer.Streamer import Streamer

import interrupt_client, MCP342X, wind_direction, HTU21D, bmp085, tgs2600, ds18b20_therm
import database  # requires MySQLdb python 2 library which is not ported to python 3 yet

pressure = bmp085.BMP085()
temp_probe = ds18b20_therm.DS18B20()
air_qual = tgs2600.TGS2600(adc_channel=0)
humidity = HTU21D.HTU21D()
wind_dir = wind_direction.wind_direction(adc_channel=0,
                                         config_file="wind_direction.json")
interrupts = interrupt_client.interrupt_client(port=49501)

db = database.weather_database()  #Local MySQL db

wind_average = wind_dir.get_value(10)  #ten seconds
ambient_temp = humidity.read_temperature()
ground_temp = temp_probe.read_temp()
air_quality = air_qual.get_value()
pressure = pressure.get_pressure()
humidity = humidity.read_humidity()
wind_speed = interrupts.get_wind()
wind_gust = interrupts.get_wind_gust()
rainfall = interrupts.get_rain()

print("Inserting...")
#db.insert(humidity.read_temperature(), temp_probe.read_temp(), air_qual.get_value(), pressure.get_pressure(), humidity.read_humidity(), wind_average, interrupts.get_wind(), interrupts.get_wind_gust(), interrupts.get_rain())
db.insert(ambient_temp, ground_temp, air_quality, pressure, humidity,
          wind_average, wind_speed, wind_gust, rainfall)
예제 #4
0
#!/usr/bin/python
import os, fcntl
credentials_file = os.path.join(os.path.dirname(__file__), "credentials.oracle")
if os.path.isfile(credentials_file):
    lock_file = "/var/lock/oracle.lock"
    f = open(lock_file, 'w')
    try:
        fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
        print "no other uploads in progress, proceeding..."
        import database
        db = database.weather_database()
        db.upload()
    except IOError:
        print "another upload is running exiting now"
    finally:
        f.close()
else:
    print "credentials file not found"