Ejemplo n.º 1
0
    def run(self, appdaemon, hadashboard):

        loop = asyncio.get_event_loop()

        # Initialize AppDaemon

        self.AD = ad.AppDaemon(self.logger, self.error, self.diag, loop,
                               **appdaemon)

        # Initialize Dashboard/API

        if hadashboard["dashboard"] is True:
            self.log(self.logger, "INFO", "Starting Dashboards")
            self.rundash = rundash.RunDash(self.AD, loop, self.logger,
                                           self.access, **hadashboard)
            self.AD.register_dashboard(self.rundash)
        else:
            self.log(self.logger, "INFO", "Dashboards are disabled")

        if "api_port" in appdaemon:
            self.log(self.logger, "INFO", "Starting API")
            self.api = api.ADAPI(self.AD, loop, self.logger, self.access,
                                 **appdaemon)
        else:
            self.log(self.logger, "INFO", "API is disabled")

        self.log(self.logger, "DEBUG", "Start Loop")

        pending = asyncio.Task.all_tasks()
        loop.run_until_complete(asyncio.gather(*pending))

        self.log(self.logger, "DEBUG", "End Loop")

        self.log(self.logger, "INFO", "AppDeamon Exited")
Ejemplo n.º 2
0
    def run(self, appdaemon, hadashboard):

        try:
            loop = asyncio.get_event_loop()

            # Initialize AppDaemon

            self.AD = ad.AppDaemon(self.logger, self.error, self.diag, loop,
                                   **appdaemon)

            # Initialize Dashboard/API

            if hadashboard["dashboard"] is True:
                self.log(self.logger, "INFO", "Starting Dashboards")
                self.rundash = rundash.RunDash(self.AD, loop, self.logger,
                                               self.access, **hadashboard)
                self.AD.register_dashboard(self.rundash)
            else:
                self.log(self.logger, "INFO", "Dashboards are disabled")

            if "api_port" in appdaemon:
                self.log(self.logger, "INFO", "Starting API")
                self.api = api.ADAPI(self.AD, loop, self.logger, self.access,
                                     **appdaemon)
            else:
                self.log(self.logger, "INFO", "API is disabled")

            # Lets hide the admin interface for now

            #if "admin_port" in appdaemon:
            #    self.log(self.logger, "INFO", "Starting Admin Interface")
            #    self.runadmin = runadmin.RunAdmin(self.AD, loop, self.logger, self.access, **appdaemon)
            #else:
            #    self.log(self.logger, "INFO", "Admin Interface is disabled")

            self.log(self.logger, "DEBUG", "Start Loop")

            pending = asyncio.Task.all_tasks()
            loop.run_until_complete(asyncio.gather(*pending))
        except:
            self.log(self.logger, "WARNING", '-' * 60)
            self.log(self.logger, "WARNING", "Unexpected error during run()")
            self.log(self.logger, "WARNING", '-' * 60)
            self.log(self.logger, "WARNING", traceback.format_exc())
            self.log(self.logger, "WARNING", '-' * 60)

        self.log(self.logger, "DEBUG", "End Loop")

        self.log(self.logger, "INFO", "AppDeamon Exited")
Ejemplo n.º 3
0
    def get_ad_api(self):
        api = adapi.ADAPI(self.AD, self.name, self._logging, self.args,
                          self.config, self.app_config, self.global_vars)

        return api