std ini file e load config
This commit is contained in:
52
env/email.ini
vendored
Normal file
52
env/email.ini
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
[address]
|
||||
from = ASE Alert System<alert@aseltd.eu>
|
||||
to = andrea.carri@aseltd.eu,alessandro.battilani@gmail.com,alessandro.valletta@aseltd.eu,alberto.sillani@aseltd.eu,majd.saidani@aseltd.eu
|
||||
cc =
|
||||
bcc =
|
||||
|
||||
[msg]
|
||||
subject = ASE Alert System
|
||||
body = <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> \
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Alert from ASE</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
|
||||
<body style="margin: 0; padding: 0;">
|
||||
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%%">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://www2.aseltd.eu/static/img/logo_ASE_small.png" alt="ASE" style="display: block;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h1 style="margin: 5px;">Alert from ASE:</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h3 style="margin: 5px;">Matlab function $matlab_cmd failed on unit => $unit - tool => $tool</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h4 style="margin: 5px;">$matlab_error</h4>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 20px; padding-bottom: 0px; color: red">
|
||||
$MatlabErrors
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 20px;">
|
||||
$MatlabWarnings
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1,3 @@
|
||||
"""Config ini setting"""
|
||||
from pathlib import Path
|
||||
ROOT_PATH = Path(__file__).resolve().parent.parent.parent.parent
|
||||
19
src/utils/config/loader_email.py
Normal file
19
src/utils/config/loader_email.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""set configurations
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
c = ConfigParser()
|
||||
c.read([f"{ROOT_PATH}/env/email.ini"])
|
||||
print(c.items)
|
||||
# email setting
|
||||
self.from_addr = c.get("address", "from")
|
||||
self.to_addr = c.get("address", "to")
|
||||
self.cc_addr = c.get("address", "cc")
|
||||
self.bcc_addr = c.get("address", "bcc")
|
||||
self.subject = c.get("msg", "subject")
|
||||
self.body = c.get("msg", "body")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
@@ -11,7 +12,7 @@ class Config:
|
||||
"""
|
||||
|
||||
c = ConfigParser()
|
||||
c.read(["../env/ftp.ini", "../env/db.ini"])
|
||||
c.read([f"{ROOT_PATH}/env/ftp.ini", f"{ROOT_PATH}/env/db.ini"])
|
||||
|
||||
# FTP setting
|
||||
self.service_port = c.getint("ftpserver", "service_port")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
@@ -11,7 +12,7 @@ class Config:
|
||||
"""
|
||||
|
||||
c = ConfigParser()
|
||||
c.read(["../env/load.ini", "../env/db.ini"])
|
||||
c.read([f"{ROOT_PATH}/env/load.ini", f"{ROOT_PATH}/env/db.ini"])
|
||||
|
||||
# LOG setting
|
||||
self.logfilename = c.get("logging", "logFilename")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
@@ -11,7 +12,7 @@ class Config:
|
||||
"""
|
||||
|
||||
c = ConfigParser()
|
||||
c.read(["../env/elab.ini", "../env/db.ini"])
|
||||
c.read([f"{ROOT_PATH}/env/elab.ini", f"{ROOT_PATH}/env/db.ini"])
|
||||
|
||||
# LOG setting
|
||||
self.logfilename = c.get("logging", "logFilename")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
@@ -11,7 +12,7 @@ class Config:
|
||||
"""
|
||||
|
||||
c = ConfigParser()
|
||||
c.read(["../env/send.ini", "../env/db.ini"])
|
||||
c.read([f"{ROOT_PATH}/env/send.ini", f"{ROOT_PATH}/env/db.ini"])
|
||||
|
||||
# LOG setting
|
||||
self.logfilename = c.get("logging", "logFilename")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from . import ROOT_PATH
|
||||
|
||||
class Config:
|
||||
"""
|
||||
@@ -10,7 +11,7 @@ class Config:
|
||||
def __init__(self):
|
||||
|
||||
c = ConfigParser()
|
||||
c.read(["../env/db.ini"])
|
||||
c.read([f"{ROOT_PATH}/env/db.ini"])
|
||||
|
||||
# DB setting
|
||||
self.dbhost = c.get("db", "hostname")
|
||||
|
||||
Reference in New Issue
Block a user