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.
Related
I'm building a website with React and Firebase that utilizes an algorithm I wrote in python. The database and authentication for the project are both handled by Firebase, so I would like to keep the cloud functions in that same ecosystem if possible.
Right now, I'm using the python-shell npm package to send and receive data from NodeJS to my python script.
I have local unit testing set up so I can test the https.onCall functions locally without needing to deploy and test from the client.
When I am testing locally, everything works perfectly.
However, when I push the functions to the cloud and trigger the function from the client, the logs in the Firebase console show that the python script is missing dependencies.
What is the best way to ensure that the script has all the dependencies available to it up on the server?
I have tried:
-Copying the actual dependency folders from my library/.../site-packages and putting them in the same directory under the /functions folder with the python script. This almost works. I just run into an issue with numpy: "No module named 'numpy.core._multiarray_umath'" is printed to the logs in Firebase.
I apologize if this is an obvious answer. I'm new to Python, and the solutions I've found online seem way to elaborate or involve hosting the python code in another ecosystem (like AWS or Heroku). I am especially hesitant to go to all that work because it runs fine locally. If I can just find a way to send the dependencies up with the script I'm good to go.
Please let me know if you need any more information.
the logs in the Firebase console show that the python script is missing dependencies.
That's because the nodejs runtime targeted by the Firebase CLI doesn't have everything you need to run python programs.
If you need to run a function that's primarily written in python, you should not use the Firebase CLI and instead uses the Google Cloud tools to target the python runtime, which should do everything you want. Yes, it might be extra work for you to learn new tools, and you will not be able to use the Firebase CLI, but it will be the right way to run python in Cloud Functions.
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.
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.
I'd like to serve django application on windows XP/Vista.
The application is an at hoc web interface to a windows program so it won't be put under heavy load (around 100 requests per second).
Do you know any small servers that can be easily deployed on windows to serve a django app? (IIS is not an option as the app should work on all versions of windows)
cherrypy includes a good server. Here's how you set it up to work with django and some benchmarks.
twisted.web has wsgi support and that could be used to run your django application. Here's how you do it.
In fact any wsgi server will do. Here's one more example, this time using spawning:
$ spawn --factory=spawning.django_factory.config_factory mysite.settings
And for using paste, the info is gathered here.
Of course, you could use apache with mod_wsgi. It would be just another wsgi server. Here are the setup instructions.
If you want to give Apache a go, check out XAMPP to see if it'll work for you. You can do a lightweight (read: no installation) "installation." Of course, you'll also want to install mod_python to run Django. This post may help you set everything up. (Note: I have not used python/Django with XAMPP myself.)
Edit: Before someone points this out, XAMPP is not generally a production-ready tool. It's simply a useful way to see whether Apache will work for you. Also, I saw that you're using SQLite after the fact.
Why not Apache ?
Nokia have developed a scaled down version of apache to run on their mobile phones. It supports python.
http://research.nokia.com/research/projects/mobile-web-server/
Also do you need anything else such as database support etc?
How do I deploy a Python project to a webserver that supports Python via CGI? I'm well versed in PHP, but do not understand CGI's relation to Python in the deployment process.
Any resource links are appreciated.
The web host in question is GoDaddy.
Generally, we use mod_wsgi to make a Python application respond to CGI.
PHP has a special role -- the language runtime IS a CGI application.
Python does not have this special role. Python -- by default -- is not a CGI application. It requires a piece of glue to play well with Apache. mod_wsgi is this glue.
To actually answer your question about deploying python as CGI (while it does not make a lot of sense on a high activity system - there are occasions where it does the job just fine) you just make sure that your files are executable, have the correct extension and then follow this tutorial. It is what I used to learn from.
EDIT: To be clear - I recommend that you look into Django to deploy web based python applications.