scalebox-sdk 0.1.25__py3-none-any.whl → 1.0.2__py3-none-any.whl

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.
Files changed (78) hide show
  1. scalebox/__init__.py +2 -2
  2. scalebox/api/__init__.py +3 -1
  3. scalebox/api/client/api/sandboxes/get_sandboxes.py +1 -1
  4. scalebox/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
  5. scalebox/api/client/models/connect_sandbox.py +59 -0
  6. scalebox/api/client/models/error.py +2 -2
  7. scalebox/api/client/models/listed_sandbox.py +24 -3
  8. scalebox/api/client/models/new_sandbox.py +10 -0
  9. scalebox/api/client/models/sandbox.py +13 -0
  10. scalebox/api/client/models/sandbox_detail.py +24 -0
  11. scalebox/cli.py +125 -125
  12. scalebox/client/aclient.py +57 -57
  13. scalebox/client/client.py +102 -102
  14. scalebox/code_interpreter/__init__.py +12 -12
  15. scalebox/code_interpreter/charts.py +230 -230
  16. scalebox/code_interpreter/code_interpreter_async.py +3 -1
  17. scalebox/code_interpreter/code_interpreter_sync.py +3 -1
  18. scalebox/code_interpreter/constants.py +3 -3
  19. scalebox/code_interpreter/exceptions.py +13 -13
  20. scalebox/code_interpreter/models.py +485 -485
  21. scalebox/connection_config.py +36 -1
  22. scalebox/csx_connect/__init__.py +1 -1
  23. scalebox/csx_connect/client.py +485 -485
  24. scalebox/csx_desktop/main.py +651 -651
  25. scalebox/exceptions.py +83 -83
  26. scalebox/generated/api.py +61 -61
  27. scalebox/generated/api_pb2.py +203 -203
  28. scalebox/generated/api_pb2.pyi +956 -956
  29. scalebox/generated/api_pb2_connect.py +1407 -1407
  30. scalebox/generated/rpc.py +50 -50
  31. scalebox/sandbox/main.py +146 -139
  32. scalebox/sandbox/sandbox_api.py +105 -91
  33. scalebox/sandbox/signature.py +40 -40
  34. scalebox/sandbox/utils.py +34 -34
  35. scalebox/sandbox_async/main.py +226 -44
  36. scalebox/sandbox_async/sandbox_api.py +124 -3
  37. scalebox/sandbox_sync/main.py +205 -130
  38. scalebox/sandbox_sync/sandbox_api.py +119 -3
  39. scalebox/test/CODE_INTERPRETER_TESTS_READY.md +323 -323
  40. scalebox/test/README.md +329 -329
  41. scalebox/test/bedrock_openai_adapter.py +73 -0
  42. scalebox/test/code_interpreter_test.py +34 -34
  43. scalebox/test/code_interpreter_test_sync.py +34 -34
  44. scalebox/test/run_stress_code_interpreter_sync.py +178 -0
  45. scalebox/test/simple_upload_example.py +131 -0
  46. scalebox/test/stabitiy_test.py +323 -0
  47. scalebox/test/test_browser_use.py +27 -0
  48. scalebox/test/test_browser_use_scalebox.py +62 -0
  49. scalebox/test/test_code_interpreter_execcode.py +289 -211
  50. scalebox/test/test_code_interpreter_sync_comprehensive.py +116 -69
  51. scalebox/test/test_connect_pause_async.py +300 -0
  52. scalebox/test/test_connect_pause_sync.py +300 -0
  53. scalebox/test/test_csx_desktop_examples.py +3 -3
  54. scalebox/test/test_desktop_sandbox_sf.py +112 -0
  55. scalebox/test/test_download_url.py +41 -0
  56. scalebox/test/test_existing_sandbox.py +1037 -0
  57. scalebox/test/test_sandbox_async_comprehensive.py +5 -3
  58. scalebox/test/test_sandbox_object_storage_example.py +151 -0
  59. scalebox/test/test_sandbox_object_storage_example_async.py +159 -0
  60. scalebox/test/test_sandbox_sync_comprehensive.py +1 -1
  61. scalebox/test/test_sf.py +141 -0
  62. scalebox/test/test_watch_dir_async.py +58 -0
  63. scalebox/test/testacreate.py +1 -1
  64. scalebox/test/testagetinfo.py +1 -3
  65. scalebox/test/testcomputeuse.py +243 -243
  66. scalebox/test/testsandbox_api.py +5 -5
  67. scalebox/test/testsandbox_async.py +17 -47
  68. scalebox/test/testsandbox_sync.py +19 -15
  69. scalebox/test/upload_100mb_example.py +377 -0
  70. scalebox/utils/httpcoreclient.py +297 -297
  71. scalebox/utils/httpxclient.py +403 -403
  72. scalebox/version.py +2 -2
  73. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/METADATA +1 -1
  74. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/RECORD +78 -60
  75. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/WHEEL +1 -1
  76. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/entry_points.txt +0 -0
  77. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/licenses/LICENSE +0 -0
  78. {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.2.dist-info}/top_level.txt +0 -0
