How to use the aioconsole.ainput function in aioconsole

To help you get started, we’ve selected a few aioconsole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitre / caldera / app / terminal / custom_shell.py View on Github external
async def start_shell(self):
        await asyncio.sleep(1)
        while True:
            try:
                cmd = await ainput(self.shell_prompt)
                self.log.debug(cmd)
                mode = re.search(r'\((.*?)\)', self.shell_prompt)
                if cmd == 'help':
                    await self._print_help()
                elif cmd.startswith('log'):
                    await self._print_logs(int(cmd.split(' ')[1]))
                elif cmd in self.modes.keys():
                    self.shell_prompt = 'caldera (%s)> ' % cmd
                elif mode:
                    await self.modes[mode.group(1)].execute(cmd)
                elif cmd == '':
                    pass
                else:
                    self.log.console('Bad command - are you in the right mode?', 'red')
            except Exception as e:
                self.log.console('Bad command: %s' % e, 'red')
github OpenXbox / xbox-smartglass-core-python / xbox / handlers / text_input.py View on Github external
async def userinput_callback(console, prompt):
    print('WAITING FOR TEXT INPUT...')
    text = await aioconsole.ainput(prompt)

    await console.send_systemtext_input(text)
    await console.finish_text_input()
github synesthesiam / voice2json / voice2json / record.py View on Github external
record_task = asyncio.create_task(record_audio(audio_source, chunk_size))

    try:
        while True:
            # Generate random intent for prompt
            random_intent = generate_intent()
            text = random_intent["text"]

            # Prompt
            print("---")
            print(text)

            # Instructions
            print("Press ENTER to start recording (CTRL+C to exit)")
            await aioconsole.ainput()

            # Record
            audio_data = bytes()
            recording = True

            # Instructions
            print("Recording from audio source. Press ENTER to stop (CTRL+C to exit).")
            await aioconsole.ainput()

            # Save WAV
            recording = False
            logging.debug("Recorded %s byte(s) of audio data", len(audio_data))

            count = 0
            wav_path = get_wav_path(text, count)
            while wav_path.exists():
github rr- / dotfiles / opt / booru-toolkit / booru_toolkit / upload / __main__.py View on Github external
async def confirm_similar_posts(plugin: PluginBase, content: bytes) -> None:
    similar_posts = await plugin.find_similar_posts(content)
    if not similar_posts:
        return
    print("Similar posts found:")
    for similarity, post in similar_posts:
        print(
            "%.02f: %s (%dx%d)"
            % (similarity, post.site_url, post.width, post.height)
        )
    await aioconsole.ainput("Hit enter to continue, ^C to abort\n")
github metamarcdw / nowallet / nowalletd.py View on Github external
async def input_loop(self):
        while True:
            input_ = await ainput(loop=self.loop)
            if not input_:
                continue
            if input_ == "@end":
                sys.exit(0)
            try:
                obj = json.loads(input_)
            except json.JSONDecodeError as err:
                self.print_json({
                    "error": "{}: {}".format(type(err).__name__, str(err))
                })
                continue
            await self.dispatch_input(obj)
github Terbau / fortnitepy / fortnitepy / auth.py View on Github external
code_type = self.get_prompt_type_name()
                if self.email is not None:
                    text = '{0}Please enter a valid {1} code ' \
                           'for {2}\n'.format(
                                prompt_message,
                                code_type,
                                self.email
                            )
                else:
                    text = '{0}Please enter a valid {1} code.\n'.format(
                        prompt_message,
                        code_type
                    )

                async with _prompt_lock:
                    code = await ainput(
                        text,
                        loop=self.client.loop
                    )

            if (prompted and self.prompt_exchange_code) or self.exchange_code_ready():  # noqa
                self.exchange_code = code or self.exchange_code
                data = await self.run_exchange_code_authenticate()
            else:
                self.authorization_code = code or self.authorization_code
                data = await self.run_authorization_code_authenticate()

        self._update_ios_data(data)

        if self.delete_existing_device_auths:
            tasks = []
            auths = await self.fetch_device_auths()
github Map-A-Droid / MAD / mapadroid / websocket / dummy_debug_rgc.py View on Github external
async def hello(websocket, path):
    print("Client registered")
    while True:
        command = await ainput("Enter command: ")
        print("Sending: %s" % command)
        await websocket.send("1;" + command)
        print("Awaiting response")

        message = None
        while message is None:
            try:
                message = await asyncio.wait_for(websocket.recv(), timeout=2.0)
            except asyncio.TimeoutError as te:
                await asyncio.sleep(0.02)
            except websockets.exceptions.ConnectionClosed as cc:
                break

        if message is not None:
            if isinstance(message, str):
                print("Receiving message: {}", str(message.strip()))
github Terbau / fortnitepy / fortnitepy / auth.py View on Github external
'Invalid account credentials passed.',
                    e
                ) from e

            if e.message_code != ('errors.com.epicgames.common.'
                                  'two_factor_authentication.required'):
                raise

            log.info('Logging in interrupted. 2fa required.')
            log.info('Fetching new valid xsrf token.')
            token = await self.fetch_xsrf_token()

            code = self.two_factor_code
            if code is None:
                async with _prompt_lock:
                    code = await ainput(
                        'Please enter the 2fa code:\n',
                        loop=self.client.loop
                    )

            try:
                await self.client.http.epicgames_mfa_login(
                    e.raw['metadata']['twoFactorMethod'],
                    code,
                    token
                )
            except HTTPException as exc:
                m = (
                    'errors.com.epicgames.accountportal.mfa_code_invalid',
                    'errors.com.epicgames.accountportal.validation'
                )
                if exc.message_code in m: