Index: channels/__init__.py ================================================================== --- channels/__init__.py +++ channels/__init__.py @@ -2,11 +2,11 @@ # api: streamtuner2 # type: base # category: ui # title: Channel plugins # description: Base implementation for channels and feature plugins -# version: 1.1 +# version: 1.2 # license: public domain # author: mario # url: http://fossil.include-once.org/streamtuner2/ # pack: # bookmarks.py configwin.py streamedit.py history.py search.py links.py @@ -118,10 +118,13 @@ self.config = self.meta.get("config", []) self.title = self.meta.get("title", self.module) # add default options values to config.conf.* dict conf.add_plugin_defaults(self.meta, self.module) + + # stub for ST2 main window / dispatcher + self.parent = stub_parent(None) # only if streamtuner2 is run in graphical mode if (parent): self.cache() self.gui(parent) @@ -584,5 +587,16 @@ # add notebook tab tab = parent.notebook_channels.insert_page_menu(vbox, ev_label, plain_label, -1) parent.notebook_channels.set_tab_reorderable(vbox, True) + +# WORKAROUND for direct channel module imports, +# eases instantiations without GUI a little, +# reducing module dependencies (conf. / ahttp. / channels. / parent.) would be better +def stub_parent(object): + def __setattr__(self, name, value): + pass + def __getattr__(self, name): + return lambda *x: None + def status(self, *x): + pass Index: cli.py ================================================================== --- cli.py +++ cli.py @@ -1,27 +1,23 @@ -# # api: streamtuner2 # title: CLI interface # description: allows to call streamtuner2 from the commandline # status: experimental # version: 0.3 # -# Returns JSON data when queried. Usually returns cache data, but the -# "category" module always loads fresh info from the directory servers. -# -# Not all channel plugins are gtk-free yet. And some workarounds are -# used here to not upset channel plugins about a missing parent window. -# -# -# +# Returns JSON data when queried. Usually returns cache data, but the +# "category" module always loads fresh info from the directory servers. +# +# Not all channel plugins are gtk-free yet. And some workarounds are +# used here to not upset channel plugins about a missing parent window. import sys #from channels import * import ahttp import action -from config import conf +from config import * import json @@ -33,11 +29,11 @@ title = "CLI interface" version = 0.3 # channel plugins - channel_modules = ["shoutcast", "xiph", "internet_radio", "jamendo", "myoggradio", "live365"] + channel_modules = ["shoutcast", "xiph", "icast", "jamendo", "radiobrowser"]# module_list() current_channel = "cli" plugins = {} # only populated sparsely by .stream() # start @@ -51,11 +47,11 @@ if not actions: a = self.help # first cmdline arg == action else: command = actions[0] - if command in self.__dict__: + if command in dir(self): cmd = self.__getattribute__(command) else: print "No such command:", command return @@ -154,11 +150,11 @@ def channels(self, channels=None): if channels: channels = channels.split(",") else: channels = self.channel_modules - return (self.channel(module) for module in channels) + return channels#(self.channel(module) for module in channels) # pretty print json def json(self, dat): print(json.dumps(dat, sort_keys=True, indent=2)) @@ -168,10 +164,10 @@ # trap for some main window calls class empty_parent (object): channel = {} null = lambda *a: None - status = null - thread = null + status = lambda *a: None + thread = lambda *a: None