The Issue
I'm trying to build a very simple GUI application that either (i) runs on a local Ubuntu 14 server, or (ii) that runs locally but can read/write data from this server. Multiple people will be using this implementation to make modifications to a very simple array data file. The final solution can either be a script, dynamic webpage, or precompiled program.
Attempted Solutions
Writing an HTML file that uses PHP to read/write form data: PHP is not enabled on this server. HTML5 FileSystem API doesn't seem to do what I need it to (i.e. it seems to only sandbox IO).
Python: Tkl/Tcl/wxWidgets are not available on this server, and most of the people who will be using this won't have it available locally either.
Your server should have X11 forwarding. Here is a page with an introduction:
http://math.msu.su/~vvb/2course/Borisenko/CppProjects/GWindow/xintro.html
I don't recommend coding an X11 application from scratch; this will take a very long time. Use an IDE like QT creator or XCode to speed up the process. If coded in C++, the X11 application should not have compatibility issues like you do with Python and PHP.
Related
The Issue
I am using my laptop with Apache to act as a server for a local project involving tensorflow and python which uses an API written in Flask to service GET and POST requests coming from an app and maybe another user on the local network.The problem is that the initial page keeps loading when I specifically import tensorflow or the object detection folder within the research folder in the tensorflow github folder, and it never seems to finish doing so, effectively getting it stuck. I suspect the issue has to do with the packages being large in size, but I didn't have any issue with that when running the application on the development server provided with Flask.
Are there any pointers that I should look for when trying to solve this issue? I checked the memory usage, and it doesn't seem to be rising substantially, as well as the CPU usage.
Debugging process
I am able to print basic hello world to the root page quite quickly, but I isolated the issue to the point when the importing takes place where it gets stuck.
The only thing I can think of is to limit the number of threads that are launched, but when I limited the number of threads per child to 5 and number of connections to 5 in the httpd-mpm.conf file, it didn't help.
The error/access logs don't provide much insight to the matter.
A few notes:
Thus far, I used Flask's development server with multi-threading enabled to serve those requests, but I found it to be prone to crashing after 5 minutes of continuous run, so I am now trying to use Apache using the wsgi interface in order to use Python scripts.
I should also note that I am not servicing html files, just basic GET and POST requests. I am just viewing them using the browser.
If it helps, I also don't use virtual environments.
I am using Windows 10, Apache 2.4 and mod_wsgi 4.5.24
The tensorflow module being a C extension module, may not be implemented so it works properly in Python sub interpreters. To combat this, force your application to run in the main Python interpreter context. Details in:
http://modwsgi.readthedocs.io/en/develop/user-guides/application-issues.html#python-simplified-gil-state-api
Can I use any external libraries that are developed for python on Pyramid?
I mean is it the 'normal python' to which I can import external libraries as I do with the standard python downloaded from python.org
What is the situation for Django and Flask and Bottle?
My intention is to create backend for a mobile app. I want to do it specifically in Python because I need to learn python.
The app is a native android app. Therefore the there is no need to use response with nice html code.
I just want Django/Flask/Pyramid to direct http request to relevant python functions. Everything else including user auth, database is handled by my code I write. Is there a better more simpler way to map http request/responses with the relevant functions without using these 3 platforms?
In case I use one of these can I still use my own libraries?
Yes, all of those frameworks are simply running Python code to handle requests. Within limits you can use external libraries just fine.
The limits usually are dictated by the WSGI server and the nature of HTTP requests; if your library changes the event model (like gevents) or relies heavily on changing the interpreter state (global state, localization) or takes a long,long time to produce results, then you may need to do more work to integrate.
In essence I want to run existing python scripts through a web browser, display the text and plots(if any) and also keeping the ability to run them through the command line.
I am wondering is there any toolkit that can help me with the development.Also it would be nice if the toolkit does or allows JavaScript based interactive plots.
Thanks!
-Abhi
WSGI is designed for just this purpose - it provides an interface for a web server to initiate python scripts.
You probably don't want to work with WSGI in the raw. Flask is a straightforward, simple framework you might use for this.
The details of how to actually build a WSGI web server are well beyond the scope of a stackoverflow answer - you can find plenty of tutorial docs on Flask's website.
My goal is to use to make it easy for non-programmers to execute a Python script with fairly complex options, on a single local machine that I have access to. I'd like to use the browser (specifically Safari on OS X) as a poor man's GUI. A short script would process the form data and then send it on to the main program(s).
I have some basic examples of python scripts run using the built-in Apache server, by clicking submit on a form whose html is th:
e.g. here. What I want to do now is do it without the server, just getting the form to invoke the script in the same directory. Do I have to learn javascript or ...? I'd be grateful for any leads you have. Thanks.
It doesn't make sense -- what a browser does when it submits a form by definition is to make a request to a web server.
If all that's going on is that you don't want to be running Apache, you could hook something simple up using the CGIHTTPServer class that's provided as part of the Python Standard library.
If you don't want a server process at all, and you're using a suitably modern browser, you may want to look at using HTML5 local storage, but that's not a Python solution.
Well, there always has to be some kind of "server" involved to communicate over HTTP. You could have a python script listening on port 80 on your machine, that in turn runs the scripts specified with the form's action attribute.
You won't get away without some sort of server, I'm afraid.
PS: There are already a couple of good minimalistic python HTTP servers that would do the trick. Just google for it.
Regards, aefxx
Pyjamas Desktop will allow you to deploy a browser-based desktop application.
I want to provide my colleagues with an interface (using Windows Forms or WPF) to control the states of virtual machines (KVM based) on a linux host. On the command line of this server, I'm using a tool, called libvirt, which provides python bindings to access its functionality.
What whould be the best pratice to remotely access several function like libvirt or reading logfiles on the server. I thought about a REST Full Webservice generated by Python. Are there other viable options to consider?
Thanks,
Henrik
I'd develop an intranet web application, using any python web framework of choice.
That way you don't have to develop/install software on your client. They just point the browser and it works.
Because you are using a server-side tool that has Python bindings, you should give a serious look at PYRO which is a Python RPC library.
http://pyro.sourceforge.net/
To use this you would also have to use Python on the client, but that shouldn't be a problem. If you haven't start writing your client, then you could do it all in IronPython. Or, if you need to add this to an already existing client, then you could still bind in either IronPython or CPython as an embedded scripting engine.
For more on PYRO and Ironpython, see this wiki page http://www.razorvine.net/python/PyroAndIronpython
Proxmox VE is a complete solution to manage KVM (and OpenVZ) based virtual machines, including a comprehensive web console, so maybe you can get a full solution without developing anything?