<commit_before>import asyncio
from subprocess import CalledProcessError

from conjureup import controllers, juju
from conjureup.app_config import app
from conjureup.consts import JAAS_DOMAIN
from conjureup.telemetry import track_screen
from conjureup.ui.views.bootstrapwait import BootstrapWaitView
from conjureup.ui.views.jaas import JaaSLoginView


class JaaSLoginController:
    def __init__(self):
        self.authenticating = asyncio.Event()
        self.view = None

    def render(self, error=None):
        app.jaas_controller = 'jaas'
        self.render_interstitial()
        app.loop.create_task(self._try_token_auth(error))

    async def _try_token_auth(self, error):
        app.log.info('Attempting to register JAAS with saved token')
        try:
            await juju.register_controller(app.jaas_controller,
                                           JAAS_DOMAIN,
                                           '', '', '')
            controllers.use('showsteps').render()
        except CalledProcessError:
            self.show_login_screen(error)

    def show_login_screen(self, error):
        track_screen("Login to JaaS")
        app.ui.set_header(
            title="Login to JaaS",
            excerpt='Enter your Ubuntu SSO credentials'
        )
        app.ui.set_body(JaaSLoginView(app,
                                      error=error,
                                      cb=self.register))

    def register(self, email=None, password=<PASSWORD>, twofa=None):
        app.loop.create_task(self._register(email, password, twofa))
        self.render_interstitial()<commit_msg>Fix allow JaaS controller not named 'jaas' in GUI (#1132)<commit_after>import asyncio
from subprocess import CalledProcessError

from conjureup import controllers, juju
from conjureup.app_config import app
from conjureup.consts import JAAS_DOMAIN
from conjureup.telemetry import track_screen
from conjureup.ui.views.bootstrapwait import BootstrapWaitView
from conjureup.ui.views.jaas import JaaSLoginView


class JaaSLoginController:
    def __init__(self):
        self.authenticating = asyncio.Event()
        self.view = None

    def render(self, error=None):
        if not app.jaas_controller:
            app.jaas_controller = 'jaas'
        self.render_interstitial()
        app.loop.create_task(self._try_token_auth(error))

    async def _try_token_auth(self, error):
        app.log.info('Attempting to register JAAS with saved token')
        try:
            await juju.register_controller(app.jaas_controller,
                                           JAAS_DOMAIN,
                                           '', '', '')
            controllers.use('showsteps').render()
        except CalledProcessError:
            self.show_login_screen(error)

    def show_login_screen(self, error):
        track_screen("Login to JaaS")
        app.ui.set_header(
            title="Login to JaaS",
            excerpt='Enter your Ubuntu SSO credentials'
        )
        app.ui.set_body(JaaSLoginView(app,
                                      error=error,
                                      cb=self.register))

    def register(self, email=None, password=<PASSWORD>, twofa=None):
        app.loop.create_task(self._register(email, password, twofa))
        self.render_interstitial()
{'fraction_non_alphanumeric': 0.0826271186440678, 'fraction_numerical': 0.0012106537530266344, 'mean_word_length': 2.272277227722772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4506954', 'n_tokens_mistral': 945, 'n_tokens_neox': 893, 'n_words': 195}