在PyDev中运行Twisted应用程序 [英] Running a Twisted Application in PyDev

查看:145
本文介绍了在PyDev中运行Twisted应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Eclipse(3.5.2)PyDev模块(1.6.4)和Python(2.6.5)来调试Twisted应用程序(10.0.0)。要从命令行运行应用程序,我将指定以下内容:

I would like to debug a Twisted Application (10.0.0) using the Eclipse (3.5.2) PyDev Module (1.6.4) and Python (2.6.5). To run the application from the command line I would specify the following:


c:\python26\python c:\python26\\ \\ scripts\twistd.py -ny mytwistedapp.py

c:\python26\python c:\python26\scripts\twistd.py -ny mytwistedapp.py

要使用PyDev完成此任务,我创建了一个新的PyDev项目并导入mytwistedapp。 py和twistd.py。在项目的运行配置下,我指定c:\python26\scripts\twistd.py作为主模块。如果我选择运行 - >调试配置,它运行没有参数的twistd.py(中途,对吗?)。如果我尝试将程序参数添加到运行配置(-ny mytwistedapp.py),它们将由PyDev调试器而不是twistd.py进行处理。两个问题:

To accomplish this using PyDev I created a new PyDev project and imported mytwistedapp.py and twistd.py. Under the project's run configuration I specified c:\python26\scripts\twistd.py as the main module. If I select Run -> Debug Configurations it runs twistd.py with no parameters (half-way there, right?). If I try to add the program arguments to the run configuration (-ny mytwistedapp.py) they are processed by the PyDev debugger instead of twistd.py. Two questions:


  1. 是否将twistd.py指定为主模块正确的方法?

  2. 如果那么,如何传递twistd.py它需要运行mytwistedapp.py(-ny mytwistedapp.py)的参数?


推荐答案

首先,非常感谢你们对此事的亲切和亲切的支持!

First off, thank you all so much for your kind and gracious support in this matter!

通过Eclipse的PyDev模块是在运行配置中将twistd.py定义为主模块。可以使用以下步骤:

The key to running a twisted application via the PyDev module of Eclipse is to define twistd.py as the Main Module in the Run Configuration. The following steps can be used:

这些说明假设您可以在系统上运行扭曲的应用程序,这意味着您已经安装了zope和扭曲。例如,以下内容已经适用于您:

These instructions assume you can already run twisted applications on your system, which means you've installed zope and twisted. For example, the following already works for you:


python twistd.py mytwistapp.tac

python twistd.py mytwistapp.tac

这些说明还假设您已经在Eclipse中安装并配置了PyDev,包括PYTHONPATH的定义。
1.导航到窗口 - >首选项 - > PyDev - >解释器(Python)
2.在Libraries选项卡(系统PYTHONPATH)下,系统Libs应该已经包含Python instllation的位置(例如,c: \python26,c:\python26\dlls\,c:\python26\lib等)。
3.将Zope egg和Twisted文件夹添加到System libs中。例如,c:\python26\lib\site- packages\twisted和c:\python26\lib\site-packages\zope.interfaces-3.6.1-py2.6-win32.egg

These instructions also assume that you have already installed and configured PyDev in Eclipse, including the definition of the PYTHONPATH. 1. Navigate to Window -> Preferences -> PyDev -> Interpreter (Python) 2. Under Libraries Tab (System PYTHONPATH), System Libs should already contain location of your Python instllation (e.g., c:\python26, c:\python26\dlls\, c:\python26\lib, etc). 3. Add the Zope egg and the Twisted folder to System libs. For example, c:\python26\lib\site-packages\twisted and c:\python26\lib\site-packages\zope.interfaces-3.6.1-py2.6-win32.egg

创建一个新的Pydev项目

Create a new Pydev project


  1. 创建一个新的PyDev项目(例如, MYPROJ)

  2. 导入您的各种扭曲的应用程序文件

  3. *将twistd.py添加到您的项目* 。而不是将文件的副本添加到我链接到现有文件(文件 - >新建 - >文件 - >高级 - >链接到文件系统中的文件 - > c:\python26\scripts\\的项目中) \\twistd.py)。这是关键,因为您将使用twistd.py从Eclipse中运行应用程序。

  1. Create a new PyDev project (e.g., MYPROJ)
  2. Import your various twisted application files
  3. * Add twistd.py to your project *. Rather than adding a copy of the file to my project I linked to the existing file (File -> New -> File -> Advanced -> "Link to file in the file system" -> c:\python26\scripts\twistd.py). This is key as you will use twistd.py to run your application from within Eclipse.

现在,您的项目已设置,创建一个新运行配置

Now that your project is setup, create a new Run Configuration.


  1. 运行 - >运行配置

  2. 在主选项卡下使用以下值

    • 名称:Twisted(或其他)

    • 项目:MYPROJ

    • 主要模块:$ {workspace_loc:MYPROJ / twistd.py}

  1. Run -> Run Configurations
  2. Use the following values under the Main Tab
    • Name: Twisted (or whatever)
    • Project: MYPROJ
    • Main Module: ${workspace_loc:MYPROJ/twistd.py}

  • 程序参数:-ny $ {workspace_loc:MYPROJ / mytwistapp.tac}



&p!就是这样!关键是导入twistd.py作为主模块,然后允许将程序参数传递给twsttd.py,就像从命令行那样。

And that's it! The key is importing twistd.py as the Main Module, which then allows the program arguments to be passed into twsttd.py, just as you would do from the command line.

这篇关于在PyDev中运行Twisted应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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