How to control CANoe with Python script? - python

I am working with Vectoe CANoe version 8.5. I have written the CAPL script to send messages. Now I want to write a python script which when executed, starts the execution in CANoe. How to achieve this.

This can be done by using the COM interface to CANoe.
You can use COM interfaces also from python.
CANoe's COM interface is well documented. Just take a look into the user documentation.
For calling COM from python, the most common way is using the pywin32 library.

You can get sample COM automation via Python .py file in (C:\Users\Public\Documents\Vector\CANoe\Sample Configurations 15.1.1\Programming\Python\) this CANoe install directory.
See image for config location
Note: Avoid using third party library to control CANoe.

There is a Python Library Python-CANoe Available to do this.
path to the library https://pypi.org/project/Python-CANoe/

Related

Using python how do I manage windows on OSX

I am trying to manage windows using python.
Specifically I am trying to find a window that I have opened using selenium then have it focused and maximise it. I believe this is possible using a window manager as there are programs like qtile written in python.
I have read on the python documentation that there is something called pythonw.
https://docs.python.org/3/using/mac.html
I am using python 3.5 but I can upgrade if this is an easier option.
How do I use this on OSX?
Is there a library or are there any more resources on this subject?
I would like to learn how to use simple window management in python for osx.
Any help is appreciated.
You need a system level window manager for this

A way to control Google Earth from Python on Linux

I have dowloaded a python script that uses win32com module (project site) to start and control Google Earth aplication on Windows. The commands in the script can also be used to interactively control Google Earth from command line.
The code is here. It works, it is exciting, BUT...
I'd like to do the same ON LINUX (Ubuntu derivatives).
The problem is: this script uses the COM interface to pass commands to GoogleEarth via interprocess communication. On linux, instead of an .exe, there is googleearth-bin executable, and I don't know how it would or shoud be to use the same interprocess communication idea on Linux.
Since the program is most probably compiled to the different OSes from (mostly) the same source code, it "seems" to me that the functionality could be in there. Now about HOW to access it from a Python script, this goes way beyond my current knowledge.
Thanks for any help!
The Google Earth COM Api has been depreciated (see http://googlegeodevelopers.blogspot.co.uk/2010/08/sunset-for-google-earth-com-api.html) so writing code against it is going to be hard-work and there are no guarantees that your code will work in the future.
Google are suggesting that people use the Plugin version of Google Earth but unfortunately, to date, this isn't supported on Linux OSs so that is not an option for you in this case.
Anyhow, caveates aside, you could look at something like pygoogleearth
http://pypi.python.org/pypi/pygoogleearth/
This is a pythonic wrapper around the Google Earth COM Interface, it should allow you to work with the COM api in python or at the least give you some pointers on the set-up.

Hachoir Python Implementation on Blackberry

I need to implement the Hachoir libraries to parse through image files (the meta-data in them). My project requires this to be done on a Blackberry device, hence that would mean I will have to port the entire Hachoir library to Blackberry.
The other thing I could do is to, write python scripts (which utilizes the Hachoir libraries) and find a way to call these scripts from the Blackberry. I read that it is possible to call python scripts using NDK on Android. Is there a similar tool for Blackberry?
So in the end I will have to install hachoir(??) on the phone, call the scripts through the "NDK equivalent tool", capture the output again through this tool and display it to the user.
Any suggestions on the tools to be used and the method in general? Are there any other suggestions for hachoir like libraries on Java? Thanks!
Peter Hansen has Python running native on the BB playbook. See this link.
Or you can write your own script using the python app, and then port it (if needed) to peter's framework (which is very cool too)
http://appworld.blackberry.com/webstore/content/32880889/

Interacting with native applications using python

I'm a Python programmer and I was wondering if there's any module or framework that would allow me to interact with native Windows/Linux applications using python.
Let's say on Windows I have MS Outlook, so would it be possible to let's say automate MS Outlook to compose or check new emails?
I understand that Linux and Windows are different, but what I'm trying to achieve is to let's say open up an application, click on a button programmatically, etc.
I'm not sure if all of these are at all possible using python, so please enlighten me regarding what you think is possible and practical.
For something like Outlook, the best bet is probably using Outlook's COM (Component Object Model) with Python COM libraries.
Most applications have some kind of API.
And most of those API's are accessible with C.
Therefore, Python offers ctypes.
That's the lowest common denominator. Other API's are available, but you have to use Google to find them. Sometimes they're on PyPi. It's best to be specific and search for the specific app because there may be app-specific Python bindings. You don't know until you search.
MacOSX offers more sophisticated tools than this (via AppleScript and AppScript) but it's unique to Mac OS X.
Here's an example in Windows:
Utilizing os.system will work to ping (a native command in Windows):
import os
os.system('ping google.com')
Alternatively, you can also you the recommended subprocess.Popen:
import subprocess
subprocess.Popen('echo "hello world"', shell=True)

How does the win32com python.Interpreter work?

Ok, so I'm trying to google the win32com python package and the python.Interpreter COM server. Unfortunately, python.Interpreter ends up as "python Interpreter" and not giving me any COM server results.
I'm trying to make a pluggable program that has a plugin to allow python code to run, and it seems like the python.Interpreter would be a good way to go. But I haven't used it before and I'm not sure how to make objects created from it available through COM.
Any advice or pointers to documentation/examples would be appreciated.
Also, would a user need to install a python package to use the COM server, or is the interpreter built into the server dll?
Thanks
Brett
See http://books.google.com/books?id=ns1WMyLVnRMC&pg=PA232&lpg=PA232&dq=win32com+%22python.interpreter%22&source=bl&ots=NVpe-E8eGg&sig=imGi73WQyOmP4rJC6-jpz4stb9M&hl=en&ei=xrAYSsTHBZH0tAORqeCSDw&sa=X&oi=book_result&ct=result&resnum=6#PPA232,M1 for excellent docs on python.interpreter -- as for your second question, normally win32com is installed as an add-on to an existing Python install, but of course you can pick a Python distro including the win32 extensions, such as Activestate's at http://www.activestate.com/activepython/ .

Categories

Resources