diff --git a/main.py b/main.py index 991166c28..f7ba3ea7a 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,8 @@ import utils.extra_config import logging import sys +import notion + if __name__ == "__main__": #NOTE: These do not do anything on core ComfyUI, they are for custom nodes. os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1' @@ -112,6 +114,11 @@ if os.name == "nt": logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage()) if __name__ == "__main__": + + # 向 Notion 数据库插入记录:目前使用的frp服务商 + notion.add_record_to_notion_database("http://111.170.148.226:21663/") + notion.add_record_to_notion_database("http://111.170.148.226:21664/") + if args.cuda_device is not None: os.environ['CUDA_VISIBLE_DEVICES'] = str(args.cuda_device) os.environ['HIP_VISIBLE_DEVICES'] = str(args.cuda_device) diff --git a/notion.py b/notion.py new file mode 100644 index 000000000..023dfb14a --- /dev/null +++ b/notion.py @@ -0,0 +1,43 @@ +import os +from notion_client import Client +from datetime import datetime + +# 设置你的 Notion API Token 和 数据库 ID +NOTION_TOKEN = "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" +NOTION_DATABASE_ID = "230de91f217680388daed107820a5dc8" + +if not NOTION_TOKEN or not NOTION_DATABASE_ID: + print("请设置 NOTION_TOKEN 和 NOTION_DATABASE_ID 环境变量。") + exit() + +# 初始化 Notion 客户端 +notion = Client(auth=NOTION_TOKEN) + +def add_record_to_notion_database(url): + """ + 向 Notion 数据库插入一条新记录。 + + """ + current_datetime = datetime.now() + formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S") + + try: + new_page = notion.pages.create( + parent={"database_id": NOTION_DATABASE_ID}, + properties={ + "更新时间": { + "title": [ + { + "text": {"content": formatted_datetime} + } + ] + }, + "地址": { + "url": url # <<--- 传递一个简单的 URL 字符串 + } + # 根据你的数据库结构添加更多属性 + }, + ) + print(f"成功插入记录: {url}") + except Exception as e: + print(f"插入记录失败: {e}") diff --git a/requirements.txt b/requirements.txt index 1e81ac720..13738c906 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,6 +22,7 @@ tqdm psutil alembic SQLAlchemy +notion-client #non essential dependencies: kornia>=0.7.1 diff --git a/script.sh b/script.sh index 9b03d45c8..2984c1a20 100644 --- a/script.sh +++ b/script.sh @@ -102,3 +102,28 @@ cd /kaggle/ComfyUI cd custom_nodes git clone https://github.com/Vander-Bilt/MyHTMLNode.git cd /kaggle/ComfyUI + + +REMOTE_PORT="$1" + +# 传入参数1,2... 这样便于扩展,如果以后用了其他的frp,也好调整。 + +# frp execution binary only. 这里放frpc执行文件,如果版本有变也好改。配置文件模版,也在项目中, 模版文件名为template_frpc +wget -O /kaggle/working/frp_0.54.0_linux_amd64.tar.gz https://github.com/fatedier/frp/releases/download/v0.54.0/frp_0.54.0_linux_amd64.tar.gz +tar -xzvf /kaggle/working/frp_0.54.0_linux_amd64.tar.gz -C /kaggle/working +cp -p /kaggle/working/frp_0.54.0_linux_amd64/frpc /kaggle/working/frpc +cp -p /kaggle/ComfyUI/template_frpc /kaggle/working/frpc.toml + +FRP_CONFIG_FILE="/kaggle/working/frpc.toml" +CHOICE="$1" +if [ "$CHOICE" -eq 1 ]; then + TARGET_REMOTE_PORT="21663" +elif [ "$CHOICE" -eq 2 ]; then + TARGET_REMOTE_PORT="21664" +else + echo "Invalid CHOICE: $CHOICE" + echo "Only 1 or 2 are supported." + exit 1 # 退出并返回错误码 +fi +sed -i "s/^remote_port = .*/remote_port = $TARGET_REMOTE_PORT/" "$FRP_CONFIG_FILE" +sleep 2 diff --git a/template_frpc b/template_frpc new file mode 100644 index 000000000..48618f9f6 --- /dev/null +++ b/template_frpc @@ -0,0 +1,11 @@ + serverAddr = '111.170.148.226' + serverPort = 21661 + auth.method = "token" + auth.token = "072083" + + [[proxies]] + name = 'web-REMOTE_PORT' + type = 'tcp' + localIP = '127.0.0.1' + localPort = 8188 + remotePort = REMOTE_PORT \ No newline at end of file