小编Leo*_*ael的帖子

如何使用我自己的横幅调用“IPython.start_ipython()”?

什么有效

调用 时IPython.embed(),可以通过banner1,banner2header来自定义交互式会话之前出现的消息,如下所示:

import IPython
IPython.embed(banner2="*** Welcome! ***")
Run Code Online (Sandbox Code Playgroud)

结果:

import IPython
IPython.embed(banner2="*** Welcome! ***")
Run Code Online (Sandbox Code Playgroud)

什么不起作用

当使用IPython.start_ipython(), 而不是IPython.embed()在上面的调用中时,我找不到任何会影响横幅的参数,除了display_banner=False完全省略它。

我能做的最好的事情就是 mangle argv,更改配置,例如:

import sys, IPython
argv = (
    sys.argv[1:] + 
    ['--TerminalInteractiveShell.banner2=*** Welcome! ***']
)
IPython.start_ipython(argv=argv)
Run Code Online (Sandbox Code Playgroud)

这是可用的,但看起来很做作。

我想我也可以在我的代码中继承IPython.ipapp.TerminalInteractiveShell并覆盖.banner1or .banner2,但这感觉有点矫枉过正。

问题

banner2我想要的只是一种进入的方式IPython.start_ipython()

有更直接的方法吗?

更多技术细节

用例是创建一个脚本,该脚本使用一些预定义的变量启动 IPython 控制台会话,以控制具有相当复杂设置的应用程序。并解释如何使用该设置。

就像是:

import sys, myapp, IPython

explain_usage_of_session = """
You can use session.blah() to frobnicate …
Run Code Online (Sandbox Code Playgroud)

python ipython

6
推荐指数
1
解决办法
1644
查看次数

Remove all information from a .git directory that can be re-downloaded

I have a git repository that, when just checked out, takes around 2.3 GiB even in the shallowest configuration, of which 1.9 GiB is inside .git/objects/pack. The working tree files are just about .5 GiB.

Considering I have a remote from which I can re-fetch all the objects if needed, the question is:

  • What (and how) can I delete from inside .git everything that I could then re-fetch safely, with simple git commands, from the remote?

Testing a bit, …

git

5
推荐指数
1
解决办法
1034
查看次数

如何在电子邮件警报中配置Airflow URL

有谁知道如何配置气流,使电子邮件警报中的链接不指向localhost:

尝试1中的2个例外:Bash命令失败日志:链接主机:vm232日志文件:/home/dev/airflow/logs/test_email_alert/email_alert/2017-03-15T20:00:00.log标记成功:链接


我得到的链接是"localhost"

谢谢

airflow

5
推荐指数
1
解决办法
2250
查看次数

以非 root 身份运行容器,以便容器“root”不会映射到正在运行的用户

问题:

如何使用 podman 以非 root 身份运行容器,以便容器内的 root 用户不会映射到运行容器的主机用户?

细节

在 podman 中,当以非 root 身份运行容器时,容器 root uid (0) 会映射到主机 uid,而所有其他 uid 都会根据文件进行映射/etc/subuid。例如:

$ grep $USER /etc/subuid
myuser:231072:65536
$ id
uid=1000(myuser) gid=1000(myuser) groups=1000(myuser)

$ podman run --rm -ti  -v /tmp:/tmp --entrypoint='["/sbin/my_init", "--"]' \
>            docker.io/phusion/baseimage:0.11 bash
[...]
*** Running bash...
root@e9f79e3fe659:/# touch /tmp/as_root

root@e9f79e3fe659:/# adduser --gecos '' --disabled-password inneruser
Adding user `inneruser' ...
Adding new group `inneruser' (1000) ...
Adding new user `inneruser' (1000) with group `inneruser' ...
Creating home …
Run Code Online (Sandbox Code Playgroud)

podman

5
推荐指数
0
解决办法
2859
查看次数

标签 统计

airflow ×1

git ×1

ipython ×1

podman ×1

python ×1