录制和重播交互式终端会话
playitagainsam的Python项目详细描述
playitagainsam是一种用于录制的工具和相应的文件格式 以及重放交互式终端会话。它的灵感来自 unix命令“script”和“ttyrec”以及python工具“playerpiano”。
有用的功能包括:
- ability to replay with fake typing for enhanced “interactivity”
- ability to replay synchronized output in multiple terminals
现在还很早,还是有点小推车,很容易撞车。但我希望这会 马上解决!
基本用法
使用附带的“pias”脚本或使用 运行“python-m playitagainsam”语法的python模块。
录制这样的会话:
$ pias record <output-file>
这将把您放入一个shell并记录所有输入和输出 在会话期间发生。一旦退出shell,所有活动都将是 作为json文档写入输出文件。
重播这样的录制会话:
$ pias play <input-file>
这将启动原始shell的模拟回放。按任意键 要键入,并在到达行尾时按“回车”键。
额外功能
playitagainsam有一些额外的特性,可以区别于类似的 解决。
多个终端
可以同时记录多个终端的活动 一个单独的会话,可以用于演示服务器 一个终端中的进程和另一个终端中的客户端进程。加入新终端 对于这样一个现有的记录会话:
$ pias --join record <output-file>
手动或自动打字的选择
虽然默认播放模式采用交互式键入,但也可以 为您自动输入PIA。你可以让它单独输入 命令,但等待您手动触发每条换行符,如下所示:
$ pias play <input-file> --auto-type
或者您可以让它自动键入所有输入,如下所示:
$ pias play <input-file> --auto-type --auto-waypoint
这些选项都接受一个整数毫秒值,该值将控制 自动打字的速度。
录音重播还是现场重播?
默认播放模式从 原始终端会话,无任何副作用。不过,这一方 在演讲过程中效果可能是可取的。
例如,演示rest api时,演示者可能希望显示 API调用对使用浏览器的服务的影响。或演示代码 可以驱动其他非控制台输出,如可视化或游戏。
–live replay选项将预先录制的输入连接到 实际现场输出和副作用:
$ pias play <input-file> –live-replay
此选项可与以前的选项组合:
$ pias play <input-file> –live-replay –auto-type –auto-waypoint
实时重播也可以运行两个或多个加入的终端会话。
javascript播放器
有一个基于javascript的播放器可用于嵌入录制的会话 变成一个HTML文档。这对于网站或基于html的演示非常有用。 代码在这里:
https://github.com/rfk/playitagainsam-js/
使用此代码的示例演示位于:
https://github.com/rfk/talk-webapitesting/
有问题
让一切正常进行可能是一件棘手的事情!有件事 你应该知道:
- All terminals should be using utf8 encoding, or you’ll see strange output and probably some outright errors.
- All terminals in a session should be the same size. This restriction may go away in the future.
- The live-replay option has its own particularities:
- Sessions created with the –append switch won’t continue after the first recording session ends.
- Sometimes keypresses “bounce”, and double characters get inserted.
- Some live-replay output sequences lasting longer than the corresponding output in the recording session can get buffered waiting for the next user action.