Plone plugin, web interface development for commandline programs - python

I am considering to write a plugin/module for one of any of wellknown CMSes like Joomla, Drupal and Plone. I am very impressed with the clarity of many Plone-based sites, and excited with many praises people gave to Plone. Besides, I love Python also. So, I want to give Plone a try. Here a some information about the plugin I want to develop:
I have some Linux commandline programs that I want to run from within the CMS environment via this plugin. The plugin then save command output, run log to the user who runs the programs. The CMS then can take the information and do all other kinds of things like graphical display of data in with graphs, or integrate with search functionality.
So, what do you think? Where should I start? I looked at table of contents for some Plone books but could not find anything close to plugin development.

I think you can't go much wrong with Aspeli's Professional Plone Development, but if you can get a cheap copy of the Definitive Guide to Plone, that'll do, even if it hasn't been updated for Plone4.

We do this all the time.
Plone is written is Python and can do everything what Python can. Python has gained popularity, on expense of Perl, as UNIX scripting language.
For further ideas, if you need to run long tasks, see Long running Plone operation with AJAX progress bar because you usually don't want to block the page loading for the duration of command-line program run.

Related

Distributing Computer App w/ GUI (Python)

I am new to Stack Overflow and had a question on a python application I have been working on for a while as part of a fun little personal project. Basically, the app consists of utilizing Selenium to login to my school portal, (I am a college freshman), navigate through a couple of pages and ultimately scrape the data off a page (beautifulsoup) that contains the campus food account balance and transactions. I thought this would be a useful thing to develop because my school makes it pretty difficult to view this information in a timely manner, and my friends and I find ourselves quite often wanting to check our balance. I completed the code that gets this done and have successfully been able to fetch transactions and display them in the console for any account given a valid school portal username and password. I am now using PySimpleGUI to create a clean interface that prompts you to simply input your login information while it attempts to retrieve this information for you. My question from all this is once this GUI is done, is there any possible way to be able to make this an "app" that can be downloaded or sent to friends so that they can use it as well? I do not want to have to send them the python code, packages to install, teach them how to run it in bash, etc. Is there a way to send them this application that they can run that does exactly what I intend for it to do? Sorry if this is unclear, I will try to elaborate if necessary..
Thank you all in advance!!
The PySimpleGUI documentation (http://www.PySimpleGUI.org) explains that one method that's worked well for distributing PySimpleGUI programs to users that do not have Python installed is using pyinstaller to convert your program into an executable. For windows, this is an EXE file. For Mac, it's an "App". There's a heading specifically for Mac users "Creating a Mac App File"
pyinstaller isn't perfect, but for distributing a PySimpleGUI program that's based on tkinter, it's worked pretty well. The least number of other packages involved the better. If your program only uses PySimpleGUI, then it should work well.
Another route is for your users to run your code in the browser. These are tricky technically as you're using sites that emulate tkinter in the browser.
A couple of known to work in-browser solutions:
Trinket - This will enable you to post your code on a website and your users can run the code in their browser. The PySimpleGUI project has a Trinket page at http://Trinket.PySimpleGUI.org
repl.it - Another option for running code in the browser. It's more complex than Trinket, but also supports more packages
These 2 online solutions aren't meant for delivering products. They are teaching aids.

Push updates to python desktop apps

I'm working in a small CG animation company that does need small tools for production and CG artists. I'm coming from an animator's background, so my knowledge of code is extremely basic, but I'm learning.
Here is the situation: I write python tools, most are using PySide for GUI. Now I need to regularly and easily deploy tools and updates to the machines in our studio (about 20 computers).
We do want to do things the right way and are willing to learn, but the amount of information is quite overwhelming for I am a neophyte.
I keep reading about various scary keywords that seem to be the answer I'm looking for, such as DevOps, CI/CD, Docker, Kubernetes...
We are setting up a Gitlab instance on our local server, and now I'm asking what would be the most suitable way to easily deploy my scripts and their requested environment easily onto the company's computers (MacOs, Windows, and Linux), and how should I package them.
I hope my question isn't vague but if so, please tell me and I'll try to be more precise.
Thanks a lot
pyupdater seems to do just what you're trying to do.
have a look at pyupdater.org and this demo.

Is there pluggable online python console?

I'm thinking if there already is some sort of online live python console (web-based) with open source code available. Anyone know of anything?
It would be really useful to have console in Django admin (like running python manage.py shell on the server's terminal), so it would be great to have django/any wsgi aplication, that can be used to enable web based live console access.
Thanks
You're looking for the Werkzug debugger.
http://werkzeug.pocoo.org/
http://werkzeug.pocoo.org/docs/debug/
It's got an interactive javascript based in-browser debugger for your WSGI projects, among many other great tools. Fantastic stuff.
For Django specifically, there's also RunServerPlus, which is part of the django-extensions package.
https://github.com/django-extensions/django-extensions
You should check out Python Anywhere. You can run python web apps, you get an SQL database, and you get a bash shell in your browser.
Have a look at python shell from Google. There's a link to source code at the top. Loading Django environment into it might be not very easy but I believe it's possible.
I'm not sure if this meets your desire but you might take a look at Chrome extension : https://chrome.google.com/webstore/detail/gdiimmpmdoofmahingpgabiikimjgcia
There is a great website called Codecademy. It teaches the fundamentals of Python, Ruby, Javascript, and HTML/CSS.
They also have online consoles for each of the languages they teach, excluding HTML/CSS. This website is Codecademy Labs. Codecademy Labs has a console you can type directly in, and an editor that displays output in the console. I hope that this helped you find what you were looking for!

Python/Sqlite program, write as browser app or desktop app?

I am in the planning stages of rewriting an Access db I wrote several years ago in a full fledged program. I have very slight experience coding, but not enough to call myself a programmer by far. I'll definitely be learning as I go, so I'd like to keep everything as simple as possible. I've decided on Python and SQLite for my program, but I need help on my next decision.
Here is my situation
1) It'll be run locally on each machine, all Windows computers
2) I would really like a nice looking GUI with colors, nice screens, menus, lists, etc,
3) I'm thinking about using a browser interface because (a) from what I've read, browser apps
can look really great, and (b) I understand there are lots of free tools to assist in setting up the GUI/GUI code with drag and drop tools, so that helps my "keep it simple" goal.
4) I want the program to be totally portable so it runs completely from one single folder on a user's PC, with no installation(s) needed for it to run
(If I did it as a browser app, isn't there the possibility that a user's browser settings could affect or break the app. How likely is this?)
For my situation, should/could I make it a browser app? What would be the pros and cons for my situation?
Writing a desktop application as a locally-hosted web application isn't typically a good idea. Although it's possible to create great user interfaces with HTML, CSS, and Javascript, it's far easier to create interfaces with conventional GUI frameworks.
Using web technologies to create your desktop GUI would introduce a great deal of unnecessary complexity to your application.
Creating user interfaces with HTML and CSS is difficult and time-consuming. HTML is a document markup language and CSS is a document formatting language; neither is well-suited to creating GUIs.
Using web technologies makes your application depend on the user's web browser. Far too many people are still using old, crippled browsers such as IE 6 and 7 that don't follow modern standards. You'll spend hours if not days trying to track down interface bugs that only happen on certain browsers.
You'll need to serve your application with a web server, introducing another layer of complexity. Your application will have to communicate with your interface through restricted web technologies without any of the benefits of a true web application.
I recommend using a desktop GUI framework, instead. In particular, I think wxPython would be the best GUI framework for you to use; it's stable, widely used, well documented, and highly portable. In addition, you can use a GUI-based interface builder such as Boa Constructor or possibly wxGlade to design your application's user interface. In summary, creating an application with almost any desktop GUI framework would be easier than using web technologies.
I've done a desktop app running on windows and I think that it is a great way to develop app.
I would recommend to have a look at bottle. It is a lightweight web framework. It is less capabale than Django for example but it does well. It can be packed with py2exe if you want to deploy on machines without Python.
There is a lot of javascript libs on the web to help you. I like jquery and jquery-ui, raphaeljs ... but there are some others.
My app is running into a small browser based on the mshtml component of Pyjama-Desktop. This way, the user doesn't know that it is a web app. But you could let the app running into the favorite browser, webbrowser python module might be interesting for you.
If your app needs to access your filesystem, a browser-based app may be tricky. For security reasons, a browser doesn't have full access to your filesystem. However, you can mimick file open with ajaxupload and file save with an iframe.
If it only deals with a sqllite database, i think that it is a very good choice.
I hope it helps
Pyjamas-Desktop
You did not mention if you are on windows or linux or any other OS.
If you are writing a browser app the first thing you are going to need is a web server, if each user is running the app on his local machine => means each user has to have a webserver running locally.
Also there are a lot of Rapid Development GUI toolkits such as wxPython and Glade which make design of GUI apps simple and easier.
I would suggest that if you are building a network app -> Take the browser route.
If you are building standalone app then go with a native application.
Here is an almost exhaustive list of all the frameworks. you can choose whatever suits your needs.
http://wiki.python.org/moin/GuiProgramming
I personally favor PyGtk, however it has a little learning curve associated with it if you havent done any GUI programming before.
I think it should work. What are you afraid of? Proxy settings, firewall?
I think running web server locally isn't hard for power user but it could be a problem for average user (even integrated with your app).
Probably You should run your app as service because forcing user to start server before entering web page, could be frustrating.
I would prefer other solutions. I would probably use Java (Swing) or C++ with QT. But I like Your approach, especially that it allows easy prototyping. If You prefer web style development you could try http://www.appcelerator.com/products/titanium-desktop-application-development/ it creates desktop apps using html+java script +webkit. But I didn't tried it my self (but I would like to).
Also Adobe Air could be probably good option for You.
I would suggest a browser application. This eliminates the need for installation on client computers (and as such, as OS agnostic), and is accessible from anywhere in the world if the DNS is set up correctly for the server.
Using a web interface allows you to make use of some of the more powerful User Interface tools, such as:
The ability to use CSS for spectacular design
The availability of JavaScript Utilities (jQuery, ExtJS, etc.)
Easily modified compared to Desktop applications
Higher accessibility
Consistent UI (e.g. Users already know how "back" works, etc)
Centralized updates (Just update the server, not each client)
Your choice of application type will be related both to the technology constraints and the type of user experience you plan to deliver.
Rich Client Application:
Usually developed as a stand-alone application.
Can support disconnected or occasionally connected scenarios.
Uses the processing and storage resources of the local machine.
Web Application:
Can support multiple platforms and browsers.
Supports only connected scenarios.
Uses the processing and storage resources of the server.
I personally favor PyQt in your case for a portable application.
The homepage for PyQt is http://www.riverbankcomputing.com/software/pyqt/
PyQt supports the Windows, Linux, UNIX and MacOS/X platforms.
PyQt4 is a set of Python bindings for Qt 4 that are dual-licensed under the GPL (version 2 and 3, with additional license exceptions) and a commercial license. There is also PySide by Nokia - new alternative bindings (as of November 2009) with LGPL license that struggle to be API compatible (at least until Qt 4.6) with PyQt4.
Tools and docs
PyQt Reference Documentation.
PyQt4 book: http://www.qtrac.eu/pyqtbook.html
The pyuic4 utility is a command line interface to the uic module. Conver xml ui from Qt to python.
Qt Designer is a powerful cross-platform GUI layout and forms builder. It allows you to rapidly design and build widgets and dialogs using on-screen forms using the same widgets that will be used in your application.
PyQt4 exposes much of the functionality of Qt 4 (From Nokia) to Python, including:
A comprehensive set of widgets
Flexible layout managers
Standard GUI features for applications (menus, toolbars, dock windows)
Easy communication between application components (signals and slots)
A unified painting system with transparency, anti-aliasing, OpenGL integration and SVG support
Internationalization (i18n) support and integration with the Qt Linguist translation tool
Etc.
You question is a little broad. I'll try to cover as much as I can.
First, what I understood and my assumptions.
In your situation, the sqlite database is just a data store. Only one process (unless your application is multiprocess) will be accessing it so you won't need to worry about locking issues. The application doesn't need to communicate with other instances etc. over the network. It's a single desktop app. The platform is Windows.
Here are some thoughts that come to mind.
If you develop an application in Python (either web based or desktop), you will have to package it as a single executable and distribute it to your users. They might have to install the Python runtime as well as any extra modules that you might be using.
Guis are in my experience easier to develop using a standalone widget system than in a browser with Javascript. There are things like Pyjamas that make this better but it's still hard.
While it's not impossible to have local web applications running on each computer, your real benefits come if you centralise it. One place to update software. No need to "distribute" etc. This of course entails that you use a more powerful database system and you can actually manage multiple users. It will also require that you worry about browser specific quirks.
I'd go with a simple desktop app that uses a prepackaged toolkit (perhaps Tkinter which ships with Python). It's not the best of approaches but it will avoid problems for you. I'd also consider using a language that's more "first class" on windows like C# so that the runtimes and other things are already there. You requirement for a fancy GUI is secondary and I'd recommend that you get the functionality working fine before you focus on the bells and whistles.
Good luck.

