Hi,

anyone there to give some quick help ?
I'm still stuck at the same point. This is my first one - I promise I'll
contribute back for docs.

Regards,

Robert.

----- Original Message -----
From: "Robert Rozman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 26, 2003 5:03 PM
Subject: [Freevo-devel] Help needed with simple plugin


> Hi,
>
> I'm trying to write plugin for Freevo that could connect to Misterhouse
> and control/check home devices and other stuff. For a start I'm writting
> simple plugin that would have 5 choices and on each menu choice it would
> send 2 commands to Misterhouse. But already here I have some problems
> (I'm python and Freevo newbie and I'm probably banging into easy to
> solve problems).
>
> I'm attaching my plugin and would kindly ask for any guidance. I'm doing
> something wrong that is obvious...
> Right now, when I select menu choice (speak for instance) it already
> runs both actions two times and then displays error as "No action
> defined for this source".
> I have this in local_conf.py:
> plugin.activate('tinia')
> TINIA_COMMANDS = [ ("Speak", "mhsend -speak 'Hi there!'"),
>  ("Speak1 ", "mhsend -speak 'Hi there! 1'"),
>  ("Speak2", "mhsend -speak 'Hi there! 2'"),
>  ("Speak3", "mhsend -speak 'Hi there! 3'"),
>  ("Speak4", "mhsend -speak 'Hi there! 4'"),
>  ("Speak5", "mhsend -speak 'Hi there! 5'") ]
>
> Please, help me to get going...
>
> Regards,
>
> Robert.
>
>


----------------------------------------------------------------------------
----


> #if 0 /*
> # -----------------------------------------------------------------------
> # tinia.py - a simple plugin to connect to Misterhouse
> # -----------------------------------------------------------------------
> # -----------------------------------------------------------------------
> # Freevo - A Home Theater PC framework
> # Copyright (C) 2003 Krister Lagerstrom, et al.
> # Please see the file freevo/Docs/CREDITS for a complete list of authors.
> #
> # This program is free software; you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation; either version 2 of the License, or
> # (at your option) any later version.
> #
> # This program is distributed in the hope that it will be useful, but
> # WITHOUT ANY WARRANTY; without even the implied warranty of MER-
> # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> # Public License for more details.
> #
> # You should have received a copy of the GNU General Public License along
> # with this program; if not, write to the Free Software Foundation, Inc.,
> # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> #
> # -----------------------------------------------------------------------
*/
> #endif
>
> #python modules
> import os, time, stat, re, copy
>
>
> #freevo modules
> import config, menu, rc, plugin, skin, osd, util
> from gui.PopupBox import PopupBox
> from item import Item
>
>
> #get the singletons so we get skin info and access the osd
> skin = skin.get_singleton()
> osd  = osd.get_singleton()
>
> class PluginInterface(plugin.MainMenuPlugin):
>     """
>     A plugin to list menus for House devices.
>
>     To activate, put the following lines in local_conf.py:
>
> plugin.activate('tinia', args=('mhsend ',))
> TINIA_COMMANDS = [ ("Speak", "mhsend -speak 'Hi there!'"),
>  ("Speak1 ", "mhsend -speak 'Hi there! 1'"),
>  ("Speak2", "mhsend -speak 'Hi there! 2'"),
>  ("Speak3", "mhsend -speak 'Hi there! 3'"),
>  ("Speak4", "mhsend -speak 'Hi there! 4'"),
>  ("Speak5", "mhsend -speak 'Hi there! 5'") ]
>
>     """
>     # make an init func that creates the cache dir if it don't exist
>
>     def __init__(self):
>
>         if not hasattr(config, 'TINIA_COMMANDS'):
>             self.reason = 'TINIA_COMMANDS not defined'
>             return
>         plugin.MainMenuPlugin.__init__(self)
>
>     def config(self):
>         return [('TINIA_COMMANDS', [ ("Speak1", "mhsend -speak 'Hi there!
1'"), ("Speak2", "mhsend -speak 'Hi there! 2'") ], 'where to get the tinia
commands')]
>
>     def items(self, parent):
>         menu_items = skin.settings.mainmenu.items
>
>         item = TiniaMainMenuItem()
>         item.name = _('Tinia')
>         item.parent = parent
>         return [ item ]
>
>
> class TiniaSiteItem(Item):
>     """
>     Menu item for one device
>     """
>     def __init__(self, parent):
>         Item.__init__(self, parent)
>         self.command = ''
>         self.location_index = None
>
>
>     def actions(self):
>         """
>         return a list of actions for this item
>         """
>         items = [ ( self.run("on") , _('Run TINIA Command On') ),
> ( self.run("off") , _('Run TINIA Command Off') ) ]
>         return items
>
>     def run(self, arg=None, menuw=None):
>         popup = PopupBox(text=_('%s : Running MHSEND command line: %s ' %
(arg,self.command)))
>         popup.show()
> print '%s : Running MHSEND command line: %s' % (arg,self.command )
> os.system('%s ' % (self.command ) )
> # sleep(2)
>         popup.destroy()
>
>
> rc.app(None)
>
>
> class TiniaMainMenuItem(Item):
>     """
>     this is the item for the main menu and creates the list
>     of Tinia in a submenu.
>     """
>     def actions(self):
>         """
>         return a list of actions for this item
>         """
>         items = [ ( self.create_menu , _('Tinia Commands' )) ]
>         return items
>
>     def create_menu(self, arg=None, menuw=None):
>         devices = []
>         for location in config.TINIA_COMMANDS:
>             devices_item = TiniaSiteItem(self)
>             devices_item.name = location[0]
>             devices_item.command = location[1]
>             devices_item.location_index =
config.TINIA_COMMANDS.index(location)
>             devices += [ devices_item ]
>         if (len(devices) == 0):
>             devices += [menu.MenuItem(_('No Tinia Commands found'),
>                                               menuw.goto_prev_page, 0)]
>         devices_menu = menu.Menu(_('Tinia Commands'), devices)
>         menuw.pushmenu(devices_menu)
>         menuw.refresh()
>
>
>



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Freevo-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to