ryry-cli 2.52__tar.gz → 2.53__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.52 → ryry_cli-2.53}/PKG-INFO +1 -4
  2. ryry_cli-2.53/ryry/constant.py +4 -0
  3. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/ryry_service.py +1 -1
  4. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/ryry_widget.py +76 -112
  5. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/taskUtils.py +4 -3
  6. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/utils.py +0 -1
  7. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/PKG-INFO +1 -4
  8. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/requires.txt +0 -3
  9. {ryry_cli-2.52 → ryry_cli-2.53}/setup.py +1 -7
  10. ryry_cli-2.52/ryry/constant.py +0 -5
  11. {ryry_cli-2.52 → ryry_cli-2.53}/LICENSE +0 -0
  12. {ryry_cli-2.52 → ryry_cli-2.53}/README.md +0 -0
  13. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/__init__.py +0 -0
  14. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/main.py +0 -0
  15. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/ryry_server_socket.py +0 -0
  16. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/ryry_webapi.py +0 -0
  17. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/script_template/__init__.py +0 -0
  18. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/script_template/main.py +0 -0
  19. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/script_template/run.py +0 -0
  20. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/server_func.py +0 -0
  21. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/store.py +0 -0
  22. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/task.py +0 -0
  23. {ryry_cli-2.52 → ryry_cli-2.53}/ryry/upload.py +0 -0
  24. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/SOURCES.txt +0 -0
  25. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/dependency_links.txt +0 -0
  26. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/entry_points.txt +0 -0
  27. {ryry_cli-2.52 → ryry_cli-2.53}/ryry_cli.egg-info/top_level.txt +0 -0
  28. {ryry_cli-2.52 → ryry_cli-2.53}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.52
3
+ Version: 2.53
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -20,12 +20,9 @@ Requires-Dist: pynvml
20
20
  Requires-Dist: requests_toolbelt
21
21
  Requires-Dist: matplotlib
22
22
  Requires-Dist: fake_useragent
23
- Requires-Dist: ping3
24
23
  Requires-Dist: piexif
25
24
  Requires-Dist: gputil
26
25
  Requires-Dist: urlparser
27
- Requires-Dist: setuptools
28
- Requires-Dist: twine
29
26
  Requires-Dist: python-crontab
30
27
  Requires-Dist: urllib3
31
28
 
@@ -0,0 +1,4 @@
1
+ #!!!!! do not change this file !!!!!
2
+ app_version="2.53"
3
+ app_bulld_anchor="Noh_2024-09-12 12:08:31.895160"
4
+ app_name="ryry-cli"
@@ -163,7 +163,7 @@ class ryryPackageThread(Thread):
163
163
  # #update cli
164
164
  # remote_version = ryry_widget._remote_package_version("ryry-cli")
165
165
  # simple = "https://pypi.python.org/simple/"
166
- # local_version = ryry_widget._local_package_version("ryry-cli")
166
+ # local_version, local_path = ryry_widget._local_package_info("ryry-cli")
167
167
  # if ryry_widget.compare_versions(remote_version, local_version) > 0:
168
168
  # print("start update progress...")
169
169
  # utils.begin_restart("auto upgrade ryry-cli", True, simple)
@@ -1,16 +1,5 @@
1
- import os
2
- import json
3
- import sys
4
- import shutil
5
- import zipfile
6
- import pkg_resources
7
- import threading
8
- import time
9
- import requests
10
- import random
11
- import subprocess
12
- import platform
13
- import re
1
+ import os, json,sys,shutil,zipfile,pkg_resources,threading,time,requests
2
+ import random, uuid, re, subprocess, platform, zipfile
14
3
  from pkg_resources import get_distribution
15
4
  import socket
16
5
 
@@ -40,17 +29,17 @@ def compare_versions(version1, version2):
40
29
  return 0
41
30
 
42
31
  #real time version get
43
- def _local_package_version(py_package):
32
+ def _local_package_info(py_package):
44
33
  _map = store.widgetMap()
45
34
  for it in _map:
46
35
  try:
47
36
  widget_path = os.path.dirname(_map[it]["path"])
48
37
  widget_config = GetWidgetConfig(widget_path)
49
38
  if widget_config["name"] == py_package:
50
- return widget_config["version"]
39
+ return widget_config["version"], widget_path
51
40
  except:
52
41
  pass
53
- return ''
42
+ return '', ''
54
43
 
55
44
  def _pypi_folder_name(name):
56
45
  import re
@@ -135,10 +124,11 @@ def CheckWidgetDataInPath(path):
135
124
 
136
125
  return True
137
126
 
138
- def addWidgetToEnv(root, mute=False):
127
+ def addWidgetToEnv(name_or_root, mute=False):
139
128
  #maybe pip package
129
+ root = ""
140
130
  try:
141
- package = pkg_resources.get_distribution(root)
131
+ package = pkg_resources.get_distribution(name_or_root)
142
132
  local_version = package.version
143
133
  name = package.project_name
144
134
  version = package.version
@@ -146,6 +136,14 @@ def addWidgetToEnv(root, mute=False):
146
136
  except:
147
137
  pass
148
138
 
139
+ if os.path.exists(root) == False:
140
+ root = os.path.join(os.path.dirname(os.path.abspath(__file__)), "widget", name_or_root)
141
+
142
+ if os.path.exists(root) == False:
143
+ if mute == False:
144
+ print(f"{name_or_root} not found")
145
+ return
146
+
149
147
  if CheckWidgetDataInPath(root) == False:
150
148
  return
151
149
  data = GetWidgetConfig(root)
@@ -204,8 +202,14 @@ def publishWidget(package_folder):
204
202
  name = None
205
203
  if "name" in data:
206
204
  name = data["name"]
205
+ if name == "Demo":
206
+ print(f"请修改widget名字, 位置为{package_folder}/config.json")
207
+ return
207
208
  if "py_package" in data:
208
209
  name = data["py_package"]
210
+ if re.match(r'^[A-Za-z0-9_-]+$', name) == False:
211
+ print(f"请修改widget名字, 只能包含英文字母、数字、下划线、中划线")
212
+ return
209
213
  local_version = "1.0"
210
214
  if "version" in data:
211
215
  local_version = data["version"]
@@ -230,94 +234,30 @@ def publishWidget(package_folder):
230
234
  requirements += f"'{reals[:reals.index(';')]}',"
231
235
  elif "#" not in reals:
232
236
  requirements += f"'{reals}',"
