ryry-cli 2.43__tar.gz → 2.46__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.43 → ryry_cli-2.46}/PKG-INFO +1 -1
  2. ryry_cli-2.46/ryry/constant.py +5 -0
  3. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/ryry_webapi.py +46 -1
  4. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/ryry_widget.py +35 -33
  5. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/server_func.py +9 -7
  6. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/PKG-INFO +1 -1
  7. {ryry_cli-2.43 → ryry_cli-2.46}/setup.py +1 -1
  8. ryry_cli-2.43/ryry/constant.py +0 -5
  9. {ryry_cli-2.43 → ryry_cli-2.46}/LICENSE +0 -0
  10. {ryry_cli-2.43 → ryry_cli-2.46}/README.md +0 -0
  11. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/__init__.py +0 -0
  12. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/main.py +0 -0
  13. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/ryry_server_socket.py +0 -0
  14. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/ryry_service.py +0 -0
  15. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/script_template/__init__.py +0 -0
  16. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/script_template/main.py +0 -0
  17. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/script_template/run.py +0 -0
  18. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/store.py +0 -0
  19. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/task.py +0 -0
  20. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/taskUtils.py +0 -0
  21. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/upload.py +0 -0
  22. {ryry_cli-2.43 → ryry_cli-2.46}/ryry/utils.py +0 -0
  23. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/SOURCES.txt +0 -0
  24. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/dependency_links.txt +0 -0
  25. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/entry_points.txt +0 -0
  26. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/requires.txt +0 -0
  27. {ryry_cli-2.43 → ryry_cli-2.46}/ryry_cli.egg-info/top_level.txt +0 -0
  28. {ryry_cli-2.43 → ryry_cli-2.46}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.43
3
+ Version: 2.46
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.46"
3
+ app_bulld_number=246
4
+ app_bulld_anchor="Noh_2024-09-02 12:32:14.910188"
5
+ app_name="ryry-cli"
@@ -178,7 +178,7 @@ def TaskCancel(taskUUID):
178
178
  return False
179
179
  return True
180
180
 
181
- def upload(localFilePath, ext):
181
+ def _upload(localFilePath, ext):
182
182
  with open(localFilePath, "rb") as f:
183
183
  files = { 'file':f }
184
184
  params = { 'ext':ext }
@@ -187,6 +187,51 @@ def upload(localFilePath, ext):
187
187
  raise Exception(f"upload fail!, reason={r2}")
188
188
  return r3
189
189
 
190
+ def upload(localFilePath, ext):
191
+ try:
192
+ return _upload(localFilePath, ext)
193
+ except:
194
+ pass
195
+ from mecord import upload as mecord_upload
196
+ try:
197
+ return mecord_upload.upload(localFilePath, None, "sg")
198
+ except:
199
+ pass
200
+ try:
201
+ return mecord_upload.upload(localFilePath, None, "test")
202
+ except:
203
+ pass
204
+ try:
205
+ import hashlib
206
+ import hmac
207
+ import base64
208
+ timestamp = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
209
+ content_type = "application/octet-stream"
210
+
211
+ random_name = ''.join(str(uuid.uuid4()).split('-'))
212
+ object_key = f"temp/{random_name}.{ext}"
213
+ bucket = "p-template-hk"
214
+ resource = f"/{bucket}/{object_key}"
215
+ endpoint = "oss-cn-hongkong.aliyuncs.com"
216
+ string_to_sign = f"PUT\n\n{content_type}\n{timestamp}\n{resource}"
217
+ signature = base64.b64encode(
218
+ hmac.new("sZDIL9uhqTgeQOkAjpbSOFm0259fwZ".encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha1).digest()
219
+ ).decode('utf-8')
220
+ url = f"https://{bucket}.{endpoint}/{object_key}"
221
+ headers = {
222
+ "Date": timestamp,
223
+ "Authorization": f"OSS LTAI5t6YZQo4MZV6LWwt4Rnj:{signature}",
224
+ "Content-Type": content_type
225
+ }
226
+ with open(localFilePath, "rb") as file:
227
+ file_data = file.read()
228
+ response = requests.put(url, data=file_data, headers=headers)
229
+ if response.status_code == 200:
230
+ return url
231
+ except:
232
+ pass
233
+ raise Exception("all upload target is fail!")
234
+
190
235
  def uploadWidget(widget_id, name, whl, ext, version):
