I am creating a simple web page which reads from the database and display on the browser.
I have a python script which reads from a file and updates the database for the changes made in the file.
I want to add a button in my webpage which executes this python file and display the updated information on the webpage.
Is there a way to link the execution of the python file to the button present on the webpage.
Any suggestions or reference is highly appreciated.
Thanks in advance.
EDITs:
I went through a couple of reference but those were not of much help.
I am not using jython or any other application that supports both java and python.
Is there a way to do it without using any other application.
The way to do this is the same way you would do it normally in Java.
http://www.java-samples.com/showtutorial.php?tutorialid=8
Related
I am using TimeStats extension on Chrome. And what I want to do now is to read the data in the LocalStorage (which contains all the information about the time I spent on each website) in a Python script and do later data processing.
I know that Ctrl+c and Ctrl+v would work in this case, but I am wondering are there any elegent and reliable ways to do that?
Thanks!
You can use native messaging to send data between your extension and an external app. The sample app for demonstrating native messaging is written in Python, so you have the communications part already solved.
EDIT:
I see now that you are talking about an extension you don't own. Google Chrome currently stores LocalStorage data in SQLite format, so you should be able to read it directly using the sqlite3 package. See the answers to this question.
The file for the timeStats extension would be chrome-extension_ejifodhjoeeenihgfpjijjmpomaphmah_0.localstorage
Note that Google can change the way of storing LocalStorage at any time.
I have an external browser plugin (which is blackbox to me). This plugin tries to fill values to input fields of html page (on load. I want to make a program, which is able if the external program filled values properly.
So what I want to do is to open an url from my python program in a browser. On load of this page is automatically executed the plugin and tries to insert values. After that I want to find specific input fields and resolve, whether they are filled correctly or not in the current instance of the browser and page.
Is there any way to do such thing using python (standard or 3rd party) modules? Could you recommend me any?
(Note: I also want to build exe file using cx_freeze, so the best would be, if the module does not depend on external files)
Thanks.
I would suggest using PyQt or Selenium.
I have a FTP server working great using Python and the pyftplib library (https://code.google.com/p/pyftpdlib/). I would like to, on login (either anonymous or user), create a html file reflecting the latest state of the server in a nice looking way. For example, all the files that are on the server and their properties nicely separated and looking nice. I thought that since I was already doing everything in Python, and my html wouldn't be overly complex, I would just have python write the html file on log in, and then the user could open the html file for the information that was written seconds before.
My main problem is that when I override the "public callbacks" section of the handlers.py (or any section so far), no file is created that I can find. I am new to python, but it seems like a modification in the handlers.py file should affect the Handler class. Another idea I plan on trying is to override the handler base class with my "on_login" function that does create the html file.
What I am really asking for is
1) Advice from anybody who has done/tried this before
2) Any red flags that are going off in your head regarding my plan
3) Any other ideas (ideally strictly using python)
Thanks!
What worked for me was not editing the handler.py file, but rather creating my own subclass (myFTPHandler) and then redefining the onconnect method to write my html file then.
Thanks for the help though!
One of our page templates is made up of a bunch of macros. These items are a bunch of html tables.
Now, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced?
If so, can you explain?
Thanks
Eric
Maybe you could create a new template including (use-macro) just the macros you want to access from python and then use z3c.pt.pagetemplate.PageTemplateFile() to render it?
Actually, it might be possible (and certainly easier) to use chameleon.zpt.template.PageTemplate('<div tal:use-macro="<your-macro-here>" />'), but I've never did this myself.
I'd probably use urllib.urlopen(url), pull the data from the page back to python and use BeautifulSoup to pull the table(s) out of the HTML... And then render that to PDF with XHTML2PDF (pisa.ho).
There might be a simpler way but for me, this would be the least stressful approach.
I'm writing a Python+Qt4 application that would ideally need to pop up a window every once in a while, to display pdf documents and allow very basic operations, namely scrolling through the different pages and printing the document.
I've found the reportLab to create pdf files, but nothing about pdf viewers. Does anyone knows anything that might help. i was really hoping for the existence of something like the QWebView widget...
thanks in advance to all
You can use the Poppler library for that.
A Python binding to poppler-qt4 that aims for completeness and for being actively maintained.
https://code.google.com/p/python-poppler-qt4/
what about okular? It is a full app, but it can always be call from another app.