How to debug with persistent local NDB data in Eclipse / Python / Appengine? - python

I'm developing a Python app for AppEngine using Eclipse / Pydev and need to debug with persistent data stored in the local NDB.
Now, the default path for the NDB on my Linux machine is /tmp and this gets discarded after each reboot. I couldn't find a way to tell Eclipse to use a custom path for the NDB, so I finally resorted to starting the dev_appserver.py via the terminal with:
dev_appserver.py --datastore_path=/home/myfolder/workspace/myapp_datastore app.yaml
Now when I start the debugger I really need persistent data to trace some tricky bugs, but as mentioned, I couldn't find a way to tell eclipse where to store the local NDB so as a consequence I can't use the debugger with persistent data.
Anybody knows a solution?
Tks!

Note: I'm a PyCharm, not an Eclipse user, the answer is based on info I saw.
A Run Configuration window with an Arguments tab allowing you to configure optional arguments for dev_appserver.py is mentioned in the (rather old) Cant Run Google appengine python app on eclipse although launcher works fine, but confirmed in 4.4. Run your application:
You still can use the command line to run your GAE application. But we
are now going to configure Eclipse to allow you to run your
application directly from Eclipse. Right-click on "todo.py", select
Run As ▸ Run Configuration. Under Main Module maintain the path to
dev_appserver.py.
Switch to the argument tab and maintain the full path name of your
project as a parameter. Put the parameter in double-quotes.
I agree, these are Run Configurations and you're asking about configuration for debugging the app. Well, at least in PyCharm they apply to running through the debugger as well, they're actually called Run/Debug Configurations.
Maybe the same applies to Eclipse as well, so IMHO it's worth to locate this tab in your Eclipse version and configure in it the arguments you desire, then check if they apply in the debugger.

Related

Profiling Django with PyCharm

My app is pretty slow even in a dev environment so I would like to figure out what's slowing it down so I can try and fix it.
I know about the debug toolbar and according to what it reports neither the database queries nor the downloaded sources are the issue, so it must be the business logic.
However, I cannot run the PyCharm profiler with the Django server because, well, it's not like running a script.
How may I profile Django with PyCharm?
You should probably set configuration properly.
Then click on Edit Configurations...
The main thing is to set Interpreter (your virtual environment). You don't have to set Custom Run Command if you use python manage.py runserver
Then you can run Django server directly from PyCharm ann Profiler too.

Vim & GAE - Is there anyway to debug python gae applications using vim?

I know that there are plugins to debugging python in vim like this one:https://github.com/joonty/vdebug
What I'm struggling is to find a way to debug GAE apps, is that even possible? If so what steps should I take to make it work?
Thanks
If you're running the GAE app locally with the development server, you should be able to debug the python runtime the same way that you'd debug other local processes.
You can't use vim to debug processes running on the Google runtimes in Google's datacenters. You might be able to use the Stackdriver Debugger to get stack traces; according to this page, the debugger is supported with Python on both the standard and the python-compat flex runtimes.

Wing IDE not stopping at break point for Google App Engine

I'm new to Python, Wing IDE and Google cloud apps.
I've been trying to get Wing IDE to stop at a breakpoint on the local (Windows 7) Google App Engine. I'm using the canned guestbook demo app and it launches fine and responds as expected in the web browser.
However breakpoints are not working. I'm not sure if this is important but I see the following status message when first starting the debugger:
Debugger: Debug process running; pid=xxxx; Not listening (too many connections) ...
My run arguments are as per the recommendation in the Wing IDE help file section "Using Wing IDE with Google App Engine", namely:
C:\x\guestbook --max_module_instances=1 --threadsafe_override=false
One problem I found when trying to follow these instructions. The instructions say go into Project Properties and the Debug/Execute tab and set the Debug Child Processes to Always Debug Child Process. I found this option doesn't exist.
Note also that in the guestbook app, if I press the pause button, the code breaks, usually in the python threading.py file in the wait method (which makes sense).
Further note also that if I create a generic console app in Wing IDE, breakpoints work fine.
I'm running 5.1.9-1 of Wing IDE Personal.
I've included the Google appengine directory and the guestbook directories in the python path.
Perhaps unrelated but I also find that sys.stdout.write strings are not appearing in the Debug I/O window.
I have copied the wingdbstub.py file (from debugger packages of Wing ide) to the folder I am currently running my project on and used 'import wingdbstub' & initiated the debug process. All went well, I can now debug modules.
As often happens with these things, writing this question gave me a couple of ideas to try. I was using the Personal edition ... so I downloaded the professional edition ... and it all worked fine.
Looks like I'm paying $95 instead of $45 when the 30 day trial runs out.

Google App Engine Launcher fails to start

I'm having a problem with the Google App Engine Launcher (the GUI thingy).
I have it installed on two PCs. Both PCs have Python. On both, the launcher ran (the first time) successfully after the installation. On both, at first it failed to deploy an app I was feeding to it, apparently due to being unable to detect Python.
On my home PC, I opened preferences and manually set the path to Python. After that, the app was deployed, and the launcher has been working fine since then, never failing to start. On my work PC, I missed the opportunity to set the Python path, and the launcher fails to start. The log tells me: ConfigParser.NoOptionError: No option 'name' in section: '0'. I suspect this could be due to the missing Python variable.
Unfortunately there doesn't appear to be any kind of config file that contains this setting for GAE. Searching the Windows registry has turned up nothing useful either. I've tried searching the site for problems with the launcher, or how to set the Python path without using GUI, but only found information on problems with apps, not the launcher itself.
A quick google suggests:
try to find and delete file google_appengine_projects.ini
here
or
in Google folder , you have google_appengine_projects.ini file.
Delete it's [0] section.
Or just uninstall and reinstall the launcher.
If still nothing, download an IDE instead - I use pycharm. It's not free (there are free ones out there) but it does manage the launcher for you.

How to debug Google App Engine scripts with PyScripter

The situation is as follows: I have downloaded the Google App Engine SDK. I have written my "helloworld" app that runs locally in my computer. I have to use PyScripter as IDE. I can't use Eclipse, that would not be a valid solution to my problem.
In PyScripter, I have set a "Run Configuration", so that an instance of the server runs locally (either in "run" mode or in "debug" mode), and can access the app via a webbrowser accessing "localhost".
Now, the problem is, breakpoints seem to be ignored. I set a breakpoint, reload the browser, and the response appears without the debugger stopping at the breakpoint I had set in my own function. I cannot debug at all.
The question is, how can I debug the app using the configuration I have described?
(Note: I am already using the "remote" python engine within PyScripter for running the local server)
I think this is a PyScripter's bug. I tested in version 1.9.9.7 and the same problem is still there.

Categories

Resources