def main(): settings = load() if not settings: return config = convert(settings) known = [ 'spotify', 'scrobbler', 'mpd', 'mpris', 'local', 'stream', 'http'] extensions = [e for e in ext.load_extensions() if e.ext_name in known] print b'Converted config:\n' print config_lib.format(config, extensions) conf_file = path.expand_path(b'$XDG_CONFIG_DIR/mopidy/mopidy.conf') if os.path.exists(conf_file): print '%s exists, exiting.' % conf_file sys.exit(1) print 'Write new config to %s? [yN]' % conf_file, if raw_input() != 'y': print 'Not saving, exiting.' sys.exit(0) serialized_config = config_lib.format(config, extensions, display=False) with io.open(conf_file, 'wb') as filehandle: filehandle.write(serialized_config) print 'Done.'
def main(): settings = load() if not settings: return config = convert(settings) known = ["spotify", "scrobbler", "mpd", "mpris", "local", "stream", "http"] extensions = [e for e in ext.load_extensions() if e.ext_name in known] print(b"Converted config:\n") print(config_lib.format(config, extensions)) conf_file = path.expand_path(b"$XDG_CONFIG_DIR/mopidy/mopidy.conf") if os.path.exists(conf_file): print("%s exists, exiting." % conf_file) sys.exit(1) print("Write new config to %s? [yN]" % conf_file, end=" ") if raw_input() != "y": print("Not saving, exiting.") sys.exit(0) serialized_config = config_lib.format(config, extensions, display=False) with io.open(conf_file, "wb") as filehandle: filehandle.write(serialized_config) print("Done.")
def run(self, config, errors, schemas): data = config_lib.format(config, schemas, errors) # Throw away all bytes that are not valid UTF-8 before printing data = data.encode(errors="surrogateescape").decode(errors="replace") print(data) return 0
def show_config(args): """Prints the effective config and exits.""" extensions = ext.load_extensions() config, errors = config_lib.load( args.config_files, extensions, args.config_overrides) # Clear out any config for disabled extensions. for extension in extensions: if not ext.validate_extension(extension): config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled itself.'} elif not config[extension.ext_name]['enabled']: config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled by config.'} print config_lib.format(config, extensions, errors) sys.exit(0)
def show_config(args): """Prints the effective config and exits.""" extensions = ext.load_extensions() config, errors = config_lib.load(args.config_files, extensions, args.config_overrides) # Clear out any config for disabled extensions. for extension in extensions: if not ext.validate_extension(extension): config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled itself.' } elif not config[extension.ext_name]['enabled']: config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled by config.' } print config_lib.format(config, extensions, errors) sys.exit(0)
def show_config_callback(option, opt, value, parser): # TODO: don't use callback for this as --config or -o set after # --show-config will be ignored. files = getattr(parser.values, 'config', b'').split(b':') overrides = getattr(parser.values, 'overrides', []) extensions = ext.load_extensions() config, errors = config_lib.load(files, extensions, overrides) # Clear out any config for disabled extensions. for extension in extensions: if not ext.validate_extension(extension): config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled its self.'} elif not config[extension.ext_name]['enabled']: config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled by config.'} print config_lib.format(config, extensions, errors) sys.exit(0)
def show_config_callback(option, opt, value, parser): # TODO: don't use callback for this as --config or -o set after # --show-config will be ignored. files = getattr(parser.values, 'config', b'').split(b':') overrides = getattr(parser.values, 'overrides', []) extensions = ext.load_extensions() config, errors = config_lib.load(files, extensions, overrides) # Clear out any config for disabled extensions. for extension in extensions: if not ext.validate_extension(extension): config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled its self.' } elif not config[extension.ext_name]['enabled']: config[extension.ext_name] = {b'enabled': False} errors[extension.ext_name] = { b'enabled': b'extension disabled by config.' } print config_lib.format(config, extensions, errors) sys.exit(0)
def run(self, config, errors, schemas): print(config_lib.format(config, schemas, errors)) return 0
def run(self, config, errors, extensions): print(config_lib.format(config, extensions, errors)) return 0