Add logbuffer for file, don't save state on initial message, client should now continue after a fetch file crash
This commit is contained in:
parent
14d1e8c8ce
commit
1501b9f820
|
@ -191,9 +191,9 @@ class CentralCommand(object):
|
||||||
diffs = diff.total_seconds()
|
diffs = diff.total_seconds()
|
||||||
if diffs > 900:
|
if diffs > 900:
|
||||||
# evLogger.warning("Very long time since audience spoke")
|
# evLogger.warning("Very long time since audience spoke")
|
||||||
status['time_since_visitor_spoke'] = 'critical'
|
status['time_since_visitor_spoke_state'] = 'critical'
|
||||||
elif diffs > 1800:
|
elif diffs > 1800:
|
||||||
status['time_since_visitor_spoke'] = 'warning'
|
status['time_since_visitor_spoke_state'] = 'warning'
|
||||||
# else:
|
# else:
|
||||||
# #clear warning
|
# #clear warning
|
||||||
# pass
|
# pass
|
||||||
|
|
|
@ -294,6 +294,7 @@ class CommandHandler(object):
|
||||||
duration = cmd['duration'] if 'duration' in cmd else None
|
duration = cmd['duration'] if 'duration' in cmd else None
|
||||||
self.playingMsgId = msgId
|
self.playingMsgId = msgId
|
||||||
|
|
||||||
|
try:
|
||||||
if self.playPopen:
|
if self.playPopen:
|
||||||
logger.info("Interrupting playback of {}".format(self.playingMsgId))
|
logger.info("Interrupting playback of {}".format(self.playingMsgId))
|
||||||
self.playPopen.kill()
|
self.playPopen.kill()
|
||||||
|
@ -370,6 +371,10 @@ class CommandHandler(object):
|
||||||
logger.critical("Had returncode {} on play: {}\n\n{}\n{}".format(returnCode, playCmd, out, err))
|
logger.critical("Had returncode {} on play: {}\n\n{}\n{}".format(returnCode, playCmd, out, err))
|
||||||
else:
|
else:
|
||||||
logger.debug("Finished playback.")
|
logger.debug("Finished playback.")
|
||||||
|
except Exception as e:
|
||||||
|
# sometimes playback gives a timeout, then a playbackFinish still needs to be send to inform the server to continue
|
||||||
|
logger.critical("Exception during playing of message")
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
self.playingMsgId = None
|
self.playingMsgId = None
|
||||||
self.muteMic = False
|
self.muteMic = False
|
||||||
|
|
|
@ -1317,6 +1317,7 @@ class Story(object):
|
||||||
self.variables = {}
|
self.variables = {}
|
||||||
self.variableValues = {} # captured variables from replies
|
self.variableValues = {} # captured variables from replies
|
||||||
self.runId = uuid.uuid4().hex
|
self.runId = uuid.uuid4().hex
|
||||||
|
self.currentLightPresetNr = None
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
self.logger.debug('pause hugvey')
|
self.logger.debug('pause hugvey')
|
||||||
|
@ -1810,8 +1811,6 @@ class Story(object):
|
||||||
message.id, message.getText()))
|
message.id, message.getText()))
|
||||||
if message.id != self.startMessage.id:
|
if message.id != self.startMessage.id:
|
||||||
self.addToLog(message)
|
self.addToLog(message)
|
||||||
else:
|
|
||||||
self.logger.debug("Not counting start message")
|
|
||||||
|
|
||||||
self.hugvey.eventLogger.info(f"message: {message.id} {message.uuid} start \"{message.getText()}\"")
|
self.hugvey.eventLogger.info(f"message: {message.id} {message.uuid} start \"{message.getText()}\"")
|
||||||
|
|
||||||
|
@ -1856,6 +1855,8 @@ class Story(object):
|
||||||
logmsg += "\n- {0} -> {1} (when: {2}) ".format(direction.msgFrom.id, direction.msgTo.id, conditions)
|
logmsg += "\n- {0} -> {1} (when: {2}) ".format(direction.msgFrom.id, direction.msgTo.id, conditions)
|
||||||
|
|
||||||
self.logger.log(LOG_BS,logmsg)
|
self.logger.log(LOG_BS,logmsg)
|
||||||
|
|
||||||
|
if message.id != self.startMessage.id:
|
||||||
self.storeState()
|
self.storeState()
|
||||||
|
|
||||||
def fadeLightPreset(self, presetNr: int):
|
def fadeLightPreset(self, presetNr: int):
|
||||||
|
@ -1864,6 +1865,7 @@ class Story(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
preset = self.configuration.getLightPresets()[presetNr]
|
preset = self.configuration.getLightPresets()[presetNr]
|
||||||
|
self.currentLightPresetNr = presetNr
|
||||||
|
|
||||||
self.hugvey.transitionLight(preset['intensity'], preset['fade'])
|
self.hugvey.transitionLight(preset['intensity'], preset['fade'])
|
||||||
|
|
||||||
|
@ -2048,7 +2050,8 @@ class Story(object):
|
||||||
os.fsync(fp.fileno())
|
os.fsync(fp.fileno())
|
||||||
|
|
||||||
os.rename(tmpfn, fn)
|
os.rename(tmpfn, fn)
|
||||||
self.logger.debug(f"saved state to {fn}")
|
duration = time.time() - self.stateSave
|
||||||
|
self.logger.debug(f"saved state to {fn} in {duration}s")
|
||||||
|
|
||||||
def hasSavedState(self):
|
def hasSavedState(self):
|
||||||
return self.hugveyHasSavedState(self.hugvey.lightId)
|
return self.hugveyHasSavedState(self.hugvey.lightId)
|
||||||
|
@ -2067,7 +2070,9 @@ class Story(object):
|
||||||
#: :type story: Story
|
#: :type story: Story
|
||||||
story.logger = mainLogger.getChild(f"{story.hugvey.id}").getChild("story")
|
story.logger = mainLogger.getChild(f"{story.hugvey.id}").getChild("story")
|
||||||
# TODO: this is not really working because it is overridden by the set-status later.
|
# TODO: this is not really working because it is overridden by the set-status later.
|
||||||
story.hugvey.setLightStatus(story.lightStateSave)
|
# story.hugvey.setLightStatus(story.lightStateSave)
|
||||||
|
if story.currentLightPresetNr is not None:
|
||||||
|
story.fadeLightPreset(story.currentLightPresetNr)
|
||||||
return story
|
return story
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue