From 67136506a4908d711f7e78530d9169613b424eea Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Sun, 20 Jun 2021 15:48:14 -0700 Subject: [PATCH] Improve backend selection system Use a string instead of changing the import line Related to #1 --- server/wss.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/wss.py b/server/wss.py index 8fcf608..a54fbce 100644 --- a/server/wss.py +++ b/server/wss.py @@ -1,9 +1,8 @@ -# Select backend - backends.port8080 uses HamClock's port 8080 service; -# backends.x11 uses an X11 server (typically Xvfb) (make sure DISPLAY is set -# correctly!) +# Select backend - 'port8080' uses HamClock's port 8080 service; 'x11' uses an +# X11 server (typically Xvfb) (make sure DISPLAY is set correctly!) -#import backends.port8080 as backend -import backends.x11 as backend +use_backend = 'x11' +# use_backend = 'port8080' import os @@ -17,9 +16,10 @@ import tornado.web, tornado.websocket, tornado.ioloop import imgproc as hcapi import argon2 import asyncio +import importlib -hcapi.backend = backend +hcapi.backend = importlib.import_module(f'backends.{use_backend}') ph = argon2.PasswordHasher()