コード例 #1
0
def switch_backlight():
    if string_to_bool(os.environ.get('SWITCH_BACKLIGHT', 'true')):
        # if str(os.environ.get('SWITCH_BACKLIGHT', 1)).lower() not in ['0', 'false', 'f']:
        if ecobee.occupied():
            ecobee.turn_backlight_on()
        else:
            ecobee.turn_backlight_off()
コード例 #2
0
def main(_args):
    print(_args)
    remove_blacklisted_words_from_dict(params.FR_DICT_BLACKLIST)
    requirements()

    input_data = pnd.read_csv(params.INPUT_TRAIN_FILENAME, sep=';')

    drug_names_path = utils.get_drug_names_path()
    if not os.path.exists(drug_names_path):
        drug_names_df = extract_drug_names(params.RCP_FILENAME,
                                           sep_regex=r'\t|,',
                                           id_col_idx=0,
                                           name_col_idx=1)
        utils.create_dir(drug_names_path)
        drug_names_df.to_csv(drug_names_path)
    else:
        drug_names_df = pnd.read_csv(drug_names_path)

    drug_names_set = set(drug_names_df[params.DRUG_NAME_COL])

    corr_lemm_data = correct_and_lemmatize(
        input_data, drug_names_set, utils.string_to_bool(_args.lemmatization))

    count = 0

    for i in range(corr_lemm_data.shape[0]):
        # # To print results
        # print(corr_lemm_data.loc[i, RAW_SENTENCE_COL])
        # print(corr_lemm_data.loc[i, CORR_LEMM_SENTENCE_COL])
        # print(corr_lemm_data.loc[i, DRUG_NAMES_COL])
        # print()

        if corr_lemm_data.loc[i, params.DRUG_NAMES_COL]:
            count += 1

    corr_lemm_path = utils.get_corr_lemm_path(_args.label)
    utils.create_dir(corr_lemm_path)
    corr_lemm_data.to_csv(corr_lemm_path)

    # To check drug names, will leave it for a while for testing
    # for i in drug_names_df.index:
    #     if 'trim' in drug_names_df.loc[i, DRUG_COMPLETE_NAME_COL]:
    #         print(drug_names_df.loc[i])
    print("We found drug names in %.2f%% of sentences." %
          (count / int(_args.max_lines) * 100))
コード例 #3
0
ファイル: main.py プロジェクト: Winerp7/Rasp-mesh
from master import MasterNode
from slave import SlaveNode
import os
from os.path import dirname, join
from dotenv import load_dotenv
from utils import string_to_bool

if __name__ == '__main__':
    dotenv_path = join('/home/pi', 'variables.env')
    load_dotenv(dotenv_path)

    is_master = string_to_bool(os.environ.get('ISMASTER'))

    if is_master:
        master = MasterNode()
        master.run()
    else:
        slave = SlaveNode()
        slave.run()
コード例 #4
0
from threading import Condition

# Load functions
from authorize import auth
from camera_utils import StreamingOutput
from utils import string_to_bool, setup_logger

load_dotenv()

# Enable logging
logger = setup_logger('api', 'INFO')

# Define Constants
HOST = os.getenv("HOST", "127.0.0.1")
PORT = int(os.getenv("PORT", "8080"))
DEBUG = string_to_bool(os.getenv("DEBUG", 'True'))


def gen(video_capture):
    while True:
        _, frame = video_capture.read()
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')


def gen_pi(output):
    while True:
        with output.condition:
            output.condition.wait()
            frame = output.frame
        yield (b'--frame\r\n'
コード例 #5
0
    owm_api_key = os.environ['OWM_API_KEY']
    temp_delta = float(os.environ.get('DEWPOINT_DELTA', TEMP_DELTA))
    r_value = float(os.environ.get('R_VALUE', R_VALUE))
    update_interval = int(os.environ.get('UPDATE_INTERVAL', 600))
    max_steam_humidity = float(os.environ.get('MAX_STEAM_HUMIDITY', 40))
    steam_humidity_hysteresis = float(os.environ.get('STEAM_HUMIDITY_HYST', 2))

    max_humidity = float(os.environ.get('MAX_HUMIDITY', 50))
    min_humidity = float(os.environ.get('MIN_HUMIDITY', 10))
    loglevel = os.environ.get('LOG_LEVEL', "INFO")
    numeric_level = getattr(logging, loglevel.upper(), 20)
    logger.setLevel(numeric_level)
    logger.warning("Logging set to %s", logging.getLevelName(numeric_level))
    fan_factors = json.loads(
        os.environ.get('FAN_FACTORS', '[0.43651,-5.99206,29.9206,-19.3651]'))

    fan_factors = [0] * (6 - len(fan_factors)) + fan_factors
    logger.debug("Fan factors are %s", fan_factors)

    while not exit_signal.is_set():
        run()
        log_handler.flush()
        # break
        show_interval = max(10, update_interval / 10.0)
        wait(update_interval,
             exit_signal,
             interval=show_interval,
             extra_message='/{} seconds waiting ...'.format(update_interval),
             log_signal=string_to_bool(
                 os.environ.get('SHOW_WAIT_COUNTDOWN', 'true')))
コード例 #6
0
ファイル: app.py プロジェクト: lion-software/Arapiles
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Main project routine
"""

import os

from flask import Flask, send_from_directory

from utils import string_to_bool

app = Flask(__name__, static_folder="front/public")

debug_mode = string_to_bool(os.environ["PRODUCTION"])


@app.route("/")
def serve():
    """ Serves React App """
    return send_from_directory(app.static_folder, "index.html")


@app.route("/<path:path>")
def static_proxy(path):
    """ Static folder serve """
    file_name = path.split("/")[-1]
    dir_name = os.path.join(app.static_folder, "/".join(path.split("/")[:-1]))
    if os.path.isdir(os.path.join(dir_name, file_name)):
        file_name += "/index.html"
    return send_from_directory(dir_name, file_name)