Notify when issue #147 occurs
This commit is contained in:
parent
d9851adf65
commit
693e8f195d
5
.envrc
5
.envrc
@ -1,4 +1,9 @@
|
|||||||
layout poetry
|
layout poetry
|
||||||
|
export MAIL_PASSWORD="ewacyay5seu2qske"
|
||||||
|
export MAIL_PORT=587
|
||||||
|
export MAIL_SERVER="smtp.fastmail.com"
|
||||||
|
export MAIL_USERNAME="kae@midnighthax.com"
|
||||||
|
export MAIL_USE_TLS=True
|
||||||
branch=$(git branch --show-current)
|
branch=$(git branch --show-current)
|
||||||
if on_git_branch master; then
|
if on_git_branch master; then
|
||||||
export MM_ENV="PRODUCTION"
|
export MM_ENV="PRODUCTION"
|
||||||
|
|||||||
@ -54,6 +54,7 @@ class Config(object):
|
|||||||
DEFAULT_IMPORT_DIRECTORY = "/home/kae/Nextcloud/tmp"
|
DEFAULT_IMPORT_DIRECTORY = "/home/kae/Nextcloud/tmp"
|
||||||
DEFAULT_OUTPUT_DIRECTORY = "/home/kae/music/Singles"
|
DEFAULT_OUTPUT_DIRECTORY = "/home/kae/music/Singles"
|
||||||
DISPLAY_SQL = False
|
DISPLAY_SQL = False
|
||||||
|
ERRORS_FROM = ['noreply@midnighthax.com']
|
||||||
ERRORS_TO = ['kae@midnighthax.com']
|
ERRORS_TO = ['kae@midnighthax.com']
|
||||||
FADE_STEPS = 20
|
FADE_STEPS = 20
|
||||||
FADE_TIME = 3000
|
FADE_TIME = 3000
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
import psutil
|
import psutil
|
||||||
import shutil
|
import shutil
|
||||||
|
import smtplib
|
||||||
|
import ssl
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from email.message import EmailMessage
|
||||||
from mutagen.flac import FLAC # type: ignore
|
from mutagen.flac import FLAC # type: ignore
|
||||||
from mutagen.mp3 import MP3 # type: ignore
|
from mutagen.mp3 import MP3 # type: ignore
|
||||||
from pydub import effects
|
from pydub import effects
|
||||||
@ -159,6 +162,32 @@ def leading_silence(
|
|||||||
return min(trim_ms, len(audio_segment))
|
return min(trim_ms, len(audio_segment))
|
||||||
|
|
||||||
|
|
||||||
|
def send_mail(to_addr, from_addr, subj, body):
|
||||||
|
# From https://docs.python.org/3/library/email.examples.html
|
||||||
|
|
||||||
|
# Create a text/plain message
|
||||||
|
msg = EmailMessage()
|
||||||
|
msg.set_content(body)
|
||||||
|
|
||||||
|
msg['Subject'] = subj
|
||||||
|
msg['From'] = from_addr
|
||||||
|
msg['To'] = to_addr
|
||||||
|
|
||||||
|
# Send the message via SMTP server.
|
||||||
|
context = ssl.create_default_context()
|
||||||
|
try:
|
||||||
|
s = smtplib.SMTP(host=Config.MAIL_SERVER, port=Config.MAIL_PORT)
|
||||||
|
if Config.MAIL_USE_TLS:
|
||||||
|
s.starttls(context=context)
|
||||||
|
if Config.MAIL_USERNAME and Config.MAIL_PASSWORD:
|
||||||
|
s.login(Config.MAIL_USERNAME, Config.MAIL_PASSWORD)
|
||||||
|
s.send_message(msg)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
finally:
|
||||||
|
s.quit()
|
||||||
|
|
||||||
|
|
||||||
def ms_to_mmss(ms: int, decimals: int = 0, negative: bool = False) -> str:
|
def ms_to_mmss(ms: int, decimals: int = 0, negative: bool = False) -> str:
|
||||||
"""Convert milliseconds to mm:ss"""
|
"""Convert milliseconds to mm:ss"""
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@ from helpers import (
|
|||||||
get_relative_date,
|
get_relative_date,
|
||||||
ms_to_mmss,
|
ms_to_mmss,
|
||||||
open_in_audacity,
|
open_in_audacity,
|
||||||
|
send_mail,
|
||||||
set_track_metadata,
|
set_track_metadata,
|
||||||
)
|
)
|
||||||
from log import log
|
from log import log
|
||||||
@ -1954,7 +1955,9 @@ class PlaylistTab(QTableWidget):
|
|||||||
try:
|
try:
|
||||||
self.item(playlist_row.row_number, column).setText(new_text)
|
self.item(playlist_row.row_number, column).setText(new_text)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
msg = f"Issue 147 occurred. {playlist_row=}, {additional_text=}"
|
||||||
|
helpers.send_mail(Config.ERRORS_TO, Confit.ERRORS_FROM,
|
||||||
|
"Issue #147 from musicmuster", msg)
|
||||||
|
|
||||||
def _update_row(self, session, row: int, track: Tracks) -> None:
|
def _update_row(self, session, row: int, track: Tracks) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user