调用 时IPython.embed(),可以通过banner1,banner2或header来自定义交互式会话之前出现的消息,如下所示:
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) 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:
.git everything that I could then re-fetch safely, with simple git commands, from the remote?Testing a bit, …
有谁知道如何配置气流,使电子邮件警报中的链接不指向localhost:
尝试1中的2个例外:Bash命令失败日志:链接主机:vm232日志文件:/home/dev/airflow/logs/test_email_alert/email_alert/2017-03-15T20:00:00.log标记成功:链接
我得到的链接是"localhost"
谢谢
如何使用 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)