Python for Flash Player - python

Would it be technically possible to embed Python into a Flex/AIR application by compiling CPython code using Alchemy?
(I'm guessing the project should be called Flython.)

Yes.
But don't expect all the standard modules to build. Some system calls won't translate. It would be a lot of work to port.

Related

How to host a script?

I am trying to finish a personal project, which I describe its operation below.
My project consists of running a script (like a service) in the cloud.
I have on the one hand, a python script (created by me) which I want to host, and on the other hand a c++ script (not created by me), which I need to use from my python script, using boost-python.
My first way was to host my python script in pythonanywhere, but it doesn't work for me because the c++ script was designed for windows (it uses libraries only for the windows platform such as windows.h) and when compiling it ends in an error (pythonanywhere uses linux as base system).
So I would like someone to help me and tell me what is the correct way to do what I describe. I understand that it can be one of the following variants, but in some cases I am not entirely convinced that it can, or I do not know how to proceed.
Pay for a Virtual Desktop, and schedule the execution of my python script.
Use what is explained here.
Use a docket image with windows and host it somewhere.
Use Heroku
Note. My project needs/use a database.
Linux also supports C compilation. It's kernel is coded in C. Try compiling your code on linux with a tool like gcc, available on it.

Making GUI with only python without framework?

Is it possible to create a user interface without the help of python framework (like tinker or pygame) and use only vanilla python code? If yes, how?
Can you briefly explain how python framework works?
Is the code of different python framework different?
If the computer did not have the framework installed, will the program still runnable if the program uses a framework?
Thanks very much
Yes, after all tinker and pygame are just python classes packaged as modules.
Python frameworks are a bunch of pre-tested and reusable modules that allow you to use and extend upon so you don't have to reinvent the wheel.
Yes, frameworks will have differences in usability and code.
The computer will always need the dependencies, though you can package these in various ways aka create a package that has all your dependencies for the program to run.
If you want as few external dependencies as possible (but still a GUI) I would strongly suggest using a Web-Microframework like bottle (single file) and utilize the user's browser for rendering.
You can make a GUI without any external framework with HTML by setting up a webserver and using the user's browser to render it.
For a browser-GUI without an external Framework: Depending on whether you know JavaScript you can either use XML-RPC (xmlrpc.server+http.server with JS in the browser) or WSGI (wsgiref) (example on that page)
Yes, totally.
Of course the if you do not prepare for this case you cannot run a program without an integral part of it like a Framework - but you can distribute your program with the Framework included.
For XML-RPC
import xmlrpc.server
import http.server
class MyHandler(xmlrpc.server.SimpleXMLRPCRequestHandler,http.server.SimpleHTTPRequestHandler):
pass
This handler will serve files from the current working directory (your actual HTML-UI and JS for communication (there are several XMP-RPC libraries for JS)) but it can also be used like in the XML-RPC-Server example to glue your code and the UI together.

Suggest a standalone python web framework?

I have a python program that I would like to present as a simple web application. The program currently uses sqlite for storage. I also need to distribute the whole thing to colleagues so having something standalone and easy to start would be ideal ( no install if possible). This web app is meant to be used locally , not by multiple users over a network.
Is there a suitable python framework that might fit my needs? I looked at Django so far but it seems a bit heavy handed for what I need.
Thanks for any suggestions.
I have never tried it myself, but you could try Bottle:
Bottle is a fast, simple and lightweight WSGI micro web-framework for
Python. It is distributed as a single file module and has no
dependencies other than the Python Standard Library.
try http://docs.python.org/library/simplehttpserver.html
As web frameworks are not part of the standard lib, you will have to install something in every case. I would propse to look at http://flask.pocoo.org/. It has a build in WSGI server.
Lots of choices for Python web frameworks! Another is web2py which is designed to work out of the box and allows, but doesn't require, through-the-web development. It is mature and has a strong community and is well-documented.
Tornado as a framework may be a lot more than what you're looking for. However it will meet the requirement of being a completely python based web server. http://tornadoweb.org
I generally just download the source, drop it in /tornado/ of my project and do includes there from the app.
I don't think that any web framework is specifically oriented for the use case you're talking about; They all assume they are running on a server and there's a browser on a remote machine that is accessing them.
A better approach is to think about the HTTP server you'll be using. It's probably preferable to use a server that's as easy to pack and ship as the rest of the python code you'll be using. Now most frameworks provide a 'development' server that's easy to invoke from the command line, but most of them are intended to be "easy for the developer" which often means they are restricted to a single thread. This is bad for deployment because single threaded servers will always feel a bit sluggish.
CherryPy stands out in contrast, by providing a full featured, embedded server that's easy to configure for many use cases, and is available by default with the rest of the framework. There are probably others, but I haven't used 'em.

Python equivalent to Java's JNLP Web Start?

Is there any way to achieve the same functionality in Python, i.e., launching a script from a browser and automatically updating it from a central server location?
Run your app on Jython and use Java Web Start?
From a comment below, http://blog.pyproject.ninja/posts/2016-03-31-web-start-on-jython.html, provides a complete example.
Note that Jython is not Python- some stuff does not work, and notably Jython is only Python-2.7 compatible.
Well this is still not a full match of the features of JNLP but maybe esky is closer to what you want. It's not browser based but once your app is installed on the client it can update itself. It might also lack something in the cross-platform department so depending on your environment YMMV.
Another alternative might be the Dabo framework at dabodev.com. It's been a few years since i looked at that but it still looks like it's alive :-)
You may be able to achieve some functionality with Skulpt although it uses classless python, so its functionality is rather limited.
Well check out this python wiki page as it lays out various options.

