def main(args=None): if args is None: args = sys.argv[1:] arguments = docopt(__doc__, argv=args, version='encbup 0.1') if arguments["--verbose"]: logging.basicConfig(level=logging.DEBUG) if arguments["--passphrase"] is None: passphrase = getpass("Please enter a passphrase: ") passphrase_again = getpass("Please confirm the passphrase: ") if passphrase != passphrase_again: sys.exit("The passphrases don't match.") else: passphrase = arguments["--passphrase"] try: rounds = int(arguments["--rounds"]) except ValueError: sys.exit("Please enter an integer for the value of the rounds.") if arguments["--encrypt"]: key = Key(passphrase, arguments["--salt"], rounds=rounds) writer = Writer(arguments["<outfile>"]) writer.write_preamble(key) writer.write_files(key, arguments["<path>"]) elif arguments["--decrypt"]: reader = Reader(arguments["<infile>"], arguments["<directory>"]) reader.process_stream(passphrase)
def test_idempotence(self): writer = Writer(self.backup_filename) key = Key(self.passphrase, rounds=2) writer.write_preamble(key) writer.write_files(key, [self.source_dir]) reader = Reader(self.backup_filename, self.restore_dir) reader.process_stream(self.passphrase) self.assertTrue(self.is_restore_complete)