Пример #1
0
def search(enpkg, pat=None):
    """
    Print the packages that are available in the (remote) KVS.
    """
    # Flag indicating if the user received any 'not subscribed to'
    # messages
    SUBSCRIBED = True

    print FMT4 % ('Name', '  Versions', 'Product', 'Note')
    print 80 * '='

    names = {}
    for key, info in enpkg.query_remote():
        names[info['name']] = name_egg(key)

    installed = {}
    for key, info in enpkg.query_installed():
        installed[info['name']] = VB_FMT % info

    for name in sorted(names, key=string.lower):
        if pat and not pat.search(name):
            continue
        disp_name = names[name]
        installed_version = installed.get(name)
        for info in enpkg.info_list_name(name):
            version = VB_FMT % info
            disp_ver = (('* ' if installed_version == version else '  ') +
                        version)
            available = info.get('available', True)
            product = info.get('product', '')
            if not(available):
                SUBSCRIBED = False
            print FMT4 % (disp_name, disp_ver, product,
                   '' if available else 'not subscribed to')
            disp_name = ''

    # if the user's search returns any packages that are not available
    # to them, attempt to authenticate and print out their subscriber
    # level
    if config.get('use_webservice') and not(SUBSCRIBED):
        user = {}
        try:
            user = config.authenticate(config.get_auth())
        except Exception as e:
            print e.message
        print config.subscription_message(user)
Пример #2
0
 def _check_auth():
     """
     Check the user's credentials against the web API.
     """
     user = {}
     try:
         user = config.authenticate(config.get_auth())
         assert(user['is_authenticated'])
         # An EPD Free user who is trying to install a package not in
         # EPD free.  Print out subscription level and fail.
         print config.subscription_message(user)
         _done(FAILURE)
     except Exception as e:
         print e.message
         # No credentials.
         print ""
         _prompt_for_auth()
Пример #3
0
 def _print_invalid_permissions():
     user = authenticate(enpkg.config)
     print("No package found to fulfill your requirement at your "
           "subscription level:")
     for line in subscription_message(enpkg.config, user).splitlines():
         print(" " * 4 + line)