ryry-cli 6.14__tar.gz → 6.16__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-6.14/ryry_cli.egg-info → ryry_cli-6.16}/PKG-INFO +2 -2
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/constant.py +2 -2
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/ryry_webapi.py +1 -1
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/store.py +59 -5
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/upload.py +13 -26
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/utils.py +216 -69
- {ryry_cli-6.14 → ryry_cli-6.16/ryry_cli.egg-info}/PKG-INFO +2 -2
- {ryry_cli-6.14 → ryry_cli-6.16}/setup.py +2 -2
- {ryry_cli-6.14 → ryry_cli-6.16}/LICENSE +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/README.md +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/__init__.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/daemon_base.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/daemon_manager.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/main.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/proxy_manager.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/ryry_server_socket.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/ryry_service.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/ryry_widget.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/script_template/__init__.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/script_template/daemon.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/script_template/main.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/script_template/run.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/server_func.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/shared_memory.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/task.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry/taskUtils.py +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry_cli.egg-info/SOURCES.txt +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry_cli.egg-info/dependency_links.txt +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry_cli.egg-info/entry_points.txt +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry_cli.egg-info/requires.txt +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/ryry_cli.egg-info/top_level.txt +0 -0
- {ryry_cli-6.14 → ryry_cli-6.16}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ryry-cli
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.16
|
|
4
4
|
Summary: ryry tools
|
|
5
5
|
Home-page: https://github.com/dalipenMedia
|
|
6
6
|
Author: dalipen
|
|
@@ -8,7 +8,7 @@ Author-email: dalipen01@gmail.com
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
@@ -308,7 +308,7 @@ def _changeDomain(url, fix_domain):
|
|
|
308
308
|
|
|
309
309
|
def upload(localFilePath, ext, keepItAlways=False, needTranscode=False, additionalUrl=False):
|
|
310
310
|
try:
|
|
311
|
-
return _upload(localFilePath, ext, keepItAlways=
|
|
311
|
+
return _upload(localFilePath, ext, keepItAlways=keepItAlways)
|
|
312
312
|
except:
|
|
313
313
|
pass
|
|
314
314
|
from mecord import upload as mecord_upload
|
|
@@ -177,19 +177,73 @@ def extend():
|
|
|
177
177
|
_genExtend()
|
|
178
178
|
elif read_data["extend"].get("device_id", "") != read_data.get("deviceInfo", {}).get("device_id", ""):
|
|
179
179
|
_genExtend()
|
|
180
|
-
elif read_data["extend"].get("app", "") == "ryry-cli 6.
|
|
180
|
+
elif read_data["extend"].get("app", "") == "ryry-cli 6.16":
|
|
181
|
+
_genExtend()
|
|
182
|
+
elif any(k not in read_data["extend"] for k in ["device_id", "host_name", "cpu", "memory", "disk", "gpu"]):
|
|
181
183
|
_genExtend()
|
|
182
184
|
else:
|
|
183
185
|
_genExtend()
|
|
184
|
-
return
|
|
186
|
+
return _extendWithRuntimeInfo()
|
|
187
|
+
|
|
188
|
+
def _format_gb(value):
|
|
189
|
+
try:
|
|
190
|
+
return f"{float(value):.1f} G"
|
|
191
|
+
except:
|
|
192
|
+
return "-"
|
|
193
|
+
|
|
194
|
+
def _format_percent(value):
|
|
195
|
+
try:
|
|
196
|
+
return f"{float(value):.1f}%"
|
|
197
|
+
except:
|
|
198
|
+
return "0%"
|
|
199
|
+
|
|
200
|
+
def _extendWithRuntimeInfo():
|
|
201
|
+
try:
|
|
202
|
+
data = json.loads(GLOBAL_EXT_JSON)
|
|
203
|
+
from ryry import utils
|
|
204
|
+
runtime = utils.runtimeInfo()
|
|
205
|
+
cpu = data.setdefault("cpu", {})
|
|
206
|
+
cpu["percent"] = runtime.get("cpu", {}).get("percent")
|
|
207
|
+
cpu["load_avg"] = runtime.get("cpu", {}).get("load_avg")
|
|
208
|
+
cpu.setdefault("logical_count", runtime.get("cpu", {}).get("logical_count"))
|
|
209
|
+
cpu.setdefault("count", runtime.get("cpu", {}).get("physical_count"))
|
|
210
|
+
|
|
211
|
+
memory_runtime = runtime.get("memory", {})
|
|
212
|
+
memory = data.setdefault("memory", {})
|
|
213
|
+
memory["total"] = _format_gb(memory_runtime.get("total_gb"))
|
|
214
|
+
memory["available"] = _format_gb(memory_runtime.get("available_gb"))
|
|
215
|
+
memory["used"] = _format_gb(memory_runtime.get("used_gb"))
|
|
216
|
+
memory["free"] = _format_gb(memory_runtime.get("free_gb"))
|
|
217
|
+
memory["percent"] = _format_percent(memory_runtime.get("percent"))
|
|
218
|
+
|
|
219
|
+
disk_runtime = runtime.get("disk", {})
|
|
220
|
+
disk = data.setdefault("disk", {})
|
|
221
|
+
disk["total"] = _format_gb(disk_runtime.get("total_gb"))
|
|
222
|
+
disk["used"] = _format_gb(disk_runtime.get("used_gb"))
|
|
223
|
+
disk["free"] = _format_gb(disk_runtime.get("free_gb"))
|
|
224
|
+
disk["percent"] = _format_percent(disk_runtime.get("percent"))
|
|
225
|
+
|
|
226
|
+
data["gpu"] = runtime.get("gpu", data.get("gpu", {}))
|
|
227
|
+
data["task_slots"] = runtime.get("task_slots", {})
|
|
228
|
+
data["timestamp"] = runtime.get("timestamp")
|
|
229
|
+
data.pop("metrics", None)
|
|
230
|
+
return json.dumps(data)
|
|
231
|
+
except:
|
|
232
|
+
return GLOBAL_EXT_JSON
|
|
185
233
|
|
|
186
234
|
def _genExtend():
|
|
187
235
|
sp = Store()
|
|
188
236
|
read_data = sp.read()
|
|
189
|
-
|
|
237
|
+
required_device_keys = ["device_id", "host_name", "cpu", "memory", "disk", "gpu"]
|
|
238
|
+
if "deviceInfo" in read_data and all(k in read_data["deviceInfo"] for k in required_device_keys):
|
|
190
239
|
extInfo = read_data["deviceInfo"]
|
|
191
240
|
else:
|
|
192
|
-
|
|
241
|
+
try:
|
|
242
|
+
from ryry import utils
|
|
243
|
+
extInfo = utils.deviceInfo()
|
|
244
|
+
read_data["deviceInfo"] = extInfo
|
|
245
|
+
except:
|
|
246
|
+
extInfo = {}
|
|
193
247
|
extInfo["app"] = constant.app_name + " " + constant.app_version
|
|
194
248
|
extInfo["device"] = platform.system()
|
|
195
249
|
extInfo["device_version"] = platform.version()
|
|
@@ -254,4 +308,4 @@ def save_user_token(user_token):
|
|
|
254
308
|
read_data["Authorization"] = user_token
|
|
255
309
|
sp.write(read_data)
|
|
256
310
|
|
|
257
|
-
|
|
311
|
+
|
|
@@ -44,7 +44,7 @@ def additionalUrl(srcFile, ossUrl):
|
|
|
44
44
|
except:
|
|
45
45
|
return ossUrl
|
|
46
46
|
|
|
47
|
-
def upload(src, taskUUID=None, needTranscode=False, keepItAlways=False, additionalUrl=False
|
|
47
|
+
def upload(src, taskUUID=None, needTranscode=False, keepItAlways=False, additionalUrl=False):
|
|
48
48
|
import os
|
|
49
49
|
from pathlib import Path
|
|
50
50
|
from ryry import taskUtils as ryry_taskUtils
|
|
@@ -74,8 +74,7 @@ def upload(src, taskUUID=None, needTranscode=False, keepItAlways=False, addition
|
|
|
74
74
|
|
|
75
75
|
# 根据targetDomain判断使用不同的上传逻辑
|
|
76
76
|
ossurl = uploadByDomain(newSrc, targetDomain, taskUUID,
|
|
77
|
-
keepItAlways=keepItAlways,
|
|
78
|
-
uploadPath=uploadPath,
|
|
77
|
+
keepItAlways=keepItAlways,
|
|
79
78
|
needTranscode=needTranscode,
|
|
80
79
|
additionalUrl=additionalUrl)
|
|
81
80
|
|
|
@@ -85,7 +84,9 @@ def upload(src, taskUUID=None, needTranscode=False, keepItAlways=False, addition
|
|
|
85
84
|
os.remove(newSrc)
|
|
86
85
|
return ossurl
|
|
87
86
|
|
|
88
|
-
def uploadByDomain(src, targetDomain,
|
|
87
|
+
def uploadByDomain(src, targetDomain,
|
|
88
|
+
taskUUID, keepItAlways=False,
|
|
89
|
+
needTranscode=False, additionalUrl=False):
|
|
89
90
|
import os
|
|
90
91
|
from pathlib import Path
|
|
91
92
|
import uuid
|
|
@@ -95,8 +96,6 @@ def uploadByDomain(src, targetDomain, taskUUID, keepItAlways=False, uploadPath=N
|
|
|
95
96
|
ext = os.path.splitext(file_name)[-1][1:]
|
|
96
97
|
|
|
97
98
|
parsed_domain, upload_path = parseDomainAndPath(targetDomain)
|
|
98
|
-
if uploadPath:
|
|
99
|
-
upload_path = uploadPath
|
|
100
99
|
if isMecordConfig(parsed_domain):
|
|
101
100
|
from mecord import upload as mecord_upload
|
|
102
101
|
return mecord_upload.upload(src, taskUUID,
|
|
@@ -114,18 +113,6 @@ def uploadByDomain(src, targetDomain, taskUUID, keepItAlways=False, uploadPath=N
|
|
|
114
113
|
ftp_config = getFtpConfig(parsed_domain)
|
|
115
114
|
if ftp_config:
|
|
116
115
|
return ftpUpload(src, file_name, ftp_config, upload_path)
|
|
117
|
-
|
|
118
|
-
if upload_path:
|
|
119
|
-
if "mnt/NAS/mcn" in upload_path or "aigc_output/" in upload_path:
|
|
120
|
-
ftp_config = getFtpConfig("219.136.123.179")
|
|
121
|
-
return ftpUpload(src, file_name, ftp_config, upload_path)
|
|
122
|
-
elif (targetDomain != None and"aigc_output/" in targetDomain):
|
|
123
|
-
ftp_config = getFtpConfig("219.136.123.179")
|
|
124
|
-
return ftpUpload(src, file_name, ftp_config, upload_path)
|
|
125
|
-
elif (targetDomain == None or len(targetDomain) <= 0) and (uploadPath and len(uploadPath) > 0):
|
|
126
|
-
#找不到domain,但是有uploadPath的情况下,默认走ftp
|
|
127
|
-
ftp_config = getFtpConfig("219.136.123.179")
|
|
128
|
-
return ftpUpload(src, file_name, ftp_config, upload_path)
|
|
129
116
|
|
|
130
117
|
from ryry import ryry_webapi
|
|
131
118
|
return ryry_webapi.upload(src, ext,
|
|
@@ -342,17 +329,17 @@ def get_domain_config(target_domain):
|
|
|
342
329
|
return None
|
|
343
330
|
|
|
344
331
|
DOMAIN_CONFIG = {
|
|
345
|
-
"192.168.50.12": {"type": "ftp", "config": ftp_192_168_50_12},
|
|
346
|
-
"219.136.123.179": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
347
|
-
"183.6.90.205": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
348
|
-
"ftp://192.168.50.12/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_192_168_50_12},
|
|
349
|
-
"ftp://183.6.90.205/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
350
|
-
"ftp://219.136.123.179/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
332
|
+
# "192.168.50.12": {"type": "ftp", "config": ftp_192_168_50_12},
|
|
333
|
+
# "219.136.123.179": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
334
|
+
# "183.6.90.205": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
335
|
+
# "ftp://192.168.50.12/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_192_168_50_12},
|
|
336
|
+
# "ftp://183.6.90.205/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
337
|
+
# "ftp://219.136.123.179/mnt/NAS/mcn/cache": {"type": "ftp", "config": ftp_219_136_123_179},
|
|
351
338
|
"res.zjtemplate.com": {"type": "oss", "config": oss_res_config},
|
|
352
339
|
"upload.zjtemplate.com": {"type": "oss", "config": oss_upload_config},
|
|
353
340
|
"oss.zjtemplate.com": {"type": "oss", "config": oss_template_config},
|
|
354
|
-
"*.mecoai.cn": {"type": "mecord-cli", "config": {}},
|
|
355
|
-
"*.mecordai.com": {"type": "mecord-cli", "config": {}},
|
|
341
|
+
# "*.mecoai.cn": {"type": "mecord-cli", "config": {}},
|
|
342
|
+
# "*.mecordai.com": {"type": "mecord-cli", "config": {}},
|
|
356
343
|
"*.mekoapp.com": {"type": "", "config": {}},
|
|
357
344
|
}
|
|
358
345
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import uuid
|
|
2
2
|
import platform
|
|
3
|
-
import subprocess
|
|
4
|
-
import os
|
|
5
|
-
import sys
|
|
6
|
-
import requests
|
|
7
|
-
|
|
8
|
-
import
|
|
3
|
+
import subprocess
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import requests
|
|
7
|
+
import time
|
|
8
|
+
from io import BytesIO
|
|
9
|
+
import psutil
|
|
9
10
|
try:
|
|
10
11
|
import pynvml
|
|
11
12
|
except ImportError:
|
|
@@ -119,73 +120,219 @@ def generate_unique_id():
|
|
|
119
120
|
unique_id = uuid.uuid5(uuid.NAMESPACE_DNS, mac + hostname)
|
|
120
121
|
return str(unique_id).replace('-', '')
|
|
121
122
|
|
|
122
|
-
def getOssImageSize(p):
|
|
123
|
-
try:
|
|
124
|
-
s = requests.session()
|
|
123
|
+
def getOssImageSize(p):
|
|
124
|
+
try:
|
|
125
|
+
s = requests.session()
|
|
125
126
|
s.keep_alive = False
|
|
126
127
|
res = s.get(p, timeout=60)
|
|
127
128
|
image = Image.open(BytesIO(res.content), "r")
|
|
128
129
|
s.close()
|
|
129
130
|
return image.size
|
|
130
|
-
except:
|
|
131
|
-
return 0, 0
|
|
132
|
-
|
|
133
|
-
def
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"
|
|
162
|
-
"
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
pynvml.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
131
|
+
except:
|
|
132
|
+
return 0, 0
|
|
133
|
+
|
|
134
|
+
def _round_float(value, digits=2):
|
|
135
|
+
try:
|
|
136
|
+
return round(float(value), digits)
|
|
137
|
+
except:
|
|
138
|
+
return None
|
|
139
|
+
|
|
140
|
+
def _percent(used, total):
|
|
141
|
+
try:
|
|
142
|
+
if not total:
|
|
143
|
+
return 0
|
|
144
|
+
return round((float(used) / float(total)) * 100, 2)
|
|
145
|
+
except:
|
|
146
|
+
return 0
|
|
147
|
+
|
|
148
|
+
def _load_average(logical_count):
|
|
149
|
+
try:
|
|
150
|
+
load1, load5, load15 = os.getloadavg()
|
|
151
|
+
normalized = _percent(load1, logical_count or 1)
|
|
152
|
+
return {
|
|
153
|
+
"1m": _round_float(load1),
|
|
154
|
+
"5m": _round_float(load5),
|
|
155
|
+
"15m": _round_float(load15),
|
|
156
|
+
"percent_1m": normalized
|
|
157
|
+
}
|
|
158
|
+
except:
|
|
159
|
+
return {
|
|
160
|
+
"1m": None,
|
|
161
|
+
"5m": None,
|
|
162
|
+
"15m": None,
|
|
163
|
+
"percent_1m": None
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
def _decode_gpu_name(name):
|
|
167
|
+
try:
|
|
168
|
+
if isinstance(name, bytes):
|
|
169
|
+
return name.decode("utf-8")
|
|
170
|
+
return str(name)
|
|
171
|
+
except:
|
|
172
|
+
return "Unknown GPU"
|
|
173
|
+
|
|
174
|
+
def _collect_gpu_info(G):
|
|
175
|
+
gpu_info = {
|
|
176
|
+
"count": 0,
|
|
177
|
+
"list": [],
|
|
178
|
+
"mem": [],
|
|
179
|
+
"devices": []
|
|
180
|
+
}
|
|
181
|
+
try:
|
|
182
|
+
if pynvml is None:
|
|
183
|
+
raise ImportError("pynvml/nvidia-ml-py not available")
|
|
184
|
+
pynvml.nvmlInit()
|
|
185
|
+
gpu_count = pynvml.nvmlDeviceGetCount()
|
|
186
|
+
gpu_info["count"] = gpu_count
|
|
187
|
+
for i in range(gpu_count):
|
|
188
|
+
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
|
|
189
|
+
name = _decode_gpu_name(pynvml.nvmlDeviceGetName(handle))
|
|
190
|
+
mem_info = pynvml.nvmlDeviceGetMemoryInfo(handle)
|
|
191
|
+
used_gb = _round_float(mem_info.used / G)
|
|
192
|
+
free_gb = _round_float(mem_info.free / G)
|
|
193
|
+
total_gb = _round_float(mem_info.total / G)
|
|
194
|
+
memory_percent = _percent(mem_info.used, mem_info.total)
|
|
195
|
+
utilization_percent = None
|
|
196
|
+
temperature_c = None
|
|
197
|
+
power_w = None
|
|
198
|
+
try:
|
|
199
|
+
utilization_percent = pynvml.nvmlDeviceGetUtilizationRates(handle).gpu
|
|
200
|
+
except:
|
|
201
|
+
pass
|
|
202
|
+
try:
|
|
203
|
+
temperature_c = pynvml.nvmlDeviceGetTemperature(handle, pynvml.NVML_TEMPERATURE_GPU)
|
|
204
|
+
except:
|
|
205
|
+
pass
|
|
206
|
+
try:
|
|
207
|
+
power_w = _round_float(pynvml.nvmlDeviceGetPowerUsage(handle) / 1000)
|
|
208
|
+
except:
|
|
209
|
+
pass
|
|
210
|
+
gpu_info["list"].append(f"GPU{i}: {name}")
|
|
211
|
+
gpu_info["mem"].append(f"GPU{i}: total:{total_gb:.1f} G free:{free_gb:.1f} G")
|
|
212
|
+
gpu_info["devices"].append({
|
|
213
|
+
"index": i,
|
|
214
|
+
"name": name,
|
|
215
|
+
"memory_total_gb": total_gb,
|
|
216
|
+
"memory_used_gb": used_gb,
|
|
217
|
+
"memory_free_gb": free_gb,
|
|
218
|
+
"memory_percent": memory_percent,
|
|
219
|
+
"utilization_percent": utilization_percent,
|
|
220
|
+
"temperature_c": temperature_c,
|
|
221
|
+
"power_w": power_w
|
|
222
|
+
})
|
|
223
|
+
pynvml.nvmlShutdown()
|
|
224
|
+
except Exception as e:
|
|
225
|
+
gpu_info["error"] = str(e)
|
|
226
|
+
try:
|
|
227
|
+
pynvml.nvmlShutdown()
|
|
228
|
+
except:
|
|
229
|
+
pass
|
|
230
|
+
return gpu_info
|
|
231
|
+
|
|
232
|
+
def runtimeInfo():
|
|
233
|
+
G = 1024 * 1024 * 1024
|
|
234
|
+
logical_count = psutil.cpu_count() or 1
|
|
235
|
+
virtual_mem = psutil.virtual_memory()
|
|
236
|
+
disk = psutil.disk_usage("/")
|
|
237
|
+
metrics = {
|
|
238
|
+
"timestamp": int(time.time()),
|
|
239
|
+
"cpu": {
|
|
240
|
+
"percent": _round_float(psutil.cpu_percent(interval=0.1)),
|
|
241
|
+
"logical_count": logical_count,
|
|
242
|
+
"physical_count": psutil.cpu_count(logical=False),
|
|
243
|
+
"load_avg": _load_average(logical_count)
|
|
244
|
+
},
|
|
245
|
+
"memory": {
|
|
246
|
+
"total_gb": _round_float(virtual_mem.total / G),
|
|
247
|
+
"available_gb": _round_float(virtual_mem.available / G),
|
|
248
|
+
"used_gb": _round_float(virtual_mem.used / G),
|
|
249
|
+
"free_gb": _round_float(virtual_mem.free / G),
|
|
250
|
+
"percent": _round_float(virtual_mem.percent)
|
|
251
|
+
},
|
|
252
|
+
"disk": {
|
|
253
|
+
"path": "/",
|
|
254
|
+
"total_gb": _round_float(disk.total / G),
|
|
255
|
+
"used_gb": _round_float(disk.used / G),
|
|
256
|
+
"free_gb": _round_float(disk.free / G),
|
|
257
|
+
"percent": _round_float(disk.percent)
|
|
258
|
+
},
|
|
259
|
+
"gpu": _collect_gpu_info(G),
|
|
260
|
+
"task_slots": {
|
|
261
|
+
"max": 1,
|
|
262
|
+
"cur": 0,
|
|
263
|
+
"idle": 1,
|
|
264
|
+
"usage_percent": 0,
|
|
265
|
+
"widget_power": {}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
try:
|
|
269
|
+
from ryry.shared_memory import shared_memory_service
|
|
270
|
+
max_counter = shared_memory_service.get_max_counter()
|
|
271
|
+
cur_counter = shared_memory_service.get_cur_counter()
|
|
272
|
+
widget_power = shared_memory_service.get_all_widget_power()
|
|
273
|
+
if max_counter >= 999 and cur_counter == 0 and not widget_power:
|
|
274
|
+
max_counter = 1
|
|
275
|
+
idle_counter = max(0, max_counter - cur_counter)
|
|
276
|
+
metrics["task_slots"] = {
|
|
277
|
+
"max": max_counter,
|
|
278
|
+
"cur": cur_counter,
|
|
279
|
+
"idle": idle_counter,
|
|
280
|
+
"usage_percent": _percent(cur_counter, max_counter),
|
|
281
|
+
"widget_power": widget_power
|
|
282
|
+
}
|
|
283
|
+
except:
|
|
284
|
+
pass
|
|
285
|
+
return metrics
|
|
286
|
+
|
|
287
|
+
def deviceInfo():
|
|
288
|
+
mac = get_mac_address()
|
|
289
|
+
mac = "" if mac == None else mac
|
|
290
|
+
cpu_serial = get_cpu_serial()
|
|
291
|
+
cpu_serial = "" if cpu_serial == None else cpu_serial
|
|
292
|
+
hostname = get_hostname()
|
|
293
|
+
G=1024*1024*1024
|
|
294
|
+
cpu_freq = None
|
|
295
|
+
cpu_cur_freq = None
|
|
296
|
+
try:
|
|
297
|
+
freq = psutil.cpu_freq()
|
|
298
|
+
if freq:
|
|
299
|
+
cpu_freq = freq.max / 1000 if freq.max else None
|
|
300
|
+
cpu_cur_freq = freq.current / 1000 if freq.current else None
|
|
301
|
+
except:
|
|
302
|
+
pass
|
|
303
|
+
|
|
304
|
+
virtual_mem = psutil.virtual_memory()
|
|
305
|
+
disk = psutil.disk_usage("/")
|
|
306
|
+
runtime = runtimeInfo()
|
|
307
|
+
data = {
|
|
308
|
+
"cpu": {
|
|
309
|
+
"logical_count" : psutil.cpu_count(),
|
|
310
|
+
"count" : psutil.cpu_count(logical=False),
|
|
311
|
+
"max_freq" : f"{cpu_freq} GHz" if cpu_freq else "None",
|
|
312
|
+
"current_freq" : f"{cpu_cur_freq} GHz" if cpu_cur_freq else "None",
|
|
313
|
+
"percent" : runtime["cpu"].get("percent"),
|
|
314
|
+
"load_avg": runtime["cpu"].get("load_avg")
|
|
315
|
+
},
|
|
316
|
+
"disk": {
|
|
317
|
+
"total": f"{(disk.total / G):.1f} G",
|
|
318
|
+
"used": f"{(disk.used / G):.1f} G",
|
|
319
|
+
"free": f"{(disk.free / G):.1f} G",
|
|
320
|
+
"percent": f"{disk.percent}%"
|
|
321
|
+
},
|
|
322
|
+
"memory": {
|
|
323
|
+
"total": f"{(virtual_mem.total / G):.1f} G",
|
|
324
|
+
"available": f"{(virtual_mem.available / G):.1f} G",
|
|
325
|
+
"used": f"{(virtual_mem.used / G):.1f} G",
|
|
326
|
+
"free": f"{(virtual_mem.free / G):.1f} G",
|
|
327
|
+
"percent": f"{virtual_mem.percent}%"
|
|
328
|
+
},
|
|
329
|
+
"gpu": runtime["gpu"],
|
|
330
|
+
"device_id": generate_unique_id(),
|
|
331
|
+
"host_name": hostname,
|
|
332
|
+
"task_slots": runtime["task_slots"],
|
|
333
|
+
"timestamp": runtime["timestamp"]
|
|
334
|
+
}
|
|
335
|
+
return data
|
|
189
336
|
|
|
190
337
|
def process_is_alive(pid: int) -> bool:
|
|
191
338
|
try:
|
|
@@ -348,4 +495,4 @@ nohup {restart_command} &''')
|
|
|
348
495
|
result = subprocess.run(f"at now + 1 minutes -f {time_task_file} > {ot}", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
349
496
|
print(f"{result.stdout}\n{result.stderr}")
|
|
350
497
|
os.remove(restart_file)
|
|
351
|
-
print("one minute later must be start!")
|
|
498
|
+
print("one minute later must be start!")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ryry-cli
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.16
|
|
4
4
|
Summary: ryry tools
|
|
5
5
|
Home-page: https://github.com/dalipenMedia
|
|
6
6
|
Author: dalipen
|
|
@@ -8,7 +8,7 @@ Author-email: dalipen01@gmail.com
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
import subprocess
|
|
4
4
|
import datetime
|
|
5
5
|
|
|
6
|
-
ryry_version = "6.
|
|
6
|
+
ryry_version = "6.16"
|
|
7
7
|
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
|
8
8
|
constanspy = os.path.join(cur_dir, "ryry", "constant.py")
|
|
9
9
|
try:
|
|
@@ -84,5 +84,5 @@ setuptools.setup(
|
|
|
84
84
|
# scripts=[
|
|
85
85
|
# 'ryry/upload.py'
|
|
86
86
|
# ],
|
|
87
|
-
python_requires='>=3.
|
|
87
|
+
python_requires='>=3.9',
|
|
88
88
|
)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|