@@ -1,243 +1,243 @@
1
- import time
2
-
3
- from scalebox.csx_desktop.main import Sandbox
4
-
5
-
6
- def desktop_automation_demo():
7
- """桌面自动化功能演示"""
8
-
9
- # 1. 创建桌面沙箱实例
10
- print("正在启动桌面沙箱...")
11
- desktop = Sandbox(timeout=3600, template="browser-use")
12
- # print(f"沙箱已启动,ID: {desktop.sandbox_id}")
13
-
14
- # 2. 启动VNC流以便远程查看桌面
15
- print("启动VNC远程桌面...")
16
- time.sleep(5)
17
- desktop.stream.start()
18
- vnc_url = desktop.stream.get_url(auto_connect=True)
19
- print(f"VNC访问URL: {vnc_url}")
20
- # print(f"VNC认证密钥: {desktop.stream.get_auth_key()}")
21
-
22
- # 等待系统完全启动
23
- time.sleep(3)
24
-
25
- # 3. 基本鼠标操作示例
26
- print("执行鼠标操作...")
27
-
28
- # 获取屏幕尺寸
29
- screen_width, screen_height = desktop.get_screen_size()
30
- print(f"屏幕尺寸: {screen_width}x{screen_height}")
31
-
32
- # 移动鼠标到屏幕中心
33
- center_x, center_y = screen_width // 2, screen_height // 2
34
- desktop.move_mouse(center_x, center_y)
35
-
36
- # 获取当前光标位置
37
- cursor_x, cursor_y = desktop.get_cursor_position()
38
- print(f"光标位置: ({cursor_x}, {cursor_y})")
39
-
40
- # 左键点击
41
- desktop.left_click(center_x, center_y)
42
-
43
- # 右键点击
44
- desktop.right_click(center_x + 100, center_y)
45
-
46
- # 双击
47
- desktop.double_click(center_x, center_y + 100)
48
-
49
- # 鼠标拖动示例
50
- desktop.drag((center_x, center_y), (center_x + 200, center_y))
51
-
52
- # 鼠标滚动
53
- desktop.scroll("down", 2) # 向下滚动2次
54
- desktop.scroll("up", 1) # 向上滚动1次
55
-
56
- # 4. 键盘输入示例
57
- print("执行键盘操作...")
58
-
59
- # 打开终端
60
- desktop.launch("xfce4-terminal") # 或 xfce4-terminal
61
- time.sleep(2)
62
-
63
- # 获取当前窗口ID
64
- current_window = desktop.get_current_window_id()
65
- print(f"当前窗口ID: {current_window}")
66
-
67
- # 输入命令
68
- desktop.write("echo 'Hello from SBX Sandbox!'")
69
- desktop.press("enter")
70
-
71
- # 特殊按键
72
- desktop.press("ctrl+shift+t") # 新建标签页
73
- time.sleep(1)
74
-
75
- desktop.write("ls -la")
76
- desktop.press("enter")
77
-
78
- # 5. 窗口管理示例
79
- print("执行窗口管理操作...")
80
-
81
- # 获取所有可见窗口
82
- terminal_windows = desktop.get_application_windows("xfce4-terminal")
83
- print(f"终端窗口: {terminal_windows}")
84
-
85
- if terminal_windows:
86
- # 获取窗口标题
87
- window_title = desktop.get_window_title(terminal_windows[0])
88
- print(f"窗口标题: {window_title}")
89
-
90
- # 6. 启动应用程序示例
91
- print("启动其他应用程序...")
92
-
93
- # 使用gtk-launch启动应用程序
94
- try:
95
- desktop.launch("firefox-esr") # 启动Firefox浏览器
96
- time.sleep(3)
97
-
98
- # 在Firefox中输入URL
99
- desktop.press("ctrl+l") # 聚焦地址栏
100
- desktop.write("https://www.google.com")
101
- desktop.press("enter")
102
-
103
- except Exception as e:
104
- print(f"启动Firefox失败: {e}")
105
-
106
- # 7. 文件操作示例 - 创建并打开文件
107
- print("执行文件操作...")
108
-
109
- # 创建测试文件
110
- test_content = """Hello World!
111
- This is a test file created from Scalebox Sandbox SDK.
112
- Current time: {time}
113
- """.format(
114
- time=time.ctime()
115
- )
116
-
117
- desktop.files.write("/tmp/test_file.txt", test_content)
118
- print("已创建测试文件")
119
-
120
- # 使用默认程序打开文件
121
- # desktop.open("/tmp/test_file.txt")
122
- # time.sleep(2)
123
-
124
- # 8. 截图功能示例
125
- print("执行截图操作...")
126
-
127
- # 截取屏幕并保存为bytes
128
- screenshot_bytes = desktop.screenshot(format="bytes")
129
- print(f"截图大小: {len(screenshot_bytes)} 字节")
130
-
131
- # 也可以获取截图流
132
- # screenshot_stream = desktop.screenshot(format="stream")
133
- # for chunk in screenshot_stream:
134
- # # 处理截图数据
135
- # pass
136
-
137
- # 9. 复杂自动化脚本示例
138
- print("执行复杂自动化任务...")
139
-
140
- # 返回终端窗口
141
- terminal_windows = desktop.get_application_windows("xfce4-terminal")
142
- if terminal_windows:
143
- # 激活终端窗口
144
- desktop.commands.run(
145
- f"DISPLAY={desktop._display} xdotool windowactivate {terminal_windows[0]}"
146
- )
147
-
148
- # 创建Python脚本并执行
149
- python_script = """#!/usr/bin/env python3
150
- import time
151
- print("starting...")
152
- for i in range(5):
153
- print(f"count: {i}")
154
- time.sleep(0.5)
155
- print("success!")
156
- """
157
-
158
- script_path = "/tmp/automation_script.py"
159
- desktop.files.write(script_path, python_script)
160
-
161
- desktop.write(f"python3 /uploads{script_path}")
162
- desktop.press("enter")
163
-
164
- # 10. 等待和定时操作
165
- print("等待操作完成...")
166
- desktop.wait(2000) # 等待2秒
167
-
168
- # 展示所有功能已完成
169
- desktop.write("echo 'All successfully!'")
170
- desktop.press("enter")
171
-
172
- print("演示完成! 沙箱将在10分钟后自动关闭或按Ctrl+C提前结束")
173
-
174
- # 保持沙箱运行以便观察
175
- try:
176
- time.sleep(600) # 保持10分钟
177
- except KeyboardInterrupt:
178
- print("提前结束沙箱会话")
179
-
180
- # 11. 清理工作会在with语句退出时自动执行
181
-
182
-
183
- # def specific_use_cases():
184
- # """特定用例示例"""
185
- #
186
- # # 用例1: 网页自动化测试
187
- # def web_automation():
188
- # with Sandbox() as desktop:
189
- # desktop.open("firefox")
190
- # time.sleep(3)
191
- # desktop.press("ctrl+l")
192
- # desktop.write("https://www.google.com")
193
- # desktop.press("enter")
194
- # time.sleep(2)
195
- # desktop.write("Scalebox Sandbox Automation")
196
- # desktop.press("enter")
197
- # # 更多网页自动化操作...
198
- #
199
- # # 用例2: GUI应用测试
200
- # def gui_app_testing():
201
- # with Sandbox() as desktop:
202
- # # 启动待测试的GUI应用
203
- # desktop.launch("some-gui-application")
204
- # time.sleep(2)
205
- #
206
- # # 执行一系列测试操作
207
- # desktop.move_mouse(100, 100)
208
- # desktop.left_click()
209
- # desktop.write("测试输入")
210
- # desktop.press("enter")
211
- #
212
- # # 验证结果
213
- # screenshot = desktop.screenshot(format="bytes")
214
- # # 这里可以添加截图分析逻辑
215
- #
216
- # # 用例3: 教育演示
217
- # def educational_demo():
218
- # with Sandbox() as desktop:
219
- # # 打开编程环境
220
- # desktop.open("vscode") # 或其他IDE
221
- #
222
- # # 逐步演示代码编写和执行过程
223
- # time.sleep(2)
224
- # desktop.write("# Python编程演示")
225
- # desktop.press("enter")
226
- # desktop.write("print('Hello, Students!')")
227
- # desktop.press("enter")
228
- #
229
- # # 保存并运行
230
- # desktop.press("ctrl+s")
231
- # desktop.press("ctrl+alt+t") # 打开终端
232
- # desktop.write("python3 demo.py")
233
- # desktop.press("enter")
234
-
235
-
236
- if __name__ == "__main__":
237
- try:
238
- desktop_automation_demo()
239
- except Exception as e:
240
- print(f"演示过程中发生错误: {e}")
241
- import traceback
242
-
243
- traceback.print_exc()
1
+ import time
2
+
3
+ from scalebox.csx_desktop.main import Sandbox
4
+
5
+
6
+ def desktop_automation_demo():
7
+ """桌面自动化功能演示"""
8
+
9
+ # 1. 创建桌面沙箱实例
10
+ print("正在启动桌面沙箱...")
11
+ desktop = Sandbox(timeout=3600, template="browser-use")
12
+ # print(f"沙箱已启动,ID: {desktop.sandbox_id}")
13
+
14
+ # 2. 启动VNC流以便远程查看桌面
15
+ print("启动VNC远程桌面...")
16
+ time.sleep(5)
17
+ desktop.stream.start()
18
+ vnc_url = desktop.stream.get_url(auto_connect=True)
19
+ print(f"VNC访问URL: {vnc_url}")
20
+ # print(f"VNC认证密钥: {desktop.stream.get_auth_key()}")
21
+
22
+ # 等待系统完全启动
23
+ time.sleep(3)
24
+
25
+ # 3. 基本鼠标操作示例
26
+ print("执行鼠标操作...")
27
+
28
+ # 获取屏幕尺寸
29
+ screen_width, screen_height = desktop.get_screen_size()
30
+ print(f"屏幕尺寸: {screen_width}x{screen_height}")
31
+
32
+ # 移动鼠标到屏幕中心
33
+ center_x, center_y = screen_width // 2, screen_height // 2
34
+ desktop.move_mouse(center_x, center_y)
35
+
36
+ # 获取当前光标位置
37
+ cursor_x, cursor_y = desktop.get_cursor_position()
38
+ print(f"光标位置: ({cursor_x}, {cursor_y})")
39
+
40
+ # 左键点击
41
+ desktop.left_click(center_x, center_y)
42
+
43
+ # 右键点击
44
+ desktop.right_click(center_x + 100, center_y)
45
+
46
+ # 双击
47
+ desktop.double_click(center_x, center_y + 100)
48
+
49
+ # 鼠标拖动示例
50
+ desktop.drag((center_x, center_y), (center_x + 200, center_y))
51
+
52
+ # 鼠标滚动
53
+ desktop.scroll("down", 2) # 向下滚动2次
54
+ desktop.scroll("up", 1) # 向上滚动1次
55
+
56
+ # 4. 键盘输入示例
57
+ print("执行键盘操作...")
58
+
59
+ # 打开终端
60
+ desktop.launch("xfce4-terminal") # 或 xfce4-terminal
61
+ time.sleep(2)
62
+
63
+ # 获取当前窗口ID
64
+ current_window = desktop.get_current_window_id()
65
+ print(f"当前窗口ID: {current_window}")
66
+
67
+ # 输入命令
68
+ desktop.write("echo 'Hello from SBX Sandbox!'")
69
+ desktop.press("enter")
70
+
71
+ # 特殊按键
72
+ desktop.press("ctrl+shift+t") # 新建标签页
73
+ time.sleep(1)
74
+
75
+ desktop.write("ls -la")
76
+ desktop.press("enter")
77
+
78
+ # 5. 窗口管理示例
79
+ print("执行窗口管理操作...")
80
+
81
+ # 获取所有可见窗口
82
+ terminal_windows = desktop.get_application_windows("xfce4-terminal")
83
+ print(f"终端窗口: {terminal_windows}")
84
+
85
+ if terminal_windows:
86
+ # 获取窗口标题
87
+ window_title = desktop.get_window_title(terminal_windows[0])
88
+ print(f"窗口标题: {window_title}")
89
+
90
+ # 6. 启动应用程序示例
91
+ print("启动其他应用程序...")
92
+
93
+ # 使用gtk-launch启动应用程序
94
+ try:
95
+ desktop.launch("firefox-esr") # 启动Firefox浏览器
96
+ time.sleep(3)
97
+
98
+ # 在Firefox中输入URL
99
+ desktop.press("ctrl+l") # 聚焦地址栏
100
+ desktop.write("https://www.google.com")
101
+ desktop.press("enter")
102
+
103
+ except Exception as e:
104
+ print(f"启动Firefox失败: {e}")
105
+
106
+ # 7. 文件操作示例 - 创建并打开文件
107
+ print("执行文件操作...")
108
+
109
+ # 创建测试文件
110
+ test_content = """Hello World!
111
+ This is a test file created from Scalebox Sandbox SDK.
112
+ Current time: {time}
113
+ """.format(
114
+ time=time.ctime()
115
+ )
116
+
117
+ desktop.files.write("/tmp/test_file.txt", test_content)
118
+ print("已创建测试文件")
119
+
120
+ # 使用默认程序打开文件
121
+ # desktop.open("/tmp/test_file.txt")
122
+ # time.sleep(2)
123
+
124
+ # 8. 截图功能示例
125
+ print("执行截图操作...")
126
+
127
+ # 截取屏幕并保存为bytes
128
+ screenshot_bytes = desktop.screenshot(format="bytes")
129
+ print(f"截图大小: {len(screenshot_bytes)} 字节")
130
+
131
+ # 也可以获取截图流
132
+ # screenshot_stream = desktop.screenshot(format="stream")
133
+ # for chunk in screenshot_stream:
134
+ # # 处理截图数据
135
+ # pass
136
+
137
+ # 9. 复杂自动化脚本示例
138
+ print("执行复杂自动化任务...")
139
+
140
+ # 返回终端窗口
141
+ terminal_windows = desktop.get_application_windows("xfce4-terminal")
142
+ if terminal_windows:
143
+ # 激活终端窗口
144
+ desktop.commands.run(
145
+ f"DISPLAY={desktop._display} xdotool windowactivate {terminal_windows[0]}"
146
+ )
147
+
148
+ # 创建Python脚本并执行
149
+ python_script = """#!/usr/bin/env python3
150
+ import time
151
+ print("starting...")
152
+ for i in range(5):
153
+ print(f"count: {i}")
154
+ time.sleep(0.5)
155
+ print("success!")
156
+ """
157
+
158
+ script_path = "/tmp/automation_script.py"
159
+ desktop.files.write(script_path, python_script)
160
+
161
+ desktop.write(f"python3 /uploads{script_path}")
162
+ desktop.press("enter")
163
+
164
+ # 10. 等待和定时操作
165
+ print("等待操作完成...")
166
+ desktop.wait(2000) # 等待2秒
167
+
168
+ # 展示所有功能已完成
169
+ desktop.write("echo 'All successfully!'")
170
+ desktop.press("enter")
171
+
172
+ print("演示完成! 沙箱将在10分钟后自动关闭或按Ctrl+C提前结束")
173
+
174
+ # 保持沙箱运行以便观察
175
+ try:
176
+ time.sleep(600) # 保持10分钟
177
+ except KeyboardInterrupt:
178
+ print("提前结束沙箱会话")
179
+
180
+ # 11. 清理工作会在with语句退出时自动执行
181
+
182
+
183
+ # def specific_use_cases():
184
+ # """特定用例示例"""
185
+ #
186
+ # # 用例1: 网页自动化测试
187
+ # def web_automation():
188
+ # with Sandbox() as desktop:
189
+ # desktop.open("firefox")
190
+ # time.sleep(3)
191
+ # desktop.press("ctrl+l")
192
+ # desktop.write("https://www.google.com")
193
+ # desktop.press("enter")
194
+ # time.sleep(2)
195
+ # desktop.write("Scalebox Sandbox Automation")
196
+ # desktop.press("enter")
197
+ # # 更多网页自动化操作...
198
+ #
199
+ # # 用例2: GUI应用测试
200
+ # def gui_app_testing():
201
+ # with Sandbox() as desktop:
202
+ # # 启动待测试的GUI应用
203
+ # desktop.launch("some-gui-application")
204
+ # time.sleep(2)
205
+ #
206
+ # # 执行一系列测试操作
207
+ # desktop.move_mouse(100, 100)
208
+ # desktop.left_click()
209
+ # desktop.write("测试输入")
210
+ # desktop.press("enter")
211
+ #
212
+ # # 验证结果
213
+ # screenshot = desktop.screenshot(format="bytes")
214
+ # # 这里可以添加截图分析逻辑
215
+ #
216
+ # # 用例3: 教育演示
217
+ # def educational_demo():
218
+ # with Sandbox() as desktop:
219
+ # # 打开编程环境
220
+ # desktop.open("vscode") # 或其他IDE
221
+ #
222
+ # # 逐步演示代码编写和执行过程
223
+ # time.sleep(2)
224
+ # desktop.write("# Python编程演示")
225
+ # desktop.press("enter")
226
+ # desktop.write("print('Hello, Students!')")
227
+ # desktop.press("enter")
228
+ #
229
+ # # 保存并运行
230
+ # desktop.press("ctrl+s")
231
+ # desktop.press("ctrl+alt+t") # 打开终端
232
+ # desktop.write("python3 demo.py")
233
+ # desktop.press("enter")
234
+
235
+
236
+ if __name__ == "__main__":
237
+ try:
238
+ desktop_automation_demo()
239
+ except Exception as e:
240
+ print(f"演示过程中发生错误: {e}")
241
+ import traceback
242
+
243
+ traceback.print_exc()
@@ -3,13 +3,13 @@ import time
3
3
  from scalebox.sandbox.commands.command_handle import PtySize