191
236
  with open(whl, "rb") as f:
192
237
  files = { 'file':f }
@@ -56,25 +56,16 @@ def _remote_package_version(py_package):
56
56
 
57
57
  #real time version get
58
58
  def _local_package_version(py_package):
59
- find_str = "grep"
60
- if platform.system() == 'Windows':
61
- find_str = "findstr"
62
- local_version = ""
63
- for pip in ["pip3","pip"]:
64
- result = subprocess.run(f"{pip} list | {find_str} {py_package}",
65
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
66
- ss = result.stdout.decode(encoding="utf8", errors="ignore").split("\n")
67
- for s in ss:
68
- s = re.sub(r'\s+', ' ', s)
69
- sl = s.strip().split(" ")
70
- if len(sl) == 2:
71
- if py_package.strip() == sl[0].strip():
72
- local_version = sl[1].strip()
73
- break
74
- else:
75
- continue
76
- break
77
- return local_version
59
+ _map = store.widgetMap()
60
+ for it in _map:
61
+ try:
62
+ widget_path = os.path.dirname(_map[it]["path"])
63
+ widget_config = GetWidgetConfig(widget_path)
64
+ if widget_config["name"] == py_package:
65
+ return widget_config["version"]
66
+ except:
67
+ pass
68
+ return ''
78
69
 
79
70
  def _pypi_folder_name(name):
80
71
  import re
@@ -366,23 +357,35 @@ def widgetInstallNotify(widgetName, newver):
366
357
  })
367
358
 
368
359
  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/",
