Пример #1
0
    def __init__(self, title, path):
        MenuItem.__init__(self, title)
        self.path = path

        for root, dirs, files in os.walk(path):
            for dir in dirs:
                self.add_child(DirectoryMenuItem(dir + "...", os.path.join(root, dir)))
            for file in files:
                self.add_child(FileMenuItem(file, file))
Пример #2
0
class SettingsPlugin(Plugin):
    def __init__(self, app, settings):
        Plugin.__init__(self, app, settings)

        self._plugin_raspilcd = None
        self.app.add_listener("load:plcd", self._load_raspilcd)
        self.app.add_listener("unload:plcd", self._unload_raspilcd)

        self.app.console.add_command("set", self._cmd_set)
        self.app.console.add_command("get", self._cmd_get)
        self.app.console.add_command("save", self._cmd_save)

    def shutdown(self):
        if self._plugin_raspilcd is None:
            return
        self._plugin_raspilcd.remove_menu_item(self.menu_root)

    # hooks
    def _load_raspilcd(self, plugin):
        self._plugin_raspilcd = plugin
        from menu import BooleanItem
        from plugins.plcd.lcdapp import MenuItem
        self.menu_root = MenuItem("Einstellungen")
        self.menu_root.add_child(BooleanItem("Beleuchtung", plugin))
        plugin.add_menu_item(self.menu_root)

    def _unload_raspilcd(self, plugin):
        self._plugin_raspilcd = None

    # cmd proxies
    def _cmd_set(self, prm):
        (plugin, key, value) = prm.split(" ")
        self.set(plugin, key, value)

    def _cmd_get(self, prm):
        try:
            (plugin, key) = prm.split(" ")
            print self.get(plugin, key)
        except KeyError:
            self.app.console.echo("key not found")

    def _cmd_save(self, prm):
        self.save()

    # api
    def set(self, plugin, key, value):
        s = self.app.get_plugin_settings(plugin)
        s[key] = value

    def get(self, plugin, key):
        s = self.app.get_plugin_settings(plugin)
        return s[key]

    def save(self):
        with file("settings.yaml", "w") as stream:
            dump(self.app.settings, stream, Dumper=Dumper)
Пример #3
0
 def _load_raspilcd(self, plugin):
     self._plugin_raspilcd = plugin
     from menu import BooleanItem
     from plugins.plcd.lcdapp import MenuItem
     self.menu_root = MenuItem("Einstellungen")
     self.menu_root.add_child(BooleanItem("Beleuchtung", plugin))
     plugin.add_menu_item(self.menu_root)
Пример #4
0
    def _add_menu(self):
        self.plugin_pmpd = self.app.get_plugin("pmpd")
        self.plugin_plcd = self.app.get_plugin("plcd")
        if self.plugin_plcd is None:
            return
        from plugins.plcd.lcdapp import MenuItem
        root = MenuItem("SHOUTcast")

        for genre in self._sc.genres():
            if not genre in self.settings["whitelist"]:
                continue
            mi_genre = MenuItem(genre)
            for (name, identifier, br, ct, lc) in self._sc.stations(genre):
                mi_station = MenuItem(name, self._select_station)
                mi_station.identifier = identifier
                mi_genre.add_child(mi_station)
            root.add_child(mi_genre)
        self.plugin_plcd.add_menu_item(root)
Пример #5
0
 def __init__(self, title, filename):
     MenuItem.__init__(self, title)
     self.filename = filename
Пример #6
0
 def __init__(self, title, plugin):
     MenuItem.__init__(self, title)
     self.plugin = plugin