def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) if (s.getBoolean(["server", "firstRun"])): # we need to get the user to sign into their AstroPrint account return render_template("setup.jinja2", debug=debug, uiApiKey=UI_API_KEY, version=VERSION, variantData=variantManager().data, astroboxName=networkManager().getHostname(), settings=s) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey=UI_API_KEY, showForceUpdate=softwareManager.forceUpdateInfo != None, releaseInfo=softwareManager.updatingRelease or softwareManager.forceUpdateInfo, lastCompletionPercent=softwareManager.lastCompletionPercent, lastMessage=softwareManager.lastMessage, variantData=variantManager().data, astroboxName=networkManager().getHostname()) elif loggedUsername and (current_user is None or not current_user.is_authenticated() or current_user.get_id() != loggedUsername): if current_user.is_authenticated(): logout_user() return render_template("locked.jinja2", username=loggedUsername, uiApiKey=UI_API_KEY, astroboxName=networkManager().getHostname(), variantData=variantManager().data) else: pm = printerManager() nm = networkManager() paused = pm.isPaused() printing = pm.isPrinting() online = nm.isOnline() return render_template("app.jinja2", user_email=loggedUsername, version=VERSION, printing=printing, paused=paused, online=online, print_capture=cameraManager().timelapseInfo if printing or paused else None, printer_profile=printerProfileManager().data, uiApiKey=UI_API_KEY, astroboxName=nm.getHostname(), variantData=variantManager().data, serialLogActive=s.getBoolean(['serial', 'log']))
def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) if (s.getBoolean(["server", "firstRun"])): # we need to get the user to sign into their AstroPrint account return render_template( "setup.jinja2", debug= debug, uiApiKey= UI_API_KEY, version= VERSION, variantData= variantManager().data, astroboxName= networkManager.getHostname(), settings=s ) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey= UI_API_KEY, showForceUpdate= softwareManager.forceUpdateInfo != None, releaseInfo= softwareManager.updatingRelease or softwareManager.forceUpdateInfo, variantData= variantManager().data, astroboxName= networkManager.getHostname() ) elif loggedUsername and (current_user is None or not current_user.is_authenticated() or current_user.get_id() != loggedUsername): if current_user.is_authenticated(): logout_user() return render_template( "locked.jinja2", username= loggedUsername, uiApiKey= UI_API_KEY, astroboxName= networkManager.getHostname(), variantData= variantManager().data ) else: paused = printer.isPaused() printing = printer.isPrinting() online = networkManager.isOnline() return render_template( "app.jinja2", user_email= loggedUsername, version= VERSION, printing= printing, paused= paused, online= online, print_capture= cameraManager().timelapseInfo if printing or paused else None, printer_profile= printerProfileManager().data, uiApiKey= UI_API_KEY, astroboxName= networkManager.getHostname(), variantData= variantManager().data )
def index(): s = settings() if (s.getBoolean(["server", "firstRun"])): # we need to get the user to sign into their AstroPrint account return render_template( "setup.jinja2", debug= debug, uiApiKey= UI_API_KEY, version= VERSION, variantData= variantManager().data ) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey= UI_API_KEY, showForceUpdate= softwareManager.forceUpdateInfo != None, releaseInfo= softwareManager.updatingRelease or softwareManager.forceUpdateInfo, variantData= variantManager().data ) else: paused = printer.isPaused() printing = printer.isPrinting() return render_template( "app.jinja2", user_email= s.get(["cloudSlicer", "email"]), version= VERSION, printing= printing, paused= paused, print_capture= cameraManager().timelapseInfo if printing or paused else None, printer_profile= printerProfileManager().data, uiApiKey= UI_API_KEY, astroboxName= networkManager.getHostname(), variantData= variantManager().data )
def __init__(self): self._eventManager = eventManager() self.logger = logging.getLogger(__name__) self.variantMgr = variantManager() self.softwareMgr = softwareManager() # upnp/ssdp self._ssdp_monitor_active = False self._ssdp_monitor_thread = None self._ssdp_notify_timeout = 10 self._ssdp_last_notify = 0 self._ssdp_last_unregister = 0 # SSDP if networkManager().isOnline(): self._ssdp_register() self._eventManager.subscribe(Events.NETWORK_STATUS, self._onNetworkStateChanged)
def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) publicKey = None if loggedUsername: user = userManager.findUser(loggedUsername) if user: publicKey = user.publicKey if (s.getBoolean(["server", "firstRun"])): swm = swManager() # we need to get the user to sign into their AstroPrint account return render_template("setup.jinja2", debug=debug, uiApiKey=UI_API_KEY, version=VERSION, commit=swm.commit, variantData=variantManager().data, astroboxName=networkManager().getHostname(), checkSoftware=swm.shouldCheckForNew, settings=s, wsToken=create_ws_token(publicKey)) elif softwareManager.status != 'idle' or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey=UI_API_KEY, forceUpdateInfo=softwareManager.forceUpdateInfo, releases=softwareManager.updatingReleases or [softwareManager.forceUpdateInfo['id']], lastCompletionPercent=softwareManager.lastCompletionPercent, lastMessage=softwareManager.lastMessage, variantData=variantManager().data, astroboxName=networkManager().getHostname(), wsToken=create_ws_token(publicKey), status=softwareManager.status) elif loggedUsername and (current_user is None or not current_user.is_authenticated or current_user.get_id() != loggedUsername): if current_user.is_authenticated: logout_user() return render_template("locked.jinja2", username=loggedUsername, uiApiKey=UI_API_KEY, astroboxName=networkManager().getHostname(), variantData=variantManager().data) else: pm = printerManager() nm = networkManager() swm = swManager() cm = cameraManager() paused = pm.isPaused() printing = pm.isPrinting() online = nm.isOnline() return render_template( "app.jinja2", user_email=loggedUsername, show_bad_shutdown=swm.wasBadShutdown and not swm.badShutdownShown, version=VERSION, commit=swm.commit, printing=printing, paused=paused, online=online, print_capture=cm.timelapseInfo if printing or paused else None, printer_profile=printerProfileManager().data, uiApiKey=UI_API_KEY, astroboxName=nm.getHostname(), variantData=variantManager().data, checkSoftware=swm.shouldCheckForNew, serialLogActive=s.getBoolean(['serial', 'log']), cameraManager=cm.name, wsToken=create_ws_token(publicKey))
def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) networkManager().setHostname('Ray') if (loggedUsername and (current_user is None or not current_user.is_authenticated or current_user.get_id() != loggedUsername)): user = octoprint.server.userManager.findUser(loggedUsername) if user is not None: login_user(user, remember=True) identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id())) if (s.getBoolean(["server", "firstRun"])): swm = swManager() # we need to get the user to sign into their AstroPrint account wstoken = create_ws_token( userManager.findUser(loggedUsername). publicKey if loggedUsername else None) # Toran's changes # jsonifying for exposing the view as REST API # return Response( # json.dumps( # { # 'debug': debug, # 'uiApiKey': UI_API_KEY, # 'version': VERSION, # 'commit': swm.commit, # 'variantData': variantManager().data, # 'astroboxName': networkManager().getHostname(), # 'checkSoftware': swm.shouldCheckForNew, # 'settings': s, # class instance # 'wsToken': wstoken # }, # sort_keys=False, # indent=4), # mimetype='application/json', # headers={'Access-Control-Allow-Origin': '*'}) return render_template( "setup.jinja2", debug=debug, uiApiKey=UI_API_KEY, version=VERSION, commit=swm.commit, variantData=variantManager().data, astroboxName=networkManager().getHostname(), checkSoftware=swm.shouldCheckForNew, settings=s, wsToken=wstoken, ) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: # Toran's changes # jsonifying for exposing the view as REST API # return Response( # json.dumps( # { # 'uiApiKey': UI_API_KEY, # 'showForceUpdate': softwareManager.forceUpdateInfo != None, # 'releaseInfo': softwareManager.updatingRelease or softwareManager.forceUpdateInfo, # 'lastCompletionPercent': softwareManager.lastCompletionPercent, # 'lastMessage': softwareManager.lastMessage, # 'variantData': variantManager().data, # dict # 'astroboxName': networkManager().getHostname(), # 'wsToken': # create_ws_token( # userManager.findUser(loggedUsername).publicKey # if loggedUsername else None) # }, # sort_keys=False, # indent=4), # mimetype='application/json', # headers = {'Access-Control-Allow-Origin': '*'}) return render_template( "updating.jinja2", uiApiKey=UI_API_KEY, showForceUpdate=softwareManager.forceUpdateInfo != None, releaseInfo=softwareManager.updatingRelease or softwareManager.forceUpdateInfo, lastCompletionPercent=softwareManager.lastCompletionPercent, lastMessage=softwareManager.lastMessage, variantData=variantManager().data, astroboxName=networkManager().getHostname(), wsToken=create_ws_token( userManager.findUser(loggedUsername). publicKey if loggedUsername else None)) else: pm = printerManager() nm = networkManager() swm = swManager() cm = cameraManager() paused = pm.isPaused() printing = pm.isPrinting() online = nm.isOnline() # Toran's changes # jsonifying for exposing the view as REST API # return Response( # json.dumps( # { # 'user_email': loggedUsername, # 'show_bad_shutdown': swm.wasBadShutdown and not swm.badShutdownShown, # 'version': VERSION, # 'commit': swm.commit, # 'printing': printing, # 'paused': paused, # 'online': online, # 'print_capture': cm.timelapseInfo if printing or paused else None, # 'printer_profile': printerProfileManager().data, # 'uiApiKey': UI_API_KEY, # 'astroboxName': nm.getHostname(), # 'variantData': variantManager().data, # dict # 'checkSoftware': swm.shouldCheckForNew, # 'serialLogActive': s.getBoolean(['serial', 'log']), # 'cameraManager': cm.name, # 'wsToken': create_ws_token( # userManager.findUser(loggedUsername).publicKey \ # if loggedUsername else None), # }, # sort_keys=False, # indent=4 # ), # mimetype='application/json', # headers = {'Access-Control-Allow-Origin': '*'} # ) return render_template( "app.jinja2", user_email=loggedUsername, show_bad_shutdown=swm.wasBadShutdown and not swm.badShutdownShown, version=VERSION, commit=swm.commit, printing=printing, paused=paused, online=online, print_capture=cm.timelapseInfo if printing or paused else None, printer_profile=printerProfileManager().data, uiApiKey=UI_API_KEY, astroboxName=nm.getHostname(), variantData=variantManager().data, # dict checkSoftware=swm.shouldCheckForNew, serialLogActive=s.getBoolean(['serial', 'log']), cameraManager=cm.name, wsToken=create_ws_token( userManager.findUser(loggedUsername).publicKey \ if loggedUsername else None) )
def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) networkManager().setHostname('Ray') if (loggedUsername and (current_user is None or \ not current_user.is_authenticated or \ current_user.get_id() != loggedUsername)): user = octoprint.server.userManager.findUser(loggedUsername) if user is not None: login_user(user, remember=True) identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id())) if (s.getBoolean(["server", "firstRun"])): swm = swManager() # we need to get the user to sign into their AstroPrint account wstoken = create_ws_token( userManager.findUser(loggedUsername).publicKey \ if loggedUsername else None) return render_template( "setup.jinja2", debug=debug, uiApiKey=UI_API_KEY, version=VERSION, commit=swm.commit, variantData=variantManager().data, astroboxName=networkManager().getHostname(), checkSoftware=swm.shouldCheckForNew, settings=s, wsToken=wstoken, ) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey=UI_API_KEY, showForceUpdate=softwareManager.forceUpdateInfo != None, releaseInfo=softwareManager.updatingRelease or softwareManager.forceUpdateInfo, lastCompletionPercent=softwareManager.lastCompletionPercent, lastMessage=softwareManager.lastMessage, variantData=variantManager().data, astroboxName=networkManager().getHostname(), wsToken=create_ws_token(userManager.findUser(loggedUsername).publicKey if loggedUsername else None) ) else: pm = printerManager() nm = networkManager() swm = swManager() cm = cameraManager() paused = pm.isPaused() printing = pm.isPrinting() online = nm.isOnline() return render_template( "app.jinja2", user_email=loggedUsername, show_bad_shutdown=swm.wasBadShutdown and not swm.badShutdownShown, version=VERSION, commit=swm.commit, printing=printing, paused=paused, online=online, print_capture=cm.timelapseInfo if printing or paused else None, printer_profile=printerProfileManager().data, uiApiKey=UI_API_KEY, astroboxName=nm.getHostname(), variantData=variantManager().data, checkSoftware=swm.shouldCheckForNew, serialLogActive=s.getBoolean(['serial', 'log']), cameraManager=cm.name, wsToken=create_ws_token( userManager.findUser(loggedUsername).publicKey \ if loggedUsername else None) )
def index(): s = settings() loggedUsername = s.get(["cloudSlicer", "loggedUser"]) if (s.getBoolean(["server", "firstRun"])): swm = swManager() # we need to get the user to sign into their AstroPrint account return render_template( "setup.jinja2", debug= debug, uiApiKey= UI_API_KEY, version= VERSION, commit= swm.commit, variantData= variantManager().data, astroboxName= networkManager().getHostname(), checkSoftware= swm.shouldCheckForNew, settings=s ) elif softwareManager.updatingRelease or softwareManager.forceUpdateInfo: return render_template( "updating.jinja2", uiApiKey= UI_API_KEY, showForceUpdate= softwareManager.forceUpdateInfo != None, releaseInfo= softwareManager.updatingRelease or softwareManager.forceUpdateInfo, lastCompletionPercent= softwareManager.lastCompletionPercent, lastMessage= softwareManager.lastMessage, variantData= variantManager().data, astroboxName= networkManager().getHostname() ) elif loggedUsername and (current_user is None or not current_user.is_authenticated() or current_user.get_id() != loggedUsername): if current_user.is_authenticated(): logout_user() return render_template( "locked.jinja2", username= loggedUsername, uiApiKey= UI_API_KEY, astroboxName= networkManager().getHostname(), variantData= variantManager().data ) else: pm = printerManager() nm = networkManager() swm = swManager() cm = cameraManager() paused = pm.isPaused() printing = pm.isPrinting() online = nm.isOnline() return render_template( "app.jinja2", user_email= loggedUsername, version= VERSION, commit= swm.commit, printing= printing, paused= paused, online= online, print_capture= cm.timelapseInfo if printing or paused else None, printer_profile= printerProfileManager().data, uiApiKey= UI_API_KEY, astroboxName= nm.getHostname(), variantData= variantManager().data, checkSoftware= swm.shouldCheckForNew, serialLogActive= s.getBoolean(['serial', 'log']), cameraManager= cm.name )