ryry-cli 2.80__tar.gz → 2.82__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.80 → ryry_cli-2.82}/PKG-INFO +1 -1
- ryry_cli-2.82/ryry/constant.py +4 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/ryry_webapi.py +48 -50
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/server_func.py +13 -1
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/store.py +41 -10
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/upload.py +29 -6
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/utils.py +1 -1
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/PKG-INFO +1 -1
- {ryry_cli-2.80 → ryry_cli-2.82}/setup.py +1 -1
- ryry_cli-2.80/ryry/constant.py +0 -4
- {ryry_cli-2.80 → ryry_cli-2.82}/LICENSE +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/README.md +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/__init__.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/main.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/ryry_server_socket.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/ryry_service.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/ryry_widget.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/script_template/__init__.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/script_template/main.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/script_template/run.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/task.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry/taskUtils.py +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/SOURCES.txt +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/dependency_links.txt +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/entry_points.txt +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/requires.txt +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/ryry_cli.egg-info/top_level.txt +0 -0
- {ryry_cli-2.80 → ryry_cli-2.82}/setup.cfg +0 -0
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import json, os,
|
|
1
|
+
import json, os, datetime
|
|
2
2
|
import uuid, requests, calendar, time
|
|
3
|
+
from requests.adapters import HTTPAdapter
|
|
4
|
+
from urllib3.util.retry import Retry
|
|
3
5
|
|
|
4
6
|
from ryry import store
|
|
5
7
|
from ryry import utils
|
|
6
8
|
from ryry import taskUtils
|
|
7
|
-
from ryry import constant
|
|
8
9
|
|
|
9
|
-
def
|
|
10
|
-
|
|
10
|
+
def _domain_post(func, params, files={}, timeout=10, domain="api.dalipen.com"):
|
|
11
|
+
headers = {
|
|
12
|
+
'Connection': 'close',
|
|
13
|
+
'Usertoken': "0cce7cfe3629e16ee9b3ea8563305d3a15c524804da1861db07c2c867d79da63"
|
|
14
|
+
}
|
|
15
|
+
url = f"https://{domain}/{func}"
|
|
11
16
|
try:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
s.headers.update({'Usertoken':"0cce7cfe3629e16ee9b3ea8563305d3a15c524804da1861db07c2c867d79da63"})
|
|
16
|
-
if len(files) <= 0:
|
|
17
|
-
s.headers.update({'Content-Type':'application/json'})
|
|
18
|
-
res = s.post(url=f"https://api.dalipen.com/{func}", json=params, timeout=timeout, verify=False)
|
|
17
|
+
if not files:
|
|
18
|
+
headers['Content-Type'] = 'application/json'
|
|
19
|
+
res = requests.post(url, json=params, timeout=timeout, verify=False, headers=headers)
|
|
19
20
|
else:
|
|
20
|
-
res =
|
|
21
|
+
res = requests.post(url, data=params, files=files, timeout=timeout, verify=False, headers=headers)
|
|
21
22
|
if res.status_code == 200:
|
|
22
|
-
result_data = json
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return 0, "", result_data["data"]
|
|
23
|
+
result_data = res.json()
|
|
24
|
+
if result_data.get("code") == 0:
|
|
25
|
+
return 0, "", result_data.get("data", "")
|
|
26
26
|
else:
|
|
27
|
-
return result_data
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return result_data.get("code", -1), result_data.get("msg", "Unknown error"), ""
|
|
28
|
+
return -99, f"HTTP {res.status_code}: {res.text}", ""
|
|
29
|
+
except requests.RequestException as e:
|
|
30
|
+
return -99, f"request {func} RequestException!", ""
|
|
30
31
|
except Exception as e:
|
|
31
|
-
return -
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
return -99, f"request {func} Exception!", ""
|
|
33
|
+
|
|
34
|
+
def _aigc_post(func, params, files={}, timeout=10):
|
|
35
|
+
status, msg, data = _domain_post(func, params, files, timeout, "api.dalipen.com")
|
|
36
|
+
if status != -99:
|
|
37
|
+
return status, msg, data
|
|
38
|
+
return _domain_post(func, params, files, timeout, "aigc.zjtemplate.com")
|
|
36
39
|
#======================================== Task Function ==============================
|
|
37
40
|
def ServerTaskConfig():
|
|
38
41
|
r1, r2, r3 = _aigc_post("aigc/task/config", {})
|
|
@@ -44,29 +47,6 @@ def ServerTaskConfig():
|
|
|
44
47
|
consecutive_step = r3["step"]
|
|
45
48
|
return min_wait_time, max_wait_time, consecutive_step
|
|
46
49
|
|
|
47
|
-
GLOBAL_EXT_JSON = "{}"
|
|
48
|
-
def _extend():
|
|
49
|
-
global GLOBAL_EXT_JSON
|
|
50
|
-
if len(GLOBAL_EXT_JSON) < 10:
|
|
51
|
-
extInfo = store.readDeviceInfo()
|
|
52
|
-
extInfo["app"] = constant.app_name + " " + constant.app_version
|
|
53
|
-
extInfo["device"] = platform.system()
|
|
54
|
-
extInfo["device_version"] = platform.version()
|
|
55
|
-
extInfo["device_name"] = platform.node()
|
|
56
|
-
extInfo["device_model"] = platform.machine()
|
|
57
|
-
|
|
58
|
-
try:
|
|
59
|
-
extInfo["ip_address"] = requests.get('https://api.ipify.org').text
|
|
60
|
-
except Exception as e:
|
|
61
|
-
extInfo["ip_address"] = "unknown"
|
|
62
|
-
|
|
63
|
-
system_language, _ = locale.getdefaultlocale()
|
|
64
|
-
system_platform = platform.system().lower()
|
|
65
|
-
extInfo["language"] = system_language if system_language else "unknown"
|
|
66
|
-
extInfo["platform"] = system_platform if system_platform else "unknown"
|
|
67
|
-
GLOBAL_EXT_JSON = json.dumps(extInfo)
|
|
68
|
-
return GLOBAL_EXT_JSON
|
|
69
|
-
|
|
70
50
|
def GetTask():
|
|
71
51
|
widget_map = []
|
|
72
52
|
map = store.widgetMap()
|
|
@@ -79,7 +59,7 @@ def GetTask():
|
|
|
79
59
|
req = {
|
|
80
60
|
"widget_map": json.dumps(widget_map),
|
|
81
61
|
"limit": 1,
|
|
82
|
-
"extend":
|
|
62
|
+
"extend": store.extend()
|
|
83
63
|
}
|
|
84
64
|
r1, r2, r3 = _aigc_post("aigc/task/getTask", req)
|
|
85
65
|
if r1 != 0:
|
|
@@ -286,7 +266,7 @@ def createTask(widget_name, params):
|
|
|
286
266
|
req = {
|
|
287
267
|
"widget_name": widget_name,
|
|
288
268
|
"widget_data": json.dumps(params),
|
|
289
|
-
"extend":
|
|
269
|
+
"extend": json.dumps(store.extend())
|
|
290
270
|
}
|
|
291
271
|
r1, r2, r3 = _aigc_post("aigc/task/createTask", req)
|
|
292
272
|
if r1 != 0:
|
|
@@ -335,4 +315,22 @@ def checkTask(checkUUID):
|
|
|
335
315
|
elif r3["status"] == 2:
|
|
336
316
|
return True, True, json.loads(r3["task_result"]), r3["progress"]
|
|
337
317
|
elif r3["status"] == 3:
|
|
338
|
-
return True, False, r3["fail_reason"], r3["progress"]
|
|
318
|
+
return True, False, r3["fail_reason"], r3["progress"]
|
|
319
|
+
|
|
320
|
+
def multiCheckTask(checkUUIDs):
|
|
321
|
+
req = {
|
|
322
|
+
"task_uuids": checkUUIDs
|
|
323
|
+
}
|
|
324
|
+
r1, r2, r3 = _aigc_post("aigc/task/checkTasks", req)
|
|
325
|
+
result = []
|
|
326
|
+
if r1 != 0:
|
|
327
|
+
for checkUUID in checkUUIDs:
|
|
328
|
+
result.append([checkUUID, False, False, "server fail", 0])
|
|
329
|
+
for r3_item in r3:
|
|
330
|
+
if r3_item["status"] < 2:
|
|
331
|
+
result.append([r3_item["uuid"], False, False, "", r3_item["progress"]])
|
|
332
|
+
elif r3_item["status"] == 2:
|
|
333
|
+
result.append([r3_item["uuid"], True, True, json.loads(r3_item["task_result"]), r3_item["progress"]])
|
|
334
|
+
elif r3_item["status"] == 3:
|
|
335
|
+
result.append([r3_item["uuid"], True, False, r3_item["fail_reason"], r3_item["progress"]])
|
|
336
|
+
return result
|
|
@@ -153,4 +153,16 @@ class AsyncTask:
|
|
|
153
153
|
"success": success,
|
|
154
154
|
"data": data,
|
|
155
155
|
"progress": progress
|
|
156
|
-
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
def multiCheck(self, taskUUIDs):
|
|
159
|
+
results = ryry_webapi.multiCheckTask(taskUUIDs)
|
|
160
|
+
json_results = {}
|
|
161
|
+
for [taskUUID, finish, success, data, progress] in results:
|
|
162
|
+
json_results[taskUUID] = {
|
|
163
|
+
"finish": finish,
|
|
164
|
+
"success": success,
|
|
165
|
+
"data": data,
|
|
166
|
+
"progress": progress
|
|
167
|
+
}
|
|
168
|
+
return json_results
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import
|
|
1
|
+
import os, platform, json, requests, locale
|
|
2
|
+
from ryry import constant
|
|
3
3
|
|
|
4
4
|
def singleton(cls):
|
|
5
5
|
_instance = {}
|
|
@@ -127,19 +127,50 @@ def writeDeviceInfo(data):
|
|
|
127
127
|
read_data = sp.read()
|
|
128
128
|
read_data["deviceInfo"] = data
|
|
129
129
|
sp.write(read_data)
|
|
130
|
+
extend()
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
def
|
|
133
|
-
global
|
|
134
|
-
if
|
|
132
|
+
GLOBAL_EXT_JSON = {}
|
|
133
|
+
def extend():
|
|
134
|
+
global GLOBAL_EXT_JSON
|
|
135
|
+
if len(GLOBAL_EXT_JSON.keys()) < 3:
|
|
135
136
|
sp = Store()
|
|
136
137
|
read_data = sp.read()
|
|
137
|
-
if "
|
|
138
|
-
|
|
138
|
+
if "extend" in read_data:
|
|
139
|
+
GLOBAL_EXT_JSON = read_data["extend"]
|
|
140
|
+
if len(GLOBAL_EXT_JSON.keys()) < 3:
|
|
141
|
+
_genExtend()
|
|
139
142
|
else:
|
|
140
|
-
|
|
141
|
-
return
|
|
143
|
+
_genExtend()
|
|
144
|
+
return GLOBAL_EXT_JSON
|
|
142
145
|
|
|
146
|
+
def _genExtend():
|
|
147
|
+
sp = Store()
|
|
148
|
+
read_data = sp.read()
|
|
149
|
+
if "deviceInfo" in read_data:
|
|
150
|
+
extInfo = read_data["deviceInfo"]
|
|
151
|
+
else:
|
|
152
|
+
extInfo = {}
|
|
153
|
+
extInfo["app"] = constant.app_name + " " + constant.app_version
|
|
154
|
+
extInfo["device"] = platform.system()
|
|
155
|
+
extInfo["device_version"] = platform.version()
|
|
156
|
+
extInfo["device_name"] = platform.node()
|
|
157
|
+
extInfo["device_model"] = platform.machine()
|
|
158
|
+
|
|
159
|
+
try:
|
|
160
|
+
extInfo["ip_address"] = requests.get('https://api.ipify.org').text
|
|
161
|
+
except Exception as e:
|
|
162
|
+
extInfo["ip_address"] = "unknown"
|
|
163
|
+
|
|
164
|
+
system_language, _ = locale.getdefaultlocale()
|
|
165
|
+
system_platform = platform.system().lower()
|
|
166
|
+
extInfo["language"] = system_language if system_language else "unknown"
|
|
167
|
+
extInfo["platform"] = system_platform if system_platform else "unknown"
|
|
168
|
+
#save
|
|
169
|
+
read_data["extend"] = extInfo
|
|
170
|
+
sp.write(read_data)
|
|
171
|
+
global GLOBAL_EXT_JSON
|
|
172
|
+
GLOBAL_EXT_JSON = extInfo
|
|
173
|
+
|
|
143
174
|
def is_multithread():
|
|
144
175
|
return get_multithread() > 1
|
|
145
176
|
|
|
@@ -160,12 +160,35 @@ def getSubdomain(targetDomain):
|
|
|
160
160
|
return None
|
|
161
161
|
|
|
162
162
|
def getFirstSupportSubdomain():
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
def get_network_hash():
|
|
164
|
+
import socket
|
|
165
|
+
from hashlib import md5
|
|
166
|
+
local_ip = local_ip = socket.gethostbyname(socket.gethostname())
|
|
167
|
+
return md5(local_ip.encode('utf-8')).hexdigest()
|
|
168
|
+
network_hash = get_network_hash()
|
|
169
|
+
def _getFirstSupportSubdomain():
|
|
170
|
+
for ip in SUBDOMAIN.keys():
|
|
171
|
+
for host_item in SUBDOMAIN[ip]:
|
|
172
|
+
if _can_connect_ftp(ip, host_item["port"], host_item["username"], host_item["password"], host_item["writepath"]):
|
|
173
|
+
return host_item
|
|
174
|
+
return None
|
|
175
|
+
from ryry import store
|
|
176
|
+
sp = store.Store()
|
|
177
|
+
read_data = sp.read()
|
|
178
|
+
firstSupportDomainConfig = read_data.get("firstSupportDomainConfig", {})
|
|
179
|
+
if len(firstSupportDomainConfig.keys()) < 1:
|
|
180
|
+
firstSupportDomainConfig = _getFirstSupportSubdomain()
|
|
181
|
+
firstSupportDomainConfig["hash"] = network_hash
|
|
182
|
+
read_data["firstSupportDomainConfig"] = firstSupportDomainConfig
|
|
183
|
+
sp.write(read_data)
|
|
184
|
+
else:
|
|
185
|
+
last_network_hash = firstSupportDomainConfig["hash"]
|
|
186
|
+
if last_network_hash != network_hash:
|
|
187
|
+
firstSupportDomainConfig = _getFirstSupportSubdomain()
|
|
188
|
+
firstSupportDomainConfig["hash"] = network_hash
|
|
189
|
+
read_data["firstSupportDomainConfig"] = firstSupportDomainConfig
|
|
190
|
+
sp.write(read_data)
|
|
191
|
+
return firstSupportDomainConfig
|
|
169
192
|
|
|
170
193
|
def download(url, saveDir):
|
|
171
194
|
import uuid, requests, os
|
|
@@ -164,7 +164,7 @@ def deviceInfo():
|
|
|
164
164
|
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
|
|
165
165
|
data["gpu"]["list"].append(f"GPU{i}: {pynvml.nvmlDeviceGetName(handle)}")
|
|
166
166
|
memInfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
|
|
167
|
-
data["gpu"]["mem"].append(f"GPU{i}: total:{memInfo.total/
|
|
167
|
+
data["gpu"]["mem"].append(f"GPU{i}: total:{(memInfo.total/G):.1f} G free:{(memInfo.free/G):.1f} G")
|
|
168
168
|
|
|
169
169
|
pynvml.nvmlShutdown()
|
|
170
170
|
except Exception as e:
|
ryry_cli-2.80/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
|