flip writing when in scripts

This commit is contained in:
2019-10-20 10:29:49 +03:00
parent c1b4ee8a23
commit 232e99fee6
4 changed files with 21 additions and 15 deletions

3
code/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
*.pyc
__pycache__
*.swp

View File

@@ -11,10 +11,7 @@ COPY docker-requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
COPY static /code/static
COPY templates /code/templates
COPY utils/__init__.py /code/utils/__init__.py
COPY utils/files.py /code/utils/files.py
COPY utils/misc.py /code/utils/misc.py
COPY utils/crypt.py /code/utils/crypt.py
COPY utils /code/utils
COPY revprox.py /code/revprox.py
COPY notifier.py /code/notifier.py
COPY app.py /code/app.py

View File

@@ -13,7 +13,7 @@ from revprox import ReverseProxied
from utils import *
__FLEES_VERSION__ = "20190830.0"
__FLEES_VERSION__ = "20191020.0"
app = Flask(__name__)
app.config.from_object(__name__)
config_values = read_config(app)

View File

@@ -72,6 +72,8 @@ _simple_list() {
}
_write() {
# stdin is open
[ -t 0 ] || stream_in=1
# no file mentioned, use the name as file
[[ -z "$FILE" ]] && {
[[ -e "$NAME" ]] && {
@@ -80,24 +82,28 @@ _write() {
NAME=$( basename "$NAME" )
}
}
# stdin is open, use stdin
[ -t 0 ] || stream_in=1
[[ -e "$FILE" ]] && {
# Input file exists, dont use stream
stream_in=0
}
[ -t 0 ] && [[ -z "$FILE" ]] && {
[[ $stream_in -ne 1 ]] && [[ -z "$FILE" ]] && {
_msg File to read needed, or use stdin
exit 1
}
_msg "Writing $NAME"
[[ "$stream_in" -eq 1 ]] && {
_write_stdin "$NAME"
} || {
return $?
}
[[ -d "$FILE" ]] && {
[[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar
_write_folder "$NAME" "$FILE"
} || {
return $?
}
_write_file "$NAME" "$FILE"
}
}
}
_write_folder() { # name, file