Skip to content

Commit abcfdc4

Browse files
author
Anycodes
committed
fix: Windows encoding compatibility
1 parent d3756b8 commit abcfdc4

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
- name: Install and test package
3030
run: |
3131
pip install .
32-
python -c "import serverless_devs; print(' Version:', serverless_devs.__version__)"
33-
python -c "from serverless_devs.installer import install_serverless_devs; print(' Installer module OK')"
32+
python -c "import serverless_devs; print('[OK] Version:', serverless_devs.__version__)"
33+
python -c "from serverless_devs.installer import install_serverless_devs; print('[OK] Installer module OK')"
3434
3535
# 阶段2: 完整安装测试(仅在 Ubuntu 和 macOS 上测试,更快)
3636
test-full-installation:
@@ -65,4 +65,4 @@ jobs:
6565
run: |
6666
export PATH="$(npm bin -g):$PATH"
6767
s --version
68-
echo " Full installation test passed"
68+
echo "[OK] Full installation test passed"

serverless_devs/installer.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def install_on_windows(non_interactive=False):
4545

4646
# 检查 npm 是否可用
4747
if not is_command_available('npm'):
48-
print("\n 未检测到 npm,正在尝试安装 Node.js...")
48+
print("\n[FAIL] 未检测到 npm,正在尝试安装 Node.js...")
4949
print(" Windows 用户请手动安装 Node.js:")
5050
print(" 下载地址: https://nodejs.org/")
5151
return False
@@ -67,16 +67,16 @@ def install_on_windows(non_interactive=False):
6767
)
6868

6969
if result.returncode == 0:
70-
print("\n 安装成功!")
70+
print("\n[OK] 安装成功!")
7171
return True
7272
else:
73-
print("\n npm 安装失败")
73+
print("\n[FAIL] npm 安装失败")
7474
if result.stderr:
7575
print(result.stderr)
7676
return False
7777

7878
except Exception as e:
79-
print(f"\n 安装失败: {e}")
79+
print(f"\n[FAIL] 安装失败: {e}")
8080
return False
8181

8282
def install_on_unix(non_interactive=False):
@@ -86,11 +86,11 @@ def install_on_unix(non_interactive=False):
8686

8787
# 检查必要的命令
8888
if not is_command_available('curl') and not is_command_available('wget'):
89-
print("\n 错误: 需要 curl 或 wget 命令")
89+
print("\n[FAIL] 错误: 需要 curl 或 wget 命令")
9090
return False
9191

9292
if not is_command_available('bash'):
93-
print("\n 错误: 需要 bash")
93+
print("\n[FAIL] 错误: 需要 bash")
9494
return False
9595

9696
# 选择下载工具
@@ -128,15 +128,15 @@ def install_on_unix(non_interactive=False):
128128
)
129129

130130
if download_result.returncode != 0:
131-
print(f"\n 下载失败: {download_result.stderr}")
131+
print(f"\n[FAIL] 下载失败: {download_result.stderr}")
132132
if not use_mirror:
133133
print("\n提示: 可以尝试使用国内镜像:")
134134
print(" export USE_MIRROR=1")
135135
print(" s-install")
136136
return False
137137

138138
if not non_interactive:
139-
print(" 下载完成")
139+
print("[OK] 下载完成")
140140

141141
# 添加执行权限
142142
os.chmod(temp_script, 0o755)
@@ -166,21 +166,21 @@ def install_on_unix(non_interactive=False):
166166
if install_result.returncode == 0:
167167
if not non_interactive:
168168
print("="*60)
169-
print(" 安装成功!")
169+
print("[OK] 安装成功!")
170170
return True
171171
else:
172172
if not non_interactive:
173173
print("="*60)
174-
print(" 安装失败")
174+
print("[FAIL] 安装失败")
175175
if non_interactive and install_result.stderr:
176176
print(install_result.stderr)
177177
return False
178178

179179
except subprocess.TimeoutExpired:
180-
print("\n 下载超时,请检查网络连接")
180+
print("\n[FAIL] 下载超时,请检查网络连接")
181181
return False
182182
except Exception as e:
183-
print(f"\n 安装过程出错: {e}")
183+
print(f"\n[FAIL] 安装过程出错: {e}")
184184
return False
185185

186186
def install_serverless_devs(non_interactive=False):
@@ -203,7 +203,7 @@ def install_serverless_devs(non_interactive=False):
203203
if is_installed:
204204
if non_interactive:
205205
# 非交互模式:已安装则跳过
206-
print(f" Serverless Devs 已安装: {version}")
206+
print(f"[OK] Serverless Devs 已安装: {version}")
207207
return True
208208
else:
209209
# 交互模式:询问是否重新安装
@@ -227,7 +227,7 @@ def install_serverless_devs(non_interactive=False):
227227

228228
is_installed, version = check_existing_installation()
229229
if is_installed:
230-
print(f" 验证成功! 已安装版本: {version}")
230+
print(f"[OK] 验证成功! 已安装版本: {version}")
231231
if not non_interactive:
232232
print("\n" + "="*60)
233233
print("安装完成! 请运行以下命令开始使用:")
@@ -237,7 +237,7 @@ def install_serverless_devs(non_interactive=False):
237237
print("="*60)
238238
return True
239239
else:
240-
print(" 验证失败: 找不到 s 命令")
240+
print("[FAIL] 验证失败: 找不到 s 命令")
241241
print("\n请尝试:")
242242
print(" 1. 重新打开终端")
243243
print(" 2. 运行: source ~/.bashrc (或 ~/.zshrc)")

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ def run(self):
2020

2121
if success:
2222
print("\n" + "="*60)
23-
print(" Serverless Devs 安装完成!")
23+
print("[OK] Serverless Devs 安装完成!")
2424
print(" 运行 's --version' 查看版本")
2525
print(" 运行 's config add' 配置密钥")
2626
print(" 运行 's init' 初始化项目")
2727
print("="*60 + "\n")
2828
else:
2929
print("\n" + "="*60)
30-
print(" 自动安装失败")
30+
print("[FAIL] 自动安装失败")
3131
print(" 请手动运行: s-install")
3232
print(" 或使用 npm: npm install -g @serverless-devs/s")
3333
print("="*60 + "\n")

0 commit comments

Comments
 (0)