示例#1
0
文件: pub.py 项目: lazypig-jan/Lan
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())
示例#2
0
 def __init__(self, path='./', name='config', section='CONFIG'):
     # 获取根目录下config.ini
     self.config_path = os.path.join(path, name + '.ini')
     # 读取配置文件
     self.config = configparser.ConfigParser()
     self.config.read(self.config_path, 'utf-8')
     # 获取section
     self.section = section
     # 判断是否有ini文件 没有就创建
     if os.path.exists(self.config_path) is False:
         self.config.add_section(section)
         Log.debug('创建' + name + '.ini')
示例#3
0
def create(args=None):
    if None is args:
        Log.error('没有name参数')
        return False
    name = args.name.split("/", 1)
    # name = ["it", "demo"]
    if name[0] == "it":
        it(name[1])
    elif name[0] == "st":
        st(name[1])
    elif name[0] == "sm":
        sm(name[1])
    else:
        Log.debug("没有相关类型 请输入it/project st/project sm/project")
示例#4
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)
示例#5
0
文件: __init__.py 项目: bbfpl/Lan
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)
示例#6
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())
示例#7
0
        if os.path.exists(self.config_path) is False:
            self.config.add_section(section)
            Log.debug('创建' + name + '.ini')

    def get(self, name=''):
        """
        获取值
        """
        if Utils.empty(name):
            Log.error('name不能为空')
            return False

        # 获取config
        val = self.config.get(self.section, name)
        return val

    def set(self, name="", value=""):
        """
        给ini设置值
        """
        self.config.set(self.section, name, value)
        # 写入配置文件
        self.config.write(open(self.config_path, "w"))


if __name__ == '__main__':
    c = Config(path='./', name='Token', section='USER')
    c.set('user', '1234')
    c.set('psw', '1233')
    Log.debug('user:'******'user'))
示例#8
0
文件: yaml.py 项目: lazypig-jan/Lan
        初始化
        """
        # 忽略掉yaml告警
        warnings.simplefilter("ignore", DeprecationWarning)

        # 每个项目下面有个config.yaml
        config_path = path + '/' + file_name + '.yaml'
        # yaml的读取
        f = open(config_path, encoding='utf-8')
        self.data = yaml.safe_load(f)
        f.close()

    def get(self, name=''):
        _data = self.data
        """
        获取yaml
        """
        if name != '':
            try:
                for item in name.split('.'):
                    _data = _data[item]
            except Exception as e:
                _data = ''
        return _data


if __name__ == '__main__':
    y = Yaml('./')
    name = y.get('name')
    Log.debug(name)
示例#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())
示例#10
0
def _fun_write_model_tpl_template(path):
    Log.debug('创建model/tpl/template.html文件')
    # 写入内容
    Utils.write_file(path + '/template.html', get_template_tpl())
示例#11
0
def _fun_write_model_tpl_nav(path):
    Log.debug('创建model/tpl/nav.html文件')
    # 写入内容
    Utils.write_file(path + '/nav.html', get_nav_tpl())
示例#12
0
def _fun_write_model_tpl_content(path):
    Log.debug('创建model/tpl/content.html文件')
    # 写入内容
    Utils.write_file(path + '/content.html', get_content_tpl())
示例#13
0
def _fun_write_index_html(path):
    Log.debug('创建index.html文件')
    # 模板编译
    template = Template(get_html())
    # 写入内容
    Utils.write_file(path + '/index.html', template.render())
示例#14
0
文件: server.py 项目: lazypig-jan/Lan
def server(args=None):
    if None is args:
        Log.error('没有name参数')
        return False

    Log.debug(args)
示例#15
0
文件: pub.py 项目: lazypig-jan/Lan
def mkdir(name='NAME'):
    Log.debug('创建目录:' + name)
    # 创建ST目录
    path = name
    Utils.mkdir(path)
    return path