コード例 #1
0
ファイル: test_path.py プロジェクト: zwl1671/mopidy
    def test_create_dir_with_name_of_existing_file_throws_oserror(self):
        conflicting_file = self.parent / "test"
        conflicting_file.touch()
        dir_path = self.parent / "test"

        with pytest.raises(OSError):
            path.get_or_create_dir(str(dir_path))
コード例 #2
0
ファイル: ext.py プロジェクト: HaBaLeS/mopidy
    def get_config_dir(cls, config):
        """Get or create configuration directory for the extension.

        :param config: the Mopidy config object
        :return: string
        """
        assert cls.ext_name is not None
        config_dir_path = bytes(os.path.join(config["core"]["config_dir"], cls.ext_name))
        path.get_or_create_dir(config_dir_path)
        return config_dir_path
コード例 #3
0
ファイル: ext.py プロジェクト: zwl1671/mopidy
    def get_config_dir(cls, config):
        """Get or create configuration directory for the extension.

        :param config: the Mopidy config object
        :return: pathlib.Path
        """
        assert cls.ext_name is not None
        config_dir_path = (path.expand_path(config["core"]["config_dir"]) /
                           cls.ext_name)
        path.get_or_create_dir(config_dir_path)
        return config_dir_path
コード例 #4
0
    def get_data_dir(self, config):
        """Get or create data directory for the extension.

        :param config: the Mopidy config object
        :returns: string
        """
        assert self.ext_name is not None
        data_dir_path = bytes(
            os.path.join(config['core']['data_dir'], self.ext_name))
        path.get_or_create_dir(data_dir_path)
        return data_dir_path
コード例 #5
0
ファイル: ext.py プロジェクト: zhanghuabin/mopidy
    def get_config_dir(cls, config):
        """Get or create configuration directory for the extension.

        :param config: the Mopidy config object
        :return: string
        """
        assert cls.ext_name is not None
        config_dir_path = bytes(os.path.join(config['core']['config_dir'],
                                             cls.ext_name))
        path.get_or_create_dir(config_dir_path)
        return config_dir_path
コード例 #6
0
ファイル: ext.py プロジェクト: HaBaLeS/mopidy
    def get_cache_dir(cls, config):
        """Get or create cache directory for the extension.

        Use this directory to cache data that can safely be thrown away.

        :param config: the Mopidy config object
        :return: string
        """
        assert cls.ext_name is not None
        cache_dir_path = bytes(os.path.join(config["core"]["cache_dir"], cls.ext_name))
        path.get_or_create_dir(cache_dir_path)
        return cache_dir_path
コード例 #7
0
    def get_data_dir(cls, config):
        """Get or create data directory for the extension.

        Use this directory to store data that should be persistent.

        :param config: the Mopidy config object
        :returns: string
        """
        data_dir_path = bytes(
            os.path.join(config['core']['data_dir'], 'local-images'))
        get_or_create_dir(data_dir_path)
        return data_dir_path
コード例 #8
0
def check_dirs_and_files(config):
    if not os.path.isdir(config['local']['media_dir']):
        logger.warning(
            'Local media dir %s does not exist.' %
            config['local']['media_dir'])

    try:
        path.get_or_create_dir(config['local']['data_dir'])
    except EnvironmentError as error:
        logger.warning(
            'Could not create local data dir: %s',
            encoding.locale_decode(error))
コード例 #9
0
ファイル: ext.py プロジェクト: HaBaLeS/mopidy
    def get_data_dir(cls, config):
        """Get or create data directory for the extension.

        Use this directory to store data that should be persistent.

        :param config: the Mopidy config object
        :returns: string
        """
        assert cls.ext_name is not None
        data_dir_path = bytes(os.path.join(config["core"]["data_dir"], cls.ext_name))
        path.get_or_create_dir(data_dir_path)
        return data_dir_path
