Fix typos and formatting
This commit is contained in:
parent
46dd36d914
commit
92767e49f9
@ -11,7 +11,7 @@ v2.1.0 (UNRELEASED)
|
|||||||
Feature release.
|
Feature release.
|
||||||
|
|
||||||
- Core: Mopidy restores its last state when started. Can be enabled by setting
|
- Core: Mopidy restores its last state when started. Can be enabled by setting
|
||||||
the config value :confval:`core/restore_state` to `true`.
|
the config value :confval:`core/restore_state` to ``true``.
|
||||||
|
|
||||||
- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command
|
- MPD: Fix MPD protocol for ``replay_gain_status`` command. The actual command
|
||||||
remains unimplemented. (PR: :issue:`1520`)
|
remains unimplemented. (PR: :issue:`1520`)
|
||||||
|
|||||||
@ -115,7 +115,7 @@ Core config section
|
|||||||
|
|
||||||
When set to ``true``, Mopidy restores its last state when started.
|
When set to ``true``, Mopidy restores its last state when started.
|
||||||
The restored state includes the tracklist, playback history,
|
The restored state includes the tracklist, playback history,
|
||||||
the playback state, and the mixers volume and mute state.
|
the playback state, the volume, and mute state.
|
||||||
|
|
||||||
Default is ``false``.
|
Default is ``false``.
|
||||||
|
|
||||||
|
|||||||
@ -164,8 +164,7 @@ class Core(
|
|||||||
|
|
||||||
def _get_data_dir(self):
|
def _get_data_dir(self):
|
||||||
# get or create data director for core
|
# get or create data director for core
|
||||||
data_dir_path = bytes(
|
data_dir_path = os.path.join(self._config['core']['data_dir'], b'core')
|
||||||
os.path.join(self._config['core']['data_dir'], 'core'))
|
|
||||||
path.get_or_create_dir(data_dir_path)
|
path.get_or_create_dir(data_dir_path)
|
||||||
return data_dir_path
|
return data_dir_path
|
||||||
|
|
||||||
@ -174,8 +173,8 @@ class Core(
|
|||||||
Save current state to disk.
|
Save current state to disk.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
file_name = bytes(os.path.join(self._get_data_dir(), b'state.json.gz'))
|
file_name = os.path.join(self._get_data_dir(), b'state.json.gz')
|
||||||
logger.info('Save state to %s', file_name)
|
logger.info('Saveing state to %s', file_name)
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
data['version'] = mopidy.__version__
|
data['version'] = mopidy.__version__
|
||||||
@ -185,15 +184,15 @@ class Core(
|
|||||||
playback=self.playback._save_state(),
|
playback=self.playback._save_state(),
|
||||||
mixer=self.mixer._save_state())
|
mixer=self.mixer._save_state())
|
||||||
storage.dump(file_name, data)
|
storage.dump(file_name, data)
|
||||||
logger.debug('Save state done.')
|
logger.debug('Saveing state done')
|
||||||
|
|
||||||
def _load_state(self, coverage):
|
def _load_state(self, coverage):
|
||||||
"""
|
"""
|
||||||
Restore state from disk.
|
Restore state from disk.
|
||||||
|
|
||||||
Load state from disk and restore it. Parameter `coverage`
|
Load state from disk and restore it. Parameter ``coverage``
|
||||||
limits the amount data to restore. Possible
|
limits the amount of data to restore. Possible
|
||||||
values for `coverage` (list of one or more of):
|
values for ``coverage`` (list of one or more of):
|
||||||
|
|
||||||
- 'tracklist' fill the tracklist
|
- 'tracklist' fill the tracklist
|
||||||
- 'mode' set tracklist properties (consume, random, repeat, single)
|
- 'mode' set tracklist properties (consume, random, repeat, single)
|
||||||
@ -202,11 +201,11 @@ class Core(
|
|||||||
- 'history' restore history
|
- 'history' restore history
|
||||||
|
|
||||||
:param coverage: amount of data to restore
|
:param coverage: amount of data to restore
|
||||||
:type coverage: list of string (see above)
|
:type coverage: list of strings
|
||||||
"""
|
"""
|
||||||
|
|
||||||
file_name = bytes(os.path.join(self._get_data_dir(), b'state.json.gz'))
|
file_name = os.path.join(self._get_data_dir(), b'state.json.gz')
|
||||||
logger.info('Load state from %s', file_name)
|
logger.info('Loading state from %s', file_name)
|
||||||
|
|
||||||
data = storage.load(file_name)
|
data = storage.load(file_name)
|
||||||
|
|
||||||
@ -224,7 +223,7 @@ class Core(
|
|||||||
self.mixer._load_state(core_state.mixer, coverage)
|
self.mixer._load_state(core_state.mixer, coverage)
|
||||||
# playback after tracklist
|
# playback after tracklist
|
||||||
self.playback._load_state(core_state.playback, coverage)
|
self.playback._load_state(core_state.playback, coverage)
|
||||||
logger.debug('Load state done.')
|
logger.debug('Loading state done')
|
||||||
|
|
||||||
|
|
||||||
class Backends(list):
|
class Backends(list):
|
||||||
|
|||||||
@ -64,11 +64,11 @@ class HistoryController(object):
|
|||||||
count = 1
|
count = 1
|
||||||
history_list = []
|
history_list = []
|
||||||
for timestamp, track in self._history:
|
for timestamp, track in self._history:
|
||||||
history_list.append(HistoryTrack(
|
history_list.append(
|
||||||
timestamp=timestamp, track=track))
|
HistoryTrack(timestamp=timestamp, track=track))
|
||||||
count += 1
|
count += 1
|
||||||
if count_max < count:
|
if count_max < count:
|
||||||
logger.info('Limiting history to %s tracks.', count_max)
|
logger.info('Limiting history to %s tracks', count_max)
|
||||||
break
|
break
|
||||||
return HistoryState(history=history_list)
|
return HistoryState(history=history_list)
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ def load(path):
|
|||||||
"""
|
"""
|
||||||
# Todo: raise an exception in case of error?
|
# Todo: raise an exception in case of error?
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
logger.info('File does not exist: %s.', path)
|
logger.info('File does not exist: %s', path)
|
||||||
return {}
|
return {}
|
||||||
try:
|
try:
|
||||||
with gzip.open(path, 'rb') as fp:
|
with gzip.open(path, 'rb') as fp:
|
||||||
|
|||||||
@ -167,9 +167,10 @@ class JsonLibrary(local.Library):
|
|||||||
self._tracks.pop(uri, None)
|
self._tracks.pop(uri, None)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
internal_storage.dump(self._json_file,
|
internal_storage.dump(self._json_file, {
|
||||||
{'version': mopidy.__version__,
|
'version': mopidy.__version__,
|
||||||
'tracks': self._tracks.values()})
|
'tracks': self._tracks.values()
|
||||||
|
})
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -56,7 +56,8 @@ class CoreActorSaveLoadStateTest(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp_dir = tempfile.mkdtemp()
|
self.temp_dir = tempfile.mkdtemp()
|
||||||
self.state_file = os.path.join(self.temp_dir, 'core', 'state.json.gz')
|
self.state_file = os.path.join(self.temp_dir,
|
||||||
|
b'core', b'state.json.gz')
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'core': {
|
'core': {
|
||||||
@ -66,7 +67,7 @@ class CoreActorSaveLoadStateTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os.mkdir(os.path.join(self.temp_dir, 'core'))
|
os.mkdir(os.path.join(self.temp_dir, b'core'))
|
||||||
|
|
||||||
self.mixer = dummy_mixer.create_proxy()
|
self.mixer = dummy_mixer.create_proxy()
|
||||||
self.core = Core(
|
self.core = Core(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user