zt-devops-cli 0.1.6__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zt-devops-cli
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: DevOps 平台迭代管理 CLI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "zt-devops-cli"
7
- version = "0.1.6"
7
+ version = "0.1.7"
8
8
  description = "DevOps 平台迭代管理 CLI"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -91,10 +91,10 @@ def open_login_page(page) -> bool:
91
91
 
92
92
  def get_cookies_from_browser() -> dict:
93
93
  """通过 Playwright 从浏览器获取 cookie"""
94
- print("正在打开浏览器,请登录...")
94
+ print("正在启动浏览器(无头模式),请登录...")
95
95
 
96
96
  with sync_playwright() as p:
97
- browser = p.chromium.launch(headless=False)
97
+ browser = p.chromium.launch(headless=True)
98
98
  context = browser.new_context()
99
99
  page = context.new_page()
100
100
 
@@ -103,9 +103,16 @@ def get_cookies_from_browser() -> dict:
103
103
 
104
104
  # 尝试自动登录
105
105
  if not open_login_page(page):
106
- print("自动登陆失败. 请在浏览器中完成登录,登录成功后会自动继续...")
107
-
108
- print("登陆中.检测关键 cookie 出现")
106
+ print(
107
+ "自动登录失败。无头模式下无法手动操作页面,请设置环境变量 "
108
+ "ZT_SSO_USERNAME ZT_SSO_PASSWORD 后重试。"
109
+ )
110
+ browser.close()
111
+ raise RuntimeError(
112
+ "无头模式需要 ZT_SSO_USERNAME / ZT_SSO_PASSWORD 环境变量以完成自动登录。"
113
+ )
114
+
115
+ print("等待登录完成...")
109
116
  page.wait_for_function(
110
117
  f"""() => {{
111
118
  const cookies = document.cookie;
@@ -151,7 +158,7 @@ def get_cookies_from_browser() -> dict:
151
158
 
152
159
  def login() -> dict:
153
160
  """手动登录 - 强制打开浏览器重新获取 cookie"""
154
- print("正在打开浏览器,请重新登录...")
161
+ print("正在启动浏览器(无头模式),请重新登录...")
155
162
  cookies = get_cookies_from_browser()
156
163
  save_cookies(cookies)
157
164
  print("登录成功,cookie 已缓存!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zt-devops-cli
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: DevOps 平台迭代管理 CLI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
File without changes
File without changes