some small fixes
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 14 Feb 2021 11:37:40 +0000 (12:37 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 14 Feb 2021 11:37:40 +0000 (12:37 +0100)
music_assistant/constants.py
music_assistant/managers/config.py
music_assistant/models/player_queue.py
music_assistant/web/server.py

index 0ff18b3c2b18f2210c37e231372b2fd0998848f3..876fde6b3d48a4214232cdb34b8c92631cceae28 100755 (executable)
@@ -1,6 +1,6 @@
 """All constants for Music Assistant."""
 
-__version__ = "0.0.86"
+__version__ = "0.0.87"
 REQUIRED_PYTHON_VER = "3.7"
 
 # configuration keys/attributes
index a93befb91d618e18b0e2ffa24bad87af39381913..4da39d0a4081dbea46a032a411ef279dee2c80d3 100755 (executable)
@@ -191,11 +191,15 @@ class ConfigManager:
     ) -> dict:
         """Set value of the given config item."""
         if new_value is None:
-            self[conf_base][conf_key].pop(conf_val)
-        else:
-            self[conf_base][conf_key][conf_val] = new_value
+            return self[conf_base][conf_key].pop(conf_val)
+        self[conf_base][conf_key][conf_val] = new_value
         return self[conf_base][conf_key].all_items()
 
+    @api_route("config/delete/:conf_base/:conf_key")
+    def delete_config(self, conf_base: str, conf_key: str) -> dict:
+        """Delete value from stored configuration."""
+        return self[conf_base].pop(conf_key)
+
     @property
     def data_path(self):
         """Return the path where all (configuration) data is stored."""
@@ -343,10 +347,9 @@ class ConfigBaseItem:
         self.mass = conf_mgr.mass
         self.conf_key = conf_key
 
-    @classmethod
-    def all_keys(cls):
+    def all_keys(self):
         """Return all possible keys of this Config object."""
-        return []
+        return {key for key in self.conf_mgr.stored_config.get(self.conf_key, {}).keys()}
 
     def __getitem__(self, item_key: str):
         """Return ConfigSubItem for given key."""
@@ -481,7 +484,11 @@ class PlayerSettings(ConfigBaseItem):
 
     def all_keys(self):
         """Return all possible keys of this Config object."""
-        return (item.player_id for item in self.mass.players.players)
+        all_keys = super().all_keys()
+        for player_id in self.mass.players.players:
+            if player_id not in all_keys:
+                all_keys.add(player_id)
+        return all_keys
 
     def get_config_entries(self, child_key: str) -> List[ConfigEntry]:
         """Return all config entries for the given child entry."""
@@ -629,6 +636,8 @@ class ConfigSubItem:
             # do some simple type checking
             if entry.multi_value:
                 # multi value item
+                if value is None:
+                    value = []
                 if not isinstance(value, list):
                     raise ValueError
             else:
@@ -636,18 +645,24 @@ class ConfigSubItem:
                 if entry.entry_type == ConfigEntryType.STRING and not isinstance(
                     value, str
                 ):
-                    if not value:
+                    if value is None:
                         value = ""
                     else:
                         raise ValueError
                 if entry.entry_type == ConfigEntryType.BOOL and not isinstance(
                     value, bool
                 ):
-                    raise ValueError
+                    if value is None:
+                        value = False
+                    else:
+                        raise ValueError
                 if entry.entry_type == ConfigEntryType.FLOAT and not isinstance(
                     value, (float, int)
                 ):
-                    raise ValueError
+                    if value is None:
+                        value = 0
+                    else:
+                        raise ValueError
             if value != self[key]:
                 if entry.store_hashed:
                     value = pbkdf2_sha256.hash(value)
index 7a57006dbb5de9a30c75388bb406c5538e8119d6..7e8db0a16460eeb4529b867466b75fc2bad703bd 100755 (executable)
@@ -529,6 +529,7 @@ class PlayerQueue:
         self._cur_item_time = 0
         self._cur_index = self._queue_stream_next_index
         self._queue_stream_next_index += 1
+        self._queue_stream_start_index = self._cur_index
         return self._cur_index
 
     async def async_queue_stream_next(self, cur_index: int) -> None:
index c67bf24e7bc88218d40353deda9ad4169032e901..9ba046631bea4648ba4894c044d512a3e1ecb3c3 100755 (executable)
@@ -171,7 +171,7 @@ class WebServer:
         }
 
     async def async_index(self, request: web.Request):
-        """Get the index page, redirect if we do not have a web directory."""
+        """Get the index page."""
         # pylint: disable=unused-argument
         html_app = os.path.join(
             os.path.dirname(os.path.abspath(__file__)), "static/index.html"