mirror of
				https://github.com/OpenVoiceOS/OpenVoiceOS
				synced 2025-06-05 22:19:21 +02:00 
			
		
		
		
	Testing of examples skill info patch
This commit is contained in:
		| @@ -0,0 +1,267 @@ | ||||
| From ba22850b5b3e6941c3792ff1eabca8060b189ba6 Mon Sep 17 00:00:00 2001 | ||||
| From: Aditya Mehra <aix.m@outlook.com> | ||||
| Date: Fri, 4 Nov 2022 11:11:22 +1030 | ||||
| Subject: [PATCH 1/4] drop examples skill and use util from osm | ||||
|  | ||||
| --- | ||||
|  __init__.py | 43 ++++++++++--------------------------------- | ||||
|  1 file changed, 10 insertions(+), 33 deletions(-) | ||||
|  | ||||
| diff --git a/__init__.py b/__init__.py | ||||
| index e8ed826..47c19d3 100644 | ||||
| --- a/__init__.py | ||||
| +++ b/__init__.py | ||||
| @@ -26,7 +26,7 @@ | ||||
|  from ovos_utils.xdg_utils import xdg_config_home | ||||
|  from .skill import (DashboardHandler, | ||||
|                      CardGenerator) | ||||
| - | ||||
| +from ovos_skills_manager.utils import get_skills_examples | ||||
|   | ||||
|  class OVOSHomescreenSkill(MycroftSkill): | ||||
|      # The constructor of the skill, which calls MycroftSkill's constructor | ||||
| @@ -38,10 +38,9 @@ def __init__(self): | ||||
|          self.selected_wallpaper = None  # Get from config after __init__ is done | ||||
|          self.wallpaper_collection = [] | ||||
|          self.rtlMode = None  # Get from config after __init__ is done | ||||
| -         | ||||
| + | ||||
|          # Populate skill IDs to use for data sources | ||||
|          self.datetime_skill = None  # Get from config after __init__ is done | ||||
| -        self.skill_info_skill = None  # Get from config after __init__ is done | ||||
|          self.datetime_api = None | ||||
|          self.skill_info_api = None | ||||
|   | ||||
| @@ -51,7 +50,7 @@ def __init__(self): | ||||
|          # Display Configuration Variables | ||||
|          self.wallpaper_rotation_enabled = False | ||||
|          self.dashboard_handler = None | ||||
| -         | ||||
| + | ||||
|          # Media State Tracking For Widget | ||||
|          # Needed for setting qml button state | ||||
|          self.media_widget_player_state = None | ||||
| @@ -62,7 +61,6 @@ def initialize(self): | ||||
|          self.card_generator = CardGenerator(self.file_system.path, self.bus, | ||||
|                                              path.dirname(__file__)) | ||||
|          self.datetime_api = None | ||||
| -        self.skill_info_api = None | ||||
|          self.loc_wallpaper_folder = self.file_system.path + '/wallpapers/' | ||||
|          self.selected_wallpaper = self.settings.get( | ||||
|              "wallpaper") or "default.jpg" | ||||
| @@ -72,9 +70,6 @@ def initialize(self): | ||||
|              "datetime_skill") or "skill-ovos-date-time.openvoiceos" | ||||
|          self.examples_enabled = 1 if self.settings.get( | ||||
|              "examples_enabled", True) else 0 | ||||
| -        if self.examples_enabled: | ||||
| -            self.skill_info_skill = self.settings.get( | ||||
| -                "examples_skill") or "ovos-skills-info.openvoiceos" | ||||
|   | ||||
|          now = datetime.datetime.now() | ||||
|          callback_time = datetime.datetime( | ||||
| @@ -124,7 +119,7 @@ def initialize(self): | ||||
|   | ||||
|          if not self.file_system.exists("wallpapers"): | ||||
|              os.mkdir(path.join(self.file_system.path, "wallpapers")) | ||||
| -             | ||||
| + | ||||
|          # Handler For Weather Response | ||||
|          self.bus.on("skill-ovos-weather.openvoiceos.weather.response", self.update_weather_response) | ||||
|   | ||||
| @@ -176,17 +171,8 @@ def update_examples(self): | ||||
|          """ | ||||
|          Loads or updates skill examples via the skill_info_api. | ||||
|          """ | ||||
| -        if not self.skill_info_api: | ||||
| -            if not self.examples_enabled: | ||||
| -                LOG.warning("Examples are disabled in settings") | ||||
| -            else: | ||||
| -                LOG.warning("Requested update before skill_info API loaded") | ||||
| -                self._load_skill_apis() | ||||
| -        if self.skill_info_api: | ||||
| -            self.gui['skill_examples'] = { | ||||
| -                "examples": self.skill_info_api.skill_info_examples()} | ||||
| -        else: | ||||
| -            LOG.warning("No skill_info_api, skipping update") | ||||
| +        skill_examples = get_skills_examples(randomize=True) | ||||
| +        self.gui['skill_examples'] = {"examples": skill_examples} | ||||
|          self.gui['skill_info_enabled'] = self.examples_enabled | ||||
|   | ||||
|      def update_dt(self): | ||||
| @@ -290,7 +276,7 @@ def check_wallpaper_path(self, wallpaper): | ||||
|              return self.def_wallpaper_folder | ||||
|          elif path.exists(file_loc_check): | ||||
|              return self.loc_wallpaper_folder | ||||
| -         | ||||
| + | ||||
|      def check_wallpaper_rotation_config(self, message=None): | ||||
|          display_config_path_local = path.join(xdg_config_home(), "OvosDisplay.conf") | ||||
|          if path.exists(display_config_path_local): | ||||
| @@ -329,13 +315,6 @@ def _load_skill_apis(self): | ||||
|          """ | ||||
|          Loads weather, date/time, and examples skill APIs | ||||
|          """ | ||||
| -         | ||||
| -        try: | ||||
| -            if not self.skill_info_api: | ||||
| -                self.skill_info_api = SkillApi.get(self.skill_info_skill) or None | ||||
| -        except Exception as e: | ||||
| -            LOG.error(f"Failed To Import OVOS Info Skill: {e}") | ||||
| - | ||||
|          # Import Date Time Skill As Date Time Provider | ||||
|          try: | ||||
|              if not self.datetime_api: | ||||
| @@ -361,7 +340,7 @@ def _split_month_string(self, month_date: str) -> list: | ||||
|   | ||||
|      ##################################################################### | ||||
|      # Build Voice Applications Model | ||||
| -     | ||||
| + | ||||
|      def find_icon_full_path(self, icon_name): | ||||
|          localuser = environ.get('USER') | ||||
|          folder_search_paths = ["/usr/share/icons/", "/usr/local/share/icons/", | ||||
| @@ -387,7 +366,7 @@ def parse_desktop_file(self, file_path): | ||||
|   | ||||
|                  with open(file_path, "r") as f: | ||||
|                      file_contents = f.read() | ||||
| -                     | ||||
| + | ||||
|                      name_start = file_contents.find("Name=") | ||||
|                      name_end = file_contents.find("\n", name_start) | ||||
|                      name = file_contents[name_start + 5:name_end] | ||||
| @@ -415,7 +394,7 @@ def parse_desktop_file(self, file_path): | ||||
|                                                 11:categories_end] | ||||
|   | ||||
|                      categories_list = categories.split(";") | ||||
| -                     | ||||
| + | ||||
|                      if "VoiceApp" in categories_list: | ||||
|                          app_entry = { | ||||
|                              "name": name, | ||||
| @@ -542,8 +521,6 @@ def get_dashboard_cards(self, message=None): | ||||
|          cards = self.dashboard_handler.get_collection() | ||||
|          collection = {"collection": cards} | ||||
|          return collection | ||||
| -     | ||||
| - | ||||
|   | ||||
|   | ||||
|  def create_skill(): | ||||
|  | ||||
| From 06e23d0a7c7085025e06b036b722e7a4d3a492ad Mon Sep 17 00:00:00 2001 | ||||
| From: Aditya Mehra <aix.m@outlook.com> | ||||
| Date: Fri, 4 Nov 2022 11:56:00 +1030 | ||||
| Subject: [PATCH 2/4] restore examples skill api optionally | ||||
|  | ||||
| --- | ||||
|  __init__.py | 13 +++++++++++-- | ||||
|  1 file changed, 11 insertions(+), 2 deletions(-) | ||||
|  | ||||
| diff --git a/__init__.py b/__init__.py | ||||
| index 47c19d3..bd24d29 100644 | ||||
| --- a/__init__.py | ||||
| +++ b/__init__.py | ||||
| @@ -41,6 +41,7 @@ def __init__(self): | ||||
|   | ||||
|          # Populate skill IDs to use for data sources | ||||
|          self.datetime_skill = None  # Get from config after __init__ is done | ||||
| +        self.skill_info_skill = None # Get from config after __init__ is done | ||||
|          self.datetime_api = None | ||||
|          self.skill_info_api = None | ||||
|   | ||||
| @@ -70,6 +71,9 @@ def initialize(self): | ||||
|              "datetime_skill") or "skill-ovos-date-time.openvoiceos" | ||||
|          self.examples_enabled = 1 if self.settings.get( | ||||
|              "examples_enabled", True) else 0 | ||||
| +        if self.examples_enabled: | ||||
| +            self.skill_info_skill = self.settings.get( | ||||
| +                "examples_skill") or "ovos-skills-info.openvoiceos" | ||||
|   | ||||
|          now = datetime.datetime.now() | ||||
|          callback_time = datetime.datetime( | ||||
| @@ -171,8 +175,13 @@ def update_examples(self): | ||||
|          """ | ||||
|          Loads or updates skill examples via the skill_info_api. | ||||
|          """ | ||||
| -        skill_examples = get_skills_examples(randomize=True) | ||||
| -        self.gui['skill_examples'] = {"examples": skill_examples} | ||||
| +        if self.skill_info_api: | ||||
| +            self.gui['skill_examples'] = { | ||||
| +                "examples": self.skill_info_api.skill_info_examples()} | ||||
| +        else: | ||||
| +            skill_examples = get_skills_examples(randomize=True) | ||||
| +            self.gui['skill_examples'] = {"examples": skill_examples} | ||||
| + | ||||
|          self.gui['skill_info_enabled'] = self.examples_enabled | ||||
|   | ||||
|      def update_dt(self): | ||||
|  | ||||
| From bbe52c7bc3bae4e47e4ace2eaa810572c34cba8e Mon Sep 17 00:00:00 2001 | ||||
| From: Aditya Mehra <aix.m@outlook.com> | ||||
| Date: Sat, 5 Nov 2022 11:03:37 +1030 | ||||
| Subject: [PATCH 3/4] remove examples skill and depend on settings to get it | ||||
|  | ||||
| --- | ||||
|  __init__.py | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
|  | ||||
| diff --git a/__init__.py b/__init__.py | ||||
| index bd24d29..2dd2f4f 100644 | ||||
| --- a/__init__.py | ||||
| +++ b/__init__.py | ||||
| @@ -73,7 +73,7 @@ def initialize(self): | ||||
|              "examples_enabled", True) else 0 | ||||
|          if self.examples_enabled: | ||||
|              self.skill_info_skill = self.settings.get( | ||||
| -                "examples_skill") or "ovos-skills-info.openvoiceos" | ||||
| +                "examples_skill") | ||||
|   | ||||
|          now = datetime.datetime.now() | ||||
|          callback_time = datetime.datetime( | ||||
|  | ||||
| From 9decdde074d790e11433a3fc54a166a415c6b236 Mon Sep 17 00:00:00 2001 | ||||
| From: builderjer <34875857+builderjer@users.noreply.github.com> | ||||
| Date: Mon, 7 Nov 2022 17:52:53 -0700 | ||||
| Subject: [PATCH 4/4] Feat/random examples (#54) | ||||
|  | ||||
| * Fix skill examples not rotating | ||||
|  | ||||
| * added setting to randomize examples | ||||
| --- | ||||
|  __init__.py      | 2 +- | ||||
|  settingsmeta.yml | 7 +++++++ | ||||
|  2 files changed, 8 insertions(+), 1 deletion(-) | ||||
|  | ||||
| diff --git a/__init__.py b/__init__.py | ||||
| index 2dd2f4f..d546d35 100644 | ||||
| --- a/__init__.py | ||||
| +++ b/__init__.py | ||||
| @@ -179,7 +179,7 @@ def update_examples(self): | ||||
|              self.gui['skill_examples'] = { | ||||
|                  "examples": self.skill_info_api.skill_info_examples()} | ||||
|          else: | ||||
| -            skill_examples = get_skills_examples(randomize=True) | ||||
| +            skill_examples = get_skills_examples(randomize=self.settings.get("randomize_examples", True)) | ||||
|              self.gui['skill_examples'] = {"examples": skill_examples} | ||||
|   | ||||
|          self.gui['skill_info_enabled'] = self.examples_enabled | ||||
| diff --git a/settingsmeta.yml b/settingsmeta.yml | ||||
| index 88ee52f..f8eab4c 100644 | ||||
| --- a/settingsmeta.yml | ||||
| +++ b/settingsmeta.yml | ||||
| @@ -20,8 +20,15 @@ skillMetadata: | ||||
|            type: text | ||||
|            label: Wallpaper | ||||
|            value: default.jpg | ||||
| +    - name: Examples | ||||
| +      fields: | ||||
|          - name: examples_enabled | ||||
|            type: bool | ||||
|            label: Enable Examples | ||||
|            value: true | ||||
| +        - name: randomize_examples | ||||
| +          type: bool | ||||
| +          label: Randomize Example Entries | ||||
| +          value: true | ||||
| + | ||||
|   | ||||
		Reference in New Issue
	
	Block a user