mbaker3 / scala-tests

Some code used to test the python api for scala.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scala tests

Scala Tools

Creates a new playlist in Scala consisting of an item "test_image.png", puts the playlist into a schedule and updates the player to sync the new changes.

Scala Monitor

Provides a class for use in monitoring a player. It will connect to a content manager, and for a chosen player report back a variety of information on that player such as files it uses and screen layouts.

Installation

Python 2.6.x is required Just clone the repo, all requirements are included (see below)

Next Steps

Take a copy of settings-template.json, name it settings.json and fill out the fields.

By default, the application will use this settings.json file.

To start the scala test app run: python scala_tools.py

To start the monitoring app run: python scala_monitor.py

Included libraries

This includes the following libraries from Scala. They are not provided via pip, which is why they are directly in the repo.

Scalalib

A set of modules with tools and utilities for common needs at playback time, communication, synchronization, publishing, Player provisioning, etc. It is not currently used by any of the files here, but is kept for reference.

Scws

Webservice modules for communicating with Content Manager 5 in a simple manner. Example command-line upload to CM included.

Creating your own python code for interacting with Scala

Initial steps

The easiest way to start is to grab the webservices subfolder of this repository. scws is not available on pip or easy_install, so just leave it as a subfolder of your directory.

from webservices.scws import scws

For example

baseurl: "http://aam-scalaplayer-test:8080/ContentManager/",
authstring: "CMWeb:liggunna",
network: "CADIENLOBBY", #used for uploading
api: "v1.2"
baseurl = "http://my-scala-box:8080/ContentManager/"
authstr = "username:password"
api = "v1.2"
content_manager = scws.ConManager(baseurl, authstr, api_vers=api)

Simple use cases

Now the Content Manager is connected, you can usue the content_manager object to access a variety of functions. For example, to list the names of all players:

players = content_manager.PlayerRS.list()
for player in players:
    print player.name

The Content Manager API can be found at the Scala developer wiki, although take care not to try to call functions from version 1.3.

The API calls typically take in an ID of an object to find, and typically return an array of relevant objects. More complex search functions can often take a SearchCritera object. For example, to search for all channels with names containing "test":

channel_filter = scws.TObj()
channel_filter.column       = u'name'
channel_filter.restriction  = u'LIKE'
channel_filter.value        = u'%test%'
test_channels = content_manager.ChannelRS.list(searchCriteria=channel_filter)

A quick tutorial is available here.

Class Layout

The basic structure of a Scala player is as follows. The Content Manager will have links to a variety of Players. A Player contains a number of Displays, which each contains a single Channel. A Channel has a list of Timeslots and a Frameset. The Frameset contains multiple Frames, and dictates how the frames are laid out, any bezel sizes, the ordering of frames from front to back, and so on. The Schedule dictates at what times a Playlist is shown, and on which Frames. A Playlist can contain Media, Audio, or Data, and specifies ordering, transitions, lengths images are displayed for, and so on and so forth.

                            /-> Timeslot -> Playlist -> Media
Player -> Display -> Channel
                            \-> Frameset -> Frame

MetaValues

Players, Messages and Media items can contain meta-values, which are accessed differently to the main objects, using MediaRS.getMetaValues(mediaId=id) for example.

Some thoughts on the Scala API

The Scala API is perfectly functional, and relatively full featured. While somewhat confusing to use and not hugely "pythonic", it does do its job reasonably thoroughly and effictively. A bit of care has to be taken with a few quirks of it though. For example I could not get it to return transmission or data size from PlanGeneratorRS.getPlanStatus(). For some bizarre reason ChannelRS.getTimeslots(channelId=chan, frameId=frame) does not work, instead you must call ChannelRS.getTimeslots({'channelId':chan}, frameId=frame) instead.

It does not appear possible to in any way easily directly interact with a Scala Player, instead, all interaction should be done through the Content Manager. There is a scripting language called ScalaScript that may potentially be used to interact with the player directly.

About

Some code used to test the python api for scala.


Languages

Language:Python 99.1%Language:Batchfile 0.7%Language:HTML 0.2%