2015-10-06 57 views
1

调试运行扭曲应用程序,我想调试一个扭曲的应用在PyCharm如何在PyCharm

from twisted.internet import defer 
from twisted.application import service, internet 
from txjason.netstring import JSONRPCServerFactory 
from txjason import handler 

class Example(handler.Handler): 
    def __init__(self, who): 
     self.who = who 

    @handler.exportRPC("add") 
    @defer.inlineCallbacks 
    def _add(self, x, y): 
     yield 
     defer.returnValue(x+y) 

    @handler.exportRPC() 
    def whoami(self): 
     return self.who 

factory = JSONRPCServerFactory() 
factory.addHandler(Example('foo'), namespace='bar') 

application = service.Application("Example JSON-RPC Server") 
jsonrpcServer = internet.TCPServer(7080, factory) 
jsonrpcServer.setServiceParent(application) 

如何运行命令行,我知道应用程序,但如何开始在PyCharm调试无法理解

回答

1

在“Python”部分的PyCharm中创建一个新的Run Configuration

如果您使用twistd启动此应用程序,则将“脚本”设置配置为指向该扭曲脚本,以及“脚本参数”,就像您在命令行中使用它们一样。您可能需要包含--nodaemon选项。

然后,您应该可以在PyCharm或set breakpoints下运行并调试它。