Python proxy an application - python

Does anyone know of a library that enables you to run an application inside some kind of sandbox, with virtual mouse and keyboard support.
The use case would be to create some kind of visual test runner, that would replay all actions taken during recording and play them back.
So far I found autopy, but the fact that it controls the real mouse position is problematic, because it prevents user interaction with other tools (debugger or anything) while running.
Cross platform would be nice, but either windows or os x is fine. Python would be ideal but anything that you could create python bindings for would be ok too.

On Linux, you could run autopy inside a VNC session.
There is also pywinauto or watsup.

On Linux you can use Swinput for simulating mouse/key events. There are few Python wrappers around the X libraries: Python X Library, PyX11Remote. You may also looking for Xvfb, which allows to setup a virtual X11 server, so you don't have to run the tests on your physical screen.
If you need to test only an application developed using Qt, GTK, Java SWT/Swing there are few test frameworks for doing this.

Related

How to control a Windows application from Python

I have the application installed on my windows PC, I want to launch that application using python and select dropdown options and do some other activities in that application.
I was able to launch the application using the os.system command, but I am not able to proceed further.
I want my program to do things like:
* select from a dropdown menu
* click on a button
How can my application control the user interface of another application?
Normally, an application exposes a user interface (UI) for users, and an application programming interface (API) for programming.
A human being uses keyboard and mouse to work with the user interface (UI)
An application uses programming to work with the application programming interface (API)
The UI is designed for humans, and the API is designed for computers.
It is sometimes possible to use programming to control the user interface of another program -- so your program acts as if it were using the keyboard and mouse. This technique is often called "UI automation", and programs that do it are sometimes called "robots".
It's a big topic, and it can be quite complex. It's almost always better to use an API instead if you can: it's faster, simpler, more reliable.
If you do need to use UI automation, there are a few different tools that can help.
You are asking about Python, so here are a few UI automation tools that work with Python:
AutoIT is a standalone product, but you can use Python to script it.
PyWinAuto is designed for use from Python.
Sikuli uses computer vision to find parts of the screen. I believe it comes with a recording tool as well.
Just to repeat: UI automation is weird and hard. If you can possibly use an API instead, your life will be much easier.
You need to install pywinauto package
Try the following code to run the .exe file
from pywinauto import application
app = application.Application()
app.start("Notepad.exe")
here you are:
(with os ^_-)
import os
os.startfile('your exe file address')

Sparkle Framework alternative for wxPython and Windows development

I create application on wxPython for MS Windows. It's a port of native OS X application I made before.
In OS X application autoupdate of application is gracefully serving with Sparkle Framework. (It detects application updates by reading appcast.xml stored on server, then does all update specific magic, checking signatures etc.)
Are any similar solutions exist for wxPython/Windows development?
Do you need such port to integrate it into wxPython?
wx.lib.softwareupdate
A mixin class using Esky that allows a frozen application to update itself when new versions of the software becomes available.
This module provides a class designed to be mixed with wx.App to form a
derived class which is able to auto-self-update the application when new
versions are released. It is built upon the Esky package, available in PyPi at
http://pypi.python.org/pypi/esky.
In order for the software update to work the application must be put into an
esky bundle using the bdist_esky distutils command, which in turn will use
py2app, py2exe or etc. to freeze the actual application. See Esky's docs for
more details. The code in this module will only have effect if the application
is frozen, and is silently ignored otherwise.
You may have a look at WinSparkle - it's a "port" of Sparkle ideas for Windows, on top of wxWindows.
Binding it to your wxPython app should be easy (swig / ctypes).
I haven't checked WinSparkle in some time, but it seems to be active, and IIRC, there are a lot of forks with enhanced download support / features.

Which Toolkit to develop Mac OSX/Windows Daemon service

I need to develop a daemon service which also has presence in System Tray. The system tray icon allows users to customize/access some options through right click menu. It might open a window as well manage those options in a better way.
The app would mostly be communicating with a RESTful service, posting and downloading files.
Now I know that for any daemon service, it needs to be native. However we don't have the luxury to maintain 3 different dev pipelines, specially since the app is experimental(but might land up in hands of users)
I have experience in Java/Scala, followed by C++/Python/JS. I would prefer java/Scala (existing codebase) but open to frameworks in other languages.
I was thinking of doing a scala based app with swing for windowing, but it is not pretty.
Any ideas?
We have an App, same base code, running on Windows, OSX and Linux (with system tray) using these two set of components:
The Tanuki Java Service Wrapper to handle the lifecycle of the app. It also allows installing the component as a "native" windows service. Version 3.2.3 is under LGPL if that helps.
The Java 6 java.awt.SystemTray which is supported on most platforms. On OSX, we use a modified version of macify to implement OSX specific gimmicks like doc icons
You could go with JavaFX and the ScalaFX bindings. They look to be very actively maintained, and the syntax seems pretty clean. Only trouble is that it seems to have poor support for using the system tray - see this discussion for details and some workarounds.
You can use Real Studio to create a Windows Service and OS X/Linux daemons. Real Studio creates native apps for Windows, OS X and Linux.

How to load SWF content into a Python application on Linux?

I have an application that uses Flash for the GUI and Python for the core logic. This combination is awesome. Unfortunately my current approach only works on Windows, as it uses the wxPython comtypes library to embed the Flash ActiveX player. Every other aspect of the app is platform-agnostic, so I'm thinking there must be some way on Linux to have Python talk to Flash.
The SWF need not require AVM2/AS3, though ideally I could use the most current Flash player available. I am using wxPython (wxWidgets) and would prefer to keep using it. Worst case I could jerry-rig something that loads the SWF in a separate process and talks over a socket connection to the Python, but I see no simple way to have the Flash display inside my application's window rather than a player window with its own menus and decorations.
Any suggestions appreciated. I'm very open to hacking at a solution if there's reason to believe it will work :)
Flash Professional has support to Adobe Air, so you could use it as front-end, usually a flash project can be released as an AIR application without major changes to its code. The communication could be done using Native Process Api (see links bellow). Then you can run it on Mac, Win e Lin.
http://www.kirupa.com/forum/showthread.php?349728-Air2-NativeProcess-launching-Python-scripts.
http://mykola.bilokonsky.net/2010/11/adobe-air-nativeprocess-and-python-introduction/

Any way to run python TK scripts on web page?

Is there any way to run a python script that utilizes TKinter on a web page such that a user could run the script and interact with the TK windows without having to download the script or have the appropriate python interpreter?
No. There is no way to do this.
The only approach I can think of, is to use some virtual screen protocol such as VNC, run your Tkinter script on a server for that protocol (e.g., a VNC server), and use a viewer browser plug-in for that protocol in the user's browser (e.g., maybe this one -- haven't tried it myself, though). A similar approach could use the NX protocol (e.g., cfr here).
Note that such solutions will most likely not scale well: they're mostly meant to let one user connect to "their desktop" from a browser. Performance, robustness and scalability of web-native approaches will all run rapid circles around any such "compatibility hack"!

Categories