ryry-cli 2.7__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.
- {ryry_cli-2.7/ryry_cli.egg-info → ryry_cli-2.10}/PKG-INFO +1 -1
- ryry_cli-2.10/ryry/constant.py +5 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/ryry_service.py +3 -3
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/ryry_webapi.py +38 -17
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/ryry_widget.py +30 -24
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/server_func.py +34 -17
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/task.py +5 -5
- {ryry_cli-2.7 → ryry_cli-2.10/ryry_cli.egg-info}/PKG-INFO +1 -1
- {ryry_cli-2.7 → ryry_cli-2.10}/setup.py +1 -1
- ryry_cli-2.7/ryry/constant.py +0 -5
- {ryry_cli-2.7 → ryry_cli-2.10}/LICENSE +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/README.md +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/__init__.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/main.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/ryry_server_socket.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/script_template/__init__.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/script_template/main.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/script_template/run.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/store.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/taskUtils.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/upload.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry/utils.py +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry_cli.egg-info/SOURCES.txt +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry_cli.egg-info/dependency_links.txt +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry_cli.egg-info/entry_points.txt +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry_cli.egg-info/requires.txt +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/ryry_cli.egg-info/top_level.txt +0 -0
- {ryry_cli-2.7 → ryry_cli-2.10}/setup.cfg +0 -0
|
@@ -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(
|
|
153
|
-
if calendar.timegm(time.gmtime()) - self.last_check_time >
|
|
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(
|
|
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 = [
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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(
|
|
222
|
+
def createTask(widget_name, params):
|
|
216
223
|
req = {
|
|
217
|
-
"
|
|
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"]
|
|
@@ -277,18 +277,16 @@ def publishWidget(package_folder):
|
|
|
277
277
|
data_file_config = {}
|
|
278
278
|
for root,dirs,files in os.walk(package_folder):
|
|
279
279
|
for file in files:
|
|
280
|
-
if file.find(".")
|
|
280
|
+
if file.find(".") > 0 and file[file.rindex("."):] == ".py":
|
|
281
281
|
continue
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
k
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
else:
|
|
291
|
-
data_file_config[k] = [file_path]
|
|
282
|
+
dir_path = os.path.relpath(root, package_folder)
|
|
283
|
+
file_path = os.path.join(dir_path, file)
|
|
284
|
+
file_path = os.path.normpath(file_path).replace("\\", "/")
|
|
285
|
+
k = dir_path.replace("\\", "/")
|
|
286
|
+
if k in data_file_config:
|
|
287
|
+
data_file_config[k].append(file_path)
|
|
288
|
+
else:
|
|
289
|
+
data_file_config[k] = [file_path]
|
|
292
290
|
package_data_str = ""
|
|
293
291
|
for k in data_file_config:
|
|
294
292
|
for p in data_file_config[k]:
|
|
@@ -367,6 +365,15 @@ def widgetInstallNotify(widgetName, newver):
|
|
|
367
365
|
}
|
|
368
366
|
})
|
|
369
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
|
+
|
|
370
377
|
def UpdateWidgetFromPypi():
|
|
371
378
|
map = store.widgetMap()
|
|
372
379
|
for it in map:
|
|
@@ -386,17 +393,21 @@ def UpdateWidgetFromPypi():
|
|
|
386
393
|
local_version = _local_package_version(py_package)
|
|
387
394
|
if compare_versions(remote_version, local_version) > 0:
|
|
388
395
|
#update
|
|
389
|
-
|
|
390
|
-
subprocess.run(f"pip3 uninstall {py_package} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
391
|
-
subprocess.run(f"pip 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)
|
|
393
|
-
subprocess.run(f"pip3 install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
|
|
394
|
-
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
396
|
+
pipReInstall(py_package, package_url)
|
|
395
397
|
widgetUpdateNotify(py_package, local_version, remote_version)
|
|
396
398
|
except Exception as ex:
|
|
397
399
|
print(ex)
|
|
398
400
|
continue
|
|
399
|
-
|
|
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
|
+
|
|
400
411
|
def installWidget(name):
|
|
401
412
|
widgetid, remote_version, package_url = ryry_webapi.findWidget(name)
|
|
402
413
|
if len(widgetid) <= 0:
|
|
@@ -405,12 +416,7 @@ def installWidget(name):
|
|
|
405
416
|
local_version = _local_package_version(name)
|
|
406
417
|
if compare_versions(remote_version, local_version) > 0:
|
|
407
418
|
#update
|
|
408
|
-
|
|
409
|
-
subprocess.run(f"pip3 uninstall {name} -y", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
410
|
-
subprocess.run(f"pip 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)
|
|
412
|
-
subprocess.run(f"pip3 install {package_url} -i https://pypi.python.org/simple/ --extra-index-url https://pypi.python.org/simple/",
|
|
413
|
-
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
419
|
+
pipReInstall(name, package_url)
|
|
414
420
|
widgetInstallNotify(name, remote_version)
|
|
415
421
|
addWidgetToEnv(name)
|
|
416
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,
|
|
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.
|
|
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.
|
|
26
|
-
self.
|
|
27
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
40
|
-
print(f"waiting...")
|
|
41
|
-
time.sleep(1)
|
|
54
|
+
time.sleep(2)
|
|
42
55
|
else:
|
|
43
|
-
print(f"widget {self.func}
|
|
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
|
|
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,
|
|
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=
|
|
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 >
|
|
190
|
-
progress =
|
|
191
|
-
return ryry_webapi.TaskUpdateProgress(realTaskUUID, progress, json.dumps(data
|
|
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
|
ryry_cli-2.7/ryry/constant.py
DELETED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|