123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import logging
- import sys
- import configparser
- import os
- from module.other.module_aes import Aes
- # ===============默认数据配置=====================
- config_name = "config.ini"
- if os.path.exists(config_name):
- with open(config_name) as f:
- pass
- config = configparser.ConfigParser()
- try:
- config.read(config_name, encoding="utf-8")
- except:
- config.read(config_name)
- # ===========用户自定义配置=======================
- custom_config_name = "custom_config.ini"
- if not os.path.exists(custom_config_name):
- with open(custom_config_name, 'w') as file:
- pass
- custom_config = configparser.ConfigParser()
- try:
- custom_config.read(custom_config_name, encoding="utf-8")
- except:
- custom_config.read(custom_config_name)
- def set_config(data_dict, section="basicSetup", _config_name="custom_config"):
- if _config_name == "config":
- for i, v in data_dict.items():
- config.set(section=section, option=i, value=v)
- try:
- config.write(open(config_name, 'w', encoding="ut-8"))
- except:
- config.write(open(config_name, 'w'))
- else:
- for i, v in data_dict.items():
- custom_config.set(section=section, option=i, value=v)
- try:
- custom_config.write(open(custom_config_name, 'w', encoding="ut-8"))
- except:
- custom_config.write(open(custom_config_name, 'w'))
- def get_config(section_items):
- __config_dict = {}
- try:
- for i, k in section_items:
- __config_dict[i] = k
- except:
- pass
- return __config_dict
- with open("key", "r") as f:
- Key = f.read()
- def set_key(authorization):
- global Authorization
- Authorization = authorization
- if authorization:
- authorization = Aes().get_key(authorization, SecretKey, SecretIv)
- with open("key", "w") as f:
- f.write(authorization)
- config_dict = get_config(config.items('basicSetup'))
- config_domain_dev_dict = get_config(config.items('domain_dev'))
- config_domain_prod_dict = get_config(config.items('domain_prod'))
- env = config_dict["env"]
- Version = config_dict["version"]
- Account = config_dict["account"]
- LastSelectPath = config_dict["last_select_path"]
- # ============用户自定义信息获取=============
- def get_custom_config(p_value, key, _custom_config_dict):
- if key in _custom_config_dict:
- if _custom_config_dict[key]:
- return _custom_config_dict[key]
- return p_value
- try:
- custom_config.add_section("basicSetup")
- except:
- pass
- custom_config_dict = get_config(custom_config.items('basicSetup'))
- is_test = "否"
- is_test = get_custom_config(is_test, "is_test", custom_config_dict)
- is_fall_dir = ""
- is_fall_dir = get_custom_config(is_fall_dir, "is_fall_dir", custom_config_dict)
- is_fall_dir = is_fall_dir.replace(",","")
- is_fall_dir = is_fall_dir.split(",")
- is_fall_dir = [x for x in is_fall_dir if x]
- if "已抠图" not in is_fall_dir:
- is_fall_dir.append("已抠图")
- is_fall_file = ""
- is_fall_file = get_custom_config(is_fall_file, "is_fall_file", custom_config_dict)
- is_fall_file = is_fall_file.replace(",","")
- is_fall_file = is_fall_file.split(",")
- is_fall_file = [x for x in is_fall_file if x]
- print("Version:",Version)
- if env == "dev":
- DOMAIN = config_domain_dev_dict["domain"]
- Host = config_domain_dev_dict["host"]
- Origin = config_domain_dev_dict["origin"]
- else:
- DOMAIN = config_domain_prod_dict["domain"]
- Host = config_domain_prod_dict["host"]
- Origin = config_domain_prod_dict["origin"]
- IsLogin = False
- SecretKey = "8E5EC2AC2191167DF9B753BA93A1E7B1"
- SecretIv = "0112030405060701"
- Authorization = Aes().get_authorization(Key, SecretKey, SecretIv)
- Headers = {
- "Authorization": Authorization,
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
- "Origin": Origin,
- "Host": Host,
- "Content-Type": "application/json;charset=UTF-8"
- }
|