Skip to main content
 首页 » 编程设计

像 ipython 或类似的工作方式的 Python 扭曲人孔

2025年05月04日11mfryf

运行这个我从网上找到的

#manhole 
from twisted.internet import reactor 
from twisted.manhole import telnet 
def createShellServer( ): 
    print 'Creating shell server instance' 
    factory = telnet.ShellFactory() 
    port = reactor.listenTCP( 2000, factory) 
    factory.namespace['x'] = application 
    factory.namespace['s'] = s 
    factory.username = 'me' 
    factory.password = 'me' 
    print 'Listening on port 2000' 
    return port 

这奏效了,我能够进入我扭曲的应用程序。但是我不能向上箭头获取以前的命令,也没有任何制表符完成。我认为只要能够回顾历史就会有很大的帮助。

这对我来说是非常新的东西。所以我想我可以使用旧方法来检查井。感谢任何帮助。

请您参考如下方法:

您正在使用旧的、已弃用的、基本上未维护的沙井实现。

相反,您应该使用 the one included in Twisted Conch .您可以找到它的使用示例以及 other Twisted Conch examples .