Beispiel #1
0
class FSServer():
    def __init__(self,config_file, settings_file):

        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        self.hardwareController = None
        self.config_file = config_file
        self.settings_file = settings_file



    def run(self):
        self._logger.info("FabScanPi-Server "+str(__version__))

        try:


            injector.provide_instance(FSEventManager, FSEventManager(), name="FSEventManager")

            # create Singleton instances
            _config = Config.instance(self.config_file)
            _settings = Settings.instance(self.settings_file)

            _hardwareController = HardwareController.instance()
            _eventManager = FSEventManager.instance()

            # Websocket Server
            self.fsWebSocketServer = FSWebSocketServer()
            self.fsWebSocketServer.start()

            _scanner = FSScanner()
            _scanner.start()

            # Web Server
            self.fsWebServer = WebServer()
            self.fsWebServer.start()

            while True:
                time.sleep(0.3)
            #self.fsWebServer.serve_forever()

        except (KeyboardInterrupt, SystemExit):

            time.sleep(0.5)
            _hardwareController.laser.off()
            _hardwareController.led.off()
            _hardwareController.turntable.stop_turning()

            sys.exit(0)
Beispiel #2
0
    def run(self):
        self._logger.info("FabScanPi-Server "+str(__version__))

        try:

            # create Singleton instances
            _config = Config.instance(self.config_file)
            _settings = Settings.instance(self.settings_file)

            _hardwareController = HardwareController.instance()
            _eventManager = FSEventManager.instance()

            # Websocket Server
            self.fsWebSocketServer = FSWebSocketServer()
            self.fsWebSocketServer.start()

            _scanner = FSScanner()
            _scanner.start()

            # Web Server
            self.fsWebServer = WebServer()
            self.fsWebServer.serve_forever()

        except (KeyboardInterrupt, SystemExit):

            time.sleep(0.5)
            _hardwareController.laser.off()
            _hardwareController.led.off()
            _hardwareController.turntable.stop_turning()

            sys.exit(0)
Beispiel #3
0
    def run(self):
        self._logger.info("FabScanPi-Server " + str(__version__))

        try:
            # inject "static" classed
            injector.provide(FSEventManagerInterface, FSEventManagerSingleton)
            injector.provide_instance(FSWebSocketServerInterface,
                                      FSWebSocketServer())
            injector.provide_instance(ConfigInterface,
                                      Config(self.config_file, True))

            injector.provide_instance(SettingsInterface,
                                      Settings(self.settings_file, True))

            # inject "dynamic" classes
            self.config = injector.get_instance(ConfigInterface)
            FSScannerFactory.injectScannerType(self.config.scanner_type)

            # start server services
            websocket_server = injector.get_instance(
                FSWebSocketServerInterface)
            websocket_server.start()

            webserver = FSWebServer()
            webserver.start()

            FSScanner().start()

            FSEventManagerSingleton().instance.subscribe(
                FSEvents.COMMAND, self.on_server_command)

            while not self.exit:
                try:
                    time.sleep(0.3)

                except KeyboardInterrupt:
                    raise

            if self.upgrade:
                self._logger.info("Upgrading FabScanPi Server")
                self.update_server()
                self.restart = True

            if self.restart:
                self._logger.info("Restarting FabScanPi Server")
                self.restart_server()
                self.exit = True

            self._logger.info("FabScan Server Exit. Bye!")
            os._exit(1)

        except (KeyboardInterrupt, SystemExit):
            sys.exit(0)
class FSServer():
    def __init__(self,config_file, settings_file):

        self._logger = logging.getLogger(__name__)
        #self._logger.setLevel(logging.INFO)
        self.hardwareController = None
        self.config_file = config_file
        self.settings_file = settings_file

    def run(self):

        try:
            # create Singleton instances

            _config = Config.instance(self.config_file)
            _settings = Settings.instance(self.settings_file)

            _hardwareController = HardwareController.instance()
            _eventManager = FSEventManager.instance()

            # Websocket Server
            self.fsWebSocketServer = FSWebSocketServer()
            self.fsWebSocketServer.start()

            _scanner = FSScanner()
            _scanner.start()

            # Web Server
            self.fsWebServer = WebServer()
            self.fsWebServer.serve_forever()

        except (KeyboardInterrupt, SystemExit):

            time.sleep(0.5)
            _hardwareController.laser.off()
            _hardwareController.led.off()
            _hardwareController.turntable.stop_turning()

            sys.exit(0)