def importKeyStoreCb(self, path, filename): if not filename or len(filename) < 1: return try: full = os.path.join(path, filename[0]) with open(full) as f: jsonKS = utils.readJsonStream(f) App.get_running_app().keyStore = \ key_store.KeyStore.readStoreFromJson(jsonKS) App.get_running_app().curSearchPath = path except (IOError, UnicodeDecodeError, ValueError, configparser.Error) as e: displayError(e) except KeyError: displayError(_("Malformed crypto container")) self.dismissPopup() self.buildKSTree()
def loadAESCb(self, path, filename): if not filename or len(filename) < 1: return try: full = os.path.join(path, filename[0]) with open(full) as f: if full.endswith(".json"): jsonAES = utils.readJsonStream(f) self.aesInput.text = jsonAES["base64AESKey"] else: self.aesInput.text = f.read() App.get_running_app().curSearchPath = path except (IOError, UnicodeDecodeError, ValueError) as e: displayError(e) except KeyError: displayError(_("No AES key in crypto container")) self.dismissPopup()
def load_state(filename): with open(filename, 'r') as f: stateJson = utils.readJsonStream(f) return ClusterState.readStateFromJson(stateJson)
lambda s: getAndVerifyReceiptURL(rv, s)), 'csv': lambda rv, inp: (singleInputToGenerator(inp), rv.verifyCSV) } if __name__ == "__main__": if len(sys.argv) < 3 or len(sys.argv) > 4: print("Usage: ./verify_receipt.py <format> <key store> [<receipt string>]") sys.exit(0) if sys.argv[1] not in INPUT_FORMATS: print(_("Input format must be one of %s.") % INPUT_FORMATS.keys()) sys.exit(0) rv = None with open(sys.argv[2], 'r') as f: data = utils.readJsonStream(f) keyStore = key_store.KeyStore.readStoreFromJson(data) rv = ReceiptVerifier.fromKeyStore(keyStore) if len(sys.argv) == 4: recs, ver = INPUT_FORMATS[sys.argv[1]](rv, sys.argv[3]) else: recs, ver = INPUT_FORMATS[sys.argv[1]](rv, sys.stdin) idx = 0 fails = 0 for r in recs: try: ver(r) except receipt.ReceiptException as e: fails += 1
usage() if chunksize < 0: usage() if len(sys.argv) < 3 or len(sys.argv) > 4: usage() # We allow this for backwards compatibility. if sys.argv[1] == 'json': del sys.argv[1] if len(sys.argv) != 3: usage() with open(sys.argv[1]) as f: jsonStore = utils.readJsonStream(f) key = utils.loadKeyFromJson(jsonStore) keyStore = key_store.KeyStore.readStoreFromJson(jsonStore) state = None if statePassthrough: state = verification_state.ClusterState.readStateFromJson( utils.readJsonStream(sys.stdin)) if continueLast: registerIdx = len(state.cashRegisters) - 1 if nprocs > 1: import multiprocessing pool = multiprocessing.Pool(nprocs)