Exemple #1
0
def tpl(tpl_path='', save_path=''):
    Log.debug('创建' + save_path + '文件')
    # 获取路径
    code_path = os.path.dirname(__file__) + tpl_path
    # 基础模板文件
    code = Utils.open_file(code_path)
    # 模板编译
    template = Template(code)
    # 写入内容
    Utils.write_file(save_path, template.render())
Exemple #2
0
 def __init__(self, path='./log/', name='log', logfile=False):
     if Utils.empty(path):
         print('请输入保存路径')
         return False
     # 配置文件 是否生成log文件
     if logfile:
         logzero.logfile(path + "/" + Utils.time_ymd() + "_" + name +
                         ".log",
                         maxBytes=1e6,
                         backupCount=1)
Exemple #3
0
def st(name="demo"):
    # 创建ST目录
    root_path = mkdir(os.getcwd())
    path = mkdir(root_path + '/' + 'st_' + name)

    init_file(path)  # 创建空__init__.py

    # 创建ST-log目录
    Utils.mkdir(path + '/log')
    # 创建配置文件
    _fun_config(path)

    _fun_write_auth(path)
    _fun_write_main(path)
    _fun_write_run(path)
    _fun_write_task(path)
Exemple #4
0
def st(name="demo"):
    # 创建ST目录
    root_path = mkdir('ST')
    st_path = mkdir(root_path + '/' + name)

    init_file(st_path)  # 创建空__init__.py

    # 创建ST-log目录
    Utils.mkdir(st_path + '/log')
    # 创建配置文件
    _fun_config(st_path)

    _fun_write_auth(st_path)
    _fun_write_main(st_path)
    _fun_write_run(st_path)
    _fun_write_task(st_path)
Exemple #5
0
def sm():
    # 创建Monitor目录
    path = os.getcwd() + '/Monitor'

    Utils.mkdir(path)
    Log.debug('创建目录:Monitor')
    # 创建配置文件
    _fun_config(path)

    # 创建run.py
    _fun_write_run(path)

    # 创建templates目录
    templates = path + '/templates'
    Utils.mkdir(templates)
    Log.debug('创建目录:templates')

    # 创建index.html
    _fun_write_index_html(templates)
Exemple #6
0
def sm(name="demo"):
    # 创建Monitor目录
    root_path = mkdir(os.getcwd())
    path = mkdir(root_path + '/' + 'monitor_' + name)

    Log.debug('创建目录:' + 'monitor_' + name)
    # 创建配置文件
    _fun_config(path)

    # 创建run.py
    _fun_write_run(path)

    # 创建templates目录
    templates = path + '/templates'
    Utils.mkdir(templates)
    Log.debug('创建目录:templates')

    # 创建index.html
    _fun_write_index_html(templates)
Exemple #7
0
    def get(self, name=''):
        """
        获取值
        """
        if Utils.empty(name):
            Log.error('name不能为空')
            return False

        # 获取config
        val = self.config.get(self.section, name)
        return val
Exemple #8
0
def _fun_config_yaml(path):
    Log.debug("创建 apis.yaml文件")
    Utils.write_file(path + '/apis.yaml',
                     Template(get_config_apis_tpl()).render())

    Log.debug('创建 config.yaml文件')
    Utils.write_file(path + '/config.yaml',
                     Template(get_config_config_tpl()).render())

    Log.debug('创建 mail.yaml文件')
    Utils.write_file(path + '/mail.yaml',
                     Template(get_config_mail_tpl()).render())

    Log.debug('创建 repore.yaml文件')
    Utils.write_file(path + '/repore.yaml',
                     Template(get_config_repore_tpl()).render())

    Log.debug('创建 response.yaml文件')
    Utils.write_file(path + '/response.yaml',
                     Template(get_config_response_tpl()).render())
Exemple #9
0
def _fun_write_model_tpl_mail_html(path):
    Log.debug('创建model/tpl/mail_html.txt文件')
    # 写入内容
    Utils.write_file(path + '/mail_html.txt', get_maile_html_tpl())
Exemple #10
0
def _fun_write_model_tpl_template(path):
    Log.debug('创建model/tpl/template.html文件')
    # 写入内容
    Utils.write_file(path + '/template.html', get_template_tpl())
Exemple #11
0
def _fun_write_model_tpl_nav(path):
    Log.debug('创建model/tpl/nav.html文件')
    # 写入内容
    Utils.write_file(path + '/nav.html', get_nav_tpl())
Exemple #12
0
def _fun_write_model_tpl_content(path):
    Log.debug('创建model/tpl/content.html文件')
    # 写入内容
    Utils.write_file(path + '/content.html', get_content_tpl())
Exemple #13
0
def _fun_write_index_html(path):
    Log.debug('创建index.html文件')
    # 模板编译
    template = Template(get_html())
    # 写入内容
    Utils.write_file(path + '/index.html', template.render())
Exemple #14
0
def init_file(path, content=''):
    # 写入内容
    Utils.write_file(path + '/__init__.py', content)
Exemple #15
0
def mkdir(name='NAME'):
    Log.debug('创建目录:' + name)
    # 创建ST目录
    path = name
    Utils.mkdir(path)
    return path