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

Issue24 #42

Merged
merged 2 commits into from
Oct 9, 2016
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
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FORK INFORMATIONS
---------
The name of this fork is still to be decided: right now I'll be using whipper.

This branch is very close to morituri's master one (the internal 'morituri' references are still unchanged). As a starting point, I've just merged the following commits:
This branch is very close to morituri's master one (internal morituri references are still unchanged). As a starting point, I've just merged the following commits:
- [#79](https://github.com/thomasvs/morituri/issues/79)
- [#92](https://github.com/thomasvs/morituri/issues/92)
- [#109](https://github.com/thomasvs/morituri/issues/109)
Expand All @@ -12,19 +12,37 @@ This branch is very close to morituri's master one (the internal 'morituri' refe
- [#140](https://github.com/thomasvs/morituri/issues/140)
- [#141](https://github.com/thomasvs/morituri/issues/141)

And changed the default logger to morituri-whatlogger's one.
And changed the default logger to [morituri-yamllogger](https://github.com/JoeLametta/morituri-yamllogger)'s one.

In order to track whipper's development it's better to check its commit history (readme needs to be updated).
In order to track whipper's current development it's better to check its commit history (README *needs* to be updated).

**WARNING:** As whipper is still under heavy development sometimes I will force push (`--force-with-lease`) to the non master branches.

BACKWARD INCOMPATIBLE CHANGES
---------
* Whipper has adopted new config/cache/state file paths
* Now always follows XDG specifications
* Paths used when XDG environment variables are available:
* `$XDG_CONFIG_HOME/whipper`
* `$XDG_CACHE_HOME/whipper`
* `$XDG_DATA_HOME/whipper`
* Paths used when XDG environment variables are **NOT** available:
* `$HOME/.config/whipper`
* `$HOME/.cache/whipper`
* `$HOME/.local/share/whipper`
* Configuration file information:
* `.moriturirc`, `morituri.conf` aren't used anymore
* `$XDG_CONFIG_HOME/whipper/whipper.conf` (OR `$HOME/.config/whipper/whipper.conf`)
* Plugins folder path:
* `$XDG_DATA_HOME/whipper/plugins` (OR `$HOME/.local/share/whipper/plugins`)

WHIPPER [![Build Status](https://travis-ci.org/JoeLametta/whipper.svg?branch=master)](https://travis-ci.org/JoeLametta/whipper)
---------
whipper is a fork of the morituri project (CDDA ripper for *nix systems aiming for accuracy over speed).

It improves morituri which development seems to have halted/slowed down merging old pull requests and improving it with bugfixes and new functions.

If possible, I'll try to mainline the useful commits of this fork but, in the future, this may not be possible because of different project choices.

The project home page is still TBD.
If possible, I'll try to upstream the progress done here but, in the future, this may not be possible because of different project choices.

RATIONALE
---------
Expand Down Expand Up @@ -150,7 +168,7 @@ The simplest way to get started making accurate rips is:

FILING BUGS
-----------
whipper's bug tracker is still TBD.
whipper's bugs are tracked using the repository issue section provided by GitHub.

morituri's bug tracker is at [http://thomas.apestaart.org/morituri/trac/](
http://thomas.apestaart.org/morituri/trac/).
Expand Down Expand Up @@ -184,7 +202,7 @@ The configuration file is stored according to [XDG Base Directory Specification]
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
when possible.

It lives in `$XDG_CONFIG_HOME/morituri/morituri.conf`
It lives in `$XDG_CONFIG_HOME/whipper/whipper.conf` (or `$HOME/.config/whipper/whipper.conf`)

The configuration file follows python's ConfigParser syntax.

Expand Down Expand Up @@ -217,3 +235,4 @@ Note: to get a literal '%' character it must be doubled.
CONTRIBUTING
------------
- Please send pull requests through GitHub.

5 changes: 3 additions & 2 deletions morituri/common/accurip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import urlparse
import urllib2

from morituri.common import log
from morituri.common import log, directory

_CACHE_DIR = os.path.join(os.path.expanduser('~'), '.morituri', 'cache')
d = directory.Directory()
_CACHE_DIR = d.getCache()


class AccuCache(log.Loggable):
Expand Down
31 changes: 12 additions & 19 deletions morituri/common/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def __init__(self, path=None):
self._pcache = PersistedCache(self._path)

def _getResultCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'result')
d = directory.Directory()
path = d.getCache('result')
return path

def getRipResult(self, cddbdiscid, create=True):
Expand Down Expand Up @@ -210,33 +210,26 @@ def __init__(self, path=None):
if not path:
d = directory.Directory()
self._path = d.getCache('table')
self._readPaths = d.getReadCaches('table')
else:
self._path = path
self._readPaths = [path, ]

self._pcache = PersistedCache(self._path)
self._readPCaches = [PersistedCache(p) for p in self._readPaths]

def get(self, cddbdiscid, mbdiscid):
# Before 0.2.1, we only saved by cddbdiscid, and had collisions
# mbdiscid collisions are a lot less likely
for pcache in self._readPCaches:
ptable = pcache.get('mbdiscid.' + mbdiscid)
if ptable.object:
break
ptable = self._pcache.get('mbdiscid.' + mbdiscid)

if not ptable.object:
for pcache in self._readPCaches:
ptable = pcache.get(cddbdiscid)
if ptable.object:
if ptable.object.getMusicBrainzDiscId() != mbdiscid:
self.debug('cached table is for different mb id %r' % (
ptable.object.getMusicBrainzDiscId()))
ptable.object = None
else:
self.debug('no valid cached table found for %r' %
cddbdiscid)
ptable = self._pcache.get(cddbdiscid)
if ptable.object:
if ptable.object.getMusicBrainzDiscId() != mbdiscid:
self.debug('cached table is for different mb id %r' % (
ptable.object.getMusicBrainzDiscId()))
ptable.object = None
else:
self.debug('no valid cached table found for %r' %
cddbdiscid)

if not ptable.object:
# get an empty persistable from the writable location
Expand Down
66 changes: 25 additions & 41 deletions morituri/common/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,40 @@
class Directory(log.Loggable):

def getConfig(self):
try:
from xdg import BaseDirectory
directory = BaseDirectory.save_config_path('morituri')
path = os.path.join(directory, 'morituri.conf')
self.info('Using XDG, configuration file is %s' % path)
except ImportError:
path = os.path.join(os.path.expanduser('~'), '.moriturirc')
self.info('Not using XDG, configuration file is %s' % path)
config_directory = os.getenv('XDG_CONFIG_HOME')
if not config_directory:
config_directory = os.path.join(os.path.expanduser('~'),
u'.config')
path = os.path.join(config_directory, u'whipper/whipper.conf')
self.info('Configuration file path: %s' % path)
return path


def getCache(self, name=None):
try:
from xdg import BaseDirectory
path = BaseDirectory.save_cache_path('morituri')
self.info('Using XDG, cache directory is %s' % path)
except (ImportError, AttributeError):
# save_cache_path was added in pyxdg 0.25
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache')
cache_directory = os.getenv('XDG_CACHE_HOME')
if not cache_directory:
cache_directory = os.path.join(os.path.expanduser('~'), u'.cache')
path = os.path.join(cache_directory, u'whipper')
self.info('Cache directory path: %s' % path)
if not os.path.exists(path):
os.makedirs(path)
if name:
path = os.path.join(path, name)
if not os.path.exists(path):
os.makedirs(path)
self.info('Not using XDG, cache directory is %s' % path)
return path

def getData(self, name=None):
data_directory = os.getenv('XDG_DATA_HOME')
if not data_directory:
data_directory = os.path.join(os.path.expanduser('~'),
u'.local/share')
path = os.path.join(data_directory, u'whipper')
self.info('Data directory path: %s' % path)
if not os.path.exists(path):
os.makedirs(path)
if name:
path = os.path.join(path, name)
if not os.path.exists(path):
os.makedirs(path)

return path

def getReadCaches(self, name=None):
paths = []

try:
from xdg import BaseDirectory
path = BaseDirectory.save_cache_path('morituri')
self.info('For XDG, read cache directory is %s' % path)
paths.append(path)
except (ImportError, AttributeError):
# save_cache_path was added in pyxdg 0.21
pass

path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache')
if os.path.exists(path):
self.info('From before XDG, read cache directory is %s' % path)
paths.append(path)

if name:
paths = [os.path.join(p, name) for p in paths]

return paths


6 changes: 3 additions & 3 deletions morituri/rip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import pkg_resources

from morituri.common import log, logcommand, common, config
from morituri.common import log, logcommand, common, config, directory
from morituri.configure import configure

from morituri.rip import cd, offset, drive, image, accurip, debug
Expand All @@ -19,8 +19,8 @@ def main(argv):

from morituri.configure import configure
pluginsdir = configure.pluginsdir
homepluginsdir = os.path.join(os.path.expanduser('~'),
'.morituri', 'plugins')
d = directory.Directory()
homepluginsdir = d.getData('plugins')

distributions, errors = pkg_resources.working_set.find_plugins(
pkg_resources.Environment([pluginsdir, homepluginsdir]))
Expand Down
3 changes: 0 additions & 3 deletions morituri/test/test_common_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ def testAll(self):

path = d.getCache()
self.failUnless(path.startswith('/home'))

paths = d.getReadCaches()
self.failUnless(paths[0].startswith('/home'))