try: args = parser.parse_args() except Exception as ex: print 'Error parsing arguments: {0}'.format(ex) exit(1) if args.encrypt and args.decrypt: print 'Only either encrypt or decrypt are valid at once' exit(1) if not args.encrypt and not args.decrypt: print 'Missing encrypt/decrypt option' exit(1) if args.encrypt: passphrase = ask_for_passphrase('Passphrase to use: ') if passphrase is None: print 'Aborted' exit(1) passphrase2 = ask_for_passphrase('Repeat passphrase: ') if passphrase != passphrase2: print 'Passphrases are different' exit(1) try: data = open(args.path).read() print encrypt(data, passphrase) except Exception as ex: print 'Error during encryption: {0}'.format(ex) else: passphrase = ask_for_passphrase('Passphrase used for encryption: ') try:
parser.add_argument('-d', '--decrypt', action='store_true', help='decrypt the configuration file') parser.add_argument('-e', '--exchange', action='store', help='specify the exchange to use. Only needed if the '\ 'config file has multiple') try: args = parser.parse_args() except Exception as ex: print 'Error parsing arguments: {0}'.format(ex) exit(1) if args.decrypt: passphrase = ask_for_passphrase( 'Configuration file decryption passphrase: ') if passphrase is None: print 'Configuration file decryption passphrase is required' exit(1) config_manager = ConfigManager() try: if args.decrypt: config_manager.load_encrypted(args.config, passphrase) else: config_manager.load(args.config) except Exception as ex: print 'Error parsing config: {0}'.format(ex) exit(1) try: