I am tasked to develop a very simple web layer for a very complex algorithm that is implemented as an Excel worksheet. This script would be called from a Ruby on Rails app that would be presenting the user with the forms, check validations and whatnot, and should return just a number. After perusing this site, my best shot is to automate Excel using Python or Ruby under Windows and run the algorithm there --we are a Ruby shop, but I've found more info for Python.
I think I can write a Python script to run the calculation in a day, but now the final question remains: how do we put a web layer on top of the core script? We are familiar with Apache, so installing Python as a Apache module is my straight thought, but we could also install Twisted and try to run the web server itself in Python.
What would be your choices?
My first choice would be to move the calculations that are in the Excel workbook into my Ruby application code. While it will likely take some additional work, my guess is that it will take less time to port the Excel app to Ruby than introducing layers of complexity on top of Excel. Additionally, calling into Excel, passing user submitted data, opens up additional possible security holes.
My second choice would be to do it the language you know best. It looks like Ruby can interact with Excel using win32ole (another example).
Related
I started a new job in which they have 0 optimization. Essentially I wanted to use a code which I have pretty much finished to clean excel files and output only the values that meet parameters. My boss said that I’d only be allowed to do this if it was a web application that was developed so I’m wondering if it’s possible and if so how would I go about it. If it can’t be done using python what would be another easy option to learn in which the code would be similar to what I wrote for the parameters in python?
I have to setup a program which reads in some parameters from a widget/gui, calculates some stuff based on database values and the input, and finally sends some ascii files via ftp to remote servers.
In general, I would suggest a python program to do the tasks. Write a Qt widget as a gui (interactively changing views, putting numbers into tables, setting up check boxes, switching between various layers - never done something as complex in python, but some experience in IDL with event handling etc), set up data classes that have unctions, both to create the ascii files with the given convention, and to send the files via ftp to some remote server.
However, since my company is a bunch of Windows users, each sitting at their personal desktop, installing python and all necessary libraries on each individual machine would be a pain in the ass.
In addition, in a future version the program is supposed to become smart and do some optimization 24/7. Therefore, it makes sense to put it to a server. As I personally rather use Linux, the server is already set up using Ubuntu server.
The idea is now to run my application on the server. But how can the users access and control the program?
The easiest way for everybody to access something like a common control panel would be a browser I guess. I have to make sure only one person at a time is sending signals to the same units at a time, but that should be doable via flags in the database.
After some google-ing, next to QtWebKit, django seems to the first choice for such a task. But...
Can I run a full fledged python program underneath my web application? Is django the right tool to do so?
As mentioned previously, in the (intermediate) future ( ~1 year), we might have to implement some computational expensive tasks. Is it then also possible to utilize C as it is within normal python?
Another question I have is on the development. In order to become productive, we have to advance in small steps. Can I first create regular python classes, which later on can be imported to my web application? (Same question applies for widgets / QT?)
Finally: Is there a better way to go? Any standards, any references?
Django is a good candidate for the website, however:
It is not a good idea to run heavy functionality from a website. it should happen in a separate process.
All functions should be asynchronous, I.E. You should never wait for something to complete.
I would personally recommend writing a separate process with a message queue and the website would only ask that process for statuses and always display a result immediatly to the user
You can use ajax so that the browser will always have the latest result.
ZeroMQ or Celery are useful for implementing the functionality.
You can implement functionality in C pretty easily. I recomment however that you write that functionality as pure c with a SWIG wrapper rather that writing it as an extension module for python. That way the functionality will be portable and not dependent on the python website.
At work I need to run a Java applet every 20-30 min to re-connect to one of the internal
applications.
I would like to automate the login in the website of this application and then run this Java applet that does not require any input at all, just accept it so I can just run the script every time the application logs me off.
Is there any way I can do this from Python using urllib or a similar library?
I know how to do the login part, but I don't know what to do the 'accept and run this applet' part.
A web application testing framework would be useful for what you ask, it allows you to simulate the interactions of an user (POST, GET, login, clicks, etc.) with a web site.
The tricky part of your question, is interacting with a Java applet - not many webapp testing frameworks will allow you to do that; in particular I don't know a Python framework that offers that functionality, but in my experience, I found that HTTPUnit worked well with applets. Of course, it's in Java and not in Python, but it's worth checking out.
This is part of some preliminary research and I am having a difficult time figuring out what options might be available or if this is even a situation where a solution even exists.
Essentially we have an existing python based simulation that we would like to make available to people via the web. It can be pretty processor intensive, so while we could just run the sim server side and write a client that connects to it, this would not be ideal.
Writing a UI in Flash/Flex or HTML5, not a problem. However, is there any way to keep the core simulation logic in python without having it live server side? Is there any existing way to embed python modules in either of these technologies?
Thanks all.
Pyjamas: Python->Javascript, set of widgets for use in a browser or a desktop
Skulpt: Python written in Javascript
Emscripten: C/C++ -> LLVM -> Javascript
Empythoned: Based on emscripten and cpython, working on a stdlib? There are bugs to file
I created a nice RSS application in Python. It took a while and most of the code just does heavy work, like formatting XML, downloading feeds, etc. To the application itself requires very little user interaction, just a initial list of RSS feeds and some parameters.
What would be really nice, is if I was able to have a web front-end which allowed me to have the user edit their feeds and parameters, then they could click a create button and it runs.
I don't really want to have to rewrite the thing in a web framework. Is there anything that will allow me to build a nice front-end allowing it to interact with the normal Python underneath?
It depends on your needs, free time, etc.
I recommend two solutions:
Django - a very rich framework which allows you to create full featured sites using only accessible components (in most cases they are good enough)
http://werkzeug.pocoo.org/ - collections of tools if you want to have possibility to control everything from the low level
web.py is a very lightweight 'library' (not framework) that you can put as a front end to your app. Just import your app within the main controller and use it as you would.
The Python standard library also includes a builting SimpleHTTPServer module which might be what you need to create a front end for your app.
You may also either deploy your Python code as CGI script on a webserver of your choice, e.g. Tomcat:
The CGI (Common Gateway Interface) defines a way for a web server to
interact with external content-generating programs, which are often
referred to as CGI programs or CGI scripts.
According to a Qura-question this might be appropriate only for small projects, but I do not say anything wrong with that since it worked well for me for perl-scripts. The same source suggests a Python WSGI (web-service gateway) service like uwsgi another service dedicated to running Python code.
Last but not least, there is the solution to encapsulate your Python into Java-code: I stumbled upon the Quora-question "How do I run Java and Python in Tomcat?" which refered to using Jython and plyJy, the latter project is not alive anymore. However, there is also a related question on the topic of bundling Python and Java..