Skip to content
Snippets Groups Projects
Commit eeab90e5 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

Merge branch 'fix-tester-mail-sender'

parents 2a9ee9f7 9490bbdb
No related branches found
No related tags found
No related merge requests found
FROM ubuntu:bionic
# Set the default shell to bash instead of sh
ENV SHELL /bin/bash
# Update path to include virtualenv
ENV PATH "/usr/local/pyvenv/bin:${PATH}"
# Set locales
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# Configure apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install --no-install-recommends apt-utils 2>&1
# Install git, required tools
RUN apt-get update && \
apt-get install -y \
apt-transport-https \
bash-completion \
build-essential \
ca-certificates \
curl \
git \
gnupg-agent \
libffi-dev \
libssl-dev \
lsb-release \
procps \
python3 \
python3-dev \
python3-venv \
shellcheck \
software-properties-common \
unzip \
vim-tiny \
2>&1
# Configure shell
RUN sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/' /root/.bashrc && \
echo ". /etc/bash_completion" >> /root/.bashrc
# Install Docker CE CLI.
RUN curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce-cli
# Install Poetry
RUN python3 -m venv /usr/local/pyvenv && \
pip install -U pip wheel 2>&1 && \
pip install psutil pyOpenSSL pyspf requests defusedxml 2>&1 && \
pip install black flake8 pre-commit pylint pysnooper 2>&1
# Clean up
RUN apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog
{
"name": "envsetup",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"extensions": [
// editor
"editorconfig.editorconfig",
"mikestead.dotenv",
// python
"ms-python.python",
// docker
"peterjausovec.vscode-docker"
]
}
---
version: '3'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/workspace
- ~/.config/git/config:/root/.config/git/config
- ~/.config/git/ignore:/root/.config/git/ignore
- ${SSH_AUTH_SOCK}:/ssh-agent
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SSH_AUTH_SOCK=/ssh-agent
working_dir: /workspace
command: sleep infinity
...
......@@ -6,7 +6,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 6d7906e131976a1ce14ab583badb734727c5da3e
rev: 45fc394c19e208123b8e9ec3f584c7ae3adef8c4
hooks:
- id: flake8
......
This diff is collapsed.
[tool.poetry]
name = "envsetup"
version = "0.1.0"
description = "Deploy, configure and test UbiCast solutions."
authors = ["UbiCast <sysadmin@ubicast.eu>"]
[tool.poetry.dependencies]
python = "^3.5"
pyspf = "2.0.11"
pyOpenSSL = "^19.0"
requests = "^2.21"
psutil = "^5.6"
defusedxml = "^0.6.0"
[tool.poetry.dev-dependencies]
pylint = "^2.3"
flake8 = "^3.7"
black = {version = "*",allows-prereleases = true,python = "^3.6"}
pysnooper = "^0.0.23"
bandit = "^1.5"
pre-commit = "^1.15"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
......@@ -4,6 +4,7 @@
Script to start tests and to manage their results
"""
import base64
from io import StringIO
import datetime
import os
......@@ -324,7 +325,10 @@ class Tester:
log("Test start: %s UTC." % start_date.strftime("%Y-%m-%d %H:%M:%S"))
# Run test
p = subprocess.Popen(
command, stdin=sys.stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
command,
stdin=sys.stdin,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
out, err = p.communicate()
if out:
......@@ -478,6 +482,7 @@ class Tester:
log(consecutive_msg)
html_report += "\n<br/>" + consecutive_msg.replace("\n", "\n<br/>")
if send_email:
sender = utils.get_conf("EMAIL_SENDER", "root@%s" % hostname)
recipients = utils.get_conf("EMAIL_ADMINS") or ""
system_domain = utils.get_conf("MS_SERVER_NAME")
system_type = "MediaServer"
......@@ -506,7 +511,7 @@ class Tester:
)
return 1
boundary = str(uuid.uuid4())
mail = """From: %(hostname)s <support@ubicast.eu>
mail = """From: %(hostname)s <%(sender)s>
To: %(recipients)s
Subject: %(system_domain)s (%(hostname)s) %(system_type)s health report: %(status)s
Mime-Version: 1.0
......@@ -522,17 +527,18 @@ Content-transfer-encoding: utf-8
--%(boundary)s
Content-type: text/plain; name="%(log_name)s"; charset=UTF-8
Content-disposition: attachment; filename="%(log_name)s"
Content-transfer-encoding: utf-8
Content-transfer-encoding: base64
%(log_content)s""" % dict(
boundary=boundary,
sender=sender,
hostname=hostname,
recipients=recipients,
status=("KO (%s tests failed)" % failures) if failures > 0 else "OK",
date=now.strftime("%Y-%m-%d %H:%M:%S"),
report=html_report,
log_name=log_name,
log_content=log_content,
log_content=base64.b64encode(log_content.encode("utf-8")).decode(),
system_domain=system_domain,
system_type=system_type,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment