Skip to main content

karotz python API

Project description

About

A (work-in-progress) Python library which provides object-oriented access to the REST-API for Karotz:

                   _           _    ________________________________
                  / \         / \ /                                 \
                  \  \       /  / | https://github.com/esc/pykarotz |
                   \  \     /  /  \____  ___________________________/
                    \  \___/  /       /_/
             _      /         \  _
 _ __  _   _| | ___|__ O __O___|| |_ ____
| '_ \| | | | |/ / _` | '__/ _ \| __|_  /
| |_) | |_| |   < (_| | | | (_) | |_ / /
| .__/ \__, |_|\_\__,_|_|  \___/ \__/___|
|_|    |___/       |           |
                    \_________/

Dependencies

Installation

Place the karotz.py file where you want to use it. egg in progress

Getting Started

First, you must register an interactive application and install this on the target Karotz. For now, you can find some great instructions on the Ruby API blog-post.

After doing this, you will have the access credentials INSTALL_ID, API_KEY and a SECRET. You have several ways to use these with pykarotz. The easiest is to place the configuration in a configuration file (standard INI format) in your home directory $HOME/.pykarotz, for example:

[karotz-app-settings]
apikey = 23426660-beef-beee-baad-food0000babe
secret = 23426660-beef-beee-baad-food0000babe
installid = 23426660-beef-beee-baad-food0000babe

If you have done everything correctly, you can establish a connection and demo the available colors from an interactive Python prompt using:

>>> import karotz as kz
>>> krtz = kz.Karotz()
>>> krtz.led.demo()
>>> krtz.stop()

In case you have placed the file somewhere else, for example if you are using Windows and have placed the file at C:\pykarotz.txt, you can initialise the Karotz class using:

>>> import karotz as kz
>>> settings = kz.parse_config(config_filename="C:\pykarotz.txt")
>>> krtz = kz.Karotz(settings=settings)

If instead, you want to hardcode the settings in your Python source file, you can do something like:

>>> import karotz as kz
>>> settings['apikey'] = "23426660-beef-beee-baad-food0000babe"
>>> settings['installid'] = "23426660-beef-beee-baad-food0000babe"
>>> settings['secret'] = "23426660-beef-beee-baad-food0000babe"
>>> krtz = kz.Karotz(settings=settings)

If you have multiple units, you can save their settings in different sections:

[karotz-one]
apikey = 23426660-beef-beee-baad-food0000babe
secret = 23426660-beef-beee-baad-food0000babe
installid = 23426660-beef-beee-baad-food0000babe
[karotz-two]
apikey = 23426660-beef-beee-baad-food0000babe
secret = 23426660-beef-beee-baad-food0000babe
installid = 23426660-beef-beee-baad-food0000babe

And then use the keyword argument section to load them:

>>> import karotz as kz
>>> krtz1 = kz.Karotz(kz.parse_config(section='karotz-one'))
>>> krtz2 = kz.Karotz(kz.parse_config(section='karotz-two'))

API

Currently the following REST API calls are supported:

  • Ears

  • Led

  • TTS

  • Config

  • Mutimedia

  • Video

You can access them in an object oriented fashion using kz.ears, kz.led and kz.tts:

>>> import karotz as kz
>>> krtz = kz.Karotz()
>>> krtz.ears.sad()
>>> krtz.led.light(kz.PURPLE)
>>> krtz.tts.speak('Why is the world so evil?')
>>> krtz.stop()

Examples

See the directory examples for some example applications.:

Testing

Install nose and then do:

$ nosetests

Similar Projects

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykarotz-0.2.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file pykarotz-0.2.tar.gz.

File metadata

  • Download URL: pykarotz-0.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pykarotz-0.2.tar.gz
Algorithm Hash digest
SHA256 18b53788c50483b7f9e2966d0cf7c495a4236e06b9ca491847428e16476273fb
MD5 7c352bc64377d35ceb28133bdfff50f2
BLAKE2b-256 4174a0bcf23323f0a4e5eb80bfcbbe74861375d0ceee311946cdbca4a5ca2871

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page