e95f6eb57a
Suppression temporaire des liens entre les tables de la BdD, Ajout de l'enregistrement des photos en BdD
74 lines
3.0 KiB
Python
74 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Configuration du projet Camétéo
|
|
|
|
Created on Fri Aug 18 21:35:59 2017
|
|
|
|
@author: arofarn
|
|
"""
|
|
|
|
###########
|
|
# IMPORTS #
|
|
###########
|
|
|
|
from datetime import datetime, timedelta, timezone
|
|
from configparser import SafeConfigParser
|
|
import os, sys
|
|
|
|
#################
|
|
# CONFIGURATION #
|
|
#################
|
|
|
|
script_path = os.path.dirname(sys.argv[0])
|
|
script_dir = os.path.abspath(script_path)
|
|
|
|
parser = SafeConfigParser(allow_no_value=True)
|
|
parser.read(script_dir + '/cameteo.conf')
|
|
|
|
#Misc
|
|
TimeZone = timezone(timedelta(hours=int(parser['MISC'].get('TimeZone', fallback=0))))
|
|
|
|
#SQL
|
|
sql_host = parser['SQL'].get('sql_host', fallback='localhost')
|
|
sql_port = parser['SQL'].get('sql_port', fallback=3306)
|
|
sql_base = parser['SQL'].get('sql_base', fallback='cameteo')
|
|
sql_user = parser['SQL'].get('sql_user', fallback='cameteo')
|
|
sql_pass = parser['SQL'].get('sql_pass', fallback='oetemac')
|
|
sql_sys = parser['SQL'].get('sql_sys', fallback='mysql')
|
|
sql_api = parser['SQL'].get('sql_api', fallback='pymysql')
|
|
sql_verbose = bool(int(parser['SQL'].get('sql_verbose', fallback=0)))
|
|
|
|
sql_uri = sql_sys + '+' + sql_api + '://' + sql_user + ':' + sql_pass + '@' + sql_host + ':' + sql_port + '/' + sql_base
|
|
|
|
#MQTT
|
|
mqtt_host = parser['MQTT'].get('mqtt_host', fallback='localhost')
|
|
mqtt_port = int(parser['MQTT'].get('mqtt_port', fallback=1883))
|
|
mqtt_client_id = parser['MQTT'].get('mqtt_client_id', fallback='mqtt2sql')
|
|
mqtt_user = parser['MQTT'].get('mqtt_user', fallback='cameteo')
|
|
mqtt_pass = parser['MQTT'].get('mqtt_pass', fallback='oetemac')
|
|
mqtt_auth = {'username' : mqtt_user, 'password' : mqtt_pass}
|
|
mqtt_qos = parser['MQTT'].get('mqtt_qos', fallback=0)
|
|
mqtt_topic = parser['MQTT'].get('mqtt_topic', fallback='sensors/#')
|
|
|
|
#Camera
|
|
camera_mqtt_topic = parser['CAMERA'].get('camera_mqtt_topic', fallback='raspi0/camera')
|
|
camera_resolution_x = int(parser['CAMERA'].get('camera_resolution_x', fallback='800'))
|
|
camera_resolution_y = int(parser['CAMERA'].get('camera_resolution_y', fallback='600'))
|
|
camera_resolution = (camera_resolution_x, camera_resolution_y)
|
|
camera_warmup_time = int(parser['CAMERA'].get('camera_warmup_time', fallback=2))
|
|
camera_iso = int(parser['CAMERA'].get('camera_iso', fallback=0))
|
|
camera_awb = parser['CAMERA'].get('camera_auto_white_balance', fallback='auto')
|
|
camera_expo_mode = parser['CAMERA'].get('camera_exposure_mode', fallback='auto')
|
|
camera_rotation = int(parser['CAMERA'].get('camera_rotation', fallback=0))
|
|
camera_contrast = int(parser['CAMERA'].get('camera_contrast', fallback=0))
|
|
|
|
photo_dir = parser['CAMERA'].get('photo_dir', fallback='/home/pi/photos/')
|
|
photo_name = parser['CAMERA'].get('photo_name', fallback='%%Y%%m%%d_%%H%%M%%S')
|
|
photo_format = parser['CAMERA'].get('photo_format', fallback='jpg')
|
|
photo_extensions = {'jpeg': 'jpg',
|
|
'png' : 'png',
|
|
'gif': 'gif',
|
|
'bmp': 'bmp',
|
|
'yuv': 'yuv',
|
|
'rgb': 'rgb',
|
|
'rgba': 'rgba'} |