diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 5bef6db..c42aae8 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -137,6 +137,8 @@ class CentralCommand(object): with open(lang_filename, 'r') as fp: self.languages[lang['code']] = json.load(fp) + self.future_language = list(self.languages.keys())[0] + def loadLightMap(self): if os.path.exists(self.lightMapFile): with open(self.lightMapFile) as fp: @@ -241,7 +243,8 @@ class CentralCommand(object): 'hugveys': [], 'logbookId': None, 'logbook': [], - 'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange() + 'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange(), + 'future_language': self.future_language, } #use this to test if any threads stay open @@ -272,6 +275,16 @@ class CentralCommand(object): nrOfStarts += 1 return nrOfStarts + def setFutureLanguage(self, lang_code): + """ + Set language for all future hugvey runs (so after a 'finish') + """ + self.timer.setMark('languageChange') + self.future_language = lang_code + for hv_id in self.hugveys: + if self.hugveys[hv_id].eventQueue: + self.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) + def setLoopTime(self, secondsAgo: int): self.timer.setMark('start', time.time() - secondsAgo) diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index 925ea98..f2a3ed4 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -150,10 +150,7 @@ def getWebSocketHandler(central_command): """ Set language for all future hugvey runs (so after a 'finish') """ - central_command.timer.setMark('languageChange') - for hv_id in central_command.hugveys: - if central_command.hugveys[hv_id].eventQueue: - central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) + central_command.setFutureLanguage(lang_code) def msgSetLoopTime(self, loop_time): parts = loop_time.split(":") diff --git a/www/index.html b/www/index.html index 7993027..e40da2d 100644 --- a/www/index.html +++ b/www/index.html @@ -16,13 +16,13 @@