From 35c8975a5c6ea7d11be7018caf59f55dcf66a8d5 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Mon, 28 Aug 2017 10:15:38 +0200 Subject: [PATCH] keymanager: don't depend on optional readline module (cherry picked from commit b8793d9577da588d8167b7f15d4bc8209e771569) --- src/borg/crypto/keymanager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/borg/crypto/keymanager.py b/src/borg/crypto/keymanager.py index a997c0db6..aa657af95 100644 --- a/src/borg/crypto/keymanager.py +++ b/src/borg/crypto/keymanager.py @@ -142,8 +142,11 @@ class KeyManager: self.store_keyblob(args) def import_paperkey(self, args): - # imported here because it has global side effects - import readline + try: + # imported here because it has global side effects + import readline + except ImportError: + print('Note: No line editing available due to missing readline support') repoid = bin_to_hex(self.repository.id)[:18] try: @@ -151,8 +154,8 @@ class KeyManager: # id line input while True: idline = input('id: ').replace(' ', '') - if idline == "": - if yes("Abort import? [yN]:"): + if idline == '': + if yes('Abort import? [yN]:'): raise EOFError() try: @@ -184,8 +187,8 @@ class KeyManager: while True: inline = input('{0:2d}: '.format(idx)) inline = inline.replace(' ', '') - if inline == "": - if yes("Abort import? [yN]:"): + if inline == '': + if yes('Abort import? [yN]:'): raise EOFError() try: (data, checksum) = inline.split('-')