233
- pip_dir = os.path.join(os.path.dirname(package_folder), "tmp")
234
- if os.path.exists(pip_dir):
235
- shutil.rmtree(pip_dir)
236
- os.makedirs(pip_dir)
237
- source_folder_name = _pypi_folder_name(name)
238
- pip_source_dir = os.path.join(pip_dir, source_folder_name)
239
- shutil.copytree(package_folder, pip_source_dir)
240
- config_json_file = os.path.join(pip_source_dir, "config.json")
241
- if os.path.exists(config_json_file):
242
- with open(config_json_file, 'r') as f:
243
- cc = json.load(f)
244
- cc["py_package"] = name
245
- cc["name"] = name
246
- cc["version"] = local_version
247
- with open(config_json_file, 'w') as f:
248
- json.dump(cc, f)
249
- if os.path.exists(os.path.join(pip_source_dir, "__init__.py")) == False:
250
- with open(os.path.join(pip_source_dir, "__init__.py"), 'w') as f:
251
- f.write("")
252
- #get datafile
253
- data_file_config = {}
254
- for root,dirs,files in os.walk(package_folder):
255
- for file in files:
256
- if file.find(".") > 0 and file[file.rindex("."):] == ".py":
257
- continue
258
- dir_path = os.path.relpath(root, package_folder)
259
- file_path = os.path.join(dir_path, file)
260
- file_path = os.path.normpath(file_path).replace("\\", "/")
261
- k = dir_path.replace("\\", "/")
262
- if k in data_file_config:
263
- data_file_config[k].append(file_path)
264
- else:
265
- data_file_config[k] = [file_path]
266
- package_data_str = ""
267
- for k in data_file_config:
268
- for p in data_file_config[k]:
269
- package_data_str += f"'{p}',"
270
- setup_py = os.path.join(pip_dir, "setup.py")
271
- with open(setup_py, 'w') as f:
272
- f.write(f'''import setuptools, os, sys, subprocess, datetime
273
-
274
- setuptools.setup(
275
- name="{name}",
276
- version="{local_version}",
277
- author="{user_id}",
278
- author_email="{user_id}@dalipen.com",
279
- description="ryry widget",
280
- long_description="privide by ryry-cli",
281
- long_description_content_type="text/markdown",
282
- url="https://ryryai.com/#/",
283
- packages=setuptools.find_packages(),
284
- classifiers=[
285
- "Programming Language :: Python :: 3",
286
- "License :: OSI Approved :: MIT License",
287
- "Operating System :: OS Independent",
288
- ],
289
- py_modules=[],
290
- install_requires=[
291
- {requirements}
292
- ],
293
- package_data={{
294
- '{name}':[{package_data_str}]
295
- }},
296
- entry_points={{
297
- 'console_scripts':[
298
- '{name} = {source_folder_name}.main:main'
299
- ]
300
- }},
301
- python_requires='>=3.4',
302
- )
303
- ''')
237
+ temp_dir = os.path.join(os.path.dirname(package_folder), "tmp")
238
+ if os.path.exists(temp_dir):
239
+ shutil.rmtree(temp_dir)
240
+ publish_zip_file = os.path.join(os.path.dirname(package_folder), "tmp.zip")
304
241
  try:
