Ejemplo n.º 1
0
    def setUpClass(cls) -> None:
        from ovos_skills_manager.appstores.ovos import OVOSstore
        OVOSstore().sync_skills_list()

        if os.environ.get("GITHUB_TOKEN"):
            from ovos_skills_manager.session import set_github_token
            set_github_token(os.environ.get("GITHUB_TOKEN"))
Ejemplo n.º 2
0
 def authenticate(self, auth_token=None, bootstrap=True):
     if auth_token is None:
         auth_token = JsonStorageXDG("OVOS-SkillsManager")["appstores"]\
             .get(self.appstore_id, {}).get("auth_token")
     if auth_token:
         set_github_token(auth_token)
         if bootstrap:
             self.bootstrap()
Ejemplo n.º 3
0
    def setUpClass(cls) -> None:
        from ovos_skills_manager.osm import OVOSSkillsManager
        cls.osm = OVOSSkillsManager()
        assert 'tmp' in cls.osm.config.path

        github_token = os.environ.get("GITHUB_TOKEN")
        if github_token:
            from ovos_skills_manager.session import set_github_token
            set_github_token(github_token)
Ejemplo n.º 4
0
 def authenticate(self,
                  auth_token: Optional[dict] = None,
                  bootstrap: bool = True):
     if auth_token is None:
         auth_token = JsonConfigXDG("OVOS-SkillsManager", subfolder="OpenVoiceOS")["appstores"]\
             .get(self.appstore_id, {}).get("auth_token")
     if auth_token:
         set_github_token(auth_token)
         if bootstrap:
             self.bootstrap()
