def change_status(self): """Manually change the status of the BITS system""" with session_scope() as session: curstatus = query.get_current_status(session) if curstatus is None: textstatus = Status.CLOSED else: textstatus = Status.OPEN if curstatus.value == Status.CLOSED else Status.CLOSED LOG.info('Change of BITS to status=%r from web interface.', textstatus) message = '' try: status = query.log_status(session, textstatus, 'web') broadcast(status.jsondict()) notifier.send_status(textstatus) message = "Ora la sede è {}.".format(textstatus) except IntegrityError: LOG.error("Status changed too quickly, not logged.") message = "Errore: modifica troppo veloce!" raise finally: self.render( 'templates/admin.html', page_message=message, roster=MACUpdateHandler.ROSTER )
def change_status(self): """Manually change the status of the BITS system""" with session_scope() as session: curstatus = query.get_current_status(session) if curstatus is None: textstatus = Status.CLOSED else: textstatus = Status.OPEN if curstatus.value == Status.CLOSED else Status.CLOSED LOG.info('Change of BITS to status={}'.format(textstatus) + ' from web interface.') message = '' try: status = query.log_status(session, textstatus, 'web') broadcast(status.jsondict()) notifier.send_status(textstatus) message = "Ora la sede è {}.".format(textstatus) except IntegrityError: LOG.error("Status changed too quickly, not logged.") message = "Errore: modifica troppo veloce!" raise finally: self.render('templates/admin.html', page_message=message)
def handle_status_command(status): """Update status. Will reject two identical and consecutive updates (prevents opening when already open and vice-versa).""" LOG.info('Received status: %r', status) try: status = int(status) except ValueError: LOG.error('Wrong type for parameters in temperature command') return if status not in (0, 1): LOG.error('Non existent status %r, ignoring.', status) return textstatus = Status.OPEN if status == 1 else Status.CLOSED with session_scope() as session: curstatus = query.get_current_status(session) if curstatus is None or curstatus.value != textstatus: status = query.log_status(session, textstatus, 'BITS') broadcast(status.jsondict()) notifier.send_status(textstatus) else: LOG.error('BITS already open/closed! Ignoring.')
def handle_status_command(status): """Update status. Will reject two identical and consecutive updates (prevents opening when already open and vice-versa).""" LOG.info('Received status: {}'.format(status)) try: status = int(status) except ValueError: LOG.error('Wrong type for parameters in temperature command') return if status not in (0, 1): LOG.error('Non existent status {}, ignoring.'.format(status)) return textstatus = Status.OPEN if status == 1 else Status.CLOSED with session_scope() as session: curstatus = query.get_current_status(session) if curstatus is None or curstatus.value != textstatus: status = query.log_status(session, textstatus, 'BITS') broadcast(status.jsondict()) notifier.send_status(textstatus) else: LOG.error('BITS already open/closed! Ignoring.')