Compare commits

...

2 Commits

Author SHA1 Message Date
db27220505 Update email parameters in parameters.yaml and modify SMTP connection in survBot.py
- Update mailserver, port, user, password, and sender in parameters.yaml
- Modify SMTP connection in survBot.py to support starttls connection if server is not "localhost"
- Read password from docker secret or environment variable if set to 'DOCKER' or 'ENV' respectively
2025-03-20 15:58:51 +01:00
3e47f4275b Add bind9-host and iputils-ping to Docker image requirements.
- Install bind9-host and iputils-ping packages in the Docker image.
- Create a new file "requirements.txt" with the specified package versions.
2025-03-20 15:58:22 +01:00
4 changed files with 64 additions and 9 deletions

View File

@ -4,13 +4,8 @@ WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN apt update && apt install -y bind9-host iputils-ping
COPY . .
RUN mkdir -p www
RUN ln -s www/survBot_out.html www/index.html
RUN cp stylesheets/*.css www/
RUN touch logo.png
RUN cp logo.png www/logo.png
CMD [ "python", "./survBot.py", "-html", "www" ]

View File

@ -137,9 +137,12 @@ html_logo: "logo.png"
# E-mail notifications
EMAIL:
mailserver: "localhost"
mailserver: "smtp.rub.de" # mail server
port: 465 # mail port
user: "seisox25" # mail user
password: "DOCKER" # mail password, read from environment variable if set to "ENV" or from docker secret if set to "DOCKER"
addresses: ["marcel.paffrath@rub.de", "kasper.fischer@rub.de"] # list of mail addresses for info mails
sender: "webmaster@geophysik.ruhr-uni-bochum.de" # mail sender
sender: "RUB SeisObs <seisobs@ruhr-uni-bochum.de>" # mail sender
stations_blacklist: [] # do not send emails for specific stations
networks_blacklist: [] # do not send emails for specific network
# specify recipients for single stations in a yaml: key = email-address, val = station list (e.g. [1Y.GR01, 1Y.GR02])

36
requirements.txt Normal file
View File

@ -0,0 +1,36 @@
Brotli==1.1.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
contourpy==1.3.1
cycler==0.12.1
decorator==5.2.1
fonttools==4.56.0
greenlet==3.1.1
h2==4.2.0
hpack==4.1.0
hyperframe==6.1.0
idna==3.10
kiwisolver==1.4.8
lxml==5.3.1
matplotlib==3.8.4
munkres==1.1.4
numpy==1.26.4
obspy==1.4.1
packaging==24.2
pillow==11.1.0
pip==25.0.1
pycparser==2.22
pyparsing==3.2.1
PySocks==1.7.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
scipy==1.15.2
setuptools==75.8.2
six==1.17.0
SQLAlchemy==1.4.54
unicodedata2==16.0.0
urllib3==2.3.0
wheel==0.45.1
zstandard==0.23.0

View File

@ -758,7 +758,28 @@ class StationQC(object):
msg.add_alternative(html_str, subtype='html')
# send message via SMTP server
s = smtplib.SMTP(server)
# set up starttls connection if server is not "localhost"
if server == 'localhost':
# create connection to localhost
s = smtplib.SMTP(server)
else:
password = mail_params.get('password')
# read password from docker secret if it is set to 'DOCKER' or
# read password from environment variable if it is set to 'ENV'
if password == 'DOCKER':
try:
with open('/run/secrets/mail_password', 'r') as f:
password = f.read().strip()
except FileNotFoundError as e:
logging.error('Could not read mail password from docker secret')
logging.error(e)
elif password == 'ENV':
password = os.environ.get(mail_params.get('password_env'))
# create SSL connection to server
s = smtplib.SMTP_SSL(server, mail_params.get('port'))
s.login(mail_params.get('user'), mail_params.get('password'))
# send mail and close connection
s.send_message(msg)
s.quit()