Skip to content

Commit

Permalink
Add environment variable and synchroize verbosity across processes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTyton committed Jul 16, 2024
1 parent 6b46cc0 commit 3bbb6af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ VOLUME /config
WORKDIR /config

#ENTRYPOINT ["/init"]
CMD python -u /app/fanficdownload.py --config="/config/config.toml" --verbose=${VERBOSE}
CMD sh -c 'if [ "$VERBOSE" = "true" ]; then python -u /app/fanficdownload.py --config="/config/config.toml" --verbose; else python -u /app/fanficdownload.py --config="/config/config.toml"; fi'
8 changes: 5 additions & 3 deletions root/app/ff_logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ctypes
import datetime
from multiprocessing import Value


class bcolors:
Expand Down Expand Up @@ -27,7 +29,8 @@ class bcolors:
"UNDERLINE": bcolors.UNDERLINE,
}

verbose = False
# Initialize a shared variable for the verbose flag
verbose = Value(ctypes.c_bool, False)


def set_verbose(value: bool) -> None:
Expand All @@ -37,8 +40,7 @@ def set_verbose(value: bool) -> None:
Args:
value (bool): The value to set the verbose flag to.
"""
global verbose
verbose = value
verbose.value = value


def log(msg: str, color: str = None) -> None:
Expand Down

0 comments on commit 3bbb6af

Please sign in to comment.