ryry-cli 2.8__tar.gz → 2.10__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 (28) hide show
  1. {ryry_cli-2.8/ryry_cli.egg-info → ryry_cli-2.10}/PKG-INFO +1 -1
  2. ryry_cli-2.10/ryry/constant.py +5 -0
  3. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/ryry_service.py +3 -3
  4. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/ryry_webapi.py +38 -17
  5. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/ryry_widget.py +21 -13
  6. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/server_func.py +34 -17
  7. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/task.py +5 -5
  8. {ryry_cli-2.8 → ryry_cli-2.10/ryry_cli.egg-info}/PKG-INFO +1 -1
  9. {ryry_cli-2.8 → ryry_cli-2.10}/setup.py +1 -1
  10. ryry_cli-2.8/ryry/constant.py +0 -5
  11. {ryry_cli-2.8 → ryry_cli-2.10}/LICENSE +0 -0
  12. {ryry_cli-2.8 → ryry_cli-2.10}/README.md +0 -0
  13. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/__init__.py +0 -0
  14. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/main.py +0 -0
  15. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/ryry_server_socket.py +0 -0
  16. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/script_template/__init__.py +0 -0
  17. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/script_template/main.py +0 -0
  18. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/script_template/run.py +0 -0
  19. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/store.py +0 -0
  20. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/taskUtils.py +0 -0
  21. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/upload.py +0 -0
  22. {ryry_cli-2.8 → ryry_cli-2.10}/ryry/utils.py +0 -0
  23. {ryry_cli-2.8 → ryry_cli-2.10}/ryry_cli.egg-info/SOURCES.txt +0 -0
  24. {ryry_cli-2.8 → ryry_cli-2.10}/ryry_cli.egg-info/dependency_links.txt +0 -0
  25. {ryry_cli-2.8 → ryry_cli-2.10}/ryry_cli.egg-info/entry_points.txt +0 -0
  26. {ryry_cli-2.8 → ryry_cli-2.10}/ryry_cli.egg-info/requires.txt +0 -0
  27. {ryry_cli-2.8 → ryry_cli-2.10}/ryry_cli.egg-info/top_level.txt +0 -0
  28. {ryry_cli-2.8 → ryry_cli-2.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.8
3
+ Version: 2.10
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -0,0 +1,5 @@
1
+ #!!!!! do not change this file !!!!!
2
+ app_version="2.10"
3
+ app_bulld_number=210
4
+ app_bulld_anchor="Noh_2024-06-12 17:59:01.639286"
5
+ app_name="ryry-cli"
@@ -149,8 +149,8 @@ class ryryPackageThread(Thread):
149
149
  return ""
150
150
  def run(self):
151
151
  while (os.path.exists(stop_thread_file) == False):
152
- time.sleep(10)
153
- if calendar.timegm(time.gmtime()) - self.last_check_time > 300:
152
+ time.sleep(1)
153
+ if calendar.timegm(time.gmtime()) - self.last_check_time > 100:
154
154
  self.last_check_time = calendar.timegm(time.gmtime())
155
155
  try:
156
156
  #update widget
@@ -178,7 +178,7 @@ class ryryPackageThread(Thread):
178
178
  break
179
179
  except Exception as ex:
180
180
  print(f'update ryry-cli fail, {ex}')
181
- time.sleep(10)
181
+ time.sleep(1)
182
182
  print(f" PackageChecker stop")
183
183
  notify_other_stoped() #because other thread is waiting some signal to close
184
184
  def markStop(self):
@@ -55,7 +55,7 @@ def _extend():
55
55
  return json.dumps(extInfo)
56
56
 
57
57
  def GetTask():
58
- widget_map = ["TESTTEST"]
58
+ widget_map = []
59
59
  map = store.widgetMap()
60
60
  for it in map:
61
61
  if isinstance(map[it], (dict)):
@@ -153,6 +153,7 @@ def retryLastTaskNotify():
153
153
  json.dump(newData, f)
154
154
  except:
155
155
  pass
156
+
156
157
  def TaskNotify(taskUUID, status, msg, dataStr, failSaveNotify=True):
157
158
  req = {
158
159
  "task_uuid": taskUUID,
@@ -169,16 +170,22 @@ def TaskNotify(taskUUID, status, msg, dataStr, failSaveNotify=True):
169
170
  return r3
170
171
 
171
172
  def TaskUpdateProgress(taskUUID, progress, dataStr):
172
- # req = aigc_ext_pb2.TaskUpdateReq()
173
- # req.taskUUID = taskUUID
174
- # req.progress = progress
175
- # req.data = dataStr
176
-
177
- # rsp = aigc_ext_pb2.TaskUpdateRes()
178
- # r1, r2, r3 = _aigc_post(req, "TaskUpdate")
179
- # if r1 != 0:
180
- # return False
181
- # rsp.ParseFromString(r3)
173
+ req = {
174
+ "task_uuid": taskUUID,
175
+ "progress": progress,
176
+ }
177
+ r1, r2, r3 = _aigc_post("aigc/task/taskProgress", req)
178
+ if r1 != 0:
179
+ return False
180
+ return True
181
+
182
+ def TaskCancel(taskUUID):
183
+ req = {
184
+ "task_uuid": taskUUID,
185
+ }
186
+ r1, r2, r3 = _aigc_post("aigc/task/taskCancel", req)
187
+ if r1 != 0:
188
+ return False
182
189
  return True
183
190
 
184
191
  def upload(localFilePath, ext):
@@ -212,9 +219,9 @@ def CreateWidgetUUID():
212
219
  return r3
213
220
 
214
221
  #======================================== Task Function ==============================
215
- def createTask(widget_id, params):
222
+ def createTask(widget_name, params):
216
223
  req = {
217
- "widget_id": widget_id,
224
+ "widget_name": widget_name,
218
225
  "widget_data": json.dumps(params),
219
226
  "extend": _extend()
220
227
  }
@@ -239,16 +246,30 @@ def findWidget(name):
239
246
  return widget_id, version, package
240
247
  return "", "", ""
241
248
 
249
+ def getAutoDeployWidget():
250
+ req = {}
251
+ r1, r2, r3 = _aigc_post("aigc/task/getAutoDeployWidget", req)
252
+ result = []
253
+ if r1 != 0:
254
+ return result
255
+ for it in r3:
256
+ widget_id = it["widget_id"]
257
+ widget_name = it["name"]
258
+ version = it["version"]
259
+ package = it["package"]
260
+ result.append([widget_id, widget_name, version, package])
261
+ return result
262
+
242
263
  def checkTask(checkUUID):
243
264
  req = {
244
265
  "task_uuid": checkUUID
245
266
  }
246
267
  r1, r2, r3 = _aigc_post("aigc/task/checkTask", req)
247
268
  if r1 != 0:
248
- return False, False, "server fail"
269
+ return False, False, "server fail", 0
249
270
  if r3["status"] < 2:
250
- return False, False, ""
271
+ return False, False, "", r3["progress"]
251
272
  elif r3["status"] == 2:
252
- return True, True, json.loads(r3["task_result"])
273
+ return True, True, json.loads(r3["task_result"]), r3["progress"]
253
274
  elif r3["status"] == 3:
254
- return True, False, r3["fail_reason"]
275
+ return True, False, r3["fail_reason"], r3["progress"]
@@ -365,6 +365,15 @@ def widgetInstallNotify(widgetName, newver):
365
365
  }
366
366
  })