4
4
  from scalebox.sandbox_sync.main import Sandbox
5
5
 
6
+
6
7
  def output_handler(output):
7
8
  """处理 输出的回调函数"""
8
9
  print(f"PTY 输出: {output}")
9
10
 
10
- sandboxes=Sandbox.list()
11
+
12
+ sandboxes = Sandbox.list()
11
13
  print(sandboxes)
12
- box=Sandbox.connect(sandbox_id="sbx-0b3ccqezz67asn3ax")
13
- print(box)
14
- result=box.commands.run("ls")
15
- print(result)
14
+ box = Sandbox.connect(sandbox_id="sbx-0b3ccqezz67asn3ax")
15
+ print(box.files.list("/"))
@@ -13,7 +13,7 @@ async def pty_output_handler(output):
13
13
 
14
14
 
15
15
  async def main():
16
- sandbox = await (AsyncSandbox.create(timeout=3600))
16
+ sandbox = await AsyncSandbox.create(timeout=3600)
17
17
  proc = await sandbox.commands.run("echo hello from async")
18
18
  print("exit_code =", proc.exit_code)
19
19
  print("stdout =", proc.stdout)
@@ -24,99 +24,69 @@ async def main():
24
24
  on_data=pty_output_handler,
25
25
  cwd="/root",
