Wing IDE not stopping at break point for Google App Engine - python

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.

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.

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.

Python 2.7.2 and Google App Engine SDK 1.6.1 on Win 7 Home Premium not working

I have installed Python 2.7.2 (Win7 32-bit) and Google App Engine SDK 1.6.1 for Win7 on a 64-bit system running Win7 Home Premium. Default folder locations for both Python and GAE. When I try to run the helloworld project as described in the Google Python Getting Started doc, the Launcher's "browse" button never becomes active. The GAE SDK is supposed to do fine with Python 2.7.
Is there a complete listing anywhere of environment variables needed for this setup to work? So far, all posts I have seen are from users who have gotten well past this absolutely basic step.
The Google docs for setting up GAE with Python 2.7 have some issues. If you are trying to launch the basic "hello world" app through the GUI App Engine interface, after following the instructions, you are probably seeing red text and all the buttons are grayed out?
If so, it is because there are errors within your helloworld.py program - this is where the Google instructions failed.
The import statement they have in the instructions:
import webapp2
This fails, it needs to point to the local instance of GAE's webapp. Also, their Python 2.7 program is incomplete. If you look at the Python 2.5 example, you will see the complete program (you may need to modify webapp --> webapp2 for Python 2.7?):
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Last thing, the YAML file in the Google instructions refer to "helloworld.app" - I can't confirm this, but I think it needs to be "helloworld.py" ?? I don't know, I may be wrong.
A couple months have gone by since you posted the question, if you found out any details, please feel free to update this question.
I was facing the same issue, browse button was disabled. I ran dev_appserver.py helloworld command at command prompt and then opened localhost:8080 in my browser the hello world program ran successfully.
I compared the helloworld example to the guestbook demo and found that the application element was key. I added the line at the top of the app.yaml file "application: helloworld" and the helloworld example started working in the Google App Engine (GAE). Note that the 'application' element is supposed to be optional as defined in the app.yaml reference. It looks like it is optional if you use the command line, and it is not optional if you use GAE.
Do you see anything in the GAE SDK logs?
Which browser are you using? What is your default browser?
The default security settings in IE require you to enable intranet access.
I recently had to rebuild my Win7 dev box. Chrome was my default browser. When I installed GAE SDK v1.6.1 I had a similar problem to what you describe.
I checked logs and fiddled with the browser configuration to resolve it.
My recollection was that once I made IE 9 my default browser again, i saw the intranet security error. After enabling access to intranet sites like localhost:8080, things started working OK, but start-up was sometimes slow. Then I made Chrome my default browser again and the start-up became a bit faster and more reliable.
I am quite sure that is because you had changed the encode from ANSI to another type (such as UTF-8) on app.yaml,
change it back to ANSI, then you can run the project on google app engine launcher.
BTW, the helloworld tutorial on google has no problem.
I had a similar issue; it turned out my problem was not due to environment variables.
Debugging GAE:
First off let me say that if you are having problems with GAE, I would strongly recommend launching using the CLI, google_appengine/dev_appserver.py. There is a large stack trace of the reason GAE is failing (instead of simply a red link in the GAE Launcher GUI) that will point you in the right direction.
Hidden bad characters:
When copying the text from google's "hello world" tutorial, there was an invisible hidden character at the start of my YAML file (I found it using kdiff, a diff tool). After deleting this character, my app launched (and showed up as not red in the GAE Launcher GUI).
Environment Variables:
As to your original question, the only relevant environment variable I have set is my PATH variable, where I have appended the folder of my python executable (in my case C:\Python27) so that I can run python files without specifying the full path to Python. Let me repeat, however, that I do not believe this is the cause of your problem, but you can more directly confirm this using the CLI.
Like pghprogrammer4 above, I solved this problem by removing bad characters in my files. They were invisible in my regular text editor (sublime text 2) but I found them with that editor's hex editor. I knew what to look for, because I noticed a space at the start of my Guestbook app (a few tutorials in). So I looked at the debug in Chrome, and it showed the character Zero Width Space. The Unicode site has the hexadecimal value of this character so I searched for that (didn't need to search far; it was the first three bytes of the file), and removed it. Thankfully Sublime Text 2 has a hexadecimal mode, but you could use any hex editor to find and remove the bad characters.
I am certain that this is due to a very particular method of copying and pasting from the Google tutorial site. It didn't happen to me in the Hello World example because I typed that out by hand. Then it appeared in one of my files, causing the CSS not to load. After that it caused the Google App Engine Launcher to think of my project as having missing files (turning up red in the launcher). I reverted to a working version (just by undoing in the text editor), and copied each set of new commands into the file from the tutorial, hoping to catch the bit of script that was doing me over. But when I got to the end it was all working. I SURMISE that this error is introduced when you copy and paste AN ENTIRE box of text from the Google App Engine tutorial site and insert it into one of your files. I suspect that ZWSP character exists on that site as the first character in the code boxes or something, but it's late and I'm not going to look into it further for now.
I guess you should just type out the tutorials - it's probably a better way to learn anyway.
I did two changes together -
1. added the line at the top of app.yaml file "application:helloworld"
2. changed the last line in app.yaml "script: helloworld.app" to "script: helloworld.py"
my GAE started working. However to islolate the issue I 'undid' both changes, it turns out that the the 2nd change - changing helloworld.app to helloworld.py did the magic

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