partofthething / infopanel

Show live data, animations, pictures, or anything on simple displays like RGB matrices
https://partofthething.com/infopanel/
GNU General Public License v3.0
31 stars 12 forks source link

Defining any values for a scene sprite throws a KeyError #2

Closed jeremyfry closed 6 years ago

jeremyfry commented 6 years ago

Partial config:

sprites:
  scroll:
      type: FancyText
      text: Test
      dx: -1
      ticks_per_movement: 1
  icon:
    type: Image
    path: /home/pi/icons/message.ppm

scenes:
  notification:
    sprites:
      - icon:
      - scroll:
        x: 0
        y: 0

Any values assigned to a sprite in a scene causes a KeyError to be generated.

INFO:infopanel.driver:Starting InfoPanel.
DEBUG:infopanel.sprites:Build <FancyText at 0, 0. dx/dy: (-1, 0), size: (32, 32)>
DEBUG:PIL.Image:Error closing: 'NoneType' object has no attribute 'close'
DEBUG:infopanel.sprites:Build <Image at 0, 0. dx/dy: (0, 0), size: (32, 32)>
DEBUG:infopanel.scenes:Initializing <class 'infopanel.scenes.Scene'>
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/infopanel-0.1-py2.7.egg/infopanel/__main__.py", line 4, in <module>
    driver.run()
  File "/usr/local/lib/python2.7/dist-packages/infopanel-0.1-py2.7.egg/infopanel/driver.py", line 206, in run
    infopanel = driver_factory(disp, datasrc, conf)
  File "/usr/local/lib/python2.7/dist-packages/infopanel-0.1-py2.7.egg/infopanel/driver.py", line 184, in driver_factory
    conf['scenes'], driver.sprites)
  File "/usr/local/lib/python2.7/dist-packages/infopanel-0.1-py2.7.egg/infopanel/scenes.py", line 100, in scene_factory
    sprite = copy.copy(existing_sprites[spritename][0])
KeyError: 'y'
jeremyfry commented 6 years ago

A little more debugging this morning. It seems that the yaml parser is getting the wrong values for the sprites list. sprite_data.items() in scenes.py is showing the following for a sprite: [('y',0), ('x',0), ('scroll', None)]

jeremyfry commented 6 years ago

And I don't know how YAML works. If someone else comes across this

- scroll:
  x: 0
  y: 0

Is equivalent to

{
  scroll: null,
  x: 0,
  y: 0,
}

You want

- scroll:
    x: 0
    y: 0

The extra two spaces before the x and y create this:

{
  scroll: {
    x: 0,
    y: 0
  }
}