I've gotten use to using print in my python code to show contents of variable and checking the shell output.
But i have now migrated all my work onto a online server. Pythonanywhere
I don't have the foggiest idea how to do the same now?
Can someone point me in the right direction?
Print to web console? To a file? Or even to the shell session?
Thanks
On production server your print statements will output log to your webserver log files
In case of pythonanywhere there are three log files
Access log:yourusername.pythonanywhere.com.access.log
Error log:yourusername.pythonanywhere.com.error.log
Server log:yourusername.pythonanywhere.com.server.log
those logs are accessible in your web tab page.
The logs you are looking for will be in server.log
As mentioned in Serjik's answer you can see the output of the console via the server log link on PythonAnywhere.
However the much better way to approach this is to use the Python logging module.. Using this module will solve many of these problems for you and solve many issues you may not have thought about (like thread safety). This lets you do things like filter log messages by severity and a whole bunch of other things.
To get started with that I would recommend having a look at the basic logging tutorial.
Related
I want to be able to give out a form, with essentially 4 inputs. Each time it is submitted, I would it to trigger a python script.
I'm not totally sure where to start here. I could have the python code live on a server somewhere and have the google apps script trigger it, but ideally I could do this without having to host my code somewhere else. I also would like to avoid paying for anything...
Any and all advice would be appreciated. Please assume I have only a small amount of knowledge about this kind of stuff.
Check out this tutorial on the AppEngine documentation.
https://developers.google.com/appengine/docs/python/gettingstartedpython27/introduction
It will help you set up using Python and WebApp2 (for your forms!) and storing this data to datastore if you wish. You could just expand and modify the guestbook tutorial they make you do to have your application/script do exactly what you need it to. It's an excellent tutorial to get started even if you don't have much knowledge about python or appengine.
Hello :) My task is to write a web framework for a Python program with some massive calculations, which are desired to be executed at proper server and the result should be sent to the browser after it's calculated. My question is - is Django the right framework for that purpose? I tried to find out where Django executes scripts, but I haven't found any satisfying answer, so I hope that I would find one here.
Thank you for any attention.
django is a server side application
Is there a way to access logs on the browser made by the sever in Selenium? For example, if the site executed a console.log("Test."), can a Selenium test case access that log? Any help would be appreciated! (Preferably in Python).
Thanks!
~Carpetfizz
You could inject javascript and override the log function (as reading the log is not permitted from JS).
See http://tobyho.com/2012/07/27/taking-over-console-log/ for an example and there are many SO questions on this topic.
The problem with this is that it still can't get the logs which happened prior to injection.
It gets easier if you override this in the test deployment directly.
I am right now working in a project where I have two GAE servers. One for development, and the other one for production.
So I needed to access the datastore to run some queries because I need some high level information about the entities we have. The way I did on the development server was by the " URL/_ah/admin ", and there I used the Interactive Console to run my queries in the server.
But the reality is obviously that I need to run that queries in my production server, I tried to acces there the same way by "myapp.appspot.com/admin/interactive" but I am getting a "Page not found", I cant acces either with " URL/_ah/admin ".
So I looking for the easiest way for me to be able to run that queries, by now it seems that I have found two posible ways that I would like to check with you.
First, it seems that I could active that Interactive Console by:
- url: /admin/.*
script: google.appengine.ext.admin.application
login: admin
And then I would have acces on the URL "myapp.appspot.com/admin/interactive". Is that correct?
Second, I have also read about the remote_api and using the remote_shell as an Interactive Console with the server. Would that be harder? Can someone of you link me a guide to do that?
I havent tried anything yet, because I must be sure of what I am going to do since this is a live project.
Thanks a lot,
Jose.
This is only made for the development server.
You can find all the code that runs it in the source and then use them as custom admin console pages.
For example, in app.yaml, place
admin_console:
pages:
- name: Interactive Console
url: /admin/interactive
and for the URI
handlers:
- url: /admin/interactive|/admin/interactive/execute
script: google.appengine.ext.admin.application
login: admin
since the interactive page relies on a POST handler in execute.
To start off, this desktop app is really to give myself an excuse to learn python and how a gui works.
Im trying to help my clients visualize how much bandwidth they are going through, when its happening and where their visitors are. All of this would be displayed by graphs or whatever would be most convienient. (Down the road, I'd like to add cpu/mem usage)
I was thinking the easiest way would be for the app to connect via sftp, download the specified log and then use regex to filter the necessary information.
I was thinking of using :
Python 2.6
Pyside
Paramiko
to start out with. I was looking at twisted for the sftp part but I though maybe keeping it simple for now would be a better choice.
Does this seem right? Should I be trying to use sftp? Or should I try to interact with some subdomain from my site to push the logs to the client? (i.e app.mysite.com)
How about regular expressions to parse the logs?
sftp or shelling out to rsync seems like a reasonable way to retrieve the logs. As for parsing them, regular expressions are what most people tend to use. However, there are other approaches, too. For instance:
Parse Apache logs to SQLite database
Using pyparsing to parse logs. This one is parsing a different kind of log file, but the approach is still interesting.
Parsing Apache access logs with Python. The author actually wrote a little parser, which is available in an apachelogs module.
You get the idea.