FIX 调整线上配置获取方式
This commit is contained in:
18
nodes/cos.py
18
nodes/cos.py
@@ -39,6 +39,9 @@ class COSDownload:
|
|||||||
)
|
)
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
try:
|
try:
|
||||||
|
if "aws_key_id" in list(os.environ.keys()):
|
||||||
|
yaml_config = os.environ
|
||||||
|
else:
|
||||||
with open(
|
with open(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"
|
||||||
@@ -48,9 +51,9 @@ class COSDownload:
|
|||||||
) as f:
|
) as f:
|
||||||
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
config = CosConfig(
|
config = CosConfig(
|
||||||
Region=yaml_config["region"],
|
Region=yaml_config["cos_region"],
|
||||||
SecretId=yaml_config["secret_id"],
|
SecretId=yaml_config["cos_secret_id"],
|
||||||
SecretKey=yaml_config["secret_key"],
|
SecretKey=yaml_config["cos_secret_key"],
|
||||||
)
|
)
|
||||||
client = CosS3Client(config)
|
client = CosS3Client(config)
|
||||||
response = client.download_file(
|
response = client.download_file(
|
||||||
@@ -99,6 +102,9 @@ class COSUpload:
|
|||||||
loguru.logger.info(f"COS UPLOAD {path} to {cos_bucket}/{subfolder}")
|
loguru.logger.info(f"COS UPLOAD {path} to {cos_bucket}/{subfolder}")
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
try:
|
try:
|
||||||
|
if "aws_key_id" in list(os.environ.keys()):
|
||||||
|
yaml_config = os.environ
|
||||||
|
else:
|
||||||
with open(
|
with open(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"
|
||||||
@@ -108,9 +114,9 @@ class COSUpload:
|
|||||||
) as f:
|
) as f:
|
||||||
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
config = CosConfig(
|
config = CosConfig(
|
||||||
Region=yaml_config["region"],
|
Region=yaml_config["cos_region"],
|
||||||
SecretId=yaml_config["secret_id"],
|
SecretId=yaml_config["cos_secret_id"],
|
||||||
SecretKey=yaml_config["secret_key"],
|
SecretKey=yaml_config["cos_secret_key"],
|
||||||
)
|
)
|
||||||
client = CosS3Client(config)
|
client = CosS3Client(config)
|
||||||
response = client.upload_file(
|
response = client.upload_file(
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import boto3
|
|||||||
import loguru
|
import loguru
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from test import yaml_config
|
||||||
|
|
||||||
|
|
||||||
class S3Download:
|
class S3Download:
|
||||||
"""AWS S3下载"""
|
"""AWS S3下载"""
|
||||||
@@ -36,6 +38,9 @@ class S3Download:
|
|||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
if "aws_key_id" in list(os.environ.keys()):
|
||||||
|
yaml_config = os.environ
|
||||||
|
else:
|
||||||
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"),encoding="utf-8",mode="r+") as f:
|
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"),encoding="utf-8",mode="r+") as f:
|
||||||
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
client = boto3.client("s3",aws_access_key_id=yaml_config["aws_key_id"],aws_secret_access_key=yaml_config["aws_access_key"])
|
client = boto3.client("s3",aws_access_key_id=yaml_config["aws_key_id"],aws_secret_access_key=yaml_config["aws_access_key"])
|
||||||
@@ -67,6 +72,9 @@ class S3Upload:
|
|||||||
def upload(self, s3_bucket, path, subfolder):
|
def upload(self, s3_bucket, path, subfolder):
|
||||||
loguru.logger.info(f"S3 UPLOAD {path} to {s3_bucket}/{subfolder}")
|
loguru.logger.info(f"S3 UPLOAD {path} to {s3_bucket}/{subfolder}")
|
||||||
try:
|
try:
|
||||||
|
if "aws_key_id" in list(os.environ.keys()):
|
||||||
|
yaml_config = os.environ
|
||||||
|
else:
|
||||||
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"),
|
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "config.yaml"),
|
||||||
encoding="utf-8", mode="r+") as f:
|
encoding="utf-8", mode="r+") as f:
|
||||||
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
yaml_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|||||||
Reference in New Issue
Block a user