ryry-cli 2.96__tar.gz → 2.97__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.
Files changed (27) hide show
  1. {ryry_cli-2.96 → ryry_cli-2.97}/PKG-INFO +1 -1
  2. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/constant.py +2 -2
  3. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/ryry_server_socket.py +37 -8
  4. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/ryry_service.py +1 -58
  5. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/task.py +68 -2
  6. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/taskUtils.py +1 -1
  7. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/PKG-INFO +1 -1
  8. {ryry_cli-2.96 → ryry_cli-2.97}/setup.py +1 -1
  9. {ryry_cli-2.96 → ryry_cli-2.97}/LICENSE +0 -0
  10. {ryry_cli-2.96 → ryry_cli-2.97}/README.md +0 -0
  11. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/__init__.py +0 -0
  12. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/main.py +0 -0
  13. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/ryry_webapi.py +0 -0
  14. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/ryry_widget.py +0 -0
  15. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/script_template/__init__.py +0 -0
  16. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/script_template/main.py +0 -0
  17. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/script_template/run.py +0 -0
  18. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/server_func.py +0 -0
  19. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/store.py +0 -0
  20. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/upload.py +0 -0
  21. {ryry_cli-2.96 → ryry_cli-2.97}/ryry/utils.py +0 -0
  22. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/SOURCES.txt +0 -0
  23. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/dependency_links.txt +0 -0
  24. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/entry_points.txt +0 -0
  25. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/requires.txt +0 -0
  26. {ryry_cli-2.96 → ryry_cli-2.97}/ryry_cli.egg-info/top_level.txt +0 -0
  27. {ryry_cli-2.96 → ryry_cli-2.97}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.96
3
+ Version: 2.97
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -1,6 +1,6 @@
1
1
  #!!!!! do not change this file !!!!!
2
- app_version="2.96"
3
- app_bulld_anchor="Noh_2025-03-20 18:02:55.610325"
2
+ app_version="2.97"
3
+ app_bulld_anchor="Noh_2025-04-03 13:56:32.263867"
4
4
  app_name="ryry-cli"
5
5
  import sys, os
6
6
  if getattr(sys, 'frozen', False):
@@ -1,19 +1,13 @@
1
- import os, time, json
1
+ import os, time, json, calendar
2
2
  from urllib.parse import *
3
3
  import threading
4
4
  from datetime import datetime, timedelta
5
- import calendar
6
5
  from threading import Thread, current_thread, Lock
7
6
  import uuid
8
7
  import queue
9
8
  import subprocess, platform
10
9
 
11
- from ryry import store
12
- from ryry import ryry_webapi
13
- from ryry import task
14
- from ryry import constant
15
- from ryry import utils
16
- from ryry import taskUtils
10
+ from ryry import store, ryry_widget, ryry_webapi, task, constant, utils, taskUtils
17
11
 
18
12
  class RyryTaskExecutor(Thread):
19
13
  THEADING_LIST = []
@@ -189,11 +183,43 @@ class RyryShortConnectThread(Thread):
189
183
  self.name = f"ShortConnect"
190
184
  self.is_running = True
191
185
  self.executor = executor
186
+ self.last_check_time = calendar.timegm(time.gmtime())
192
187
  self.start()
193
188
 
194
189
  def taskCallback(self, taskUUID, is_ok, msg, result):
195
190
  ryry_webapi.TaskNotify(taskUUID, is_ok, msg, result)
196
191
 
192
+ def checkWidgetVersion(self):
193
+ if calendar.timegm(time.gmtime()) - self.last_check_time > 300:
194
+ self.last_check_time = calendar.timegm(time.gmtime())
195
+ try:
196
+ #update widget
197
+ ryry_widget.UpdateWidgetFromPypi()
198
+ except Exception as ex:
199
+ print(f'update widget fail, {ex}')
200
+
201
+ # if platform.system() != 'Darwin':
202
+ # try:
203
+ # #update cli
204
+ # remote_version = ryry_widget._remote_package_version("ryry-cli")
205
+ # simple = "https://pypi.python.org/simple/"
206
+ # local_version, local_path = ryry_widget._local_package_info("ryry-cli")
207
+ # if ryry_widget.compare_versions(remote_version, local_version) > 0:
208
+ # print("start update progress...")
209
+ # utils.begin_restart("auto upgrade ryry-cli", True, simple)
210
+ # device_id = utils.generate_unique_id()
211
+ # machine_name = socket.gethostname()
212
+ # ver = get_distribution("ryry-cli").version
213
+ # taskUtils.notifyWechatRobot({
214
+ # "msgtype": "text",
215
+ # "text": {
216
+ # "content": f"机器<{machine_name}[{device_id}]>[{ver}] ryry-cli开始升级[{local_version}]->[{remote_version}]"
217
+ # }
218
+ # })
219
+ # break
220
+ # except Exception as ex:
221
+ # print(f'update ryry-cli fail, {ex}')
222
+
197
223
  def run(self):
