|
@@ -10,12 +10,12 @@ import base64
|
|
import json
|
|
import json
|
|
import logging
|
|
import logging
|
|
import os
|
|
import os
|
|
|
|
+import threading
|
|
import time
|
|
import time
|
|
|
|
|
|
import apns2
|
|
import apns2
|
|
import boto3
|
|
import boto3
|
|
import jpush
|
|
import jpush
|
|
-from PIL import UnidentifiedImageError
|
|
|
|
from boto3.session import Session
|
|
from boto3.session import Session
|
|
from django.views.generic.base import View
|
|
from django.views.generic.base import View
|
|
from pyfcm import FCMNotification
|
|
from pyfcm import FCMNotification
|
|
@@ -24,10 +24,13 @@ from AnsjerPush.config import AI_IDENTIFICATION_TAGS_DICT, CONFIG_US, CONFIG_EUR
|
|
from AnsjerPush.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, APNS_MODE, APNS_CONFIG, BASE_DIR, \
|
|
from AnsjerPush.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, APNS_MODE, APNS_CONFIG, BASE_DIR, \
|
|
JPUSH_CONFIG, FCM_CONFIG
|
|
JPUSH_CONFIG, FCM_CONFIG
|
|
from AnsjerPush.config import CONFIG_INFO
|
|
from AnsjerPush.config import CONFIG_INFO
|
|
|
|
+from AnsjerPush.config import PUSH_BUCKET
|
|
from Model.models import UidPushModel, AiService, VodHlsTag, VodHlsTagType
|
|
from Model.models import UidPushModel, AiService, VodHlsTag, VodHlsTagType
|
|
from Object import MergePic
|
|
from Object import MergePic
|
|
from Object.DynamodbObject import DynamodbObject
|
|
from Object.DynamodbObject import DynamodbObject
|
|
from Object.ETkObject import ETkObject
|
|
from Object.ETkObject import ETkObject
|
|
|
|
+from Object.OCIObjectStorage import OCIObjectStorage
|
|
|
|
+from Object.RedisObject import RedisObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.SageMakerAiObject import SageMakerAiObject
|
|
from Object.SageMakerAiObject import SageMakerAiObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
@@ -35,8 +38,6 @@ from Object.enums.MessageTypeEnum import MessageTypeEnum
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
from Service.DevicePushService import DevicePushService
|
|
from Service.DevicePushService import DevicePushService
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
-from Object.RedisObject import RedisObject
|
|
|
|
-import threading
|
|
|
|
|
|
|
|
TIME_LOGGER = logging.getLogger('time')
|
|
TIME_LOGGER = logging.getLogger('time')
|
|
|
|
|
|
@@ -299,6 +300,7 @@ class AiView(View):
|
|
nickname = uid
|
|
nickname = uid
|
|
|
|
|
|
userID_ids = []
|
|
userID_ids = []
|
|
|
|
+ region = 4 if CONFIG_INFO == CONFIG_EUR else 3
|
|
for up in uid_push_list:
|
|
for up in uid_push_list:
|
|
push_type = up['push_type']
|
|
push_type = up['push_type']
|
|
appBundleId = up['appBundleId']
|
|
appBundleId = up['appBundleId']
|
|
@@ -323,7 +325,7 @@ class AiView(View):
|
|
alarm=label_str,
|
|
alarm=label_str,
|
|
is_st=3,
|
|
is_st=3,
|
|
add_time=now_time,
|
|
add_time=now_time,
|
|
- storage_location=2,
|
|
|
|
|
|
+ storage_location=region,
|
|
border_coords=json.dumps(new_bounding_box_dict)
|
|
border_coords=json.dumps(new_bounding_box_dict)
|
|
)
|
|
)
|
|
userID_ids.append(userID_id)
|
|
userID_ids.append(userID_id)
|
|
@@ -485,35 +487,42 @@ class AiView(View):
|
|
|
|
|
|
def upload_s3(self, file_dict, dir_path):
|
|
def upload_s3(self, file_dict, dir_path):
|
|
try:
|
|
try:
|
|
- if CONFIG_INFO == CONFIG_US or CONFIG_INFO == CONFIG_EUR:
|
|
|
|
- # 存国外
|
|
|
|
- aws_key = AWS_ACCESS_KEY_ID[1]
|
|
|
|
- aws_secret = AWS_SECRET_ACCESS_KEY[1]
|
|
|
|
- session = Session(aws_access_key_id=aws_key,
|
|
|
|
- aws_secret_access_key=aws_secret,
|
|
|
|
- region_name="us-east-1")
|
|
|
|
- s3 = session.resource("s3")
|
|
|
|
- bucket = "foreignpush"
|
|
|
|
- else:
|
|
|
|
- # 存国内
|
|
|
|
- aws_key = AWS_ACCESS_KEY_ID[0]
|
|
|
|
- aws_secret = AWS_SECRET_ACCESS_KEY[0]
|
|
|
|
- session = Session(aws_access_key_id=aws_key,
|
|
|
|
- aws_secret_access_key=aws_secret,
|
|
|
|
- region_name="cn-northwest-1")
|
|
|
|
- s3 = session.resource("s3")
|
|
|
|
- bucket = "push"
|
|
|
|
-
|
|
|
|
|
|
+ # if CONFIG_INFO == CONFIG_US or CONFIG_INFO == CONFIG_EUR:
|
|
|
|
+ # # 存国外
|
|
|
|
+ # aws_key = AWS_ACCESS_KEY_ID[1]
|
|
|
|
+ # aws_secret = AWS_SECRET_ACCESS_KEY[1]
|
|
|
|
+ # session = Session(aws_access_key_id=aws_key,
|
|
|
|
+ # aws_secret_access_key=aws_secret,
|
|
|
|
+ # region_name="us-east-1")
|
|
|
|
+ # s3 = session.resource("s3")
|
|
|
|
+ # bucket = "foreignpush"
|
|
|
|
+ # else:
|
|
|
|
+ # # 存国内
|
|
|
|
+ # aws_key = AWS_ACCESS_KEY_ID[0]
|
|
|
|
+ # aws_secret = AWS_SECRET_ACCESS_KEY[0]
|
|
|
|
+ # session = Session(aws_access_key_id=aws_key,
|
|
|
|
+ # aws_secret_access_key=aws_secret,
|
|
|
|
+ # region_name="cn-northwest-1")
|
|
|
|
+ # s3 = session.resource("s3")
|
|
|
|
+ # bucket = "push"
|
|
|
|
+ #
|
|
|
|
+ # for file_path, upload_path in file_dict.items():
|
|
|
|
+ # print('-------')
|
|
|
|
+ # print(file_path)
|
|
|
|
+ # print('-------')
|
|
|
|
+ # upload_data = open(file_path, "rb")
|
|
|
|
+ # # upload_key = "test"
|
|
|
|
+ # s3.Bucket(bucket).put_object(Key=upload_path, Body=upload_data)
|
|
|
|
+ region = 'eur' if CONFIG_INFO == CONFIG_EUR else 'us'
|
|
|
|
+ oci = OCIObjectStorage(region)
|
|
for file_path, upload_path in file_dict.items():
|
|
for file_path, upload_path in file_dict.items():
|
|
- print('-------')
|
|
|
|
- print(file_path)
|
|
|
|
- print('-------')
|
|
|
|
upload_data = open(file_path, "rb")
|
|
upload_data = open(file_path, "rb")
|
|
- # upload_key = "test"
|
|
|
|
- s3.Bucket(bucket).put_object(Key=upload_path, Body=upload_data)
|
|
|
|
|
|
+ # OCI上传对象
|
|
|
|
+ oci.put_object(PUSH_BUCKET, upload_path, upload_data, 'image/jpeg')
|
|
return True
|
|
return True
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(repr(e))
|
|
|
|
|
|
+ TIME_LOGGER.error('rekoAI上传对象异常errLine={errLine}, errMsg={errMsg}'
|
|
|
|
+ .format(errLine=e.__traceback__.tb_lineno, errMsg=repr(e)))
|
|
return False
|
|
return False
|
|
|
|
|
|
def get_msg_title(self, appBundleId, nickname):
|
|
def get_msg_title(self, appBundleId, nickname):
|