Beispiel #1
0
def main(argv):

    config_file = None
   
    try:
        opts, args = getopt.getopt(argv,"hc:",["cfgfile="])
    except getopt.GetoptError:
        print 'repository.py -c <cfgfile>'
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print 'repository.py -c <cfgfile>'
            sys.exit()
        elif opt in ("-c", "--cfgfile"):
            config_file = arg
        
    if config_file is None:
        print 'repository.py -c <cfgfile>'
        sys.exit(2)

    repository = Repository(config_file)
    
    sensor = Sensor('ground', config_file)
    readings = sensor.get_readings()

    if readings is not None:
        s=json.dumps(readings, sort_keys=True, indent=4, separators=(',', ': '))
        print s
        repository.save_readings(readings)