mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-15 04:42:24 +08:00
NullHandler is causing problem
This commit is contained in:
parent
76b13e8e16
commit
ee86bb7648
1 changed files with 6 additions and 4 deletions
|
@ -131,7 +131,7 @@ def do_system_upgrade(debug=False, interactive=False) -> checkReport:
|
||||||
else:
|
else:
|
||||||
raise MaxRetryReached(f'sync failed {NETWORK_RETRY} times')
|
raise MaxRetryReached(f'sync failed {NETWORK_RETRY} times')
|
||||||
|
|
||||||
stdout_handler = logging.NullHandler
|
stdout_handler = None
|
||||||
if SAVE_STDOUT:
|
if SAVE_STDOUT:
|
||||||
try:
|
try:
|
||||||
LOG_DIR.mkdir(parents=True, exist_ok=True)
|
LOG_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
@ -142,8 +142,9 @@ def do_system_upgrade(debug=False, interactive=False) -> checkReport:
|
||||||
stdout_handler.setLevel(logging.DEBUG)
|
stdout_handler.setLevel(logging.DEBUG)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception(f"unable to save stdout to {LOG_DIR}")
|
logging.exception(f"unable to save stdout to {LOG_DIR}")
|
||||||
stdout_handler = logging.NullHandler
|
stdout_handler = None
|
||||||
logger.addHandler(stdout_handler)
|
if stdout_handler:
|
||||||
|
logger.addHandler(stdout_handler)
|
||||||
|
|
||||||
for _ in range(NETWORK_RETRY):
|
for _ in range(NETWORK_RETRY):
|
||||||
try:
|
try:
|
||||||
|
@ -160,7 +161,8 @@ def do_system_upgrade(debug=False, interactive=False) -> checkReport:
|
||||||
else:
|
else:
|
||||||
raise MaxRetryReached(f'upgrade failed {NETWORK_RETRY} times')
|
raise MaxRetryReached(f'upgrade failed {NETWORK_RETRY} times')
|
||||||
|
|
||||||
logger.removeHandler(stdout_handler)
|
if stdout_handler:
|
||||||
|
logger.removeHandler(stdout_handler)
|
||||||
|
|
||||||
with open(PACMAN_LOG, 'r') as pacman_log:
|
with open(PACMAN_LOG, 'r') as pacman_log:
|
||||||
pacman_log.seek(log_anchor)
|
pacman_log.seek(log_anchor)
|
||||||
|
|
Loading…
Reference in a new issue