Ejemplo n.º 1
0
def _check_validations(validations):
    invalids = [v for v in validations if not validation_re.match(v)]
    if invalids:
        for v in invalids:
            echo.error('Invalid validation request "{}", format must be'
                       ' name=revision'.format(v))
        raise RuntimeError()
Ejemplo n.º 2
0
def close(snap_name, channel_names):
    """Close one or more channels for the specific snap."""
    snap_series = storeapi.constants.DEFAULT_SERIES

    store = storeapi.StoreClient()

    with _requires_login():
        info = store.get_account_information()

    try:
        snap_id = info['snaps'][snap_series][snap_name]['snap-id']
    except KeyError:
        echo.error(
            'Your account lacks permission to close channels for this snap. '
            'Make sure the logged in account has upload permissions on '
            '\'{}\' in series \'{}\'.'.format(snap_name, snap_series))
        raise

    closed_channels, c_m_tree = store.close_channels(snap_id, channel_names)

    tabulated_status = _tabulated_channel_map_tree(c_m_tree)
    print(tabulated_status)

    print()
    if len(closed_channels) == 1:
        msg = 'The {} channel is now closed.'.format(closed_channels[0])
    else:
        msg = 'The {} and {} channels are now closed.'.format(
            ', '.join(closed_channels[:-1]), closed_channels[-1])
    logger.info(msg)
Ejemplo n.º 3
0
def _fail_login(msg: str = "") -> bool:
    echo.error(msg)
    echo.error("Login failed.")
    return False
Ejemplo n.º 4
0
def _fail_login(msg=''):
    echo.error(msg)
    echo.error('Login failed.')
    return False
Ejemplo n.º 5
0
def _fail_login(msg: str = '') -> bool:
    echo.error(msg)
    echo.error('Login failed.')
    return False
Ejemplo n.º 6
0
def _fail_login(msg=''):
    echo.error(msg)
    echo.error('Login failed.')
    return False