|
|
@@ -1,7 +1,10 @@
|
|
|
+from wsgiref import headers
|
|
|
from dotenv import load_dotenv, find_dotenv
|
|
|
from pathlib import Path # Python 3.6+ only
|
|
|
import configparser, json, pytz
|
|
|
+import requests
|
|
|
import pillow_avif
|
|
|
+
|
|
|
TIME_ZONE = pytz.timezone("Asia/Shanghai")
|
|
|
from numpy import true_divide
|
|
|
from databases import (
|
|
|
@@ -13,6 +16,7 @@ from databases import (
|
|
|
SqlQuery,
|
|
|
batch_insert_device_configs,
|
|
|
)
|
|
|
+
|
|
|
# 初始化数据表
|
|
|
create_all_database()
|
|
|
session = SqlQuery()
|
|
|
@@ -31,14 +35,18 @@ if len(all_sys_configs) == 0:
|
|
|
batch_insert_sys_configs(session, sys_config_json)
|
|
|
# 初始化数据表---结束
|
|
|
|
|
|
+
|
|
|
def get_config_by_items(config_dict):
|
|
|
__config_dict = {}
|
|
|
for i, k in config_dict:
|
|
|
__config_dict[i] = k
|
|
|
return __config_dict
|
|
|
+
|
|
|
+
|
|
|
keys = ["面料", "里料"]
|
|
|
|
|
|
-def getSysConfigs(key,item,default=None):
|
|
|
+
|
|
|
+def getSysConfigs(key, item, default=None):
|
|
|
session = SqlQuery()
|
|
|
crud = CRUD(SysConfigs)
|
|
|
one_item = crud.read(session, conditions={"key": key})
|
|
|
@@ -47,12 +55,14 @@ def getSysConfigs(key,item,default=None):
|
|
|
print(item, config.get(item, default))
|
|
|
return config.get(item, default)
|
|
|
|
|
|
+
|
|
|
def get_dict_value(_dict, key, default=None):
|
|
|
if key in _dict:
|
|
|
return _dict[key]
|
|
|
else:
|
|
|
return default
|
|
|
|
|
|
+
|
|
|
MACHINE_LEVEL = (
|
|
|
"二档"
|
|
|
if getSysConfigs("other_configs", "device_speed", "二档") == ""
|
|
|
@@ -181,7 +191,7 @@ Company = "惠利玛"
|
|
|
is_test_plugins = true_divide
|
|
|
|
|
|
|
|
|
-OUT_PIC_MODE = "."+getSysConfigs("basic_configs", "image_out_format", "png") # ".png"
|
|
|
+OUT_PIC_MODE = "." + getSysConfigs("basic_configs", "image_out_format", "png") # ".png"
|
|
|
|
|
|
OUT_PIC_SIZE = (
|
|
|
[1600]
|
|
|
@@ -208,7 +218,9 @@ RUNNING_MODE = getSysConfigs("other_configs", "running_mode", "普通模式")
|
|
|
DEFAULT_CUTOUT_MODE = getSysConfigs("other_configs", "cutout_mode", "普通抠图")
|
|
|
|
|
|
|
|
|
-CUTOUT_MODE = 0 if getSysConfigs("other_configs", "cutout_mode", "普通抠图") =="普通抠图" else 1
|
|
|
+CUTOUT_MODE = (
|
|
|
+ 0 if getSysConfigs("other_configs", "cutout_mode", "普通抠图") == "普通抠图" else 1
|
|
|
+)
|
|
|
import importlib
|
|
|
|
|
|
# plugins = [
|
|
|
@@ -249,9 +261,7 @@ CHECK_LOWER_Y = int(
|
|
|
getSysConfigs("other_configs", "check_lower_y", 4)
|
|
|
) # 检测亮度区域,倒数第几行
|
|
|
IS_GET_GREEN_MASK = (
|
|
|
- True
|
|
|
- if getSysConfigs("other_configs", "is_get_green_mask", "否") == "是"
|
|
|
- else False
|
|
|
+ True if getSysConfigs("other_configs", "is_get_green_mask", "否") == "是" else False
|
|
|
) # 是否进行绿幕抠图
|
|
|
IMAGE_SAVE_MAX_WORKERS = int(
|
|
|
getSysConfigs("other_configs", "image_save_max_workers", 4)
|
|
|
@@ -259,3 +269,27 @@ IMAGE_SAVE_MAX_WORKERS = int(
|
|
|
COLOR_GRADATION_CYCLES = int(
|
|
|
getSysConfigs("other_configs", "color_gradation_cycles", 22)
|
|
|
) # 色阶处理循环次数
|
|
|
+
|
|
|
+
|
|
|
+def recordDataPoint(token=None, page="", uuid=None, data=""):
|
|
|
+ """记录日志"""
|
|
|
+ if token == None:
|
|
|
+ return
|
|
|
+ if page == "":
|
|
|
+ return
|
|
|
+ if uuid == None:
|
|
|
+ return
|
|
|
+ headers = {"Content-Type": "application/json", "authorization": "Bearer " + token}
|
|
|
+ params = {
|
|
|
+ "site": 1,
|
|
|
+ "type": 5,
|
|
|
+ "channel": "aigc-camera",
|
|
|
+ "uuid": uuid,
|
|
|
+ "page": page,
|
|
|
+ "page_url": "/",
|
|
|
+ "describe": {"action": page, "data": data},
|
|
|
+ "time": 0,
|
|
|
+ }
|
|
|
+ return requests.post(
|
|
|
+ headers=headers, data=json.dumps(params), url=DOMAIN + "/api/record/point"
|
|
|
+ )
|