コード例 #1
0
ファイル: test_library.py プロジェクト: pprkut/beets
    def tearDown(self):
        super(DestinationTest, self).tearDown()
        self.lib._connection().close()

        # Reset config if it was changed in test cases
        config.clear()
        config.read(user=False, defaults=True)
コード例 #2
0
ファイル: test_importfeeds.py プロジェクト: adamjakab/Beets
 def setUp(self):
     config.clear()
     config.read(user=False)
     self.importfeeds = ImportFeedsPlugin()
     self.lib = Library(':memory:')
     self.feeds_dir = tempfile.mkdtemp()
     config['importfeeds']['dir'] = self.feeds_dir
コード例 #3
0
ファイル: test_library.py プロジェクト: ykumar6/beets
    def tearDown(self):
        super(DestinationTest, self).tearDown()
        self.lib._connection().close()

        # Reset config if it was changed in test cases
        config.clear()
        config.read(user=False, defaults=True)
コード例 #4
0
 def setUp(self):
     config.clear()
     config.read(user=False)
     self.importfeeds = ImportFeedsPlugin()
     self.lib = Library(':memory:')
     self.feeds_dir = tempfile.mkdtemp()
     config['importfeeds']['dir'] = self.feeds_dir
コード例 #5
0
ファイル: test_ui.py プロジェクト: nanux/beets
    def test_beetsdir_config_does_not_load_default_user_config(self):
        os.environ["BEETSDIR"] = self.beetsdir

        with open(self.user_config_path, "w") as file:
            file.write("anoption: value")

        config.read()
        self.assertFalse(config["anoption"].exists())
コード例 #6
0
ファイル: test_ui.py プロジェクト: tux-00/beets
    def test_default_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = self.beetsdir

        config.read()
        self.assertEqual(config['library'].as_filename(),
                         os.path.join(self.beetsdir, 'library.db'))
        self.assertEqual(config['statefile'].as_filename(),
                         os.path.join(self.beetsdir, 'state.pickle'))
コード例 #7
0
ファイル: test_ui.py プロジェクト: tux-00/beets
    def test_beetsdir_config_does_not_load_default_user_config(self):
        os.environ['BEETSDIR'] = self.beetsdir

        with open(self.user_config_path, 'w') as file:
            file.write('anoption: value')

        config.read()
        self.assertFalse(config['anoption'].exists())
コード例 #8
0
ファイル: test_ui.py プロジェクト: axujen/beets
    def test_beetsdir_config_does_not_load_default_user_config(self):
        os.environ['BEETSDIR'] = self.beetsdir

        with open(self.user_config_path, 'w') as file:
            file.write('anoption: value')

        config.read()
        self.assertFalse(config['anoption'].exists())
コード例 #9
0
ファイル: test_ui.py プロジェクト: axujen/beets
    def test_default_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = self.beetsdir

        config.read()
        self.assertEqual(config['library'].as_filename(),
                         os.path.join(self.beetsdir, 'library.db'))
        self.assertEqual(config['statefile'].as_filename(),
                         os.path.join(self.beetsdir, 'state.pickle'))
コード例 #10
0
ファイル: test_ui.py プロジェクト: tux-00/beets
    def test_beetsdir_config(self):
        os.environ['BEETSDIR'] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, 'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('anoption: overwrite')

        config.read()
        self.assertEqual(config['anoption'].get(), 'overwrite')
コード例 #11
0
ファイル: test_ui.py プロジェクト: axujen/beets
    def test_beetsdir_config(self):
        os.environ['BEETSDIR'] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, 'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('anoption: overwrite')

        config.read()
        self.assertEqual(config['anoption'].get(), 'overwrite')
コード例 #12
0
ファイル: test_ui.py プロジェクト: nanux/beets
    def test_beetsdir_config(self):
        os.environ["BEETSDIR"] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, "config.yaml")
        with open(env_config_path, "w") as file:
            file.write("anoption: overwrite")

        config.read()
        self.assertEqual(config["anoption"].get(), "overwrite")
コード例 #13
0
    def test_default_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = util.py3_path(self.beetsdir)

        config.read()
        self.assert_equal_path(
            util.bytestring_path(config['library'].as_filename()),
            os.path.join(self.beetsdir, b'library.db'))
        self.assert_equal_path(
            util.bytestring_path(config['statefile'].as_filename()),
            os.path.join(self.beetsdir, b'state.pickle'))