305
- #build
306
- subprocess.run(f"python {setup_py} sdist bdist_wheel", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=pip_dir, encoding="utf-8")
307
- #uninstall
308
- subprocess.run(f"pip uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="utf-8")
309
- subprocess.run(f"pip3 uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="utf-8")
310
- #install
311
- whl = utils.firstExitWithDir(os.path.join(pip_dir, "dist"), "whl")
312
- subprocess.run(f"pip install {whl} --extra-index-url https://pypi.python.org/simple/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="utf-8")
313
- subprocess.run(f"pip3 install {whl} --extra-index-url https://pypi.python.org/simple/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="utf-8")
242
+ shutil.copytree(package_folder, temp_dir)
243
+ #archive zip file
244
+ with zipfile.ZipFile(publish_zip_file, 'w', zipfile.ZIP_DEFLATED) as zipf:
245
+ for root, dirs, files in os.walk(temp_dir):
246
+ if root.startswith(".") or root == "__pycache__":
247
+ continue
248
+ for file in files:
249
+ file_path = os.path.join(root, file)
250
+ relative_path = os.path.relpath(file_path, temp_dir)
251
+ zipf.write(file_path, arcname=relative_path)
314
252
  #upload
315
- ryry_webapi.uploadWidget(widget_id, name, whl, ".whl", local_version)
253
+ ryry_webapi.uploadWidget(widget_id, name, publish_zip_file, ".zip", local_version)
316
254
  print(f"发布 {name}_{local_version} -> 成功")
317
255
  except Exception as ex:
318
256
  print(ex)
319
257
  finally:
320
- shutil.rmtree(pip_dir)
258
+ shutil.rmtree(temp_dir)
259
+ if os.path.exists(publish_zip_file)
260
+ os.remove(publish_zip_file)
321
261
 
322
262
  def widgetUpdateNotify(widgetName, oldver, newver):
323
263
  device_id = utils.generate_unique_id()
@@ -341,7 +281,7 @@ def widgetInstallNotify(widgetName, newver):
341
281
  }
342
282
  })
343
283
 
344
- def pipReInstall(name, url):
284
+ def widgetReInstall(name, url, local_path):
345
285
  def find_pip_command():
346
286
  possible_pips = ['pip3.11', 'pip', 'pip3']
347
287
  for cmd in possible_pips:
@@ -357,11 +297,33 @@ def pipReInstall(name, url):
357
297
 
358
298
  raise RuntimeError("No pip command found on the system.")
359
299
  pip_cmd = find_pip_command()
360
- if name:
361
- subprocess.run(f"{pip_cmd} uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
362
- subprocess.run(f"{pip_cmd} install {url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
363
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
300
+ if url.endswith(".whl"):
301
+ if name:
302
+ subprocess.run(f"{pip_cmd} uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
303
+ subprocess.run(f"{pip_cmd} install {url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
304
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
305
+ elif url.endswith(".zip"):
306
+ if os.path.exists(local_path) == False:
307
+ local_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "widget", name)
364
308
 
309
+ download_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), ''.join(str(uuid.uuid4()).split('-')) + ".zip")
310
+ with open(download_file, 'wb+') as f:
311
+ f.write(requests.get(url).content)
312
+ try:
313
+ if os.path.exists(download_file) and os.stat(download_file).st_size > 100:
314
+ if os.path.exists(local_path):
315
+ shutil.rmtree(local_path)
316
+ os.makedirs(local_path)
317
+ with zipfile.ZipFile(download_file, "r") as zip_ref:
318
+ zip_ref.extractall(local_path)
319
+ = os.path.join(local_path, "requirements.txt")
320
+ if os.path.exists(requirements_file):
321
+ subprocess.run(f"{pip_cmd} install -r {requirements_file} -i https://pypi.python.org/simple/",
322
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
323
+ finally:
324
+ if os.path.exists(download_file):
325
+ os.remove(download_file)
326
+
365
327
  def UpdateWidgetFromPypi():
366
328
  _map = store.widgetMap()
367
329
  for it in _map:
@@ -380,12 +342,12 @@ def UpdateWidgetFromPypi():
380
342
  local_version = data.get("version", "")
381
343
  widgetid, remote_version, package_url = ryry_webapi.findWidget(py_package)
382
344
  if len(local_version) <= 0:
383
- local_version = _local_package_version(py_package)
345
+ local_version, local_path = _local_package_info(py_package)
384
346
  if len(local_version) <= 0:
385
347
  continue
386
348
  if compare_versions(remote_version, local_version) > 0:
387
349
  #update
388
- pipReInstall(py_package, package_url)
350
+ widgetReInstall(py_package, package_url, local_path)
389
351
  widgetUpdateNotify(py_package, local_version, remote_version)
390
352
  except Exception as ex:
391
353
  print(ex)
@@ -393,7 +355,7 @@ def UpdateWidgetFromPypi():
393
355
  for widget_id, widget_name, remote_version, package_url in ryry_webapi.getAutoDeployWidget():
394
356
  if widget_id not in _map:
395
357
  try:
396
- pipReInstall(widget_name, package_url)
358
+ widgetReInstall(widget_name, package_url)
397
359
  widgetInstallNotify(widget_name, remote_version)
398
360
  addWidgetToEnv(widget_name)
399
361
  except Exception as ex:
@@ -405,12 +367,14 @@ def installWidget(name):
405
367
  if len(widgetid) <= 0:
406
368
  print(f"{name} 不存在")
407
369
  return
408
- local_version = _local_package_version(name)
370
+ local_version, local_path = _local_package_info(name)
409
371
  if compare_versions(remote_version, local_version) > 0:
410
372
  #update
411
- pipReInstall(name, package_url)
373
+ widgetReInstall(name, package_url, local_path)
412
374
  widgetInstallNotify(name, remote_version)
413
- addWidgetToEnv(name)
375
+ addWidgetToEnv(name, True)
376
+ print(f"成功安装 {name} {remote_version}")
414
377
  else:
415
378
  print(f"本地已是最新版本 {remote_version}")
416
-
379
+
380
+ installWidget("McnDayTask")
@@ -81,8 +81,8 @@ def getTaskLog(taskUUID):
81
81
  return []
82
82
 
83
83
  def _uploadLog(taskUUID):
84
+ log_path = f"{os.path.dirname(os.path.abspath(__file__))}/log_{taskUUID}.log"
84
85
  try:
85
- log_path = f"{os.path.dirname(os.path.abspath(__file__))}/log_{taskUUID}.log"
86
86
  with open(log_path, 'w') as f:
87
87
  f.write("\n".join(getTaskLog(taskUUID)))
88
88
  notifyWechatRobot({
@@ -91,10 +91,11 @@ def _uploadLog(taskUUID):
91
91
  "media_id": uploadFile2Wechat(log_path)
92
92
  }
93
93
  })
94
- if os.path.exists(log_path):
95
- os.remove(log_path)
96
94
  except:
97
95
  pass
96
+ finally:
97
+ if os.path.exists(log_path):
98
+ os.remove(log_path)
98
99
 
99
100
  def notifyTaskFail(taskUUID, reason):
100
101
  try:
@@ -11,7 +11,6 @@ from datetime import datetime, timedelta
11
11
  import http
12
12
  import json
13
13
  from pathlib import Path
14
- import zipfile
15
14
  import socket
16
15
  from PIL import Image
17
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.52
3
+ Version: 2.53
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -20,12 +20,9 @@ Requires-Dist: pynvml
20
20
  Requires-Dist: requests_toolbelt
21
21
  Requires-Dist: matplotlib
22
22
  Requires-Dist: fake_useragent
23
- Requires-Dist: ping3
24
23
  Requires-Dist: piexif
25
24
  Requires-Dist: gputil
26
25
  Requires-Dist: urlparser
27
- Requires-Dist: setuptools
28
- Requires-Dist: twine
29
26
  Requires-Dist: python-crontab
30
27
  Requires-Dist: urllib3
31
28
 
@@ -7,11 +7,8 @@ pynvml
7
7
  requests_toolbelt
8
8
  matplotlib
9
9
  fake_useragent
10
- ping3
11
10
  piexif
12
11
  gputil
13
12
  urlparser
14
- setuptools
15
- twine
16
13
  python-crontab
17
14
  urllib3
@@ -3,8 +3,7 @@ import os
3
3
  import subprocess
4
4
  import datetime
5
5
 
6
- ryry_version = "2.52"
7
- ryry_build_number = int(ryry_version.replace(".",""))
6
+ ryry_version = "2.53"
8
7
  cur_dir = os.path.dirname(os.path.abspath(__file__))
9
8
  constanspy = os.path.join(cur_dir, "ryry", "constant.py")
10
9
  try:
@@ -17,7 +16,6 @@ try:
17
16
  with open(constanspy, 'w') as f:
18
17
  f.write(f'''#!!!!! do not change this file !!!!!
19
18
  app_version="{ryry_version}"
20
- app_bulld_number={ryry_build_number}
21
19
  app_bulld_anchor="{build_user}_{build_pts}"
22
20
  app_name="ryry-cli"
23
21
  ''')
@@ -25,7 +23,6 @@ except:
25
23
  with open(constanspy, 'w') as f:
26
24
  f.write(f'''#!!!!! do not change this file !!!!!
27
25
  app_version="{ryry_version}"
28
- app_bulld_number=1
29
26
  app_bulld_anchor=""
30
27
  app_name="ryry-cli"
31
28
  ''')
@@ -58,12 +55,9 @@ setuptools.setup(
58
55
  'requests_toolbelt',
59
56
  'matplotlib',
60
57
  'fake_useragent',
61
- 'ping3',
62
58
  'piexif',
63
59
  'gputil',
64
60
  'urlparser',
65
- 'setuptools',
66
- 'twine',
67
61
  'python-crontab',
68
62
  'urllib3',
69
63
  ],
@@ -1,5 +0,0 @@
1
- #!!!!! do not change this file !!!!!
2
- app_version="2.52"
3
- app_bulld_number=252
4
- app_bulld_anchor="Noh_2024-09-09 11:49:02.049734"
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