198
224
  print(f" {self.name} start")
199
225
  min_wait_time = 5
@@ -243,6 +269,9 @@ class RyryShortConnectThread(Thread):
243
269
  except Exception as ex:
244
270
  taskUtils.taskPrint(None, f"{self.name} === exception : {ex}")
245
271
  time.sleep(wait_time)
272
+ if self.executor.isWorking() == False:
273
+ #自动更新widget
274
+ self.checkWidgetVersion()
246
275
 
247
276
  print(f" {self.name} stop")
248
277
 
@@ -76,7 +76,6 @@ class ryryService:
76
76
  self.THEADING_LIST.append(executor)
77
77
  self.THEADING_LIST.append(TaskConnector.RyryShortConnectThread(executor))
78
78
  self.THEADING_LIST.append(ryryStateThread())
79
- self.THEADING_LIST.append(ryryPackageThread())
80
79
  #3: service step
81
80
  while (os.path.exists(stop_file) == False):
82
81
  time.sleep(10)
@@ -122,63 +121,6 @@ class ryryService:
122
121
  time.sleep(1)
123
122
  print("ryryService has ended!")
124
123
 
125
- class ryryPackageThread(Thread):
126
- def __init__(self):
127
- super().__init__()
128
- self.name = f"ryryPackageThread"
129
- if platform.system() == 'Windows':
130
- self.time_task_file = os.path.join(constant.base_path, "update_ryry.bat")
131
- elif platform.system() == 'Linux' or platform.system() == 'Darwin':
132
- self.time_task_file = os.path.join(constant.base_path, "update_ryry.sh")
133
- if os.path.exists(self.time_task_file):
134
- os.remove(self.time_task_file)
135
- self.last_check_time = calendar.timegm(time.gmtime())
136
- self.start()
137
- def getCommandResult(self, cmd):
138
- try:
139
- result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
140
- if result.returncode == 0:
141
- return result.stdout.decode(encoding="utf8", errors="ignore").replace("\n","").strip()
142
- except subprocess.CalledProcessError as e:
143
- print(f"getCommandResult fail {e}")
144
- return ""
145
- def run(self):
146
- while (os.path.exists(stop_thread_file) == False):
147
- time.sleep(10)
148
- if calendar.timegm(time.gmtime()) - self.last_check_time > 300:
149
- self.last_check_time = calendar.timegm(time.gmtime())
150
- try:
151
- #update widget
152
- ryry_widget.UpdateWidgetFromPypi()
153
- except Exception as ex:
154
- print(f'update widget fail, {ex}')
155
- # if platform.system() != 'Darwin':
156
- # try:
157
- # #update cli
158
- # remote_version = ryry_widget._remote_package_version("ryry-cli")
159
- # simple = "https://pypi.python.org/simple/"
160
- # local_version, local_path = ryry_widget._local_package_info("ryry-cli")
161
- # if ryry_widget.compare_versions(remote_version, local_version) > 0:
162
- # print("start update progress...")
163
- # utils.begin_restart("auto upgrade ryry-cli", True, simple)
164
- # device_id = utils.generate_unique_id()
165
- # machine_name = socket.gethostname()
166
- # ver = get_distribution("ryry-cli").version
167
- # taskUtils.notifyWechatRobot({
168
- # "msgtype": "text",
169
- # "text": {
170
- # "content": f"机器<{machine_name}[{device_id}]>[{ver}] ryry-cli开始升级[{local_version}]->[{remote_version}]"
171
- # }
172
- # })
173
- # break
174
- # except Exception as ex:
175
- # print(f'update ryry-cli fail, {ex}')
176
- time.sleep(10)
177
- print(f" PackageChecker stop")
178
- notify_other_stoped() #because other thread is waiting some signal to close
179
- def markStop(self):
180
- print(f" PackageChecker waiting stop")
181
-
182
124
  class ryryStateThread(Thread):
183
125
  def __init__(self):
184
126
  super().__init__()
@@ -211,6 +153,7 @@ class ryryStateThread(Thread):
211
153
  except:
212
154
  time.sleep(60)
213
155
  print(f" StateChecker stop")
156
+ notify_other_stoped() #because other thread is waiting some signal to close
214
157
  def markStop(self):
215
158
  print(f" StateChecker waiting stop")
216
159
 
@@ -5,10 +5,66 @@ import sys
5
5
  import signal
6
6
  import subprocess, multiprocessing
7
7
  from threading import Thread, current_thread, Lock
8
+ import xmlrpc.client
8
9
 
9
10
  from ryry import ryry_webapi,store,taskUtils,utils,constant
10
11
  from pathlib import Path
