ryry-cli 2.28__tar.gz → 2.29__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.28/ryry_cli.egg-info → ryry_cli-2.29}/PKG-INFO +1 -1
- ryry_cli-2.29/ryry/constant.py +5 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/ryry_widget.py +2 -1
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/script_template/run.py +1 -5
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/server_func.py +30 -16
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/store.py +13 -16
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/task.py +11 -56
- {ryry_cli-2.28 → ryry_cli-2.29/ryry_cli.egg-info}/PKG-INFO +1 -1
- {ryry_cli-2.28 → ryry_cli-2.29}/setup.py +1 -1
- ryry_cli-2.28/ryry/constant.py +0 -5
- {ryry_cli-2.28 → ryry_cli-2.29}/LICENSE +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/README.md +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/__init__.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/main.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/ryry_server_socket.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/ryry_service.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/ryry_webapi.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/script_template/__init__.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/script_template/main.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/taskUtils.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/upload.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry/utils.py +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry_cli.egg-info/SOURCES.txt +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry_cli.egg-info/dependency_links.txt +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry_cli.egg-info/entry_points.txt +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry_cli.egg-info/requires.txt +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/ryry_cli.egg-info/top_level.txt +0 -0
- {ryry_cli-2.28 → ryry_cli-2.29}/setup.cfg +0 -0
|
@@ -174,8 +174,9 @@ def addWidgetToEnv(root, mute=False):
|
|
|
174
174
|
return
|
|
175
175
|
data = GetWidgetConfig(root)
|
|
176
176
|
widget_id = data["widget_id"]
|
|
177
|
+
name = data["name"]
|
|
177
178
|
mainPythonPath = os.path.join(root, "main.py")
|
|
178
|
-
store.insertWidget(widget_id, mainPythonPath)
|
|
179
|
+
store.insertWidget(widget_id, name, mainPythonPath)
|
|
179
180
|
if mute == False:
|
|
180
181
|
print(f"add {widget_id.ljust(len(widget_id)+4)} {mainPythonPath}")
|
|
181
182
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import time, urllib3, sys, os
|
|
1
|
+
import time, urllib3, sys, os, uuid
|
|
2
2
|
from threading import Thread, Lock
|
|
3
3
|
|
|
4
4
|
from ryry import ryry_webapi
|
|
5
5
|
from ryry import upload
|
|
6
6
|
from ryry import taskUtils
|
|
7
|
+
from ryry import task
|
|
7
8
|
|
|
8
9
|
lock = Lock()
|
|
9
10
|
def print_progress_bar(iteration, total, name, idx, total_bars):
|
|
@@ -35,24 +36,37 @@ class TaskThread(Thread):
|
|
|
35
36
|
if self.call_back == None:
|
|
36
37
|
raise Exception("need callback function")
|
|
37
38
|
self.start()
|
|
39
|
+
|
|
38
40
|
def run(self):
|
|
39
41
|
self.checking = False
|
|
40
42
|
self.result = False, "Unknow"
|
|
41
43
|
if len(self.func) > 0:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
cmd = task.cmdWithWidgetName(self.func)
|
|
45
|
+
if cmd:
|
|
46
|
+
print("======")
|
|
47
|
+
executeSuccess, result_obj = task.executeLocalPython("local_" + ''.join(str(uuid.uuid4()).split('-')), cmd, self.params)
|
|
48
|
+
print(result_obj)
|
|
49
|
+
if executeSuccess and result_obj["status"] == 0:
|
|
50
|
+
self.call_back(self.idx, result_obj["result"])
|
|
51
|
+
return
|
|
52
|
+
else:
|
|
53
|
+
print("=====123123123=")
|
|
54
|
+
# run_server
|
|
55
|
+
self.checkUUID = ryry_webapi.createTask(self.func, self.params)
|
|
56
|
+
print("")
|
|
57
|
+
self.checking = True
|
|
58
|
+
self.checkCount = 0
|
|
59
|
+
time.sleep(5)
|
|
60
|
+
while self.checking and self.checkCount < 200:
|
|
61
|
+
finish, success, data, progress = ryry_webapi.checkTask(self.checkUUID)
|
|
62
|
+
print_progress_bar(progress, 100, f"Task{self.idx} {self.func}", self.idx+1, self.total)
|
|
63
|
+
if finish:
|
|
64
|
+
self.checking = False
|
|
65
|
+
if success:
|
|
66
|
+
self.call_back(self.idx, data)
|
|
67
|
+
return
|
|
68
|
+
self.checkCount += 1
|
|
69
|
+
time.sleep(3)
|
|
56
70
|
else:
|
|
57
71
|
print(f"widget {self.func} not found")
|
|
58
72
|
self.call_back(self.idx, None)
|
|
@@ -64,7 +78,7 @@ class TaskThread(Thread):
|
|
|
64
78
|
class Task:
|
|
65
79
|
thread_data = {}
|
|
66
80
|
|
|
67
|
-
def __init__(self, func: str, multi_params: list[dict], fromUUID=
|
|
81
|
+
def __init__(self, func: str, multi_params: list[dict], fromUUID=""):
|
|
68
82
|
urllib3.disable_warnings()
|
|
69
83
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
70
84
|
|
|
@@ -29,14 +29,6 @@ class Store(object):
|
|
|
29
29
|
def write(self, data):
|
|
30
30
|
with open(self.path, 'w') as f:
|
|
31
31
|
json.dump(data, f)
|
|
32
|
-
|
|
33
|
-
def token():
|
|
34
|
-
sp = Store()
|
|
35
|
-
read_data = sp.read()
|
|
36
|
-
if "token" in read_data:
|
|
37
|
-
return read_data["token"]
|
|
38
|
-
else:
|
|
39
|
-
return ""
|
|
40
32
|
|
|
41
33
|
#============================== widget ================================
|
|
42
34
|
def isCreateWidget():
|
|
@@ -61,7 +53,7 @@ def widgetMap():
|
|
|
61
53
|
else:
|
|
62
54
|
return {}
|
|
63
55
|
|
|
64
|
-
def insertWidget(widget_id, path):
|
|
56
|
+
def insertWidget(widget_id, name, path):
|
|
65
57
|
sp = Store()
|
|
66
58
|
read_data = sp.read()
|
|
67
59
|
if "widgets" not in read_data:
|
|
@@ -72,7 +64,8 @@ def insertWidget(widget_id, path):
|
|
|
72
64
|
else:
|
|
73
65
|
widgetsMap[widget_id] = {
|
|
74
66
|
"isBlock": False,
|
|
75
|
-
"path" : path
|
|
67
|
+
"path" : path,
|
|
68
|
+
"name" : name
|
|
76
69
|
}
|
|
77
70
|
for k in list(widgetsMap.keys()):
|
|
78
71
|
if isinstance(widgetsMap[k], (dict)):
|
|
@@ -135,13 +128,17 @@ def writeDeviceInfo(data):
|
|
|
135
128
|
read_data["deviceInfo"] = data
|
|
136
129
|
sp.write(read_data)
|
|
137
130
|
|
|
131
|
+
cache_device_info = None
|
|
138
132
|
def readDeviceInfo():
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
global cache_device_info
|
|
134
|
+
if cache_device_info == None:
|
|
135
|
+
sp = Store()
|
|
136
|
+
read_data = sp.read()
|
|
137
|
+
if "deviceInfo" in read_data:
|
|
138
|
+
cache_device_info = read_data["deviceInfo"]
|
|
139
|
+
else:
|
|
140
|
+
cache_device_info = {}
|
|
141
|
+
return cache_device_info
|
|
145
142
|
|
|
146
143
|
def is_multithread():
|
|
147
144
|
return get_multithread() > 1
|
|
@@ -30,8 +30,6 @@ def runTask(it, timeout):
|
|
|
30
30
|
msg = ""
|
|
31
31
|
if len(result_obj["message"]) > 0:
|
|
32
32
|
msg = str(result_obj["message"])
|
|
33
|
-
if is_ok:
|
|
34
|
-
checkResult(taskUUID, result_obj)
|
|
35
33
|
taskUtils.taskPrint(taskUUID, f"{current_thread().name}=== task {taskUUID} is_ok={is_ok} ")
|
|
36
34
|
taskUtils.saveCounter(taskUUID, (calendar.timegm(time.gmtime()) - start_time), is_ok)
|
|
37
35
|
return is_ok, msg, json.dumps(result_obj["result"], separators=(',', ':'))
|
|
@@ -51,7 +49,15 @@ def cmdWithWidget(widget_id):
|
|
|
51
49
|
return path
|
|
52
50
|
return None
|
|
53
51
|
|
|
54
|
-
def
|
|
52
|
+
def cmdWithWidgetName(name):
|
|
53
|
+
map = store.widgetMap()
|
|
54
|
+
for widget_id in map.keys():
|
|
55
|
+
if map[widget_id]["name"] == name and map[widget_id]["isBlock"] == False:
|
|
56
|
+
is_block = map[widget_id]["isBlock"]
|
|
57
|
+
return map[widget_id]["path"]
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
def executeLocalPython(taskUUID, cmd, param, timeout=3600):
|
|
55
61
|
inputArgs = os.path.join(os.path.dirname(os.path.abspath(__file__)), f"{taskUUID}.in")
|
|
56
62
|
if os.path.exists(inputArgs):
|
|
57
63
|
os.remove(inputArgs)
|
|
@@ -127,58 +133,6 @@ def executeLocalPython(taskUUID, cmd, param, timeout):
|
|
|
127
133
|
os.remove(outArgs)
|
|
128
134
|
return executeSuccess, outData
|
|
129
135
|
|
|
130
|
-
def _needChangeValue(taskUUID, data, type, key):
|
|
131
|
-
if "type" not in data:
|
|
132
|
-
taskUtils.taskPrint(taskUUID, "result is not avalid")
|
|
133
|
-
return False
|
|
134
|
-
if data["type"] != type:
|
|
135
|
-
return False
|
|
136
|
-
if "extension" not in data or key not in data["extension"] or len(data["extension"][key]) == 0:
|
|
137
|
-
return True
|
|
138
|
-
return False
|
|
139
|
-
|
|
140
|
-
def checkResult(taskUUID, data):
|
|
141
|
-
try:
|
|
142
|
-
for it in data["result"]:
|
|
143
|
-
if "extension" not in it:
|
|
144
|
-
continue
|
|
145
|
-
if _needChangeValue(taskUUID, it, "text", "cover_url"):
|
|
146
|
-
it["extension"]["cover_url"] = ""
|
|
147
|
-
if _needChangeValue(taskUUID, it, "audio", "cover_url"):
|
|
148
|
-
it["extension"]["cover_url"] = ""
|
|
149
|
-
if _needChangeValue(taskUUID, it, "image", "cover_url"):
|
|
150
|
-
it["extension"]["cover_url"] = ""
|
|
151
|
-
if _needChangeValue(taskUUID, it, "video", "cover_url"):
|
|
152
|
-
it["extension"]["cover_url"] = ""
|
|
153
|
-
|
|
154
|
-
if "cover_url" in it["extension"] and len(it["extension"]["cover_url"]) > 0:
|
|
155
|
-
cover_url = str(it["extension"]["cover_url"]).replace('\\u0026', '&')
|
|
156
|
-
parsed_url = urlparse(cover_url)
|
|
157
|
-
params = parse_qs(parsed_url.query)
|
|
158
|
-
#add width & height if need
|
|
159
|
-
if "width" not in params and "height" not in params:
|
|
160
|
-
w, h = utils.getOssImageSize(cover_url)
|
|
161
|
-
if w > 0 and h > 0:
|
|
162
|
-
params["width"] = w
|
|
163
|
-
params["height"] = h
|
|
164
|
-
it["extension"]["width"] = w
|
|
165
|
-
it["extension"]["height"] = h
|
|
166
|
-
#remove optional parameters
|
|
167
|
-
for k in ["Expires","OSSAccessKeyId","Signature","security-token"]:
|
|
168
|
-
params.pop(k, None)
|
|
169
|
-
if "width" in it["extension"]:
|
|
170
|
-
if isinstance(it["extension"]["width"], str):
|
|
171
|
-
it["extension"]["width"] = int(it["extension"]["width"])
|
|
172
|
-
if "height" in it["extension"]:
|
|
173
|
-
if isinstance(it["extension"]["height"], str):
|
|
174
|
-
it["extension"]["height"] = int(it["extension"]["height"])
|
|
175
|
-
updated_query_string = urlencode(params, doseq=True)
|
|
176
|
-
final_url = parsed_url._replace(query=updated_query_string).geturl()
|
|
177
|
-
it["extension"]["cover_url"] = final_url
|
|
178
|
-
except Exception as ex:
|
|
179
|
-
taskUtils.taskPrint(taskUUID, f"result: {data} status is not valid, exception is {ex} , ignore")
|
|
180
|
-
pass
|
|
181
|
-
|
|
182
136
|
def updateProgress(data, progress=50, taskUUID=None):
|
|
183
137
|
realTaskUUID = taskUUID
|
|
184
138
|
if realTaskUUID == None or len(realTaskUUID) <= 0:
|
|
@@ -188,7 +142,8 @@ def updateProgress(data, progress=50, taskUUID=None):
|
|
|
188
142
|
progress = 0
|
|
189
143
|
if progress > 100:
|
|
190
144
|
progress = 100
|
|
191
|
-
|
|
145
|
+
if realTaskUUID.startswith("local_") == False:
|
|
146
|
+
return ryry_webapi.TaskUpdateProgress(realTaskUUID, progress, json.dumps(data))
|
|
192
147
|
|
|
193
148
|
def timeout_killprocess(proc, timeout): # """超过指定的秒数后杀死进程"""
|
|
194
149
|
import threading
|
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
import subprocess
|
|
4
4
|
import datetime
|
|
5
5
|
|
|
6
|
-
ryry_version = "2.
|
|
6
|
+
ryry_version = "2.29"
|
|
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")
|
ryry_cli-2.28/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
|