python _+ django, is it compiled code?

Just looking into python from a .net background.
Is python compiled like .net?
If yes, can it be obfuscated and is it more or less secure than .net compiled code that is obfuscated?
does pretty much every web host (unix) support django and python?
There are many implementations of the Python language; the three that are certainly solid, mature and complete enough for production use are CPython, IronPython, and Jython. All of them are typically compiled to some form of bytecode, also known as intermediate code. The compilation from source to bytecode may take place as and when needed, but you can also do it in advance if you prefer; however Google App Engine, which lets you run small Python web apps, including Django, for free, as one of its limitations requires you to upload source and not compiled code (I know of no other host imposing the same limitation, but then I know of none giving you so many resources for free in exchange;-).
You might be most at home with IronPython, which is a Microsoft product (albeit, I believe, the first Microsoft product to be entirely open-source): in that case you can be certain that it is "compiled like .net", because it is (part of) .net (more precisely, .net and silverlight). Therefore it cannot be neither more nor less obfuscated and/or secure than .net (meaning, any other .net language).
Jython works on JVM, the Java Virtual Machine, much like IronPython works on Microsoft's Common Language Runtime, aka CLR. CPython has its own dedicated virtual machine.
For completeness, other implementations (not yet recommended for production use) include pypy, a highly flexible implementation that supports many possible back-ends (including but not limited to .net); unladen swallow, focused on evolving CPython to make it faster; pynie, a Python compiler to the Parrot virtual machine; wpython, a reimplementation based on "wordcode" instead of "bytecode"; and no doubt many, many others.
CPython, IronPython, Jython and pypy can all run Django (other implementations might also be complete enough for that, but I'm not certain).
I don't know about the security part but.
Python is interpreted. Like PHP. (It's turned into bytecode which CPython reads)
Django is just a framework on top of Python.
Python can be compiled.
And no not all hosts support python + django.
You shouldn't have to worry about obfuscating your code, specially since it's going to run on your server.
You are not supposed to put your code in a public directory anyway. The right thing to do with django (as oposed to PHP) is to make the code accessible by the webserver, but not by the public.
And if your server's security has been breached, then you have other things to worry about...
Obfuscation is false security. And the only thing worse than no security is false security. Why would you obfuscate a web app anyways?
Python is compiled to bytecode and run on a virtual machine, but usually distributed as source code.
Unless you really plan to run your webapp on "pretty much every web host" that question doesn't matter. There are many good hosts that support python and django.
Code obfuscation in .NET are mostly a question of changing variable names to make it harder to understand the disassembled code. Yes, you can do those techniques with CPython too.
Now, why ever you would want to is another question completely. It doesn't actually provide you with any security, and does not prevent anybody from stealing your software.
The Python is interpreted language. But you can compile the python program into a Unix executable using Freeze.

Categories