You've already forked FrameTour-RenderWorker
通过argv传skip_if_exist默认值
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from opentelemetry.trace import Status, StatusCode
|
from opentelemetry.trace import Status, StatusCode
|
||||||
@@ -70,7 +71,7 @@ def upload_to_oss(url, file_path):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def download_from_oss(url, file_path, skip_if_exist=False):
|
def download_from_oss(url, file_path, skip_if_exist=None):
|
||||||
"""
|
"""
|
||||||
使用签名URL下载文件到OSS
|
使用签名URL下载文件到OSS
|
||||||
:param skip_if_exist: 如果存在就不下载了
|
:param skip_if_exist: 如果存在就不下载了
|
||||||
@@ -82,6 +83,11 @@ def download_from_oss(url, file_path, skip_if_exist=False):
|
|||||||
with tracer.start_as_current_span("download_from_oss") as span:
|
with tracer.start_as_current_span("download_from_oss") as span:
|
||||||
span.set_attribute("file.url", url)
|
span.set_attribute("file.url", url)
|
||||||
span.set_attribute("file.path", file_path)
|
span.set_attribute("file.path", file_path)
|
||||||
|
|
||||||
|
# 如果skip_if_exist为None,则从启动参数中读取
|
||||||
|
if skip_if_exist is None:
|
||||||
|
skip_if_exist = 'skip_if_exist' in sys.argv
|
||||||
|
|
||||||
if skip_if_exist and os.path.exists(file_path):
|
if skip_if_exist and os.path.exists(file_path):
|
||||||
span.set_attribute("file.exist", True)
|
span.set_attribute("file.exist", True)
|
||||||
span.set_attribute("file.size", os.path.getsize(file_path))
|
span.set_attribute("file.size", os.path.getsize(file_path))
|
||||||
|
Reference in New Issue
Block a user