我可以在Windows上不安装Cygwin的情况下使用Expect吗? [英] Can I use Expect on Windows without installing Cygwin?

查看:517
本文介绍了我可以在Windows上不安装Cygwin的情况下使用Expect吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Expect是用于产生子应用程序并对其进行控制的模块.我对Python和Ruby感兴趣.

Expect is a module used for spawning child applications and controlling them. I'm interested in Python and Ruby.

推荐答案

WExpect for Python .

wexpect.py文件中的注释(打字稿不变,并突出显示了内容)

Notes in the wexpect.py file (typos unchanged and highlighting added)

Wexpect 是pexpext到Windows的端口.由于缺少适用于Windows的python 要运行的必要模块(pty,tty,select,termios,fctnl和资源) 期待,有必要创建一个实现任何功能的后端 依靠这些模块使用的那些. Wtty.py 是此后端.在 Windows世界控制台不是同质的.他们可以使用低水平或高水平 级别的输入和输出功能,并正确处理两种情况 子进程是为Spawn的Instacne创建的,带有一个中间子级 可以连续从控制台读取数据,并通过管道发送该数据 到wtty实例. Spawner.py 可通过阅读和整理来重新使用 数据.

Wexpect is a port of pexpext to Windows. Since python for Windows lacks the requisite modules (pty, tty, select, termios, fctnl, and resource) to run pexpect, it was necessary to create a back-end that implemented any functions that were used that relied on these modules. Wtty.py is this back-end. In the Windows world consoles are not homogeneous. They can use low level or high level input and output functions, and to correctly deal with both cases two child processes are created for instacne of Spawn, with an intermidate child that can continuously read from the console, and send that data over a pipe to an instance of wtty. Spawner.py is resposible from reading and piping data.

我已尽可能保留完整的代码,并尝试保留尽可能多的注释 完好无损是可能的(特别是对于尚未更改的功能) 的评论将误导他们与特定于操作系统的关系 功能.同样,函数sendcontrol和sendeof在以下位置未实现 这次,因为我找不到这些功能的有意义的Windows版本.
此外,控制台在Windows上没有关联的fild描述符,因此 全局变量child_fd将始终为None.

I've left as much code intact as I could and also tried to leave as many comments intact is possible (espicially for functions that have not been changed) so many of the comments will be misleading in their relationship to os specific functionality. Also, the functions sendcontrol and sendeof are unimplemnted at this time, as I could not find meaningful Windows versions of these functions.
additionally, consoles do not have associated fild descriptors on Windows, so the global variable child_fd will always be None.

这篇关于我可以在Windows上不安装Cygwin的情况下使用Expect吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