367
367
 
368
+ def pipReInstall(name, url):
369
+ if name:
370
+ subprocess.run(f"pip uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
371
+ subprocess.run(f"pip3 uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
372
+ subprocess.run(f"pip install {url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
373
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
374
+ subprocess.run(f"pip3 install {url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
375
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
376
+
368
377
  def UpdateWidgetFromPypi():
369
378
  map = store.widgetMap()
370
379
  for it in map:
@@ -384,17 +393,21 @@ def UpdateWidgetFromPypi():
384
393
  local_version = _local_package_version(py_package)
385
394
  if compare_versions(remote_version, local_version) > 0:
386
395
  #update
387
- subprocess.run(f"pip uninstall {py_package} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
388
- subprocess.run(f"pip3 uninstall {py_package} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
389
- subprocess.run(f"pip install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
390
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
391
- subprocess.run(f"pip3 install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
392
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
396
+ pipReInstall(py_package, package_url)
393
397
  widgetUpdateNotify(py_package, local_version, remote_version)
394
398
  except Exception as ex:
395
399
  print(ex)
396
400
  continue
397
-
401
+ for widget_id, widget_name, remote_version, package_url in ryry_webapi.getAutoDeployWidget():
402
+ if widget_id not in map:
403
+ try:
404
+ pipReInstall(widget_name, package_url)
405
+ widgetInstallNotify(widget_name, remote_version)
406
+ addWidgetToEnv(widget_name)
407
+ except Exception as ex:
408
+ print(ex)
409
+ continue
410
+
398
411
  def installWidget(name):
399
412
  widgetid, remote_version, package_url = ryry_webapi.findWidget(name)
400
413
  if len(widgetid) <= 0:
@@ -403,12 +416,7 @@ def installWidget(name):
403
416
  local_version = _local_package_version(name)
404
417
  if compare_versions(remote_version, local_version) > 0:
405
418
  #update
406
- subprocess.run(f"pip uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
407
- subprocess.run(f"pip3 uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
408
- subprocess.run(f"pip install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
409
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
410
- subprocess.run(f"pip3 install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
411
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
419
+ pipReInstall(name, package_url)
412
420
  widgetInstallNotify(name, remote_version)
413
421
  addWidgetToEnv(name)
414
422
 
@@ -1,19 +1,33 @@
1
- import time, urllib3
2
- from threading import Thread
1
+ import time, urllib3, sys, os
2
+ from threading import Thread, Lock
3
3
 
4
4
  from ryry import ryry_webapi
5
5
  from ryry import store
6
6
  from ryry import taskUtils
7
7
 
8
+ lock = Lock()
9
+ def print_progress_bar(iteration, total, name, idx, total_bars):
10
+ length=50
11
+ percent = ("{0:.1f}").format(100 * (iteration / float(total)))
12
+ filled_length = int(length * iteration // total)
13
+ bar = '█' * filled_length + '-' * (length - filled_length)
14
+ with lock:
15
+ sys.stdout.write(f'\0337') # Save cursor position
16
+ sys.stdout.write(f'\033[{total_bars-idx+1}A') # Move cursor up to the specific progress bar line
17
+ sys.stdout.write(f'\r{name}: |{bar}| {percent}% Complete')
18
+ sys.stdout.write(f'\0338') # Restore cursor position
19
+ sys.stdout.flush()
20
+
8
21
  class TaskThread(Thread):
9
22
  params = False
10
23
  idx = 0
11
24
  call_back = None
12
- def __init__(self, idx, func, func_id, params, callback):
25
+ def __init__(self, idx, total, func, params, callback):
13
26
  super().__init__()
14
27
  self.idx = idx
28
+ self.total = total
15
29
  self.func = func
16
- self.widgetid = func_id
30
+ self.checkUUID = None
17
31
  self.params = params
18
32
  self.call_back = callback
19
33
  if self.call_back == None:
@@ -22,31 +36,34 @@ class TaskThread(Thread):
22
36
  def run(self):
23
37
  self.checking = False
24
38
  self.result = False, "Unknow"
25
- if self.widgetid == None:
26
- self.widgetid, _, _ = ryry_webapi.findWidget(self.func)
27
- if len(self.widgetid) > 0:
28
- checkUUID = ryry_webapi.createTask(self.widgetid, self.params)
39
+ if len(self.func) > 0:
40
+ self.checkUUID = ryry_webapi.createTask(self.func, self.params)
41
+ print("")
29
42
  checking = True
30
43
  checkCount = 0
31
- while checking or checkCount > 600:
32
- finish, success, data = ryry_webapi.checkTask(checkUUID)
44
+ time.sleep(5)
45
+ while checking or checkCount > 100:
46
+ finish, success, data, progress = ryry_webapi.checkTask(self.checkUUID)
47
+ print_progress_bar(progress, 100, f"Task{self.idx} {self.func}", self.idx+1, self.total)
33
48
  if finish:
34
49
  checking = False
35
50
  if success:
36
51
  self.call_back(self.idx, data)
37
52
  return
38
53
  checkCount += 1
39
- if checkCount % 10 == 0:
40
- print(f"waiting...")
41
- time.sleep(1)
54
+ time.sleep(2)
42
55
  else:
43
- print(f"widget {self.func}-{self.widgetid} not found")
56
+ print(f"widget {self.func} not found")
44
57
  self.call_back(self.idx, None)
45
-
58
+
59
+ def __del__(self):
60
+ if self.checking and self.checkUUID:
61
+ ryry_webapi.TaskCancel(self.checkUUID)
62
+
46
63
  class Task:
47
64
  thread_data = {}
48
65
 
49
- def __init__(self, func: str, multi_params: list[dict], fromUUID=None, func_id=None):
66
+ def __init__(self, func: str, multi_params: list[dict], fromUUID=None):
50
67
  urllib3.disable_warnings()
51
68
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
52
69
 
@@ -60,7 +77,7 @@ class Task:
60
77
  for param in multi_params:
61
78
  param["fromUUID"] = realTaskUUID
62
79
  self.thread_data[str(idx)] = {
63
- "thread" : TaskThread(idx, func, func_id, param, _callback),
80
+ "thread" : TaskThread(idx, len(multi_params), func, param, _callback),
64
81
  "result" : None
65
82
  }
66
83
  idx+=1
@@ -176,19 +176,19 @@ def checkResult(taskUUID, data):
176
176
  final_url = parsed_url._replace(query=updated_query_string).geturl()
177
177
  it["extension"]["cover_url"] = final_url
178
178
  except Exception as ex:
179
- taskUtils.taskPrint(taskUUID, f"result: {data} status is not valid, exception is {ex} ")
179
+ taskUtils.taskPrint(taskUUID, f"result: {data} status is not valid, exception is {ex} , ignore")
180
180
  pass
181
181
 
182
- def updateProgress(data, progress=0.5, taskUUID=None):
182
+ def updateProgress(data, progress=50, taskUUID=None):
183
183
  realTaskUUID = taskUUID
184
184
  if realTaskUUID == None or len(realTaskUUID) <= 0:
185
185
  realTaskUUID = taskUtils.taskInfoWithFirstTask()
186
186
 
187
187
  if progress < 0:
188
188
  progress = 0
189
- if progress > 1:
190
- progress = progress / 100.0
191
- return ryry_webapi.TaskUpdateProgress(realTaskUUID, progress, json.dumps(data["result"]))
189
+ if progress > 100:
190
+ progress = 100
191
+ return ryry_webapi.TaskUpdateProgress(realTaskUUID, progress, json.dumps(data))
192
192
 
193
193
  def timeout_killprocess(proc, timeout): # """超过指定的秒数后杀死进程"""
194
194
  import threading
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.8
3
+ Version: 2.10
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.8"
6
+ ryry_version = "2.10"
7
7
  ryry_build_number = int(ryry_version.replace(".",""))
8
8
  cur_dir = os.path.dirname(os.path.abspath(__file__))
9
9
  constanspy = os.path.join(cur_dir, "ryry", "constant.py")
@@ -1,5 +0,0 @@
1
- #!!!!! do not change this file !!!!!
2
- app_version="2.8"
3
- app_bulld_number=28
4
- app_bulld_anchor="Noh_2024-06-07 15:00:45.698883"
5
- app_name="ryry-cli"
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