26
26
  envs={"CUSTOM_ENV": "value"},
27
- request_timeout=40
27
+ request_timeout=40,
28
28
  )
29
29
  print(f"PTY 已创建,PID: {pty_handle.pid}")
30
30
 
31
31
  # 5. 向 PTY 发送输入
32
32
  await sandbox.pty.send_stdin(
33
- pid=pty_handle.pid,
34
- data=b"echo 'Hello from PTY 0s'\n",
35
- request_timeout=10
33
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 0s'\n", request_timeout=10
36
34
  )
37
35
  await asyncio.sleep(30)
38
36
  await sandbox.pty.send_stdin(
39
- pid=pty_handle.pid,
40
- data=b"echo 'Hello from PTY 30s'\n",
41
- request_timeout=10
37
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 30s'\n", request_timeout=10
42
38
  )
43
39
  await asyncio.sleep(30)
44
40
  await sandbox.pty.send_stdin(
45
- pid=pty_handle.pid,
46
- data=b"echo 'Hello from PTY 60s'\n",
47
- request_timeout=10
41
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 60s'\n", request_timeout=10
48
42
  )
49
43
  await asyncio.sleep(30)
50
44
  await sandbox.pty.send_stdin(
51
- pid=pty_handle.pid,
52
- data=b"echo 'Hello from PTY 90s'\n",
53
- request_timeout=10
45
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 90s'\n", request_timeout=10
54
46
  )