コード例 #10
0
ファイル: ext.py プロジェクト: zhanghuabin/mopidy
    def get_data_dir(cls, config):
        """Get or create data directory for the extension.

        Use this directory to store data that should be persistent.

        :param config: the Mopidy config object
        :returns: string
        """
        assert cls.ext_name is not None
        data_dir_path = bytes(os.path.join(config['core']['data_dir'],
                                           cls.ext_name))
        path.get_or_create_dir(data_dir_path)
        return data_dir_path
コード例 #11
0
ファイル: ext.py プロジェクト: zwl1671/mopidy
    def get_cache_dir(cls, config):
        """Get or create cache directory for the extension.

        Use this directory to cache data that can safely be thrown away.

        :param config: the Mopidy config object
        :return: pathlib.Path
        """
        assert cls.ext_name is not None
        cache_dir_path = (path.expand_path(config["core"]["cache_dir"]) /
                          cls.ext_name)
        path.get_or_create_dir(cache_dir_path)
        return cache_dir_path
コード例 #12
0
ファイル: ext.py プロジェクト: zwl1671/mopidy
    def get_data_dir(cls, config):
        """Get or create data directory for the extension.

        Use this directory to store data that should be persistent.

        :param config: the Mopidy config object
        :returns: pathlib.Path
        """
        assert cls.ext_name is not None
        data_dir_path = (path.expand_path(config["core"]["data_dir"]) /
                         cls.ext_name)
        path.get_or_create_dir(data_dir_path)
        return data_dir_path
コード例 #13
0
    def __init__(self, config, audio):
        super(M3UBackend, self).__init__()

        self._config = config

        try:
            path.get_or_create_dir(config['m3u']['playlists_dir'])
        except EnvironmentError as error:
            logger.warning('Could not create M3U playlists dir: %s',
                           encoding.locale_decode(error))

        self.playlists = M3UPlaylistsProvider(backend=self)
        self.library = M3ULibraryProvider(backend=self)
コード例 #14
0
ファイル: ext.py プロジェクト: zhanghuabin/mopidy
    def get_cache_dir(cls, config):
        """Get or create cache directory for the extension.

        Use this directory to cache data that can safely be thrown away.

        :param config: the Mopidy config object
        :return: string
        """
        assert cls.ext_name is not None
        cache_dir_path = bytes(os.path.join(config['core']['cache_dir'],
                                            cls.ext_name))
        path.get_or_create_dir(cache_dir_path)
        return cache_dir_path
コード例 #15
0
ファイル: actor.py プロジェクト: bencevans/mopidy
    def __init__(self, config, audio):
        super(M3UBackend, self).__init__()

        self._config = config

        try:
            path.get_or_create_dir(config['m3u']['playlists_dir'])
        except EnvironmentError as error:
            logger.warning(
                'Could not create M3U playlists dir: %s',
                encoding.locale_decode(error))

        self.playlists = M3UPlaylistsProvider(backend=self)
        self.library = M3ULibraryProvider(backend=self)
コード例 #16
0
ファイル: __main__.py プロジェクト: muharremtac/mopidy
def create_file_structures_and_config(args, extensions_data):
    path.get_or_create_dir(b'$XDG_DATA_DIR/mopidy')
    path.get_or_create_dir(b'$XDG_CONFIG_DIR/mopidy')

    # Initialize whatever the last config file is with defaults
    config_file = args.config_files[-1]
    if os.path.exists(path.expand_path(config_file)):
        return

    try:
        default = config_lib.format_initial(extensions_data)
        path.get_or_create_file(config_file, mkdir=False, content=default)
        logger.info('Initialized %s with default config', config_file)
    except IOError as error:
        logger.warning('Unable to initialize %s with default config: %s',
                       config_file, encoding.locale_decode(error))
コード例 #17
0
 def test_creating_dir(self):
     dir_path = os.path.join(self.parent, b'test')
     self.assert_(not os.path.exists(dir_path))
     created = path.get_or_create_dir(dir_path)
     self.assert_(os.path.exists(dir_path))
     self.assert_(os.path.isdir(dir_path))
     self.assertEqual(created, dir_path)
