代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
__author__ = "苦叶子"
"""
公众号: 开源优测
Email: lymking@foxmail.com
"""
import os
import random
import codecs
basedir = os.path.abspath(os.path.dirname(__file__))
choice = ("QWERTYUIOPASDFGHJKLMNBVCXZqazxswedcvfrtgbnhyujmkiolp1234567890!@#$%^&*")
class Config:
if os.path.exists('.env'):
print('Import environment from .env')
for line in codecs.open('.env', encoding="utf-8"):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
#print(var[0] + "=" + var[1])
SECRET_KEY = os.environ.get('SECRET_KEY')# or random.choices(choice, k=16)
MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.126.com')
MAIL_PORT = int(os.environ.get('MAIL_PORT', '587'))
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'true').lower() in ['true', 'on', '1']
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
FLASKY_MAIL_SUBJECT_PREFIX = os.environ.get('FLASKY_MAIL_SUBJECT_PREFIX')
FLASKY_MAIL_SENDER = os.environ.get('FLASKY_MAIL_SENDER')
FLASKY_ADMIN = os.environ.get('FLASKY_ADMIN')
SSL_REDIRECT = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_RECORD_QUERIES = True
FLASKY_POSTS_PER_PAGE = 20
FLASKY_FOLLOWERS_PER_PAGE = 50
FLASKY_COMMENTS_PER_PAGE = 30
FLASKY_SLOW_DB_QUERY_TIME = 0.5
# 自定义参数
AUTO_LOGS = os.environ.get('AUTO_LOGS')
AUTO_REPORT = os.environ.get('AUTO_REPORT')
RUNNERS = []
TRIGGER = None
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'AutoLine-dev.sqlite') #os.environ.get('DEV_DATABASE_URL')
TRIGGER_DATABASE_URL = 'sqlite:///' + os.path.join(basedir, 'AutoLine-dev.sqlite')
class ProductionConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') + "?charset=utf8" # or 'sqlite:///' + os.path.join(basedir, 'AutoLine.sqlite')
#SQLALCHEMY_ECHO = True
TRIGGER_DATABASE_URL = os.environ.get('TRIGGER_DATABASE_URL')
@classmethod
def init_app(cls, app):
Config.init_app(app)
# 发送初始化错误信息给管理员
import logging
from logging.handlers import SMTPHandler
credentials = None
secure = None
if getattr(cls, 'MAIL_USERNAME', None) is not None:
credentials = (cls.MAIL_USERNAME, cls.MAIL_PASSWORD)
if getattr(cls, 'MAIL_USE_TLS', None):
secure = ()
mail_handler = SMTPHandler(
mailhost=(cls.MAIL_SERVER, cls.MAIL_PORT),
fromaddr=cls.FLASKY_MAIL_SENDER,
toaddrs=[cls.FLASKY_ADMIN],
subject=cls.FLASKY_MAIL_SUBJECT_PREFIX + ' AutoLine Startup Error',
credentials=credentials,
secure=secure)
mail_handler.setLevel(logging.ERROR)
app.logger.addHandler(mail_handler)
config = {
"development": DevelopmentConfig,
"production": ProductionConfig,
"default": DevelopmentConfig
}
# 关键字自定义配置
USER_KEYS = {
"web": ["BuiltIn", "Collections", "String", "DateTime", "Screenshot", "SeleniumLibrary"],
"app": ["BuiltIn", "Collections", "String", "DateTime", "Screenshot", "AppiumLibrary"],
"http": ["BuiltIn", "Collections", "String", "DateTime", "RequestsLibrary"],
"all": ["BuiltIn", "Collections", "String", "Screenshot", "DateTime",
"SeleniumLibrary", "AppiumLibrary", "RequestsLibrary",
"Process", "Telnet", "OperatingSystem"]
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。