55
47
  await asyncio.sleep(30)
56
48
  await sandbox.pty.send_stdin(
57
- pid=pty_handle.pid,
58
- data=b"echo 'Hello from PTY 120s'\n",
59
- request_timeout=10
49
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 120s'\n", request_timeout=10
60
50
  )
61
51
  await asyncio.sleep(30)
62
52
  await sandbox.pty.send_stdin(
63
- pid=pty_handle.pid,
64
- data=b"echo 'Hello from PTY 150s'\n",
65
- request_timeout=10
53
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 150s'\n", request_timeout=10
66
54
  )
67
55
  await asyncio.sleep(30)
68
56
  await sandbox.pty.send_stdin(
69
- pid=pty_handle.pid,
70
- data=b"echo 'Hello from PTY 180s'\n",
71
- request_timeout=10
57
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 180s'\n", request_timeout=10
72
58
  )
73
59
  await asyncio.sleep(30)
74
60
  await sandbox.pty.send_stdin(
75
- pid=pty_handle.pid,
76
- data=b"echo 'Hello from PTY 210s'\n",
77
- request_timeout=10
61
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 210s'\n", request_timeout=10
78
62
  )
79
63
  await asyncio.sleep(30)
80
64
  await sandbox.pty.send_stdin(
81
- pid=pty_handle.pid,
82
- data=b"echo 'Hello from PTY 240s'\n",
83
- request_timeout=10
65
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 240s'\n", request_timeout=10
84
66
  )
