From 2e7f0db1be8dd886258bda9d0b37ec1c98bac2ff Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:13:09 +0000 Subject: [PATCH] fix:modernize homescreen integration (#16) * fix:modernize homescreen integration companion to https://github.com/OpenVoiceOS/OVOS-workshop/pull/283 * packaging * fix:add app name * ovos-workshop>=2.4.0,<3.0.0 --- MANIFEST.in | 7 +-- __init__.py | 4 +- {res/icon => gui}/ovos-file-browser.svg | 0 {res/desktop => locale/en-us}/skill.json | 33 ++-------- requirements.txt | 2 +- res/desktop/skill-ovos-local-media.desktop | 12 ---- scripts/bump_alpha.py | 18 ------ scripts/bump_build.py | 21 ------- scripts/bump_major.py | 27 --------- scripts/bump_minor.py | 24 -------- scripts/prepare_skillstore.py | 70 ---------------------- scripts/prepare_translations.py | 53 ---------------- scripts/release_skillstore.py | 41 ------------- scripts/remove_alpha.py | 13 ---- setup.py | 6 +- 15 files changed, 11 insertions(+), 320 deletions(-) rename {res/icon => gui}/ovos-file-browser.svg (100%) rename {res/desktop => locale/en-us}/skill.json (53%) delete mode 100644 res/desktop/skill-ovos-local-media.desktop delete mode 100644 scripts/bump_alpha.py delete mode 100644 scripts/bump_build.py delete mode 100644 scripts/bump_major.py delete mode 100644 scripts/bump_minor.py delete mode 100644 scripts/prepare_skillstore.py delete mode 100644 scripts/prepare_translations.py delete mode 100644 scripts/release_skillstore.py delete mode 100644 scripts/remove_alpha.py diff --git a/MANIFEST.in b/MANIFEST.in index 7e4d479..92de07b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,8 +1,3 @@ -recursive-include dialog * -recursive-include vocab * recursive-include locale * -recursive-include res * -recursive-include ui * -recursive-include skill * -include *.json +recursive-include gui * include *.txt \ No newline at end of file diff --git a/__init__.py b/__init__.py index a8e12fd..1f9640a 100644 --- a/__init__.py +++ b/__init__.py @@ -12,7 +12,7 @@ from ovos_utils.parse import fuzzy_match, MatchStrategy from ovos_utils.process_utils import RuntimeRequirements from ovos_utils.sound import get_sound_duration -from ovos_workshop.decorators import intent_handler +from ovos_workshop.decorators import intent_handler, homescreen_app from ovos_workshop.decorators.ocp import ocp_search from ovos_workshop.skills.common_play import OVOSCommonPlaybackSkill @@ -54,7 +54,6 @@ def runtime_requirements(self): def initialize(self): self.ocp = OCPInterface(self.bus) self.udev_thread = None - self.add_event(f'{self.skill_id}.home', self.show_home) self.add_event(f'{self.skill_id}.scan', self.scan_local_media) self.gui.register_handler('file.play', self.handle_file) self.gui.register_handler('folder.play', self.handle_folder_playlist) @@ -187,6 +186,7 @@ def handle_udev_event(self, action, device): if device.device_node is not None: self.gui.show_notification("A USB device was removed", noticetype="transient", style="info") + @homescreen_app(icon="ovos-file-browser.svg", name="File Browser") @intent_handler("open.file.browser.intent") def show_home(self, message): """ diff --git a/res/icon/ovos-file-browser.svg b/gui/ovos-file-browser.svg similarity index 100% rename from res/icon/ovos-file-browser.svg rename to gui/ovos-file-browser.svg diff --git a/res/desktop/skill.json b/locale/en-us/skill.json similarity index 53% rename from res/desktop/skill.json rename to locale/en-us/skill.json index bf266f7..41f5e47 100644 --- a/res/desktop/skill.json +++ b/locale/en-us/skill.json @@ -1,22 +1,10 @@ { - "skill_id": "skill-ovos-local-media", - "requirements": { - "python": [ - "ovos_workshop~=0.0, >=0.0.12a20", - "ovos-utils~=0.0, >=0.0.28", - "ovos-bus-client" - ], - "system": {}, - "skill": [] - }, - "url": "https://github.com/OpenVoiceOS/skill-ovos-local-media", - "authorname": "OpenVoiceOS", - "skillname": "skill-ovos-local-media", - "branch": "dev", + "skill_id": "skill-ovos-local-media.openvoiceos", + "source": "https://github.com/OpenVoiceOS/skill-ovos-local-media", + "author": "OpenVoiceOS", + "name": "Local Media", "license": "apache-2.0", - "icon": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/folder-open.svg", - "description": "File Browser For Open Voice OS", - "short_description": "", + "description": "Local Media File Browser For Open Voice OS", "examples": [ "start file browser app", "show my usb drive", @@ -45,13 +33,6 @@ "open usb", "start usb browser app" ], - "credits": [ - "OpenVoiceOS (@OpenVoiceOS)\nAditya Mehra (@AIIX)" - ], - "category": "Daily", - "categories": [ - "Daily" - ], "tags": [ "usb", "local", @@ -60,7 +41,5 @@ "filebrowser", "manager", "file" - ], - "foldername": "skill-ovos-local-media", - "desktopFile": true + ] } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 766fca2..c051ed2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ ovos-utils >= 0.1.0 ovos-bus-client>=0.0.9,<2.0.0 -ovos-workshop>=0.0.16 +ovos-workshop>=2.4.0,<3.0.0 diff --git a/res/desktop/skill-ovos-local-media.desktop b/res/desktop/skill-ovos-local-media.desktop deleted file mode 100644 index 72dd090..0000000 --- a/res/desktop/skill-ovos-local-media.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -X-DBUS-StartupType=None -X-KDE-StartupNotify=false -Version=1.0 -Terminal=false -Type=Application -Name=File Browser -Exec=mycroft-gui-app --hideTextInput --skill=skill.file-browser.openvoiceos.home -Icon=ovos-file-browser -Categories=VoiceApp -StartupNotify=false - diff --git a/scripts/bump_alpha.py b/scripts/bump_alpha.py deleted file mode 100644 index e465543..0000000 --- a/scripts/bump_alpha.py +++ /dev/null @@ -1,18 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_build.py b/scripts/bump_build.py deleted file mode 100644 index 61099f8..0000000 --- a/scripts/bump_build.py +++ /dev/null @@ -1,21 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_major.py b/scripts/bump_major.py deleted file mode 100644 index 2610fbb..0000000 --- a/scripts/bump_major.py +++ /dev/null @@ -1,27 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_MAJOR" -minor_var_name = "VERSION_MINOR" -build_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(minor_var_name): - print(f"{minor_var_name} = 0") - elif line.startswith(build_var_name): - print(f"{build_var_name} = 0") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_minor.py b/scripts/bump_minor.py deleted file mode 100644 index 86dfd9d..0000000 --- a/scripts/bump_minor.py +++ /dev/null @@ -1,24 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_MINOR" -build_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(build_var_name): - print(f"{build_var_name} = 0") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/prepare_skillstore.py b/scripts/prepare_skillstore.py deleted file mode 100644 index b504b16..0000000 --- a/scripts/prepare_skillstore.py +++ /dev/null @@ -1,70 +0,0 @@ -from ovos_skills_manager import SkillEntry -from os.path import exists, join, dirname -from shutil import rmtree -import os -from os import makedirs -import json -from ovos_utils.bracket_expansion import expand_parentheses, expand_options - - -branch = "dev" -repo = "skill-ovos-local-media" -author = "OpenVoiceOS" - -url = f"https://github.com/{author}/{repo}@{branch}" - -skill = SkillEntry.from_github_url(url) -tmp_skills = "/tmp/osm_installed_skills" -skill_folder = f"{tmp_skills}/{skill.uuid}" - -base_dir = dirname(dirname(__file__)) -desktop_dir = join(base_dir, "res", "desktop") -android_ui = join(base_dir, "ui", "+android") -makedirs(desktop_dir, exist_ok=True) - -readme = join(base_dir, "README.md") -jsonf = join(desktop_dir, "skill.json") -desktopf = join(desktop_dir, f"{repo}.desktop") -skill_code = join(base_dir, "__init__.py") - -res_folder = join(base_dir, "locale", "en-us") - - -def read_samples(path): - samples = [] - with open(path) as fi: - for _ in fi.read().split("\n"): - if _ and not _.strip().startswith("#"): - samples += expand_options(_) - return samples - -samples = [] -for root, folders, files in os.walk(res_folder): - for f in files: - if f.endswith(".intent"): - samples += read_samples(join(root, f)) -skill._data["examples"] = list(set(samples)) - -has_android = exists(android_ui) -with open(skill_code) as f: - has_homescreen = f"{repo}.{author}.home" in f.read() - -if not exists(readme): - with open(readme, "w") as f: - f.write(skill.generate_readme()) - -if has_homescreen and not exists(desktopf): - with open(desktopf, "w") as f: - f.write(skill.desktop_file) - -if not exists(jsonf): - data = skill.json -else: - with open(jsonf) as f: - data = json.load(f) - -# set dev branch -data["branch"] = "dev" -data["desktopFile"] = True -with open(jsonf, "w") as f: - json.dump(data, f, indent=4) diff --git a/scripts/prepare_translations.py b/scripts/prepare_translations.py deleted file mode 100644 index 01a674d..0000000 --- a/scripts/prepare_translations.py +++ /dev/null @@ -1,53 +0,0 @@ -"""this script should run every time the contents of the locale folder change -except if PR originated from @gitlocalize-app -TODO - on commit to dev -""" - -import json -from os.path import dirname -import os - -locale = f"{dirname(dirname(__file__))}/locale" -tx = f"{dirname(dirname(__file__))}/translations" - - -for lang in os.listdir(locale): - intents = {} - dialogs = {} - vocs = {} - regexes = {} - for root, _, files in os.walk(f"{locale}/{lang}"): - b = root.split(f"/{lang}")[-1] - - for f in files: - if b: - fid = f"{b}/{f}" - else: - fid = f - with open(f"{root}/{f}") as fi: - strings = [l.replace("{{", "{").replace("}}", "}") - for l in fi.read().split("\n") if l.strip() - and not l.startswith("#")] - - if fid.endswith(".intent"): - intents[fid] = strings - elif fid.endswith(".dialog"): - dialogs[fid] = strings - elif fid.endswith(".voc"): - vocs[fid] = strings - elif fid.endswith(".rx"): - regexes[fid] = strings - - os.makedirs(f"{tx}/{lang.lower()}", exist_ok=True) - if intents: - with open(f"{tx}/{lang.lower()}/intents.json", "w") as f: - json.dump(intents, f, indent=4) - if dialogs: - with open(f"{tx}/{lang.lower()}/dialogs.json", "w") as f: - json.dump(dialogs, f, indent=4) - if vocs: - with open(f"{tx}/{lang.lower()}/vocabs.json", "w") as f: - json.dump(vocs, f, indent=4) - if regexes: - with open(f"{tx}/{lang.lower()}/regexes.json", "w") as f: - json.dump(regexes, f, indent=4) diff --git a/scripts/release_skillstore.py b/scripts/release_skillstore.py deleted file mode 100644 index a176d89..0000000 --- a/scripts/release_skillstore.py +++ /dev/null @@ -1,41 +0,0 @@ -import json -from os.path import join, dirname - -base_dir = dirname(dirname(__file__)) - - -def get_version(): - """ Find the version of the package""" - version_file = join(base_dir, 'version.py') - major, minor, build, alpha = (None, None, None, None) - with open(version_file) as f: - for line in f: - if 'VERSION_MAJOR' in line: - major = line.split('=')[1].strip() - elif 'VERSION_MINOR' in line: - minor = line.split('=')[1].strip() - elif 'VERSION_BUILD' in line: - build = line.split('=')[1].strip() - elif 'VERSION_ALPHA' in line: - alpha = line.split('=')[1].strip() - - if ((major and minor and build and alpha) or - '# END_VERSION_BLOCK' in line): - break - version = f"{major}.{minor}.{build}" - if alpha and int(alpha) > 0: - version += f"a{alpha}" - return version - - -desktop_dir = join(base_dir, "res", "desktop") - -jsonf = join(desktop_dir, "skill.json") - -with open(jsonf) as f: - data = json.load(f) - -data["branch"] = "v" + get_version() - -with open(jsonf, "w") as f: - json.dump(data, f, indent=4) diff --git a/scripts/remove_alpha.py b/scripts/remove_alpha.py deleted file mode 100644 index fca7342..0000000 --- a/scripts/remove_alpha.py +++ /dev/null @@ -1,13 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") - -alpha_var_name = "VERSION_ALPHA" - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/setup.py b/setup.py index 3f45d88..1cb8277 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ def get_requirements(requirements_filename: str): def find_resource_files(): - resource_base_dirs = ("locale", "ui") + resource_base_dirs = ("locale", "gui") base_dir = path.dirname(__file__) package_data = ["*.json"] for res in resource_base_dirs: @@ -79,10 +79,6 @@ def get_version(): package_dir={SKILL_PKG: ""}, package_data={SKILL_PKG: find_resource_files()}, packages=[SKILL_PKG], - data_files = [ - ('share/applications', ['res/desktop/skill-ovos-local-media.desktop']), - ('share/icons', ['res/icon/ovos-file-browser.svg']) - ], include_package_data=True, install_requires=get_requirements("requirements.txt"), extras_require={"notify": get_requirements("notify-requirements.txt")},