def _onQRCodeDetected(self, value): self.logger.info("QRCode detected : %s" % value) self._unsubscribeToQRCodeReader() try: barcodestr = value[0][0] decrypted = simple_encryption.decrypt(barcodestr, self.cnonce) if decrypted.count(';') >= 2: self.logger.info("QR code received, processing...") self.status(ALQRCodeWifiConfigurator.STATUS_QRCODEDETECTED) self._playSound("end_reco.wav") self._setup_wifi(decrypted) else: self.almemory.raiseEvent("BootConfig/QrState", "Error") self.status(ALQRCodeWifiConfigurator.STATUS_ERROR) self.logger.info( "Invalid QR code, please show again; nonce = %i" % self.cnonce) self._playSound("bip_gentle.wav") except Exception as e: self.almemory.raiseEvent("BootConfig/QrState", "Error") self.status(ALQRCodeWifiConfigurator.STATUS_ERROR) self._playSound("bip_gentle.wav") self.logger.error( "Unexpected QR code: (%s), please show again; nonce = %i" % (repr(value), self.cnonce))
def test_61(self): result = decrypt(None, 0) self.assertEqual(result, None)
def test_5(self): result = decrypt("hsi etTi sats!", 1) self.assertEqual(result, "This is a test!")
def test_6(self): result = decrypt("s eT ashi tist!", 2) self.assertEqual(result, "This is a test!")
def test_4(self): result = decrypt("This is a test!", 0) self.assertEqual(result, "This is a test!")