Esempio n. 1
0
 def run(self):
     try:
         SkillsInstaller.install(
             snipsfile_path=self.options['--snipsfile'],
             silent=self.options['--silent'],
             force_download=self.options['--force-download'])
     except SkillsInstallerWarning as e:
         pp.pwarning(str(e))
     except Exception as e:
         pp.perror(str(e))
Esempio n. 2
0
 def install_from_urls(skill_urls, silent=False, force_download=False):
     SkillsInstaller.print_start(silent)
     num_installed = 0
     for url in skill_urls:
         try:
             SkillInstaller.install(url, force_download=force_download)
             num_installed = num_installed + 1
         except SkillInstallerWarning as e:
             pp.pwarning(str(e))
         except Exception as e:
             pp.perror(str(e))
     SkillsInstaller.print_done(num_installed, silent)
     return num_installed
Esempio n. 3
0
 def run(self):
     pp.silent = self.options['--silent']
     interactive = not self.options['--non-interactive']
     addon_id = self.options['<addon_id>']
     try:
         if addon_id == "spotify":
             AddonInstaller.install_spotify_addon(
                 params=self.options['PARAMS'], interactive=interactive)
         else:
             raise AddonInstallerException(
                 "Error: Unknown add-on {}".format(addon_id))
     except AddonInstallerWarning as e:
         pp.pwarning(str(e))
     except Exception as e:
         pp.perror(str(e))
Esempio n. 4
0
    def run(self):

        try:
            speaker_id = self.options['<speaker_id>']
            if speaker_id is not None:
                update_asoundconf = not self.options['--skip-asoundconf']
                params = self.options['PARAMS']
                SpeakerInstaller.install_from_params(speaker_id,
                                                     update_asoundconf,
                                                     params_list=params)
            else:
                SpeakerInstaller.install(
                    snipsfile_path=self.options['--snipsfile'])
        except SpeakerInstallerWarning as e:
            pp.pwarning(str(e))
        except Exception as e:
            pp.perror(str(e))
Esempio n. 5
0
 def run(self):
     pp.silent = self.options['--silent']
     debug = self.options['--debug']
     try:
         GlobalInstaller.install(
             self.options['--snipsfile'],
             skip_bluetooth=self.options['--skip-bluetooth'],
             skip_systemd=self.options['--skip-systemd'],
             email=self.options['--email'],
             password=self.options['--password'],
             force_download=self.options['--force-download'])
     except GlobalInstallerWarning as e:
         if debug:
             raise e
         pp.pwarning(str(e))
     except Exception as e:
         if debug:
             raise e
         pp.perror(str(e))
Esempio n. 6
0
    def run(self):
        """ Command runner.

        Docopt command:
        
        snipsmanager setup microphone [--snipsfile=<snipsfile>] [<microphone_id> [--skip-asoundconf] [PARAMS ...]]
        """
        try:
            microphone_id = self.options['<microphone_id>']
            if microphone_id is not None:
                update_asoundconf = not self.options['--skip-asoundconf']
                params = self.options['PARAMS']
                MicrophoneInstaller.install_from_params(microphone_id,
                                                        update_asoundconf,
                                                        params_list=params)
            else:
                MicrophoneInstaller.install(
                    snipsfile_path=self.options['--snipsfile'])
        except MicrophoneInstallerWarning as e:
            pp.pwarning(str(e))
        except Exception as e:
            pp.perror(str(e))
Esempio n. 7
0
    def install_spotify_addon(params=None, interactive=True):
        pp.pcommand("Installing Spotify add-on")

        if params is None or len(params) == 0:
            if interactive:
                pp.psubmessage("You need to provide a Spotify token",
                               indent=True)
                pp.psubmessage(
                    "Please open \033[1m\033[4m{}\033[0m in a web browser and follow the instructions to obtain it"
                    .format(AddonInstaller.SPOTIFY_LOGIN_URL),
                    indent=True)
                token = ask_for_input("Spotify token:")
            else:
                pp.pwarning(
                    "Spotify add-on not installed. Please provide the Spotify token as a parameter, or omit the `--non-interative` flag"
                )
                return
        else:
            token = params[0]

        Addons.install("spotify", [token])

        pp.psuccess("Spotify add-on installed")
Esempio n. 8
0
    def install_from_snipsfile(snipsfile,
                               skip_bluetooth=False,
                               skip_systemd=False,
                               email=None,
                               password=None,
                               force_download=False):
        pp.pheader("Running Snips Manager installer")

        if snipsfile is None:
            raise GlobalInstallerException(
                "Error running installer: no Snipsfile provided")

        try:
            AssistantFetcher.fetch(email=email,
                                   password=password,
                                   force_download=force_download)
            AssistantLoader.load()
        except Exception as e:
            pp.pwarning(str(e))

        try:
            SkillsInstaller.install(force_download=force_download)
        except Exception as e:
            pp.pwarning(str(e))

        try:
            MicrophoneInstaller.install()
        except Exception as e:
            pp.pwarning(str(e))

        try:
            SpeakerInstaller.install()
        except Exception as e:
            pp.pwarning(str(e))

        if not skip_bluetooth and is_raspi_os():
            try:
                BluetoothInstaller.install(force_download=force_download)
            except Exception as e:
                pp.pwarning(str(e))

        if not skip_systemd and is_raspi_os():
            try:
                SystemdBluetooth.setup()
            except Exception as e:
                pp.pwarning(str(e))
            try:
                SystemdSnipsManager.setup()
            except Exception as e:
                pp.pwarning(str(e))

        if not skip_systemd:
            pp.pheadersuccess(
                "Snips Manager installer complete! You can now reboot your device, or manually run 'snipsmanager run' to start the Snips Manager server"
            )
        else:
            pp.pheadersuccess(
                "Snips Manager installer complete! Now run 'snipsmanager run' to start the Snips Manager server."
            )