85
67
  await asyncio.sleep(30)
86
68
  await sandbox.pty.send_stdin(
87
- pid=pty_handle.pid,
88
- data=b"echo 'Hello from PTY 270s'\n",
89
- request_timeout=10
69
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 270s'\n", request_timeout=10
90
70
  )
91
71
  await asyncio.sleep(30)
92
72
  await sandbox.pty.send_stdin(
93
- pid=pty_handle.pid,
94
- data=b"echo 'Hello from PTY 300s'\n",
95
- request_timeout=10
73
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 300s'\n", request_timeout=10
96
74
  )
97
75
  await asyncio.sleep(30)
98
76
  await sandbox.pty.send_stdin(
99
- pid=pty_handle.pid,
100
- data=b"echo 'Hello from PTY 330s'\n",
101
- request_timeout=10
77
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 330s'\n", request_timeout=10
102
78
  )
103
79
  await asyncio.sleep(30)
104
80
  await sandbox.pty.send_stdin(
105
- pid=pty_handle.pid,
106
- data=b"echo 'Hello from PTY 360s'\n",
107
- request_timeout=10
81
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 360s'\n", request_timeout=10
108
82
  )
109
83
  await asyncio.sleep(30)
110
84
  await sandbox.pty.send_stdin(
111
- pid=pty_handle.pid,
112
- data=b"echo 'Hello from PTY 390s'\n",
113
- request_timeout=10
85
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 390s'\n", request_timeout=10
114
86
  )
115
87
  await asyncio.sleep(30)
116
88
  await sandbox.pty.send_stdin(
117
- pid=pty_handle.pid,
118
- data=b"echo 'Hello from PTY 420s'\n",
119
- request_timeout=10
89
+ pid=pty_handle.pid, data=b"echo 'Hello from PTY 420s'\n", request_timeout=10
120
90
  )
121
91
 
122
92
  # 6. 调整 PTY 大小