コード例 #14
0
ファイル: test_ui.py プロジェクト: dangmai/beets
    def test_default_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = util.py3_path(self.beetsdir)

        config.read()
        self.assert_equal_path(
            util.bytestring_path(config['library'].as_filename()),
            os.path.join(self.beetsdir, b'library.db'))
        self.assert_equal_path(
            util.bytestring_path(config['statefile'].as_filename()),
            os.path.join(self.beetsdir, b'state.pickle'))
コード例 #15
0
ファイル: test_ui.py プロジェクト: nanux/beets
    def test_beetsdir_config_paths_resolve_relative_to_beetsdir(self):
        os.environ["BEETSDIR"] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, "config.yaml")
        with open(env_config_path, "w") as file:
            file.write("library: beets.db\n")
            file.write("statefile: state")

        config.read()
        self.assertEqual(config["library"].as_filename(), os.path.join(self.beetsdir, "beets.db"))
        self.assertEqual(config["statefile"].as_filename(), os.path.join(self.beetsdir, "state"))
コード例 #16
0
ファイル: test_ui.py プロジェクト: axujen/beets
    def test_beetsdir_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, 'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('library: beets.db\n')
            file.write('statefile: state')

        config.read()
        self.assertEqual(config['library'].as_filename(),
                         os.path.join(self.beetsdir, 'beets.db'))
        self.assertEqual(config['statefile'].as_filename(),
                         os.path.join(self.beetsdir, 'state'))
