pytest_wdl/providers/dx.py
def login(logout: bool = False, interactive: bool = True):
    """
    Checks that the user is logged into DNAnexus, otherwise log them in.

    Args:
        logout: Whether to log out before exiting the context. Ignored if the user is
            already logged in.
        interactive: Whether to allow interactive login.

    Raises:
        PluginError: if `interactive` is `False` and the user cannot be logged in
            non-interactively
    """
    if dxpy.SECURITY_CONTEXT:
        try:
            dxpy.whoami()
        except dxpy.exceptions.InvalidAuthentication:
            dxpy.SECURITY_CONTEXT = None

    if dxpy.SECURITY_CONTEXT:
        yield
    else:
        if config.get_instance():
            conf = config.get_instance().get_provider_defaults("dxwdl")
        else:
            conf = {}

        username = conf.get("username")
        token = conf.get("token")

        if ENV_DX_USERNAME not in os.environ and username:
            os.environ[ENV_DX_USERNAME] = username

        args = Namespace(
            auth_token=None,
            token=token,
            host=None,
            port=None,
            protocol="https",
            timeout=conf.get("timeout", "1d"),
            save=True,
            staging=False,
            projects=False
        )

        try:
            if not token and "password" in conf:
                # Use configured credentials to log user in automatically
                with patch("builtins.input", return_value=username), \
                        patch("getpass.getpass", return_value=conf["password"]):
                    dx.login(args)
            elif not (token or interactive):
                raise ValueError(
                    "User is not logged in, credentials were not provided, and "
                    "interactive login is not allowed"
                )
            else:
                # If token is not specified, this will require interactive login
                dx.login(args)

            yield
        except Exception as lerr:
            raise PluginError(
                "DNAnexus (dx) extensions require you to be logged into your account"
            ) from lerr
        finally:
            if logout:
                dx.logout(args)

    Checks that the user is logged into DNAnexus, otherwise log them in.

    Args:
        logout: Whether to log out before exiting the context. Ignored if the user is
            already logged in.
        interactive: Whether to allow interactive login.

    Raises:
        PluginError: if `interactive` is `False` and the user cannot be logged in
            non-interactively
    
Checks that the user is logged into DNAnexus, otherwise log them in.
Checks that the user is logged into DNAnexus otherwise log them in .
def login(logout: bool = False, interactive: bool = True):
    if dxpy.SECURITY_CONTEXT:
        try:
            dxpy.whoami()
        except dxpy.exceptions.InvalidAuthentication:
            dxpy.SECURITY_CONTEXT = None
    if dxpy.SECURITY_CONTEXT:
        yield
    else:
        if config.get_instance():
            conf = config.get_instance().get_provider_defaults("dxwdl")
        else:
            conf = {}
        username = conf.get("username")
        token = conf.get("token")
        if ENV_DX_USERNAME not in os.environ and username:
            os.environ[ENV_DX_USERNAME] = username
        args = Namespace(
            auth_token=None,
            token=token,
            host=None,
            port=None,
            protocol="https",
            timeout=conf.get("timeout", "1d"),
            save=True,
            staging=False,
            projects=False
        )
        try:
            if not token and "password" in conf:
                with patch("builtins.input", return_value=username), \
                        patch("getpass.getpass", return_value=conf["password"]):
                    dx.login(args)
            elif not (token or interactive):
                raise ValueError(
                    "User is not logged in, credentials were not provided, and "
                    "interactive login is not allowed"
                )
            else:
                dx.login(args)
            yield
        except Exception as lerr:
            raise PluginError(
                "DNAnexus (dx) extensions require you to be logged into your account"
            ) from lerr
        finally:
            if logout:
                dx.logout(args)
def login ( logout : bool = False , interactive : bool = True ) : if dxpy . SECURITY_CONTEXT : try : dxpy . whoami ( ) except dxpy . exceptions . InvalidAuthentication : dxpy . SECURITY_CONTEXT = None if dxpy . SECURITY_CONTEXT : yield else : if config . get_instance ( ) : conf = config . get_instance ( ) . get_provider_defaults ( "dxwdl" ) else : conf = { } username = conf . get ( "username" ) token = conf . get ( "token" ) if ENV_DX_USERNAME not in os . environ and username : os . environ [ ENV_DX_USERNAME ] = username args = Namespace ( auth_token = None , token = token , host = None , port = None , protocol = "https" , timeout = conf . get ( "timeout" , "1d" ) , save = True , staging = False , projects = False ) try : if not token and "password" in conf : with patch ( "builtins.input" , return_value = username ) , patch ( "getpass.getpass" , return_value = conf [ "password" ] ) : dx . login ( args ) elif not ( token or interactive ) : raise ValueError ( "User is not logged in, credentials were not provided, and " "interactive login is not allowed" ) else : dx . login ( args ) yield except Exception as lerr : raise PluginError ( "DNAnexus (dx) extensions require you to be logged into your account" ) from lerr finally : if logout : dx . logout ( args )
Checks that the user is logged into DNAnexus, otherwise log them in.
Checks that the user is logged into DNAnexus otherwise log them in .
"""
    Checks that the user is logged into DNAnexus, otherwise log them in.

    Args:
        logout: Whether to log out before exiting the context. Ignored if the user is
            already logged in.
        interactive: Whether to allow interactive login.

    Raises:
        PluginError: if `interactive` is `False` and the user cannot be logged in
            non-interactively
    """ # Use configured credentials to log user in automatically # If token is not specified, this will require interactive login
if `interactive` is `False` and the user cannot be logged in
non-interactively
if ` interactive ` is ` False ` and the user cannot be logged in non - interactively
PluginError
logout
bool
Whether to log out before exiting the context. Ignored if the user is
already logged in.
Whether to log out before exiting the context . Ignored if the user is already logged in .
interactive
bool
Whether to allow interactive login.
Whether to allow interactive login .