fixed: datetime.datetime crash - use hasattr instead of exception handling

https://github.com/ltdrdata/ComfyUI-Manager/issues/1503
This commit is contained in:
Dr.Lt.Data
2025-02-01 11:37:53 +09:00
parent 4760deaf9c
commit 1a7edf7f0e
3 changed files with 7 additions and 7 deletions

View File

@@ -20,13 +20,13 @@ import cm_global
import manager_downloader
import folder_paths
try:
from datetime import datetime
import datetime
if hasattr(datetime, 'datetime'):
def current_timestamp():
return datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
except:
return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
else:
# NOTE: Occurs in some Mac environments.
import time
import datetime
logging.error(f"[ComfyUI-Manager] fallback timestamp mode\n datetime module is invalid: '{datetime.__file__}'")
def current_timestamp():
return str(time.time()).split('.')[0]