コード例 #18
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_creating_dir(self):
     dir_path = os.path.join(self.parent, b'test')
     self.assert_(not os.path.exists(dir_path))
     created = path.get_or_create_dir(dir_path)
     self.assert_(os.path.exists(dir_path))
     self.assert_(os.path.isdir(dir_path))
     self.assertEqual(created, dir_path)
コード例 #19
0
ファイル: __main__.py プロジェクト: bencevans/mopidy
def create_file_structures_and_config(args, extensions_data):
    path.get_or_create_dir(b'$XDG_DATA_DIR/mopidy')
    path.get_or_create_dir(b'$XDG_CONFIG_DIR/mopidy')

    # Initialize whatever the last config file is with defaults
    config_file = args.config_files[-1]
    if os.path.exists(path.expand_path(config_file)):
        return

    try:
        default = config_lib.format_initial(extensions_data)
        path.get_or_create_file(config_file, mkdir=False, content=default)
        logger.info('Initialized %s with default config', config_file)
    except IOError as error:
        logger.warning(
            'Unable to initialize %s with default config: %s',
            config_file, encoding.locale_decode(error))
コード例 #20
0
ファイル: test_path.py プロジェクト: zwl1671/mopidy
    def test_creating_dir(self):
        dir_path = self.parent / "test"
        assert not dir_path.exists()

        created = path.get_or_create_dir(str(dir_path))

        assert dir_path.is_dir()
        assert created == dir_path
コード例 #21
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_creating_nested_dirs(self):
     level2_dir = os.path.join(self.parent, b'test')
     level3_dir = os.path.join(self.parent, b'test', b'test')
     self.assert_(not os.path.exists(level2_dir))
     self.assert_(not os.path.exists(level3_dir))
     created = path.get_or_create_dir(level3_dir)
     self.assert_(os.path.exists(level2_dir))
     self.assert_(os.path.isdir(level2_dir))
     self.assert_(os.path.exists(level3_dir))
     self.assert_(os.path.isdir(level3_dir))
     self.assertEqual(created, level3_dir)
コード例 #22
0
 def test_creating_nested_dirs(self):
     level2_dir = os.path.join(self.parent, b'test')
     level3_dir = os.path.join(self.parent, b'test', b'test')
     self.assert_(not os.path.exists(level2_dir))
     self.assert_(not os.path.exists(level3_dir))
     created = path.get_or_create_dir(level3_dir)
     self.assert_(os.path.exists(level2_dir))
     self.assert_(os.path.isdir(level2_dir))
     self.assert_(os.path.exists(level3_dir))
     self.assert_(os.path.isdir(level3_dir))
     self.assertEqual(created, level3_dir)
コード例 #23
0
ファイル: test_path.py プロジェクト: zwl1671/mopidy
    def test_creating_nested_dirs(self):
        level2_dir = self.parent / "test"
        level3_dir = self.parent / "test" / "test"
        assert not level2_dir.exists()
        assert not level3_dir.exists()

        created = path.get_or_create_dir(str(level3_dir))

        assert level2_dir.is_dir()
        assert level3_dir.is_dir()
        assert created == level3_dir
コード例 #24
0
 def test_create_dir_with_unicode(self):
     with self.assertRaises(ValueError):
         dir_path = compat.text_type(os.path.join(self.parent, b'test'))
         path.get_or_create_dir(dir_path)
コード例 #25
0
ファイル: actor.py プロジェクト: AddBassStudios/mopidy
 def _get_data_dir(self):
     # get or create data director for core
     data_dir_path = os.path.join(self._config['core']['data_dir'], b'core')
     path.get_or_create_dir(data_dir_path)
     return data_dir_path
