cli.py 文件源码

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

项目:neres 作者: glogiotatidis 项目源码 文件源码
def cli(ctx, email, password, account, environment):
    cookiejar = os.path.expanduser('~/.config/neres/{}.cookies'.format(environment))
    if not os.path.exists(os.path.dirname(cookiejar)):
        os.makedirs(os.path.dirname(cookiejar), 0o700)
    newrelic.initialize_cookiejar(cookiejar)

    if ctx.invoked_subcommand != 'login':
        with Spinner('Authorizing: '):
            if all([email, password]):
                newrelic.login(email, password)
            else:
                if not newrelic.check_if_logged_in():
                    raise click.ClickException('Login first')

        if not account and ctx.invoked_subcommand != 'list-accounts':
            account = newrelic.get_accounts()[0]['id']

    ctx.obj = {}
    ctx.obj['ACCOUNT'] = account
    ctx.obj['EMAIL'] = email
    ctx.obj['PASSWORD'] = password
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号