예제 #1
0
파일: commands.py 프로젝트: edlandm/beets
def config_func(lib, opts, args):
    # Make sure lazy configuration is loaded
    config.resolve()

    # Print paths.
    if opts.paths:
        filenames = []
        for source in config.sources:
            if not opts.defaults and source.default:
                continue
            if source.filename:
                filenames.append(source.filename)

        # In case the user config file does not exist, prepend it to the
        # list.
        user_path = config.user_config_path()
        if user_path not in filenames:
            filenames.insert(0, user_path)

        for filename in filenames:
            print(filename)

    # Open in editor.
    elif opts.edit:
        path = config.user_config_path()

        if 'EDITOR' in os.environ:
            editor = os.environ['EDITOR']
            args = [editor, editor, path]
        elif platform.system() == 'Darwin':
            args = ['open', 'open', '-n', path]
        elif platform.system() == 'Windows':
            # On windows we can execute arbitrary files. The os will
            # take care of starting an appropriate application
            args = [path, path]
        else:
            # Assume Unix
            args = ['xdg-open', 'xdg-open', path]

        try:
            os.execlp(*args)
        except OSError:
            raise ui.UserError("Could not edit configuration. Please"
                               "set the EDITOR environment variable.")

    # Dump configuration.
    else:
        print(config.dump(full=opts.defaults))
예제 #2
0
def config_func(lib, opts, args):
    # Make sure lazy configuration is loaded
    config.resolve()

    # Print paths.
    if opts.paths:
        filenames = []
        for source in config.sources:
            if not opts.defaults and source.default:
                continue
            if source.filename:
                filenames.append(source.filename)

        # In case the user config file does not exist, prepend it to the
        # list.
        user_path = config.user_config_path()
        if user_path not in filenames:
            filenames.insert(0, user_path)

        for filename in filenames:
            print(filename)

    # Open in editor.
    elif opts.edit:
        path = config.user_config_path()

        if 'EDITOR' in os.environ:
            editor = os.environ['EDITOR']
            args = [editor, editor, path]
        elif platform.system() == 'Darwin':
            args = ['open', 'open', '-n', path]
        elif platform.system() == 'Windows':
            # On windows we can execute arbitrary files. The os will
            # take care of starting an appropriate application
            args = [path, path]
        else:
            # Assume Unix
            args = ['xdg-open', 'xdg-open', path]

        try:
            os.execlp(*args)
        except OSError:
            raise ui.UserError("Could not edit configuration. Please"
                               "set the EDITOR environment variable.")

    # Dump configuration.
    else:
        print(config.dump(full=opts.defaults))
예제 #3
0
 def __init__(self):
     subcommands, plugins, lib = _setup({})
     self.library = lib
     self.stats = {}
     self.update_stats()
     config.resolve()
예제 #4
0
import os
import sys
from configparser import ConfigParser

import click

from beets import config
from beets.util import confit

from summertunes.cli.run_mpv import run_mpv
from summertunes.cli.run_serve import run_serve
from summertunes.config_defaults import CONFIG_DEFAULTS

import beetsplug.web

config.resolve()

CONFIG_DEFAULTS['beets_web_port'] = config['web']['port'].get(8337)
for k in CONFIG_DEFAULTS:
    try:
        CONFIG_DEFAULTS[k] = config['summertunes'][k].get()
    except confit.NotFoundError:
        pass

PATH_APP_DIR = click.get_app_dir('summertunes')
PATH_CONFIG = os.path.join(click.get_app_dir('summertunes'), 'summertunes.conf')
CONTEXT_SETTINGS = dict(
    help_option_names=['-h', '--help'],
    default_map={
        'mpv': CONFIG_DEFAULTS,
        'serve': CONFIG_DEFAULTS,