Python client for Voyager Application Server

Hi everyone,
I’ve been using Voyager for a little more than a year now, but finally had something worthy to post up here. I was digging around and having trouble trying to see if anyone had written anything in Python for interacting with the API, and I couldn’t find much, so I took it upon myself to start writing one.

It’s only a few days old, as I worked on it over the weekend, but it’s fairly functional at this point. Features so far:

Connects/maintains connection to Voyager via heartbeats to polling/actions
Allows registering functions as handlers for specific commands (example in script)
Stores Signals and Messages internally for retrieval otherwise
Voyager console log messages are stored if enabled
Generic send_message(‘<command’>, {any: params, go: here}) command
Convenience functions for some common functions, ie client.cmd.mount(‘park’), client.cmd.connect_setup(), etc.

In the example, you can see print_jpg_info is tied to a handler for ‘NewJPGReady’, and automatically extracts the jpg data and writes it to a file.

I know it’s not the most comprehensive implementation of the API yet, but I want to build my own public web dashboard for my setup using websockets to keep the data fresh, and this is where I ended up starting out. My plan is to use the ControlData messages as they’re received to then reformat and push the data to any websocket clients that are connected.

I thought with the prevalence of Python, some other people may find this useful and wanted to pass it along.

If you have any questions or requests, please let me know/submit a pull, and I’ll see what I can do.

Clear skies and happy hunting!

5 Likes

This is great!! Thanks so much for writing and sharing it.

Thanks for sharing! This has been on my TODO list forever!

Super, thanks.was looking in this as wel

Thanks! I’m glad some people will find it useful too. I think the next thing I might work on is handling Authentication, as well as forking off the handler functions into their own thread so they don’t block receiving other messages. If there are any other suggestions, let me know, and I’ll see what I can do :smiley:

1 Like

I also just pushed a script I wrote to check data from Astrospheric, if you have a pro account. Set your api key, lat, long, and seeing/transparency/cloud limits, and it will poll the API and make a decision based on the next X hours from the duration starting from Y offset. Right now, it just averages all of the values over that time period and checks them against the limits set, then returns RUN or HALT so it can be captured in dragscript. I may figure out some weighting system later, but it gets the job done for now. Just tossing it out there for anyone else to make use of.

For example, to check 2 hours from now, for the next 9 hours (9 is the default, can be set):

$ python3 ./astro.py -o 2 -l
seeing: 3.0, trans: 14.444444444444445, cloud: 4.793028322440088
RUN

-l prints out the averaged values for running by hand, leaving it off just returns RUN/HALT for voyager to catch cleaner.

1 Like

This is brilliant, thank for your efforts!

Fantastic, I’ve also been wanting something like this – lots of ideas for things to do in Python but getting this framework going was my procrastination explanation :slight_smile: !

Great work, thank you.
Rowland

Can we have a chat about how to use it for some stuff I’d like to do ?
I’d like to connect using the user/password scheme and drive some specific actions.

Cheers
Mike