Python Vs Ruby On Rails : on Size

I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me).
My main concern is about the size and simplicity of final installable (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me?
I personally prefer Python/django. Size is small given u have necessary things installed.
With disk space at the current price, size shouldn't matter. Give both a try and figure out which will be easier for you to learn and maintain. Despite the fact that people believe that when you know one language, you know all, that's only true as long as you write code on the "hello world" level.
One option with Ruby on Rails is to go with a JRuby deployment which would allow you to pack it all into a single .war file. This would require the person deploying the web application to have a java web application server (Jetty is probably the smallest and easiest to bundle).
With Rails, you are generally going to have to install Ruby and any required ruby gems. The Ruby install is going to be machine specific- different for Windows/Linux. Everything else should be easily scripted. If you go with an Apache Passenger (mod_ruby) solution, you will need to get that installed as well.
In reality, I haven't run into many server applications with simple, compact installs.
I just used heroku to deploy a blog written in Rails, and it was a fantastically easy experience. If you're interested in simplicity, it's probably the most simple deploy I've ever experienced.
I don't think you can get them both. I'm sorry to say this but you have to choose which one is more important to you.
Django application is smaller in size because many things is already provided out of the box, but deployment is not as easy.
On the other hand, RoR apps deployment is easier (both Ruby MRI or JRuby) but the application's size is naturally larger given you have to install other gems and Ruby On Rails plugins.
If you are experienced with Java and concerned about deploying Django and Rails apps, I'd recommend you give JRuby a try. This will give you several benefits from a Java-perpective:
You can call Java-classes and components from your Ruby/Rails app
You can use a familiar IDE such as Netbeans
You can package and deploy our entire Rails app as a single WAR-file with all dependencies included
With the cheeseshop, any python application can be made installable with a single command. I'm a big fan of Django, but it will require you to hook into an external webserver, as the built in server is for development only. You might look for something that has a more robust builtin web server if you want something you can just plunk down and start running. Twisted might meet your needs, though there's a bit more of a learning curve on that. I'm not sure how other python or ruby apps stand up on this front.

Categories

Resources