def run(self): if not self._allowRoot: self._checkForRoot() global userManager global eventManager global loginManager global debug global softwareManager global VERSION from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler from astroprint.printfiles.watchdogs import UploadCleanupWatchdogHandler debug = self._debug # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) s = settings() # then initialize logging self._initLogging(self._debug, self._logConf) logger = logging.getLogger(__name__) if s.getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception("Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): # Global as I can't work out a way to get it into PrinterStateConnection global printer global gcodeManager global userManager from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) # then initialize logging self._initLogging(self._debug) logger = logging.getLogger(__name__) gcodeManager = gcodefiles.GcodeManager() printer = Printer(gcodeManager) if settings().getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception("Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): # Global as I can't work out a way to get it into PrinterStateConnection global printer global gcodeManager global userManager from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) # then initialize logging self._initLogging(self._debug) logger = logging.getLogger(__name__) gcodeManager = gcodefiles.GcodeManager() printer = Printer(gcodeManager) if settings().getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception( "Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global printer global gcodeManager global userManager global eventManager global loginManager global networkManager global debug global softwareManager global VERSION from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler debug = self._debug # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) s = settings() # then initialize logging self._initLogging(self._debug, self._logConf) logger = logging.getLogger(__name__) softwareManager = swManager() VERSION = softwareManager.versionString logger.info("Starting OctoPrint (%s)" % VERSION) softwareManager.checkForcedUpdate() eventManager = events.eventManager() gcodeManager = gcodefiles.GcodeManager() printer = Printer(gcodeManager) # configure timelapse octoprint.timelapse.configureTimelapse() # setup command triggers events.CommandTrigger(printer) if self._debug: events.DebugEventListener() if s.getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception("Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global printer global gcodeManager global userManager global eventManager global loginManager global debug global wifiManager from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler debug = self._debug # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) # then initialize logging self._initLogging(self._debug) logger = logging.getLogger(__name__) logger.info("Starting OctoPrint %s" % DISPLAY_VERSION) eventManager = events.eventManager() gcodeManager = gcodefiles.GcodeManager() printer = Printer(gcodeManager) wifiManager = wifi.WifiManager(printer) # configure timelapse octoprint.timelapse.configureTimelapse() # setup command triggers events.CommandTrigger(printer) if self._debug: events.DebugEventListener() if settings().getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception( "Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global printer global gcodeManager global userManager global eventManager global loginManager global debug from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler debug = self._debug # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) # then initialize logging self._initLogging(self._debug) logger = logging.getLogger(__name__) eventManager = events.eventManager() gcodeManager = gcodefiles.GcodeManager() gpioManager = gpio.gpioManager() monitorManager = monitor.monitorManager() printer = Printer(gcodeManager) gpioManager.setPrinter(printer) monitorManager.setPrinter(printer) # configure timelapse octoprint.timelapse.configureTimelapse() # setup system and gcode command triggers events.SystemCommandTrigger(printer) events.GcodeCommandTrigger(printer) events.SerialMonitor(printer) if self._debug: events.DebugEventListener() if settings().getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception("Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global userManager global eventManager global loginManager global debug global softwareManager global discoveryManager global VERSION global UI_API_KEY from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler from astroprint.printfiles.watchdogs import UploadCleanupWatchdogHandler from astroprint.printfiles.watchdogs import EtherBoxHandler debug = self._debug # first initialize the settings singleton and make sure it # uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) s = settings() if not s.getBoolean(['api', 'regenerate']) and s.getString( ['api', 'key']): UI_API_KEY = s.getString(['api', 'key']) else: UI_API_KEY = ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes) # then initialize logging self._initLogging(self._debug, self._logConf) logger = logging.getLogger(__name__) if s.getBoolean(["accessControl", "enabled"]): userManagerName = s.get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception( "Could not instantiate user manager %s, will run " "with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global printer global gcodeManager global userManager global eventManager global loginManager global networkManager global debug global softwareManager global VERSION from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler debug = self._debug # first initialize the settings singleton and make sure it uses given configfile and basedir if available self._initSettings(self._configfile, self._basedir) s = settings() # then initialize logging self._initLogging(self._debug, self._logConf) logger = logging.getLogger(__name__) if s.getBoolean(["accessControl", "enabled"]): userManagerName = settings().get(["accessControl", "userManager"]) try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError, e: logger.exception( "Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName)
def run(self): if not self._allowRoot: self._checkForRoot() global gcodeManager global userManager global eventManager global loginManager global debug from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import Application, FallbackHandler debug = self._debug # then initialize logging self._initLogging(self._debug) logger = logging.getLogger(__name__) eventManager = events.eventManager() gcodeManager = gcodefiles.GcodeManager() self.printer = Printer(gcodeManager) # configure timelapse octoprint.timelapse.configureTimelapse() # setup system and gcode command triggers events.SystemCommandTrigger(self.printer) events.GcodeCommandTrigger(self.printer) if self._debug: events.DebugEventListener() if settings.get("access_control", "enabled"): userManagerName = settings.get("access_control", "user_manager") try: clazz = util.getClass(userManagerName) userManager = clazz() except AttributeError as e: logger.exception( "Could not instantiate user manager %s, will run with accessControl disabled!" % userManagerName) app.wsgi_app = ReverseProxied(app.wsgi_app) app.secret_key = settings.get('server', 'secret_key') if not app.secret_key: raise NoSecretKeyError() loginManager = LoginManager() loginManager.session_protection = "strong" loginManager.user_callback = load_user if userManager is None: loginManager.anonymous_user = users.DummyUser principals.identity_loaders.appendleft(users.dummy_identity_loader) loginManager.init_app(app) if self._host is None: self._host = settings.get("server", "host") if self._port is None: self._port = settings.get("server", "port") logger.info("Listening on http://%s:%d" % (self._host, self._port)) app.debug = self._debug from octoprint.server.ajax import ajax from octoprint.server.api import api app.register_blueprint(ajax, url_prefix="/ajax") app.register_blueprint(api, url_prefix="/api") self._router = SockJSRouter(self._createSocketConnection, "/sockjs") self._tornado_app = Application(self._router.urls + [ (r"/downloads/timelapse/([^/]*\.mpg)", LargeResponseHandler, { "path": settings.getpath("timelapse"), "as_attachment": True}), (r"/downloads/gcode/([^/]*\.(gco|gcode))", LargeResponseHandler, { "path": settings.getpath("uploads"), "as_attachment": True}), (r".*", FallbackHandler, {"fallback": WSGIContainer(app.wsgi_app)}) ]) self._server = HTTPServer(self._tornado_app) self._server.listen(self._port, address=self._host) eventManager.fire("Startup") if settings.get("serial", "autoconnect"): port, baudrate = (settings.get('serial', e) for e in ('port', 'baudrate')) connectionOptions = getConnectionOptions() if port in connectionOptions["ports"]: self.printer.connect(port, baudrate) try: IOLoop.instance().start() except: logger.fatal( "Now that is embarrassing... Something really really went" "wrong here. Please report this including the stacktrace below" "in OctoPrint's bugtracker. Thanks!") logger.exception("Stacktrace follows:")