merge到master
This commit is contained in:
parent
fb24904b6b
commit
9916881124
|
@ -1,9 +1,19 @@
|
|||
import traceback
|
||||
import grpc
|
||||
import BeiHangGrpc_pb2_grpc, BeiHangGrpc_pb2
|
||||
import BeiHangGrpc_pb2_grpc
|
||||
import BeiHangGrpc_pb2
|
||||
import logging
|
||||
|
||||
myLogger = logging.getLogger('log')
|
||||
|
||||
|
||||
def helmet(ip: str, pic_url: str):
|
||||
"""安全帽事件
|
||||
|
||||
def helmet_test(ip, pic_url):
|
||||
Args:
|
||||
ip (_type_): _description_
|
||||
pic_url (_type_): _description_
|
||||
"""
|
||||
channel = grpc.insecure_channel(ip) # 监听频道
|
||||
stub = BeiHangGrpc_pb2_grpc.Helmet_RegStub(channel) # 客户端使用Stub类发送请求,参数为频道,为了绑定链接
|
||||
image_id = 3
|
||||
|
@ -17,13 +27,16 @@ def helmet_test(ip, pic_url):
|
|||
request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id, imgUrl=pic_url)
|
||||
try:
|
||||
response = stub.sendHelmet_Info(request)
|
||||
print("network success! \n")
|
||||
print(response.helmetinfoList[0].head_helmet)
|
||||
if response.helmetinfoList:
|
||||
for i in response.helmetinfoList:
|
||||
if i.head_helmet == 0:
|
||||
return True, response
|
||||
return False, response
|
||||
except Exception:
|
||||
print("network error! \n")
|
||||
myLogger.error(traceback.format_exc())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
helmet_test(
|
||||
helmet(
|
||||
ip='122.224.229.24:2000',
|
||||
pic_url='http://1.203.161.103:2800/media/2022/07/06/dsf_bf6446cc-f9cd-11ec-bd2d-e4246c7d1635_34597240_34614457.jpg')
|
||||
|
|
|
@ -2,3 +2,12 @@ class AiService:
|
|||
algo_dict = {
|
||||
"helmet": "apps.helmet.algo.helmet"
|
||||
}
|
||||
|
||||
def analyse(codes: list, path: str):
|
||||
"""多线程进行算法分析图片
|
||||
|
||||
Args:
|
||||
codes: 算法列表
|
||||
path (str): 图片地址
|
||||
"""
|
||||
pass
|
||||
|
|
|
@ -68,11 +68,12 @@ def get_ep_default():
|
|||
|
||||
|
||||
def algo_handle(codes: list, data: dict):
|
||||
"""算法
|
||||
"""算法处理
|
||||
|
||||
Args:
|
||||
code (str): 算法标识列表
|
||||
data (dict): 需要处理的内容
|
||||
data (dict): 需要处理的图片信息
|
||||
|
||||
"""
|
||||
return ['helmet']
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class RpartyViewSet(CustomModelViewSet):
|
|||
ins = serializer.save(type='remployee', password=make_password('0000'))
|
||||
obj.admin = ins
|
||||
obj.save()
|
||||
post = Post.objects.get(code='rparty')
|
||||
post = Post.objects.get(code='remployee')
|
||||
UserPost.objects.get_or_create(user=ins, dept=obj.dept,
|
||||
defaults={
|
||||
'user': ins,
|
||||
|
|
|
@ -80,11 +80,13 @@ class VisitorViewSet(CustomModelViewSet):
|
|||
name = vdata['name']
|
||||
phone = vdata['phone']
|
||||
code = vdata['code']
|
||||
# 校验短信验证码
|
||||
check_phone_code(phone, code)
|
||||
# 查询是否已注册
|
||||
user = User.objects.filter(phone=phone).first()
|
||||
if user:
|
||||
raise ParseError('该手机号已注册,请直接登录')
|
||||
# 访客账户创建
|
||||
user = User()
|
||||
user.type = 'visitor'
|
||||
user.name = name
|
||||
|
|
Loading…
Reference in New Issue