360
+ def find_pip_command():
361
+ possible_pips = ['pip', 'pip3']
362
+ for cmd in possible_pips:
363
+ pip_path = shutil.which(cmd)
364
+ if pip_path:
365
+ return cmd
366
+
367
+ for version in range(12, 8, -1):
368
+ cmd = f"pip3.{version}"
369
+ pip_path = shutil.which(cmd)
370
+ if pip_path:
371
+ return cmd
372
+
373
+ raise RuntimeError("No pip command found on the system.")
374
+ pip_cmd = find_pip_command()
375
+ if name:
376
+ subprocess.run(f"{pip_cmd} uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
377
+ subprocess.run(f"{pip_cmd} install {url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
375
378
  stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
376
379
 
377
380
  def UpdateWidgetFromPypi():
378
- map = store.widgetMap()
379
- for it in map:
381
+ _map = store.widgetMap()
382
+ for it in _map:
380
383
  is_block = False
381
- if isinstance(map[it], (dict)):
382
- is_block = map[it]["isBlock"]
383
- path = map[it]["path"]
384
+ if isinstance(_map[it], (dict)):
385
+ is_block = _map[it]["isBlock"]
386
+ path = _map[it]["path"]
384
387
  else:
385
- path = map[it]
388
+ path = _map[it]
386
389
  path = os.path.dirname(path)
387
390
  if is_block == False and os.path.exists(path):
388
391
  data = GetWidgetConfig(path)
@@ -403,7 +406,7 @@ def UpdateWidgetFromPypi():
403
406
  print(ex)
404
407
  continue
405
408
  for widget_id, widget_name, remote_version, package_url in ryry_webapi.getAutoDeployWidget():
406
- if widget_id not in map:
409
+ if widget_id not in _map:
407
410
  try:
408
411
  pipReInstall(widget_name, package_url)
409
412
  widgetInstallNotify(widget_name, remote_version)
@@ -420,7 +423,6 @@ def installWidget(name):
420
423
  local_version = _local_package_version(name)
421
424
  if compare_versions(remote_version, local_version) > 0:
422
425
  #update
423
- print(f"install -> {package_url}")
424
426
  pipReInstall(name, package_url)
425
427
  widgetInstallNotify(name, remote_version)
426
428
  addWidgetToEnv(name)
@@ -23,7 +23,7 @@ class TaskThread(Thread):
23
23
  params = False
24
24
  idx = 0
25
25
  call_back = None
26
- def __init__(self, idx, total, func, params, callback):
26
+ def __init__(self, idx, total, func, params, callback, timeout=3600):
27
27
  super().__init__()
28
28
  self.idx = idx
29
29
  self.total = total
@@ -32,6 +32,7 @@ class TaskThread(Thread):
32
32
  self.checking = False
33
33
  self.checkCount = 0
34
34
  self.params = params
35
+ self.timeout = timeout
35
36
  self.call_back = callback
36
37
  if self.call_back == None:
37
38
  raise Exception("need callback function")
@@ -45,7 +46,7 @@ class TaskThread(Thread):
45
46
  if cmd:
46
47
  self.checkUUID = "local_" + ''.join(str(uuid.uuid4()).split('-'))
47
48
  self.params["task_id"] = self.checkUUID
48
- executeSuccess, result_obj = task.executeLocalPython(self.checkUUID, cmd, self.params)
49
+ executeSuccess, result_obj = task.executeLocalPython(self.checkUUID, cmd, self.params, self.timeout)
49
50
  if executeSuccess and result_obj["status"] == 0:
50
51
  self.call_back(self.idx, result_obj["result"])
51
52
  return
@@ -55,8 +56,9 @@ class TaskThread(Thread):
55
56
  print("")
56
57
  self.checking = True
57
58
  self.checkCount = 0
58
- time.sleep(5)
59
- while self.checking and self.checkCount < 400:
59
+ wait_time_step = 5
60
+ time.sleep(wait_time_step)
61
+ while self.checking and self.checkCount < self.timeout / wait_time_step:
60
62
  finish, success, data, progress = ryry_webapi.checkTask(self.checkUUID)
61
63
  print_progress_bar(progress, 100, f"Task{self.idx} {self.func}", self.idx+1, self.total)
62
64
  if finish:
@@ -65,7 +67,7 @@ class TaskThread(Thread):
65
67
  self.call_back(self.idx, data)
66
68
  return
67
69
  self.checkCount += 1
68
- time.sleep(5)
70
+ time.sleep(wait_time_step)
69
71
  else:
70
72
  print(f"widget {self.func} not found")
71
73
  self.call_back(self.idx, None)
@@ -79,7 +81,7 @@ class Task:
79
81
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
80
82
  thread_data = {}
81
83
 
82
- def __init__(self, func: str, multi_params: list[dict], fromUUID=""):
84
+ def __init__(self, func: str, multi_params: list[dict], fromUUID="", timeout=3600):
83
85
  self.thread_data = {}
84
86
 
85
87
  realTaskUUID = fromUUID
@@ -98,7 +100,7 @@ class Task:
98
100
  param["fromUUID"] = realTaskUUID
99
101
  param["domain"] = domain
100
102
  self.thread_data[str(idx)] = {
101
- "thread" : TaskThread(idx, len(multi_params), func, param, _callback),
103
+ "thread" : TaskThread(idx, len(multi_params), func, param, _callback, timeout),
102
104
  "result" : None
103
105
  }
104
106
  idx+=1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.43
3
+ Version: 2.46
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.43"
6
+ ryry_version = "2.46"
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.43"
3
- app_bulld_number=243
4
- app_bulld_anchor="Noh_2024-08-26 22:08:34.396686"
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
File without changes
File without changes