简体   繁体   English

在IntelliJ中调试Crossbar.io应用

[英]Debugging Crossbar.io app in IntelliJ

I'm building an app using Crossbar.io in IntelliJ. 我正在使用IntelliJ中的Crossbar.io构建应用程序。 Since you start the app using the crossbar start command in the shell I'm not clear on how to (ideally automatically) attach the Python debugger to the appropriate scripts. 由于您是在Shell中使用crossbar start命令启动应用程序的,因此我不清楚如何(理想情况下自动)将Python调试器附加到适当的脚本。 Anyone have any ideas? 有人有想法么?

Nice question. 好问题。

I was a little bit confused about how to debug as well because it seems like crossbar is sort of mixing up python 2 and 3 together. 我对如何调试也有些困惑,因为crossbar似乎将python 2和3混合在一起。 I wanted to install crossbar.io under a virtual environment with Python 3 because the examples components are using python 3 but for some reason I could not manage to install crossbar under a virtual environment with Python 3 and Im forced to use Python 2 for WAMP routing instead. 我想在使用Python 3的虚拟环境中安装crossbar.io,因为示例组件使用的是python 3,但是由于某些原因,我无法在使用Python 3的虚拟环境中安装crossbar,而我被迫使用Python 2进行WAMP路由代替。 I normally use pyenv rather than virtualenv, however, I believe they both are similar. 我通常使用pyenv而不是virtualenv,但是,我相信它们都是相似的。 I ended up creating 2 pyenvs. 我最终创建了2个pyenvs。 One with Python 2.7.6 purely for crossbario router and the other with Python 3.4.2 for App Components. 一个使用Python 2.7.6纯粹用于crossbario路由器,另一个使用Python 3.4.2适用于App Components。

My Solution 我的解决方案

Have a look at the Screenshot 看看截图

I don't know if it is the best way to solve this problem but this is what I did. 我不知道这是否是解决此问题的最佳方法,但这就是我所做的。 I used PyCharm but I believe IntelliJ is similar as well. 我使用了PyCharm,但我相信IntelliJ也是如此。

I haven't tried this under virtualenv but I reckon it is quite similar. 我没有在virtualenv下尝试过,但是我认为它非常相似。

  1. Install python 2.7.6 via pyenv 通过pyenv安装python 2.7.6

    \n$ pyenv install 2.7.6 $ pyenv安装2.7.6\n
  2. Create a pyenv with Python 2 for crossbar.io 使用Python 2为crossbar.io创建pyenv

    \n$ pyenv virtualenv 2.7.6 crossbar $ pyenv virtualenv 2.7.6交叉开关\n$ pyenv activate crossbar $ pyenv激活交叉开关\n(crossbar)$ pip install crossbar (crossbar)$ pip安装crossbar\n
  3. Find and copy the full path for crossbar executable you have just installed. 查找并复制刚安装的Crossbar可执行文件的完整路径。

    \n(crossbar)$ which crossbar (crossbar)$其中\n

    and copy the path. 并复制路径。

  4. Install python 3.4.2 via pyenv 通过pyenv安装python 3.4.2

    \n$ pyenv install 3.4.2 $ pyenv安装3.4.2\n
  5. Create a pyenv with Python 3 for app components 使用Python 3为应用程序组件创建pyenv

    \n$ pyenv virtualenv 3.4.2 app $ pyenv virtualenv 3.4.2应用程序\n$ pyenv activate app $ pyenv激活应用\n(app)$ pip install autobahn (app)$点安装高速公路\n
  6. Create a normal PyCharm project with "app" as a local python environment. 使用“ app”作为本地python环境创建一个普通的PyCharm项目。 I mean use python executable from app pyenv as an interpreter. 我的意思是使用来自应用pyenv的python可执行文件作为解释器。

  7. Generate a hello world crossbar.io app. 生成一个hello world crossbar.io应用程序。

    \n$ pyenv activate crossbar $ pyenv激活交叉开关\n(crossbar)$ crossbar init --template hello:python (crossbar)$ crossbar初始化--template hello:python\n
  8. From menubar go to Run/Edit configuration... 从菜单栏中转到运行/编辑配置...

  9. Click a green + icon and select Python 单击绿色+图标,然后选择Python
  10. Paste the full path for crossbar executable script. 粘贴交叉开关可执行脚本的完整路径。
    \n~/.pyenv/versions/crossbar/bin/crossbar 〜/ .pyenv /版本/交叉/斌/横梁\n
  11. put the word start as Script parameters. 将单词start作为脚本参数。
  12. Make sure to select crossbar as a Python interpreter not app. 确保选择crossbar作为Python解释器而不是app。 Please correct me if Im wrong but I believe the interpreter we select here is only for running and debugging purpose not for code completion and stuffs. 如果我错了,请纠正我,但我相信我们在这里选择的解释器仅用于运行和调试,而不用于代码完成和填充。
  13. Make sure to put the path where .crossbar folder is located as a Working directory path. 确保将.crossbar文件夹所在的路径放置为工作目录路径。
  14. Visit 0.0.0.0:8080 to trigger the debug session. 访问0.0.0.0:8080触发调试会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM