加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
config.py 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
福叔攒钱买房车 提交于 2021-12-04 17:49 . 添加了采集器。
import os,datetime,json
import traceback
today = datetime.datetime.now().strftime("%Y-%m-%d")
root_path = os.path.split(os.path.realpath(__file__))[0]
log_save_path = root_path + "/logs/"+today+".log"
active = ""
# active = "prod"
# active = "home"
import platform
def get_active_profile():
if active !="":
return "-"+active
return ""
def thirdparty_path():
if platform.system().lower() == 'windows':
return os.path.join(root_path,"thirdparty")+"/chromium/win/chrome.exe"
elif platform.system().lower() == 'linux':
return os.path.join(root_path,"thirdparty")+"/chromium/linux/chrome"
def load_chrome_userdata():
return os.path.join(root_path,"thirdparty")+"/userdata"
def load_config():
config_path = os.path.join(root_path+"/config/config"+get_active_profile()+".json")
with open(config_path,"r") as f:
return json.load(f)
def load_mysql_uri():
config = load_config()
mysql = config["mysql"]
mysql_uri = "mysql+pymysql://"+mysql["user"]+":"+mysql["password"]+"@"+mysql["host"]+":"+str(mysql["port"])+"/"+mysql["dbname"]+"?charset="+mysql["charset"]
return mysql_uri
def load_debug():
config = load_config()
if "debug" in config:
return config["debug"]
else:
return False
def load_htmlroot():
config = load_config()
return config["htmlroot"]
def load_enable_cache_html():
config = load_config()
return config["enable_cache_html"]
def load_temp_save_path():
config = load_config()
return config["tmp"]
def load_qcloud():
config = load_config()
return config["qcloud"]
if __name__ == '__main__':
print(load_config())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化