def alias(instance, *path): aliases = Aliases.instance() if not path: Show.aliases() return alias = path[0] result = aliases.get_prefix(alias) if len(path) == 1: if result: LOGGER.info('Alias %s=%s', result[0], result[1]) else: LOGGER.error('Don\'t understand alias %s.' % alias) return parts = (p.strip() for p in ' '.join(path[1:]).split('&')) parts = [p for p in parts if p] if not parts: LOGGER.error('Don\'t understand alias %s.', ' '.join(path)) return if 'delete'.startswith(parts[0]): if len(parts) > 1: LOGGER.error('alias delete takes no arguments: %s.', ' '.join(path)) elif not result: LOGGER.error('Don\'t understand alias %s.' % alias) else: del aliases[result[0]] LOGGER.info('Alias %s deleted.', result[0]) else: aliases[alias] = parts LOGGER.info('Alias %s=%s', alias, parts)
def alias(_, *path): aliases = Aliases.instance() if not path: Show.aliases() return al = path[0] result = aliases.get_prefix(al) if len(path) == 1: if result: LOGGER.info('Alias %s=%s', result[0], ' '.join(result[1])) else: LOGGER.error('Don\'t understand alias %s.', al) return parts = (p.strip() for p in ' '.join(path[1:]).split('&')) parts = [p for p in parts if p] if not parts: LOGGER.error('Don\'t understand alias %s.', ' '.join(path)) return if 'delete'.startswith(parts[0]): if len(parts) > 1: LOGGER.error('alias delete takes no arguments: %s.', ' '.join(path)) elif not result: LOGGER.error('Don\'t understand alias %s.', al) else: del aliases[result[0]] LOGGER.info('Alias %s deleted.', result[0]) else: aliases[al] = parts LOGGER.info('Alias %s=%s', al, ' '.join(parts))
def broadcast(echomesh_instance, on_or_off=None): if on_or_off is None: Show.broadcast(echomesh_instance) else: on_or_off = on_or_off.lower() b_on = on_or_off in ['on', 'true'] if not (b_on or on_or_off in ['off', 'false']): raise Exception('You can only turn broadcast mode "on" or "off".') name = 'ON' if b_on else 'off' if b_on == echomesh_instance.broadcasting(): message = 'was already' else: echomesh_instance.set_broadcasting(b_on) message = 'is now' LOGGER.info('broadcast mode %s %s.', message, name)