Debugging Fabfile's Using An IDE

自古美人都是妖i 提交于 2019-12-23 04:38:29

问题


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.

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


回答1:


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.

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.

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”)

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.

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.

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

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

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)



来源:https://stackoverflow.com/questions/19839989/debugging-fabfiles-using-an-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!