コード例 #17
0
ファイル: test_ui.py プロジェクト: tux-00/beets
    def test_beetsdir_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = self.beetsdir

        env_config_path = os.path.join(self.beetsdir, 'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('library: beets.db\n')
            file.write('statefile: state')

        config.read()
        self.assertEqual(config['library'].as_filename(),
                         os.path.join(self.beetsdir, 'beets.db'))
        self.assertEqual(config['statefile'].as_filename(),
                         os.path.join(self.beetsdir, 'state'))
コード例 #18
0
    def test_beetsdir_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = util.py3_path(self.beetsdir)

        env_config_path = os.path.join(self.beetsdir, b'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('library: beets.db\n')
            file.write('statefile: state')

        config.read()
        self.assert_equal_path(
            util.bytestring_path(config['library'].as_filename()),
            os.path.join(self.beetsdir, b'beets.db'))
        self.assert_equal_path(
            util.bytestring_path(config['statefile'].as_filename()),
            os.path.join(self.beetsdir, b'state'))
コード例 #19
0
ファイル: test_ui.py プロジェクト: dangmai/beets
    def test_beetsdir_config_paths_resolve_relative_to_beetsdir(self):
        os.environ['BEETSDIR'] = util.py3_path(self.beetsdir)

        env_config_path = os.path.join(self.beetsdir, b'config.yaml')
        with open(env_config_path, 'w') as file:
            file.write('library: beets.db\n')
            file.write('statefile: state')

        config.read()
        self.assert_equal_path(
            util.bytestring_path(config['library'].as_filename()),
            os.path.join(self.beetsdir, b'beets.db'))
        self.assert_equal_path(
            util.bytestring_path(config['statefile'].as_filename()),
            os.path.join(self.beetsdir, b'state'))
コード例 #20
0
ファイル: __init__.py プロジェクト: jenzie/beets
def _raw_main(args, load_config=True):
    """A helper function for `main` without top-level exception
    handling.
    """
    # Load global configuration files.
    if load_config:
        config.read()

    # Temporary: Migrate from 1.0-style configuration.
    from beets.ui import migrate
    if load_config:
        migrate.automigrate()

    # Get the default subcommands.
    from beets.ui.commands import default_commands

    # Add plugin paths.
    sys.path += get_plugin_paths()
    # Load requested plugins.
    plugins.load_plugins(config['plugins'].as_str_seq())
    plugins.send("pluginload")

    # Construct the root parser.
    commands = list(default_commands)
    commands += plugins.commands()
    commands.append(migrate.migrate_cmd)  # Temporary.
    parser = SubcommandsOptionParser(subcommands=commands)
    parser.add_option('-l',
                      '--library',
                      dest='library',
                      help='library database file to use')
    parser.add_option('-d',
                      '--directory',
                      dest='directory',
                      help="destination music directory")
    parser.add_option('-v',
                      '--verbose',
                      dest='verbose',
                      action='store_true',
                      help='print debugging information')

    # Parse the command-line!
    options, subcommand, suboptions, subargs = parser.parse_args(args)
    config.set_args(options)

    # Open library file.
    dbpath = config['library'].as_filename()
    try:
        lib = library.Library(
            dbpath,
            config['directory'].as_filename(),
            get_path_formats(),
            Template(config['art_filename'].get(unicode)),
            config['timeout'].as_number(),
            get_replacements(),
        )
    except sqlite3.OperationalError:
        raise UserError(u"database file {0} could not be opened".format(
            util.displayable_path(dbpath)))
    plugins.send("library_opened", lib=lib)

    # Configure the logger.
    if config['verbose'].get(bool):
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    log.debug(u'data directory: {0}\n'
              u'library database: {1}\n'
              u'library directory: {2}'.format(
                  util.displayable_path(config.config_dir()),
                  util.displayable_path(lib.path),
                  util.displayable_path(lib.directory),
              ))

    # Configure the MusicBrainz API.
    mb.configure()

    # Invoke the subcommand.
    subcommand.func(lib, suboptions, subargs)
    plugins.send('cli_exit', lib=lib)
コード例 #21
0
 def test_command_line_option_relative_to_working_dir(self):
     config.read()
     os.chdir(self.temp_dir)
     self.run_command('--library', 'foo.db', 'test', lib=None)
     self.assert_equal_path(config['library'].as_filename(),
                            os.path.join(os.getcwd(), 'foo.db'))
コード例 #22
0
ファイル: __init__.py プロジェクト: flz/beets
def _raw_main(args, load_config=True):
    """A helper function for `main` without top-level exception
    handling.
    """
    # Load global configuration files.
    if load_config:
        config.read()

    # Temporary: Migrate from 1.0-style configuration.
    from beets.ui import migrate
    if load_config:
        migrate.automigrate()

    # Get the default subcommands.
    from beets.ui.commands import default_commands

    # Add plugin paths.
    sys.path += get_plugin_paths()
    # Load requested plugins.
    plugins.load_plugins(config['plugins'].as_str_seq())
    plugins.send("pluginload")

    # Construct the root parser.
    commands = list(default_commands)
    commands += plugins.commands()
    commands.append(migrate.migrate_cmd)  # Temporary.
    parser = SubcommandsOptionParser(subcommands=commands)
    parser.add_option('-l', '--library', dest='library',
                      help='library database file to use')
    parser.add_option('-d', '--directory', dest='directory',
                      help="destination music directory")
    parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
                      help='print debugging information')

    # Parse the command-line!
    options, subcommand, suboptions, subargs = parser.parse_args(args)
    config.set_args(options)

    # Open library file.
    dbpath = config['library'].as_filename()
    try:
        lib = library.Library(
            dbpath,
            config['directory'].as_filename(),
            get_path_formats(),
            Template(config['art_filename'].get(unicode)),
            config['timeout'].as_number(),
            get_replacements(),
        )
    except sqlite3.OperationalError:
        raise UserError(u"database file {0} could not be opened".format(
            util.displayable_path(dbpath)
        ))
    plugins.send("library_opened", lib=lib)

    # Configure the logger.
    if config['verbose'].get(bool):
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    log.debug(u'data directory: {0}\n'
              u'library database: {1}\n'
              u'library directory: {2}'.format(
        util.displayable_path(config.config_dir()),
        util.displayable_path(lib.path),
        util.displayable_path(lib.directory),
    ))

    # Invoke the subcommand.
    subcommand.func(lib, suboptions, subargs)
コード例 #23
0
ファイル: test_ui.py プロジェクト: nanux/beets
    def test_default_config_paths_resolve_relative_to_beetsdir(self):
        os.environ["BEETSDIR"] = self.beetsdir

        config.read()
        self.assertEqual(config["library"].as_filename(), os.path.join(self.beetsdir, "library.db"))
        self.assertEqual(config["statefile"].as_filename(), os.path.join(self.beetsdir, "state.pickle"))