示例#1
0
    def run(self):
        """ Command runner.

        Docopt command:
        
        snipsmanager fetch assistant [--id=<id> --url=<url> --file=<filename>]
        """
        force_download = self.options['--force-download']
        try:
            aid = self.options['--id']
            url = self.options['--url']
            file = self.options['--file']
            email = self.options['--email']
            password = self.options['--password']
            if aid is not None or url is not None or file is not None:
                AssistantFetcher.fetch_from_params(
                    aid=aid,
                    url=url,
                    file=file,
                    email=email,
                    password=password,
                    force_download=force_download)
            else:
                AssistantFetcher.fetch(self.options['--snipsfile'],
                                       email=email,
                                       password=password,
                                       force_download=force_download)
        except Exception as e:
            pp.perror(str(e))
示例#2
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))
示例#3
0
 def run(self):
     try:
         mqtt_hostname = self.options['--mqtt-host']
         mqtt_port = self.options['--mqtt-port']
         if mqtt_hostname is not None or mqtt_port is not None:
             SystemdBluetooth.setup_from_params(mqtt_hostname=mqtt_hostname,
                                                mqtt_port=mqtt_port)
         else:
             SystemdBluetooth.setup(self.options['--snipsfile'])
     except Exception as e:
         pp.perror(str(e))
示例#4
0
    def run(self):
        """ Command runner.

        Docopt command:
        
        snipsmanager load assistant [--file=<file> --platform-only]
        """
        try:
            generate_classes = not self.options['--platform-only']
            AssistantLoader.load(self.options['--file'], generate_classes=generate_classes)
        except Exception as e:
            pp.perror(str(e))
示例#5
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
示例#6
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))
示例#7
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))
示例#8
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))
示例#9
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))
示例#10
0
 def run(self):
     try:
         BluetoothInstaller.install(force_download=self.options['--force-download'])
     except Exception as e:
         pp.perror(str(e))
示例#11
0
def main():
    """ Main entry point. """
    options = docopt(__doc__, version=VERSION)

    try:
        if options['setup'] == True and options['microphone'] == True:
            from snipsmanager.commands.setup.microphone import MicrophoneInstaller
            MicrophoneInstaller(options).run()
        elif options['setup'] == True and options['speaker'] == True:
            from snipsmanager.commands.setup.speaker import SpeakerInstaller
            SpeakerInstaller(options).run()
        elif options['setup'] == True and options['systemd'] == True and options['bluetooth'] == True:
            from snipsmanager.commands.setup.systemd.bluetooth import SystemdBluetooth
            SystemdBluetooth(options).run()
        elif options['setup'] == True and options['systemd'] == True and options['skills'] == True:
            from snipsmanager.commands.setup.systemd.snipsmanager import Systemdsnipsmanager
            Systemdsnipsmanager(options).run()
        elif options['login'] == True:
            from snipsmanager.commands.session.login import Login
            Login(options).run()
        elif options['logout'] == True:
            from snipsmanager.commands.session.logout import Logout
            Logout(options).run()
        elif options['fetch'] == True and options['assistant'] == True:
            from snipsmanager.commands.assistant.fetch import AssistantFetcher
            AssistantFetcher(options).run()
        elif options['load'] == True and options['assistant'] == True:
            from snipsmanager.commands.assistant.load import AssistantLoader
            AssistantLoader(options).run()
        elif options['install'] == True and options['bluetooth'] == True:
            from snipsmanager.commands.install.bluetooth import BluetoothInstaller
            BluetoothInstaller(options).run()
        elif options['install'] == True and options['skill'] == True:
            from snipsmanager.commands.install.skill import SkillInstaller
            SkillInstaller(options).run()
        elif options['install'] == True and options['addon'] == True:
            from snipsmanager.commands.install.addon import AddonInstaller
            AddonInstaller(options).run()
        elif options['install'] == True and options['skills'] == True:
            from snipsmanager.commands.install.skills import SkillsInstaller
            SkillsInstaller(options).run()
        elif options['install'] == True:
            from snipsmanager.commands.install.install import GlobalInstaller
            GlobalInstaller(options).run()
    except KeyboardInterrupt:
        try:
            print("\n")
            pp.perror("Snips Manager installer interrupted")
            sys.exit(0)
        except SystemExit:
            os._exit(0)

    try:
        if options['run'] == True:
            from snipsmanager.commands.run import Runner
            Runner(options).run()
    except KeyboardInterrupt:
        try:
            print("\n")
            logger.error("Snips Manager server stopped")
            sys.exit(0)
        except SystemExit:
            os._exit(0)
示例#12
0
 def run(self):
     snipsfile_path = self.options['--snipsfile_path'] or os.getcwd()
     try:
         SystemdSnipsManager.setup(snipsfile_path=snipsfile_path)
     except Exception as e:
         pp.perror(str(e))
示例#13
0
 def run(self):
     try:
         Login.login(email=self.options['--email'],
                     password=self.options['--password'])
     except Exception as e:
         pp.perror("Error logging in: {}".format(str(e)))