Esempio n. 1
0
    def page_openapp(self, appname):
        # Check if another app is running, if so, run its stop function
        if self.server.activeapp == appname:
            return redirect("/apps/%s/" % appname)

        self.server.stop_current_app()

        if appname in self.server.apps:
            # robot_state:
            # 0: Manual start/stop
            # 1: Start robot automatically (alive feature according to preferences)
            # 2: Start robot automatically and enable alive feature
            # 3: Start robot automatically and disable alive feature
            if self.server.apps[appname].config.has_key('robot_state'):
                print_info(self.server.apps[appname].config['robot_state'])
                if self.server.apps[appname].config['robot_state'] > 0:
                    Robot.start()

            self.server.activeapp = appname

            try:
                print_appstarted(appname)
                self.server.apps[appname].start(self.server)
            except AttributeError:
                print_info("%s has no start function" % self.server.activeapp)

            return redirect("/apps/%s/" % appname)
        else:
            return redirect(url_for("index"))
Esempio n. 2
0
    def start(self, appname):
        if appname in self.active_apps:
            # already activated
            if not self.apps[appname].config['multi_user']:
                flash(
                    "This app can only be opened once, and is running elsewhere."
                )
                return False
        elif appname in self.background_apps:
            self.background_apps.remove(appname)
            self.active_apps.append(appname)
        else:
            if appname in self.apps:
                # robot activation:
                if self.apps[appname].config[
                        'activation'] >= Robot.Activation.AUTO:
                    Robot.start()

                self.active_apps.append(appname)

                try:
                    print_appstarted(appname)
                    self.apps[appname].start(self)
                except AttributeError:
                    print_info("%s has no start function" % appname)

            else:
                return False

        running_apps = []
        running_apps.extend(self.active_apps)
        running_apps.extend(self.background_apps)

        return True