stratosphere.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:stratosphere 作者: victortrac 项目源码 文件源码
def main(project, env, action, verbose, format, template_path):
    if verbose >= 2:
        level = 5
    elif verbose == 1:
        level = logging.DEBUG
    else:
        logging.getLogger('googleapiclient').setLevel(logging.ERROR)
        logging.getLogger('oauth2client').setLevel(logging.ERROR)
        level = logging.INFO

    logging.addLevelName(5, "TRACE")
    logging.basicConfig(format='%(asctime)s %(levelname)s:%(name)s:%(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S', level=level)

    logger.debug('Debug log enabled')
    logger.info("Log level: {}".format(level))

    if action in ['apply', 'template']:
        if template_path is None:
            logging.error('A path to a template file is required for {}'.format(action))
            sys.exit(1)
        template_class = load_template_module(template_path)
        template = template_class(project, env)

        if format == "json":
            template.formatter = template.asJSON

        if action == 'apply':
            template.__repr__()
            apply_deployment(project, template)
        elif action == 'template':
            t = template.__repr__()
            logger.info('Template successfully rendered, printing to stdout...')
            print(t)
            sys.exit(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号