(params, skip_init=False, suppress_goodbye=False, new_login=False)
| 870 | |
| 871 | |
| 872 | def loop(params, skip_init=False, suppress_goodbye=False, new_login=False): # type: (KeeperParams, bool, bool, bool) -> int # suppress_goodbye kept for API compat |
| 873 | global prompt_session |
| 874 | error_no = 0 |
| 875 | suppress_errno = False |
| 876 | |
| 877 | logging.getLogger().setLevel(logging.DEBUG if params.debug else logging.WARNING if params.batch_mode else logging.INFO) |
| 878 | enforcement_checked = set() |
| 879 | prompt_session = None |
| 880 | if not params.batch_mode: |
| 881 | if os.isatty(0) and os.isatty(1): |
| 882 | completer = CommandCompleter(params, aliases) |
| 883 | # Create key bindings with Ctrl+Q to exit (consistent with supershell) |
| 884 | bindings = KeyBindings() |
| 885 | @bindings.add('c-q') |
| 886 | def _(event): |
| 887 | """Exit shell on Ctrl+Q""" |
| 888 | event.app.exit(exception=EOFError) |
| 889 | prompt_session = PromptSession(multiline=False, |
| 890 | editing_mode=EditingMode.VI, |
| 891 | completer=completer, |
| 892 | complete_style=CompleteStyle.MULTI_COLUMN, |
| 893 | complete_while_typing=False, |
| 894 | key_bindings=bindings) |
| 895 | |
| 896 | if not skip_init: |
| 897 | display.welcome() |
| 898 | versioning.welcome_print_version(params) |
| 899 | # Show government warning for GOV environments when entering interactive shell |
| 900 | if params.server and 'govcloud' in params.server.lower(): |
| 901 | display.show_government_warning() |
| 902 | |
| 903 | if not params.batch_mode and not skip_init: |
| 904 | if params.user: |
| 905 | try: |
| 906 | LoginCommand().execute(params, email=params.user, password=params.password, new_login=new_login) |
| 907 | except KeyboardInterrupt: |
| 908 | logging.info('') |
| 909 | except EOFError: |
| 910 | return 0 |
| 911 | except Exception as e: |
| 912 | logging.error(e) |
| 913 | else: |
| 914 | if params.device_token: |
| 915 | logging.info('Region: %s', params.server) |
| 916 | logging.info('') |
| 917 | logging.info("You are not logged in.") |
| 918 | logging.info(f'Type {Fore.GREEN}login <email>{Fore.RESET} to authenticate or {Fore.GREEN}server <region>{Fore.RESET} to change data centers.') |
| 919 | logging.info(f'Type {Fore.GREEN}?{Fore.RESET} for a list of all available commands.') |
| 920 | |
| 921 | # Mark that we're in the shell loop (used by supershell to know if it should start a shell on exit) |
| 922 | params._in_shell_loop = True |
| 923 | |
| 924 | # NB! USE_LOCAL_DAG=TRUE should be used only for testing. Warn here — after the |
| 925 | # login/decrypt output, right before the first prompt — so the notice isn't buried: |
| 926 | # the local test DAG engine routes PAM/DAG/discovery commands to a local SQLite |
| 927 | # graph instead of the gateway/router, so they may fail or behave incorrectly |
| 928 | # until it is disabled or removed. |
| 929 | if not params.batch_mode and not skip_init: |
nothing calls this directly
no test coverage detected