Ejemplo n.º 5
0
def search_skill(method: str, query: str, fuzzy: bool, no_ignore_case: bool,
                 thresh: float, appstore: str):
    osm = OVOSSkillsManager()
    set_github_token(osm.config["appstores"].get(appstore,
                                                 {}).get("auth_token"))

    ignore_case = not no_ignore_case
    thresh = thresh / 100

    if appstore == "all":
        for s in APPSTORE_OPTIONS:
            if s != "all" and s != "default":
                osm.enable_appstore(s)
    elif appstore != "default":
        for s in APPSTORE_OPTIONS:
            if s != appstore and s != "default" and s != "all":
                osm.disable_appstore(s)
        osm.enable_appstore(appstore)

    if method == "name":
        skills = [
            s for s in osm.search_skills_by_name(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]
    elif method == "url":
        skills = [s for s in osm.search_skills_by_url(query)]
    elif method == "category":
        skills = [
            s for s in osm.search_skills_by_category(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]
    elif method == "author":
        skills = [
            s for s in osm.search_skills_by_author(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]
    elif method == "tag":
        skills = [
            s for s in osm.search_skills_by_tag(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]
    elif method == "description":
        skills = [
            s for s in osm.search_skills_by_description(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]
    else:
        skills = [
            s for s in osm.search_skills(
                query, fuzzy=fuzzy, ignore_case=ignore_case, thresh=thresh)
        ]

    return skills
 def setUpClass(cls):
     if os.environ.get("GITHUB_TOKEN"):
         from ovos_skills_manager.session import set_github_token
         set_github_token(os.environ.get("GITHUB_TOKEN"))
    def setUpClass(self) -> None:
        if os.environ.get("GITHUB_TOKEN"):
            from ovos_skills_manager.session import set_github_token
            set_github_token(os.environ.get("GITHUB_TOKEN"))
        # some examples gathered from parsing andlo's list
        self.agpls = [
            "https://github.com/skeledrew/brain-skill",
            "https://github.com/danielquinn/mycroft-evil-laugh",
            "https://github.com/Quinn2017/Skill-Arbitrator-of-Disputes"
        ]
        self.lgpls = [
            "https://github.com/MycroftAI/skill-homeassistant",
            "https://github.com/BongoEADGC6/mycroft-home-assistant",
            "https://github.com/deevrek/homeassistant-skill",
            "https://github.com/00tiagopolicarpo00/skill-radio-rne",
            "https://github.com/chris-mcawesome12/Mycroft-Home-Assistant",
            "https://github.com/mschot/mycroft-smartthings",
            "https://github.com/SomePati/skill-radio-oe1"
        ]
        self.gpls = [
            "https://github.com/zelmon64/skill-finished-booting",
            "https://github.com/forslund/skill-cocktail",
            "https://github.com/AIIX/plasma-activities-skill",
            "https://github.com/Arc676/Number-Guess-Mycroft-Skill",
            "https://github.com/Arc676/Crystal-Ball-Mycroft-Skill",
            "https://github.com/andlo/picroft-google-aiy-voicekit-skill",
            "https://github.com/danielwine/wikiquote-skill"
        ]
        self.gpl2 = [
            "https://github.com/the7erm/mycroft-skill-jupiter-broadcasting",
            "https://github.com/the7erm/mycroft-skill-diagnostics",
            "https://github.com/the7erm/mycroft-skill-podcast",
            "https://github.com/techstoa/mycroft-sonos",
            "https://github.com/the7erm/mycroft-skill-simple-media-controls"
        ]
        self.mits = ["https://github.com/ChanceNCounter/dismissal-skill"]
        self.apaches = [
            "https://github.com/MycroftAI/fallback-unknown",
            "https://github.com/MycroftAI/fallback-duckduckgo",
            "https://github.com/LinusS1/fallback-recommendations-skill"
        ]
        self.unlicense = [
            "https://github.com/dmp1ce/mycroft-bitcoinprice-skill",
            "https://github.com/Gits3/Lottery-Skill",
            "https://github.com/sofwerx/mycroft-articlekeyword-skill",
            "https://github.com/mason88/skill-federal-closings"
        ]
        self.epl2 = ["https://github.com/openhab/openhab-mycroft"]
        self.epl1 = ["https://github.com/mortommy/mycroft-skill-openhab"]
        self.isc = [
            "https://github.com/k3yb0ardn1nja/mycroft-skill-kodi",
            "https://github.com/kfarwell/mycroft-skill-quodlibet"
        ]
        # these are missing the MIT header and regular detection will fail
        self.mit_fails = [
            "https://github.com/MatthewScholefield/skill-question-learner",
            "https://github.com/ITE-5th/skill-face-recognizer",
            "https://github.com/MatthewScholefield/skill-kickstarter-tracker",
            "https://github.com/jaller94/skill-rock-paper-scissors",
            "https://github.com/JamesPoole/podcast-skill",
            "https://github.com/MatthewScholefield/skill-repeat-recent",
            "https://github.com/avimeens/skill-wemo-controller-using-wit",
            "https://github.com/mathias/skill-heroku-status",
            "https://github.com/JamesPoole/skill-tuner"
        ]
        # not the full license, but links to it
        self.apache_fails = ["https://github.com/camuthig/mycroft-lifx"]

        # TODO more license text examples
        self.bsd0_template = """Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
        THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        """
        self.isc_template = """Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
        THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        """
        self.mit_template_noheader = """
Ejemplo n.º 8
0
    def setUpClass(cls):
        sys.path.append(os.path.dirname(os.path.dirname(__file__)))

        if os.environ.get("GITHUB_TOKEN"):
            from ovos_skills_manager.session import set_github_token
            set_github_token(os.environ.get("GITHUB_TOKEN"))
import os
import sys
import unittest

sys.path.append(os.path.dirname(os.path.dirname(__file__)))

# TODO setup a test skill repo, since a random url can simply vanish

if os.environ.get("GITHUB_TOKEN"):
    from ovos_skills_manager.session import set_github_token
    set_github_token(os.environ.get("GITHUB_TOKEN"))


class TestGithubUtils(unittest.TestCase):
    def test_normalize_url(self):
        from ovos_skills_manager.github.utils import normalize_github_url
        normie = "https://github.com/JarbasSkills/skill-wolfie"
        raw = "https://raw.githubusercontent.com/JarbasSkills/skill-wolfie"
        api = "https://api.github.com/repos/JarbasSkills/skill-wolfie"
        urls = [
            normie, raw, api, normie + "/blob/master/__init__.py",
            normie + "/blob/v0.1/res/desktop/skill.json",
            raw + "/v0.1/res/desktop/skill.json",
            api + "/commits/09de4133f8d53230f93b61b5fd8e8267f4b0aec4",
            api + "/zipball/v0.1", api + "/tarball/v0.1"
        ]
        for url in urls:
            self.assertEqual(normalize_github_url(url), normie)

    def test_branch_from_url(self):
        from ovos_skills_manager.github.utils import get_branch_from_github_url, \