Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover plugins in system directories too #348

Merged
merged 1 commit into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,31 @@ python2 -m whipper -h

## Logger plugins

Whipper supports using external logger plugins to write rip `.log` files.
Whipper allows using external logger plugins to customize the template of `.log` files.

List available plugins with `whipper cd rip -h`. Specify a logger to rip with by passing `-L loggername`:
The available plugins can be listed with `whipper cd rip -h`. Specify a logger to rip with by passing `-L loggername`:

```bash
whipper cd rip -L what
whipper cd rip -L eac
```

Whipper searches for logger plugins in the following paths:

- `$XDG_DATA_HOME/whipper/plugins`
- Paths returned by the following Python instruction:

`[x + '/whipper/plugins' for x in site.getsitepackages()]`

- If whipper is run in a `virtualenv`, it will use these alternative instructions (from `distutils.sysconfig`):
- `get_python_lib(plat_specific=False, standard_lib=False, prefix='/usr/local') + '/whipper/plugins'`
- `get_python_lib(plat_specific=False, standard_lib=False) + '/whipper/plugins'`

On a default Debian/Ubuntu installation, the following paths are searched by whipper:

- `$HOME/.local/share/whipper/plugins`
- `/usr/local/lib/python2.7/dist-packages/whipper/plugins`
- `/usr/lib/python2.7/dist-packages/whipper/plugins`

### Official logger plugins

I suggest using whipper's default logger unless you've got particular requirements.
Expand Down
18 changes: 15 additions & 3 deletions whipper/command/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import sys
import pkg_resources
import musicbrainzngs

import site
import whipper

from distutils.sysconfig import get_python_lib
from whipper.command import cd, offset, drive, image, accurip, mblookup
from whipper.command.basecommand import BaseCommand
from whipper.common import common, directory, config
Expand All @@ -21,9 +21,21 @@
def main():
server = config.Config().get_musicbrainz_server()
musicbrainzngs.set_hostname(server)

# Find whipper's plugins paths (local paths have higher priority)
plugins_p = [directory.data_path('plugins')] # local path (in $HOME)
if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv
plugins_p.append(
get_python_lib(plat_specific=False, standard_lib=False,
prefix='/usr/local') + '/whipper/plugins')
plugins_p.append(get_python_lib(plat_specific=False,
standard_lib=False) + '/whipper/plugins')
else:
plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()]

# register plugins with pkg_resources
distributions, _ = pkg_resources.working_set.find_plugins(
pkg_resources.Environment([directory.data_path('plugins')])
pkg_resources.Environment(plugins_p)
)
list(map(pkg_resources.working_set.add, distributions))
try:
Expand Down