How to debug Google App Engine scripts with PyScripter - python

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.

Related

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

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.

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.

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.

GAE - Online admin console

Is there some way I can run custom python code on my google appengine app online? Is there a python console somewhere that I can use? I've seen vague references here and there, but nothing concrete.
Check out these previous answers on how to enable the interactive console (that you can use on the local dev appserver) on your deployed application.
You can use remote shell, that is on your app engine sdk.
For example
~/bin/google_appengine/remote_api_shell.py -s your-app-identifier.appspot.com s~your-app-identifier
When you are inside the shell, you will have the db module enabled. in order to use your models, you will have to import them.

Debugging App Engine with --backends

I can debug my application in Eclipse without running any backends just fine. Now I want to debug my application with the backends enabled.
I start the dev_appserver via Eclipse with the --backends. But the execution doesn't stop at the breakpoints I set. I tried setting the application ports to the same as without backends by passing --multiprocess_min_port=8080, but that didn't help either.
What am I missing?

Categories

Resources