Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can?
No: the "plugin" you mention runs in the user's browser, your server-side script (Python or otherwise) runs on the server, a completely different proposition. This relates to your other recent question about a server-side script accessing information on your desktop: your client machine tends to be very protected against possibly malicious server-side apps (never enough, but everybody keeps trying to make it more and more protected these days).
Server-side web scripts have no access to the client other than through requests. You need to use JavaScript, Java, or Flash to access devices that the browser (and consequently user) allows them to.
Not as easy, no. But there are extensions you can use. E.g.
A Win32 Python Extension for Accessing Video Devices (e.g. a USB WebCam, a TV-Card, ...)
http://videocapture.sourceforge.net/
Tutorial:
http://technobabbler.com/?p=22
Related
I have a windows application built with progress openedge technology.
I have created a python script to generate an excel file but I need to deploy it to the client and im afraid of requiring special permissions on the client side if I compile it to .exe and attempt to run it.
Can someone suggest me a method to be able to integrate python with my project smoothly without breaking anything?
You could compile it on your own machine then try to run it while logged in as a guest user. If a guest account can run it without complaints it will probably run fine on the client machine.
This is crude because you still haven't tested all possible client platforms (unless you're talking about one specific client), also we don't know what's inside your script.
Use icacls to set appropriate permissions of your compiled script before shipping.
I'm not sure about the special permissions thing, but is it possible for you to turn your script into a CGI program and stick it on your webserver, or wrapper it with WebSpeed? Then your app could call a web service to get the .xls file.
I've seen Google's documentation and a lot of examples over the internet about how to use Firebase within Android / iOS applications, but I want to develop a client Firebase application which runs on a linux machine.
My requirements are:
Client runs on linux environment (either writtern in C++ or python).
Server is written in Javascript (NodeJS).
Server and client should have bi-directional communication between them using firebase realtime database.
I've seen also the firebase REST api, but I assume that is not good enough for me since I haven't seen a client listener api that listens on a something like onValueChanged.
Question:
How can I implement a linux-based app in C++ or python that listens to messages from server (data changes) using a listener, without having to call some get function each and every few seconds (just like NodeJS have the ref.on("child_changed",...) or ref.on("value",...)?
Help is much appreciated!
Unfortunately there is not official library for Realtime Database in Python but there are some third party wrappers around REST API.
Specifically I would look at Pyrebase library which also supports listening to live changes https://github.com/thisbejim/Pyrebase#streaming
For more information, libraries or other languages look at this page https://firebase.google.com/docs/database/rest/start
Google offers a C++ SDK you can download it here.
There is also a tutorial on the bottom of the page, but if you really want to dig into some code, here is the quickstart code on github from google with examples for each category on Firebase.
Google has also implemented a Game for demonstration purposes in C++ for Desktop OSs. here There you can find more advanced features and code samples.
I have only tried it with an XCode project on Mac OS X, and it works fine. I have no code for real time database but you should find the sample project in the github repo. https://github.com/firebase/quickstart-cpp
I hope this helps!
Greetings.
Haven't you try to use a Realtime Database triggers for C++ (that's is currently on beta) that allows you to simulate the same workflow as on JS?
From my point of view, it is the best way to get it to work as you want.
https://firebase.google.com/docs/functions/database-events
How can I execute a Python script on a webpage?
I've used XAMPP to create the Apache server. Are there any tutorials/examples or guides on how to execute a .py script? I'm using Windows 7 and have installed Python on my local machine. If I access the .py script via the web link, it looks as if its HTML code and nothing is executed.
Typically, you don't execute Python in the browser. Instead, the browser accesses a resource (or "webpage", like http://example.com/mypage) by requesting the resource from the server. The server (for example, Apache), when administered correctly, passes off handling of the request to some Python script. Then, your Python script creates some output (for example, HTML) which the server then returns to the browser for the browser to display.
However, some web sites have found it useful to have logic (scripts) run in the browser, rather than on the server. The standard way of doing this is using JavaScript (although in the past there WERE other languages built into browsers, such as VBScript in Internet Explorer).
Right now, pretty much all browsers have settled on JavaScript as THE scripting language in the browser. In order for you to use any other language in the browser (including Python), the browser must support that scripting language (or needs to have an add-on to support that scripting language). Simply having Python installed on your client alongside the browser is not enough. For more information, please see the Python documentation Web Browser Programming.
Another option is to use something like Pyjs. This is a library that has you write your code in Python, and converts the necessary parts to JavaScript. This isn't exactly "Python in the browser", but it might be something you are looking for.
I guess this links will help....
https://community.apachefriends.org/f/viewtopic.php?t=42975
Usually a good resource for Python is the official documentation.
They do a great job of explaining many aspects of Python. Using Python on the web is a big part and they have a great overview.
I currently have a local python application that scans a users drive, maps it into a tree and displays this information with javascript. I would really like to try to develop something with a Drop-Box like system to manage drive trees.
I have searched and read that App Engine specifically doesn't allow access to a user's local disk. Is there a way to use webpy or something else to access a user's local drive to create a tree directory out of it?
You'd have to create a "client" and "server" type of interface to do this. So it wouldn't be a solely JavaScript with Python on the server program. They'd have to have something running on their end as well, communicating in the background.
HTML5 allows some local storage, but not what you're looking for.
You could create a signed java applet that will run along side the javascript and allow access to local files. You may be able to find an applet already developed that you can call from javascript. You have to be careful with this though because once the user trusts the applet it's installed and any site can call the applet unless the applet code is restricted to a specific site.
I have a Django application that I would like to deploy to the desktop. I have read a little on this and see that one way is to use freeze. I have used this with varying success in the past for Python applications, but am not convinced it is the best approach for a Django application.
My questions are: what are some successful methods you have used for deploying Django applications? Is there a de facto standard method? Have you hit any dead ends? I need a cross platform solution.
I did this a couple years ago for a Django app running as a local daemon. It was launched by Twisted and wrapped by py2app for Mac and py2exe for Windows. There was both a browser as well as an Air front-end hitting it. It worked pretty well for the most part but I didn't get to deploy it out in the wild because the larger project got postponed. It's been a while and I'm a bit rusty on the details, but here are a few tips:
IIRC, the most problematic thing was Python loading C extensions. I had an Intel assembler module written with C "asm" commands that I needed to load to get low-level system data. That took a while to get working across both platforms. If you can, try to avoid C extensions.
You'll definitely need an installer. Most likely the app will end up running in the background, so you'll need to mark it as a Windows service, Unix daemon, or Mac launchd application.
In your installer you'll want to provide a way to locate a free local TCP port. You may have to write a little stub routine that the installer runs or use the installer's built-in scripting facility to find a port that hasn't been taken and save it to a config file. You then load the config file inside your settings.py and whatever front-end you're going to deploy. That's the shared port. Or you could just pick a random number and hope no other service on the desktop steps on your toes :-)
If your front-end and back-end are separate apps then you'll need to design an API for them to talk to each other. Make sure you provide a flag to return the data in both raw and human-readable form. It really helps in debugging.
If you want Django to be able to send notifications to the user, you'll want to integrate with something like Growl or get Python for Windows extensions so you can bring up toaster pop-up notifications.
You'll probably want to stick with SQLite for database in which case you'll want to make sure you use semaphores to tackle multiple requests vying for the database (or any other shared resource). If your app is accessed via a browser users can have multiple windows open and hit the app at the same time. If using a custom front-end (native, Air, etc...) then you can control how many instances are running at a given time so it won't be as much of an issue.
You'll also want some sort of access to local system logging facilities since the app will be running in the background and make sure you trap all your exceptions and route it into the syslog. A big hassle was debugging Windows service startup issues. It would have been impossible without system logging.
Be careful about hardcoded paths if you want to stay cross-platform. You may have to rely on the installer to write a config file entry with the actual installation path which you'll have to load up at startup.
Test actual deployment especially across a variety of firewalls. Some of the desktop firewalls get pretty aggressive about blocking access to network services that accept incoming requests.
That's all I can think of. Hope it helps.
If you want a good solution, you should give up on making it cross platform. Your code should all be portable, but your deployment - almost by definition - needs to be platform-specific.
I would recommend using py2exe on Windows, py2app on MacOS X, and building deb packages for Ubuntu with a .desktop file in the right place in the package for an entry to show up in the user's menu. Unfortunately for the last option there's no convenient 'py2deb' or 'py2xdg', but it's pretty easy to make the relevant text file by hand.
And of course, I'd recommend bundling in Twisted as your web server for making the application easily self-contained :).