Exemple #1
0
def main():
    while True:
        val = app.getTable()
        #print(val)
        for i in val:
            app.update(i[1], i[0])          
        time.sleep(30)
Exemple #2
0
def set_settings():
    if request.json['threshold_humidity']:
        strategy.conf['threshold_humidity'] = request.json['threshold_humidity']
    if request.json['threshold_temperature']:
        strategy.conf['threshold_temperature'] = request.json['threshold_temperature']
    if request.json['max_temperature']:
        strategy.conf['max_temperature'] = request.json['max_temperature']
    if request.json['history_length']:
        strategy.conf['history_length'] = request.json['history_length']
    update()
    return '', 204
Exemple #3
0
def set_settings():
    if request.json['threshold_humidity']:
        strategy.conf['threshold_humidity'] = request.json[
            'threshold_humidity']
    if request.json['threshold_temperature']:
        strategy.conf['threshold_temperature'] = request.json[
            'threshold_temperature']
    if request.json['max_temperature']:
        strategy.conf['max_temperature'] = request.json['max_temperature']
    if request.json['history_length']:
        strategy.conf['history_length'] = request.json['history_length']
    update()
    return '', 204
Exemple #4
0
def test_update_puts_no_prefix(mock_intent, mock_bot,
                               cfn_create_no_prefix_event, setup, monkeypatch):
    """ test_update_puts_bot_no_prefix """
    context, builder, _ = setup
    cfn_create_no_prefix_event['ResourceProperties'].pop('slotTypes')
    mock_bot.return_value = '1234'

    builder.put.return_value = {"name": 'LexBot', "version": '$LATEST'}
    intent = Intent('a', 'b', 'c', 'd', None)
    mock_intent.return_value = intent
    patch_builder(context, builder, monkeypatch)

    response = app.update(cfn_create_no_prefix_event, context)

    builder.put.assert_called_once_with('1234')

    assert response['BotName'] == 'LexBot'
    assert response['BotVersion'] == BOT_VERSION
Exemple #5
0
    def test_0_update(self):

        self.assertEqual(ap.update(), ('', 204))
Exemple #6
0
            fetch_gb(id, config.taxon)
            sleep(1 / 3)  # LIMIT 3 REQUESTS PER SECOND
    else:
        print(f"[WARN] Error with request: {r.url}")


def fetch_gb(id, taxon=None):
    r = eutils.fetch(db='nuccore', id=id, rettype='gb')
    if r.ok:
        gb = GenBank.read(StringIO(r.text))
        filename = f"{gb.locus}{'.' + taxon if taxon else ''}.gb"
        file_out = os.path.join(config.genbank_dir, filename)
        if os.path.exists(file_out):
            print(f"[WARN] {file_out} already exists")
        else:
            with open(file_out, 'w') as fh:
                fh.write(r.text)
            print(f"[INFO] Fetched file: {file_out}")
    else:
        print(f"[WARN] Could not download '{id}'")


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('action', choices=['init', 'update'])
    args = parser.parse_args()
    if args.action == 'init':
        app.init()
    elif args.action == 'update':
        app.update()
Exemple #7
0
def test_update_deleted_slot(cfn_create_event, setup, monkeypatch):
    context, _, _ = setup
    app.update(cfn_create_event, context)
Exemple #8
0
def off():
    strategy.stop()
    update()
    return '', 204
Exemple #9
0
def on():
    strategy.start()
    update()
    return '', 204
Exemple #10
0
def off():
    strategy.stop()
    update()
    return '', 204
Exemple #11
0
def on():
    strategy.start()
    update()
    return '', 204