1 from extomeAI.source import MeteoFrance
3 from celery import Celery
4 from configparser import ConfigParser
5 from logging.config import fileConfig
6 from logging import getLogger
7 from pathlib import Path
8 from shutil import rmtree
9 from subprocess import Popen, PIPE
12 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
17 def __init__(self, clean = False):
18 logger.info("Extome-IA engine launched")
21 print("Ne pas oublier d'exporter la BDD dans pgModeler")
22 print("Ni de copier l'archive dans la data")
25 # Cleaning the data directory
26 logger.info("Cleaning and restoring data directory")
27 directory = Path.cwd() / 'data'
28 if directory.is_dir():
30 p = Path(Path.cwd() / 'data')
33 # Cleaning the postgresql database
34 config = ConfigParser()
35 config.read((Path.cwd() / 'config') / 'main.cfg')
37 host = config['postgresql']['host']
38 user = config['postgresql']['user']
39 port = config['postgresql']['port']
40 dbname = config['postgresql']['dbname']
42 logger.info("PostgreSQL database deletion")
43 command = ['dropdb', '-h', host, '-U', user, '-p', port, dbname]
44 process = Popen(command, stdout=PIPE, stderr=PIPE)
47 logger.info("PostgreSQL database creation")
48 command = ['createdb', '-h', host, '-U', user, '-p', port, dbname]
49 process = Popen(command, stdout=PIPE, stderr=PIPE)
52 def add_meteofrance(self):
53 self.meteofrance = MeteoFrance()
57 engine = ExtomeEngine(clean = False)
58 engine.add_meteofrance()