使用IDE调试Fabfile [英] Debugging Fabfile's Using An IDE

查看:76
本文介绍了使用IDE调试Fabfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够调试结构文件,但是由于某些原因,当我使用IDE运行/调试fabfile.py时,似乎没有任何反应.我看到状态消息,表明调试过程正在开始,但是它刚刚结束,并且调试控制台中没有输出.

I would like to be able to debug a fabric file, but for some reason when I run/debug my fabfile.py using my IDE, nothing seems to happen. I see status messages that a debug process is starting, but it just ends and there is no output in my debug console.

我已经使用Wing IDE和PyDev/Eclipse尝试了此操作.

I have tried this with Wing IDE and PyDev/Eclipse to no avail.

推荐答案

以下是我最终使用PyCharm进行设置的方法.我使用专业版进行了此操作,但我认为这也适用于免费社区版.如果您尝试尝试,请告诉我们.

Here is how I ended up setting this up using PyCharm. I did this with the professional version but I think this would work with the free community edition as well. If you try it, please let us know.

与大多数类似的事情一样,一旦您知道了魔术设置,这将非常容易.所有这些说明都是通过PyCharm进行的,但是其中一些可以通过其他方式完成.

As with most things like this, once you know the magic settings, it was very easy. All these instructions are through PyCharm but several of them can be done in alternate ways.

将Fabric软件包安装到项目环境中(使用设置-> Project Interpreter软件包安装).这会将Fabric安装到虚拟环境的站点程序包文件夹中,并将fab.exe和fab-script.py文件放入/Scripts文件夹中.找到fab-scripts.py文件的位置并复制路径(类似"C:\\ Scripts \ fab-script.py")

Install Fabric package to the project environment (using the Settings-->Project Interpreter package installation). This installs Fabric to the virtual environment’s site package folder as well as putting a fab.exe and fab-script.py file in the /Scripts folder. Find the location of the fab-scripts.py file and copy the path (something like this "C:\\Scripts\fab-script.py")

现在,使用此脚本文件名创建运行配置(运行->编辑配置…-> Python).脚本参数指向fabfile.py和执行/调试的命令.脚本参数为:-f fabfile dev:"MyBranch1" deploy这允许我使用"MyBranch1"参数调试"dev"任务,然后运行"deploy"任务.用您的任务名称替换dev:"MyBranch1"部署.工作目录指向您的项目文件夹,该文件夹也是fabfile.py所在的位置(至少在我的配置下).我的设置如下所示.

Now, create a run configuration (Run --> Edit Configuration… --> Python) with this script file name. The Script parameters point to the fabfile.py and the command to execute/debug. The Script parameters are: -f fabfile dev:"MyBranch1" deploy This allows me to debug the "dev" task with a "MyBranch1" parameter then run the "deploy" task. Replace the dev:"MyBranch1" deploy with whatever your task name is. The Working directory points to your project folder which is also where the fabfile.py is located (at least with my configuration). My setup looks like this.

打开fabfile.py,并在要停止调试器的位置放置一个断点.在这种情况下,由于我正在调试部署任务,因此我在此处放置了断点.

Open the fabfile.py and put a breakpoint where you would like to stop the debugger. In this case, since I’m debugging the deploy task, I put the breakpoint there.

现在要调试fab运行,将活动配置设置为刚刚完成的配置,然后单击debug.

Now to debug the fab run, set the active configuration to the one just made and click debug.

在遇到断点时,您将关闭并使用PyCharm调试Fabric fabfile.py

When the breakpoint is hit, you are off and debugging your fabric fabfile.py with PyCharm

当您准备好运行调试的fabfile时,请打开终端并使用调试中使用的参数运行fab命令.再次,将命令提示符指向项目(工作)目录. (注意:脚本"文件夹中的fab.exe需要从命令行执行-通过将其置于环境变量path属性中)

When you are ready to run your debugged fabfile, open the Terminal and run the fab command with the parameters used in the debugging. Again, point the command prompt at the project (working) directory. (NOTE: The fab.exe in the Scripts folder needs to be executable from the command line – by having it in the environment variables path property)

这篇关于使用IDE调试Fabfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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