Compare commits

...

9 Commits

8 changed files with 50 additions and 27 deletions

23
config_example/config.j2 Normal file
View File

@ -0,0 +1,23 @@
import logging
DEBUG = False
#
# Logging
#
APP_NAME = "file2mail"
LOG_HOSTNAME = "loggy" # When DEBUG is True
LOG_LEVEL = logging.INFO # STDOUT logging
# Folder to be monitored for new files
TARGET_FOLDER = "{{ server_ftp_scan_target_folder }}"
# Recipiant for the files found in TARGET_PATH
SEND_TO = "scan@mount-mockery.de"
# Sender
SEND_FROM = "Scanner <scan@<smtp_server>>"
SMTP_SERVER = "{{ server_ftp_scan_smtp_server }}"
SMTP_USER = "{{ server_ftp_scan_smtp_user }}"
SMTP_PASSWORD = "{{ server_ftp_scan_smtp_password }}"

View File

@ -1,14 +0,0 @@
# Folder to be monitored for new files
TARGET_FOLDER = "<target_folder>"
# Recipiant for the files found in TARGET_PATH
SEND_TO = "scan@mount-mockery.de"
# Sender
SEND_FROM = "Scanner <scan@<smtp_server>>"
SMTP_SERVER = "<smtp_server>"
SMTP_USER = "<smtp_user>"
SMTP_PASSWORD = "<smtp_password>"
# Possible log-levels: DEBUG, INFO, WARNING, ERROR
LOG_LEVEL = "INFO"

View File

@ -2,11 +2,9 @@
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import config import config
import fstools import fstools
import json
import logging import logging
import mail import mail
import os import os
import psutil
import report import report
import signal import signal
import time import time
@ -14,9 +12,7 @@ import time
CYCLE_TIME = 60 CYCLE_TIME = 60
SLEEP_TIME = .5 SLEEP_TIME = .5
logger = logging.getLogger('root') logger = report.default_logging_config()
report.stdoutLoggingConfigure(log_name_lvl=[('root', config.LOG_LEVEL), ])
class GracefulKiller: class GracefulKiller:
kill_now = False kill_now = False

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
# #
BASEPATH=`dirname $0` BASEPATH=`dirname $0`
python $BASEPATH/file2mail.py $BASEPATH/venv/bin/python $BASEPATH/file2mail.py

@ -1 +1 @@
Subproject commit c10e8792abb05671dab6de51cdadda3bf8ead50f Subproject commit 9237f6f7f77eed79b8163077c1b4d87189193fbe

View File

@ -1,8 +1,24 @@
#!/bin/sh #!/bin/bash
# #
BASEPATH=`realpath $(dirname $0)` BASEPATH=`realpath $(dirname $0)`
python3 -m venv $BASEPATH/venv #
$BASEPATH/venv/bin/pip install --upgrade pip # Create venv
find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r #
$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U if [[ ! -e $BASEPATH/venv ]]; then
python3 -m venv $BASEPATH/venv > /dev/null 2>&1
# $BASEPATH/venv/bin/pip install --upgrade pip
find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r > /dev/null 2>&1
echo "venv changed"
fi
#
# Update venv modules
#
for req_mod in $($BASEPATH/venv/bin/pip list --format=json | jq -r '.[] | .name'); do
$BASEPATH/venv/bin/pip install -U $req_mod | grep install > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
echo $req_mod changed
fi
done
#|xargs -n1 $BASEPATH/venv/bin/pip install -U

2
report

@ -1 +1 @@
Subproject commit b53dd30eae1d679b7eec4999bec50aed55bc105b Subproject commit 60be78310ee6b6a5a091f27f9e5e514927d7520f

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
pathlib
psutil