示例#1
0
class Config(object):
    """Define the config parameters for this app."""
    logger.info("Start of the Config() class.")

    # Location for environment variables is automatically set by the env_variables.yaml file when running in GCP
    if local:
        from env_tools import apply_env
        apply_env()
        logger.info("Applied .env variables using env_tools")

    # AWS credentials
    aws_account_id = environ.get('AWS_ACCOUNT_ID')
    aws_access_key = environ.get('AWS_ACCESS_KEY_ID')
    aws_secret_access_key = environ.get('AWS_SECRET_ACCESS_KEY')
    aws_user = environ.get('AWS_USER')
    aws_region = environ.get('AWS_REGION')
    aws_arn = environ.get('AWS_ARN')

    # App-related
    SECRET_KEY = environ.get(
        'SECRET_KEY') or '0mW7@LN0n32L6ntaj0d8jzsXiAW4mkPL7u5l'
    domain_url = environ.get('DOMAIN_URL')

    # Date & time formatting prefs
    date_format = '%Y-%m-%d'
    datetime_format = '%Y-%m-%d %H:%M:%S'
    step_when_format = '%a %H:%M'

    logger.info("End of the Config() class.")
示例#2
0
文件: main.py 项目: brystmar/biffers
from global_logger import logger, local
from config import Config
from flask import Flask
import boto3

# Use the local dynamodb connection when running locally
if local:
    db = boto3.resource('dynamodb', region_name=Config.aws_region, aws_access_key_id=Config.aws_access_key,
                        aws_secret_access_key=Config.aws_secret_access_key, endpoint_url='http://*****:*****@app.route('/hello')
def hello_world():
    return 'Hello World!'


if local:  # if __name__ == '__main__':
    app.run(host='localhost', port=5000, debug=True)
    print("Running locally via __main__: http://localhost:5000")
    logger.info("Running locally via __main__: http://localhost:5000")
示例#3
0
def traffic_controller_available_CB(client, userdata, message):
	global is_tc_available
	logger.info("[MQTT] traffic_controller_available_CB :  " + str(message.payload) + "(Q" + str(message.qos) + ", R" + str(message.retain) + ")")
	is_tc_available = message.payload
示例#4
0
def path_allowed_CB(client, userdata, message):
	logger.info("[MQTT] path_allowed_CB :  " + str(message.payload) + "(Q" + str(message.qos) + ", R" + str(message.retain) + ")")
def path_req_CB(client, userdata, message):
    # logger.info("+++++++++++++++++++++  THis is Self define CB")
    logger.info("[path_req_CB] Received message '" + str(message.payload) +
                "' on topic '" + message.topic + "' with QoS " +
                str(message.qos))