コード例 #26
0
ファイル: actor.py プロジェクト: zvonimirfras/mopidy
 def _get_data_dir(self):
     # get or create data director for core
     data_dir_path = os.path.join(self._config['core']['data_dir'], b'core')
     path.get_or_create_dir(data_dir_path)
     return data_dir_path
コード例 #27
0
ファイル: __main__.py プロジェクト: kidaa30/mopidy
def create_core_dirs(config):
    path.get_or_create_dir(config['core']['cache_dir'])
    path.get_or_create_dir(config['core']['config_dir'])
    path.get_or_create_dir(config['core']['data_dir'])
コード例 #28
0
ファイル: actor.py プロジェクト: zwl1671/mopidy
 def _get_data_dir(self):
     # get or create data director for core
     data_dir_path = (path.expand_path(self._config["core"]["data_dir"]) /
                      "core")
     path.get_or_create_dir(data_dir_path)
     return data_dir_path
コード例 #29
0
ファイル: test_path.py プロジェクト: zwl1671/mopidy
    def test_creating_existing_dir(self):
        created = path.get_or_create_dir(str(self.parent))

        assert self.parent.is_dir()
        assert created == self.parent
コード例 #30
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_creating_existing_dir(self):
     created = path.get_or_create_dir(self.parent)
     self.assert_(os.path.exists(self.parent))
     self.assert_(os.path.isdir(self.parent))
     self.assertEqual(created, self.parent)
コード例 #31
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_create_dir_with_none(self):
     with self.assertRaises(ValueError):
         path.get_or_create_dir(None)
コード例 #32
0
ファイル: __main__.py プロジェクト: zwl1671/mopidy
def create_core_dirs(config):
    path.get_or_create_dir(config["core"]["cache_dir"])
    path.get_or_create_dir(config["core"]["config_dir"])
    path.get_or_create_dir(config["core"]["data_dir"])
コード例 #33
0
 def test_create_dir_with_name_of_existing_file_throws_oserror(self):
     conflicting_file = os.path.join(self.parent, b'test')
     open(conflicting_file, 'w').close()
     dir_path = os.path.join(self.parent, b'test')
     with self.assertRaises(OSError):
         path.get_or_create_dir(dir_path)
コード例 #34
0
 def test_creating_existing_dir(self):
     created = path.get_or_create_dir(self.parent)
     self.assert_(os.path.exists(self.parent))
     self.assert_(os.path.isdir(self.parent))
     self.assertEqual(created, self.parent)
コード例 #35
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_create_dir_with_unicode(self):
     with self.assertRaises(ValueError):
         dir_path = compat.text_type(os.path.join(self.parent, b'test'))
         path.get_or_create_dir(dir_path)
コード例 #36
0
ファイル: test_path.py プロジェクト: mopidy/mopidy
 def test_create_dir_with_name_of_existing_file_throws_oserror(self):
     conflicting_file = os.path.join(self.parent, b'test')
     open(conflicting_file, 'w').close()
     dir_path = os.path.join(self.parent, b'test')
     with self.assertRaises(OSError):
         path.get_or_create_dir(dir_path)
コード例 #37
0
ファイル: test_path.py プロジェクト: zwl1671/mopidy
 def test_create_dir_with_none(self):
     with pytest.raises(TypeError):
         path.get_or_create_dir(None)
コード例 #38
0
 def test_create_dir_with_none(self):
     with self.assertRaises(ValueError):
         path.get_or_create_dir(None)
コード例 #39
0
ファイル: __main__.py プロジェクト: SeeSpotRun/mopidy
def create_core_dirs(config):
    path.get_or_create_dir(config["core"]["cache_dir"])
    path.get_or_create_dir(config["core"]["config_dir"])
    path.get_or_create_dir(config["core"]["data_dir"])
コード例 #40
0
ファイル: __main__.py プロジェクト: vrs01/mopidy
def create_core_dirs(config):
    path.get_or_create_dir(config['core']['cache_dir'])
    path.get_or_create_dir(config['core']['config_dir'])
    path.get_or_create_dir(config['core']['data_dir'])