ryry-cli 3.0__tar.gz → 3.2__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-3.0 → ryry_cli-3.2}/PKG-INFO +1 -1
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/constant.py +2 -2
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/ryry_webapi.py +36 -9
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/upload.py +1 -1
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/PKG-INFO +1 -1
- {ryry_cli-3.0 → ryry_cli-3.2}/setup.py +1 -1
- {ryry_cli-3.0 → ryry_cli-3.2}/LICENSE +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/README.md +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/__init__.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/main.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/ryry_server_socket.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/ryry_service.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/ryry_widget.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/script_template/__init__.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/script_template/main.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/script_template/run.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/server_func.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/store.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/task.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/taskUtils.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry/utils.py +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/SOURCES.txt +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/dependency_links.txt +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/entry_points.txt +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/requires.txt +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/ryry_cli.egg-info/top_level.txt +0 -0
- {ryry_cli-3.0 → ryry_cli-3.2}/setup.cfg +0 -0
|
@@ -2,6 +2,7 @@ import json, os, datetime
|
|
|
2
2
|
import uuid, requests, calendar, time
|
|
3
3
|
from requests.adapters import HTTPAdapter
|
|
4
4
|
from urllib3.util.retry import Retry
|
|
5
|
+
from urllib.parse import urlparse, urlunparse
|
|
5
6
|
|
|
6
7
|
from ryry import store, utils, taskUtils, constant, task
|
|
7
8
|
|
|
@@ -255,6 +256,22 @@ def _upload(localFilePath, ext, keep_it_always=False):
|
|
|
255
256
|
raise Exception(f"upload fail!, reason={r2}")
|
|
256
257
|
return r3
|
|
257
258
|
|
|
259
|
+
def _changeDomain(url, fix_domain):
|
|
260
|
+
parsed_url = urlparse(url)
|
|
261
|
+
return urlunparse(parsed_url._replace(netloc=fix_domain))
|
|
262
|
+
# netloc = parsed_url.netloc
|
|
263
|
+
# if 'meco-web-hk-beta.oss-cn-hongkong.aliyuncs.com' in netloc:
|
|
264
|
+
# mecord_netloc = 'oss.zjtemplate.com'
|
|
265
|
+
# elif 'meco-web-sg.oss-accelerate.aliyuncs.com' in netloc:
|
|
266
|
+
# mecord_netloc = 'oss.zjtemplate.com'
|
|
267
|
+
# elif 'p-template-hk.oss-cn-hongkong.aliyuncs.com' in netloc:
|
|
268
|
+
# mecord_netloc = 'oss.zjtemplate.com'
|
|
269
|
+
# elif 'p-upload-gz.oss-cn-guangzhou.aliyuncs.com' in netloc:
|
|
270
|
+
# mecord_netloc = 'upload.zjtemplate.com'
|
|
271
|
+
# elif 'mecord' in netloc:
|
|
272
|
+
# mecord_netloc = 'm.mecordai.com'
|
|
273
|
+
# mecord_url = parsed_url._replace(netloc=fix_domain)
|
|
274
|
+
|
|
258
275
|
def upload(localFilePath, ext, keep_it_always=False):
|
|
259
276
|
try:
|
|
260
277
|
return _upload(localFilePath, ext, keep_it_always)
|
|
@@ -262,33 +279,35 @@ def upload(localFilePath, ext, keep_it_always=False):
|
|
|
262
279
|
pass
|
|
263
280
|
from mecord import upload as mecord_upload
|
|
264
281
|
try:
|
|
265
|
-
|
|
282
|
+
url = mecord_upload.upload(localFilePath, None, "sg")
|
|
283
|
+
return _changeDomain(url, "m.mecordai.com")
|
|
266
284
|
except:
|
|
267
285
|
pass
|
|
268
286
|
try:
|
|
269
|
-
|
|
287
|
+
url = mecord_upload.upload(localFilePath, None, "test")
|
|
288
|
+
return _changeDomain(url, "m-beta.mecordai.com")
|
|
270
289
|
except:
|
|
271
290
|
pass
|
|
272
|
-
|
|
291
|
+
def upload_oss(localFilePath, ext, bucket, endpoint):
|
|
273
292
|
import hashlib
|
|
274
293
|
import hmac
|
|
275
294
|
import base64
|
|
276
|
-
timestamp = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
|
295
|
+
timestamp = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
|
277
296
|
content_type = "application/octet-stream"
|
|
278
297
|
|
|
279
298
|
random_name = ''.join(str(uuid.uuid4()).split('-'))
|
|
299
|
+
if ext[0:1] == ".":
|
|
300
|
+
ext = ext[1:]
|
|
280
301
|
object_key = f"temp/{random_name}.{ext}"
|
|
281
|
-
bucket = "p-template-hk"
|
|
282
302
|
resource = f"/{bucket}/{object_key}"
|
|
283
|
-
endpoint = "oss-cn-hongkong.aliyuncs.com"
|
|
284
303
|
string_to_sign = f"PUT\n\n{content_type}\n{timestamp}\n{resource}"
|
|
285
304
|
signature = base64.b64encode(
|
|
286
|
-
hmac.new("
|
|
305
|
+
hmac.new("2UtzA9cHnfNdZOtxLVuhM8SOz5HEdv".encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha1).digest()
|
|
287
306
|
).decode('utf-8')
|
|
288
307
|
url = f"https://{bucket}.{endpoint}/{object_key}"
|
|
289
308
|
headers = {
|
|
290
309
|
"Date": timestamp,
|
|
291
|
-
"Authorization": f"OSS
|
|
310
|
+
"Authorization": f"OSS LTAI5tLseFAXY33JA7zWDf4o:{signature}",
|
|
292
311
|
"Content-Type": content_type
|
|
293
312
|
}
|
|
294
313
|
with open(localFilePath, "rb") as file:
|
|
@@ -296,6 +315,14 @@ def upload(localFilePath, ext, keep_it_always=False):
|
|
|
296
315
|
response = requests.put(url, data=file_data, headers=headers)
|
|
297
316
|
if response.status_code == 200:
|
|
298
317
|
return url
|
|
318
|
+
try:
|
|
319
|
+
url = upload_oss(localFilePath, ext, "p-template-hk", "oss-cn-hongkong.aliyuncs.com")
|
|
320
|
+
return _changeDomain(url, "oss.zjtemplate.com")
|
|
321
|
+
except:
|
|
322
|
+
pass
|
|
323
|
+
try:
|
|
324
|
+
url = upload_oss(localFilePath, ext, "p-upload-gz", "oss-cn-guangzhou.aliyuncs.com")
|
|
325
|
+
return _changeDomain(url, "upload.zjtemplate.com")
|
|
299
326
|
except:
|
|
300
327
|
pass
|
|
301
328
|
raise Exception("all upload target is fail!")
|
|
@@ -391,7 +418,7 @@ def checkTask(checkUUID):
|
|
|
391
418
|
result_data = json.load(f)
|
|
392
419
|
finish = result_data["finish"]
|
|
393
420
|
success = result_data["success"]
|
|
394
|
-
data = result_data["data"]
|
|
421
|
+
data = json.loads(result_data["data"])
|
|
395
422
|
progress = result_data["progress"]
|
|
396
423
|
return finish, success, data, progress
|
|
397
424
|
else:
|
|
@@ -43,7 +43,7 @@ def additionalUrl(srcFile, ossUrl):
|
|
|
43
43
|
except:
|
|
44
44
|
return ossUrl
|
|
45
45
|
|
|
46
|
-
def upload(src, taskUUID=None,
|
|
46
|
+
def upload(src, taskUUID=None, needTranscode=True, keep_it_always=False):
|
|
47
47
|
import os
|
|
48
48
|
from pathlib import Path
|
|
49
49
|
from ryry import taskUtils
|
|
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
|