MCPcopy
hub / github.com/borgbackup/borg / detect

Method detect

src/borg/crypto/key.py:388–409  ·  view source on GitHub ↗
(cls, repository, manifest_data, *, other=False)

Source from the content-addressed store, hash-verified

386
387 @classmethod
388 def detect(cls, repository, manifest_data, *, other=False):
389 key = cls(repository)
390 target = key.find_key()
391 prompt = "Enter passphrase for key %s: " % target
392 passphrase = Passphrase.env_passphrase(other=other)
393 if passphrase is None:
394 passphrase = Passphrase()
395 if not key.load(target, passphrase):
396 for retry in range(0, 3):
397 passphrase = Passphrase.getpass(prompt)
398 if key.load(target, passphrase):
399 break
400 Passphrase.display_debug_info(passphrase)
401 else:
402 raise PasswordRetriesExceeded
403 else:
404 if not key.load(target, passphrase):
405 Passphrase.display_debug_info(passphrase)
406 raise PassphraseWrong
407 key.init_ciphers(manifest_data)
408 key._passphrase = passphrase
409 return key
410
411 def _load(self, key_data, passphrase):
412 try:

Callers 13

parseMethod · 0.45
parseMethod · 0.45
key_factoryFunction · 0.45
test_keyfileMethod · 0.45
test_keyfile_kfenvMethod · 0.45
test_keyfile2Method · 0.45
test_keyfile2_kfenvMethod · 0.45
test_keyfile_blake2Method · 0.45
test_roundtripMethod · 0.45

Calls 7

PassphraseClass · 0.85
find_keyMethod · 0.80
env_passphraseMethod · 0.80
getpassMethod · 0.80
display_debug_infoMethod · 0.80
loadMethod · 0.45
init_ciphersMethod · 0.45

Tested by 9

test_keyfileMethod · 0.36
test_keyfile_kfenvMethod · 0.36
test_keyfile2Method · 0.36
test_keyfile2_kfenvMethod · 0.36
test_keyfile_blake2Method · 0.36
test_roundtripMethod · 0.36
test_key_file_roundtripFunction · 0.36