I'm trying to find out if there is a way I could embed a Python back-end into an AIR application? I'm looking to employ an approach similar to the one outlined here to implement the business logic for my application, but additionally, I would like to provide the user with a single binary which they can load. I don't want the user to have to fire up a seperate server process to make this work. Is this possible in some way or am I out of luck?
You cannot embed your Python server in an AIR application. So basically you are out of luck.
The simplest solution probably is to run a server on a central location that all your users can connect to from their AIR apps. That means that all/most of the data will be on your server, and not on the users computer, I don't know if that is a big issue but I guess it is.
Also depending on your target systems you could create the program you want yourself without (fully) depending on AIR. You can generate executables for windows and osx from Flash CS3/4 or you can use a special (commercial) executable-maker that provides some more functionality. Wrapping this exe and your python program in a meta-executable that launches both should be possible with some work. Of course you won't have the benefits if the AIR installer etc in this case.
OK, so since it didn't seem possible to go that way around, I came up with an alternative that seems to work for what I want.
Instead of trying to embed Python inside AIR, I've gone the other way around: I'm building my Python code into a stand-alone executable using PyInstaller and bundling the AIR application as a resource. The Python code then starts up it's webserver and fires off the AIR app which can then connect to the (local) remote services as required.
Probably. We are using a J2EE server side which uses SOAP webservices to talk to our AIR application on the frontend. You should be able to do the same because soap doesn't care which technology sits on either side of it.
You can always have the application launch from a single binary which first fires up the server, then the client, if both are expected to sit on the users system. Also it gives you flexibility to have a more service oriented model later, if you want to. Without knowing what your app does, it is hard to know if that makes sense or not.
For setting up the python side of SOAP webservices, here's a useful link to a diveintopython article. Then, if you have your server running with the wsdl, FlexBuilder can generate the AIR side of the webservices for you.
Related
tl;dr -- how do I combine a pair of SDK projects together and have the "menuconfig" system work properly?
I have a simple project in mind for an ESP32 module: Have the ESP32 provide a new dedicated WiFi network that allows a smart phone to connect directly to the ESP32. Once connected, the phone can point its web browser to the IP address of the ESP32 (hard-coded as 192.168.1.1) and the ESP32 will accept HTTP connections from the phone. Thus the user will have a simple interface through which to interact with the ESP32 using HTML data-entry forms, buttons and so on.
Note, this connection goes no further than the ESP32, no internet connection is required at all for this project.
Luckily, the SDK for the module includes lots of examples, and I have managed to get the web server working, and also the WiFi access point, but not both at the same time. These are two example projects ("... examples/protocols/http_server/simple" and "... examples/wifi/getting_started/softAP").
So far I've managed to discover that the WiFi access point software runs in the "background" and continues even after the main() function has ended. This means that I should be able to bring in the web-server code from the other example and execute it in the main() function. I'm pretty sure that will be feasible (please correct me if I'm mistaken).
The Question:
Each of these two example projects contain a "idf.py menuconfig" command that lets the user quickly change any of the important settings such as the WiFi SSID or the HTTP basic authentication password.
I'd like to retain this menu system after the two projects have been combined because it's extremely useful and somewhat reduces the human error involved in altering the code before recompiling.
Is there a simple way to combine the menuconfig systems from two SDK example projects into a single one that can be used to fully configure a project that is a combination of both code-bases?
Further info: I'm using the ESP-IDF dev kit on an Ubuntu 20 virtual machine, connecting to the ESP32 via USB.
It's very simple. The menuconfig items are described in the component's Kconfig.projbuild file. If you want add those items from one project to the other, you can simply copy-paste the content of one main/Kconfig.projbuild file to the other one and that's it. See ESP IDF documentation for details.
What I want to create is a music player that can interact with YouTube using its Data API.
I actually have already developed my application (only for Windows, multi-platform is not a priority at the moment) using AutoIt and it's working properly. For now I createad a GUI to simply execute mpv.io, send commands to it and get its STDOUT to manage informations/errors.
Now I wanted to create a web interface to control this application using my smartphone in particular. I tried to look into TCP implementation and also WebSockets to send real time information like the playback position, but I'm not too sure what to look into.
As you probably can understand, I don't have much experience especially in network stuff so a help would be much appreciated. In the past I've fiddled with HTML,CSS,JavaScript so the web interface should not be a problem but for the communication part I don't have many ideas.
Since I created some very basic application with Python in the past, someone already suggested me to use a web framework like Flask, and so I started to properly learn Python but I find difficulties with GUIs...
So, to do a little summary I'm currently asking what can be a proper method to develop this application, also starting from scratch and changing programming language, since I'm always open to learn something new.
This might be a vague question, but I failed to rephrase it properly. So here's an explanation.
I developed an app that was originally developed as a Mac application, using API's from both Carbon/Cocoa to achieve my task. (The goal of the application is to send 'keystrokes' to an app after mouse movements / other keystrokes. I use Accessibility API's for that).
But now, I want to add scripting support, so there can be conditional keystrokes. Such as: after 5 times of pressing 'Y', I want to press the button 'B'.
Within OSX, there's no possibility for a Python app to do such a thing, and I can't find any libraries that allow me to do it. So I figured I'd make the app two-fold. First: I'll write an app in Cocoa/Carbon with the basic functions: SendKeyToApp(pid,key) and WaitForMovement().
The python app will communicate with that app, using those method calls. The question here is: how do I communicate between those two apps? Will I use a HTTP Server, a Socket Server, some kind of subprocess.Popen() hacks. I frankly have no idea.
Does anyone have any ideas to achieve such a task?
Easier. I went to use Accessibility API's from within Python, and it all allowed me to easily do this without any Cocoa / Carbon at all.
For the ones interested, it's called atomac.
PyObjC is perhaps what you're looking for:
PyObjC (pronounced pie-obz-see) is the key piece which makes it possible to write Cocoa applications in Python. It enables Python objects to message Objective-C objects as if they're fellow Python objects, and likewise facilitates Objective-C objects to message Python objects as brethren.
You could write a bridge between your python app and your cocoa app using PyObjC.
There are many ways to synchronize/communicate the data between two applications, but let me explain the simplest :
RESTful Serialization:
Serialize the objects into XML/JSON or any other custom format both app frameworks can parse. eg. http://docs.python.org/library/json.html
If both apps are on the same server/machine I'm expecting all you have to do is to encode/store the data into the same file(s) and read/parse the data from respective file(s) in other application.
Otherwise you may need to create a web service for accessing the data file.
Let me know in comments if you have further queries.
In my eyes the simplest way to establish communication between two applications is the client-server protocol XMLRPC. Both Cocoa and Python do support it.
The Python part is fairly simple:
import xmlrpc.client
rpcProxy = xmlrpc.client.ServerProxy(URL_OF_SERVER)
rpcProxy.SendKeyToApp(pid,key)
As for the Cocoa-part, I don't know, but it seems to be possible: XML-RPC Server in Cocoa or Best way to use XML-RPC in Cocoa application?
On osx, many native applications support AppleScript (aka OSA) as their native scripting API. Thus your question becomes one of interacting between Python and Applescript (and figuring out how to talk to your target application in AppleScript in the first place).
There is some OSA support in the Python standard library and a third-party module py-applescript you might want to look at.
I'm interested in something based on Jabber but I didn't find a free/opensource one so I'm thinking of writing one.
I've installed a Jabber server and now thinking about the ways in which I can write the client. I'm thinking of one of either these two methods.
1) An ajax call made to a jabber script running on the webserver that takes care of connecting to the server. But then I thought because of the dependencies involved in the jabber client, it might end up consuming too much memory when a few clients connect.
2) The other method is to run a client running as a daemon that takes care of all the heavy lifting. This way I need to have only one instance of the client that sends a spoofed message (sender's name as that of whatever the user entered on the site). A simple script running on the webserver talks to this daemon over some sort of API (XMLRPC or Msgpack maybe?)
I think #2 is better but I'm not sure. Are there other ways I can implement this? I'm considering using Perl or Python for this.
Jabber is usually called XMPP nowadays, and there are dozens of clients and servers, something for every language. If you are using Javascript (you mention Ajax), you probably want Strophe. Most servers are modular, so you only load the features you need (consider Tigase, ejabberd, or xmpppy). Writing your own is even worse an idea than it sounds.
BOSH
Install prosody because it is really eaSily installed and has BOSH support built-in. You could skip this but then you need to find out how to use BOSH via ejabberd.
use strophe.js to implement this(using BOSH). New browsers support cross-domain request(CORS -> read Proxy-less BOSH part). The old browsers you could use proxy or use flash in the middle as proxy.
read Professional XMPP Programming with JavaScript and jQuery to learn strophe. It even has chapters explaining how to create chat.
Node.js
Or you could consider installing node.js to create your chat system using socket.io.
I'm building a website where I hook people up so that they can anonymously vent to strangers. You either choose to be a listener, or a talker, and then you get catapulted into a one-on-one chat room.
The reason for the app's construction is because you often can't vent to friends, because your deepest vulnerabilities can often be leveraged against you later on. (Like it or not, this is a part of human nature. Sad.)
I'm looking for some insight into how I should architect everything. I found this neat tutorial, http://giantflyingsaucer.com/blog/?p=875, which suggests using python & stackless + flash. Someone else suggested I should try using p2p sockets, but I don't even know where to begin to look for info on that.
Any other suggestions? I'd like to keep it simple. :^)
Unless you expect super high load, this is simple enough that it doesn't really matter what you use on the backend: just pick something you're comfortable with. PHP, Python, Ruby, Even a bash script using CGI - your skill level with the language is likely to make more difference that the language features themselves.
I would use an XMPP server like ejabberd or OpenFire to power the backend. XMPP contains everything you need for creating chat/real-time applications. You can use a Flex/Flash Actionscript library like Actionscript 3 XIFF to communicate with the XMPP server.
Flash is user-unfriendly for UI (forms, etc) and it is relatively easy to do what you want using HTML and Javascript on the front-end.
One possible approach for reading the messages would be to regularly do an Ajax request from the server for any new messages. Format the new message and insert it into the DOM.
You will probably need to answer at least these questions before you continue, though:
1) Are you recreating IRQ (everyone sees your posts), or is this a random one-to-one chat, like chatroulette?
1a) Is this a way for a specific person to talk to another specific person, or is this more like twitter?
2) What is your plan for scaling up if this idea takes off? Memcached should probably be a method of last-resort ("bandaid over a bullet-hole"). What's your roadmap for eventually handling a large volume of messages?
3) Is there any way to ignore users? Talk to certain users? Hide your rants from users?
Hey Zach I had to create a socket server for a flash game I made. I built my server in C#, but I would use whatever language your familiar with. If you let me know what your most comfortable with I could try to help find a good tutorial.
The one thing I spent many hours on was getting flash to work from a website with a socket server. With the newer versions of Flash you need to send back a policy file. In my case this needed to be the first chunk of data sent back to the client when they connected to the socket server.
Not sure what to tell you about structuring the back end. I need to know a little bit more about your programming experience. I had an array of all user connections, and was placing them in different "Rooms" so they could play each other. So just some simple arrays and understanding how to send messages to the clients would help you here.
If you have any familiarity with C# I would have no problem sending you the source code for my socket server.