11
12
 
13
+ # _rpc_server_process = None
14
+ # _rpc_port = 8000
15
+ # _rpc_server_lock = Lock()
16
+
17
+ # def stop_rpc_server():
18
+ # global _rpc_server_process
19
+ # with _rpc_server_lock:
20
+ # if _rpc_server_process is not None:
21
+ # try:
22
+ # _rpc_server_process.terminate()
23
+ # _rpc_server_process.wait(timeout=5)
24
+ # except:
25
+ # _rpc_server_process.kill()
26
+ # _rpc_server_process = None
27
+
28
+ # def restart_rpc_server():
29
+ # stop_rpc_server()
30
+ # ensure_rpc_server_running()
31
+
32
+ # def ensure_rpc_server_running():
33
+ # global _rpc_server_process
34
+ # with _rpc_server_lock:
35
+ # if _rpc_server_process is None or _rpc_server_process.poll() is not None:
36
+ # backend_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'backend.py')
37
+ # _rpc_server_process = subprocess.Popen([sys.executable, backend_path])
38
+ # time.sleep(2) # 等待服务器启动
39
+
40
+ # # 检查服务器是否成功启动
41
+ # try:
42
+ # client = xmlrpc.client.ServerProxy(f'http://localhost:{_rpc_port}')
43
+ # client.initialize_model()
44
+ # except:
45
+ # stop_rpc_server()
46
+ # raise Exception("RPC server failed to start")
47
+
48
+ # def check_code_update():
49
+ # """检查代码是否有更新,如果有更新则重启服务"""
50
+ # backend_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'backend.py')
51
+ # current_mtime = os.path.getmtime(backend_path)
52
+
53
+ # # 获取上次记录的修改时间
54
+ # last_mtime_file = os.path.join(os.path.dirname(backend_path), '.last_mtime')
55
+ # last_mtime = 0
56
+ # if os.path.exists(last_mtime_file):
57
+ # with open(last_mtime_file, 'r') as f:
58
+ # last_mtime = float(f.read().strip() or 0)
59
+
60
+ # # 如果文件被修改,重启服务
61
+ # if current_mtime > last_mtime:
62
+ # print("Detected code update, restarting RPC server...")
63
+ # restart_rpc_server()
64
+ # # 更新最后修改时间
65
+ # with open(last_mtime_file, 'w') as f:
66
+ # f.write(str(current_mtime))
67
+
12
68
  def runTask(it, timeout):
13
69
  start_time = calendar.timegm(time.gmtime())
14
70
  taskUUID = it["taskUUID"]
@@ -63,6 +119,16 @@ def cmdWithWidgetName(name):
63
119
  return None
64
120
 
65
121
  def executeLocalPython(taskUUID, cmd, param, timeout=3600):
122
+ # # 检查代码更新
123
+ # check_code_update()
124
+
125
+ # # 确保RPC服务器运行
126
+ # ensure_rpc_server_running()
127
+
128
+ # # 添加RPC服务器信息到环境变量
129
+ env = os.environ.copy()
130
+ # env['RPC_SERVER_PORT'] = str(_rpc_port)
131
+
66
132
  inputArgs = os.path.join(constant.base_path, f"{taskUUID}.in")
67
133
  if os.path.exists(inputArgs):
68
134
  os.remove(inputArgs)
@@ -84,8 +150,8 @@ def executeLocalPython(taskUUID, cmd, param, timeout=3600):
84
150
  process = None
85
151
  try:
86
152
  if timeout == 0:
87
- timeout = 60*30 #max half hour expire time
88
- process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
153
+ timeout = 60*30
154
+ process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
89
155
  timeout_killprocess(process, timeout)
90
156
  output, error = process.communicate()
91
157
  if process.returncode == 0:
@@ -40,7 +40,7 @@ def appendTaskAndDomain(taskUUID, subDomain):
40
40
  with open(task_config_file, 'w') as f:
41
41
  json.dump(task_config, f)
42
42
 
43
- WECHAT_URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=f40c5fb0-2734-48b0-a2d0-0faedf7dd2e4"
43
+ WECHAT_URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1b006560-7012-4bf0-8c5e-a23830bc0a0b"
44
44
  def uploadFile2Wechat(filepath):
45
45
  real_robot_url = WECHAT_URL
46
46
  params = parse.parse_qs( parse.urlparse( real_robot_url ).query )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.96
3
+ Version: 2.97
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -3,7 +3,7 @@ import os
3
3
  import subprocess
4
4
  import datetime
5
5
 
6
- ryry_version = "2.96"
6
+ ryry_version = "2.97"
7
7
  cur_dir = os.path.dirname(os.path.abspath(__file__))
8
8
  constanspy = os.path.join(cur_dir, "ryry", "constant.py")
9
9
  try:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes