예제 #1
0
def main(args):

    binstar = get_binstar(args)

    spec = args.spec
    if spec._basename:
        dist = binstar.distribution(spec.user, spec.package, spec.version,
                                    spec.basename)
        log.info(dist.pop('basename'))
        log.info(dist.pop('description') or 'no description')
        log.info('')
        metadata = dist.pop('attrs', {})
        for key_value in dist.items():
            log.info('%-25s: %r' % key_value)
        log.info('Metadata:')
        for key_value in metadata.items():
            log.info('    + %-25s: %r' % key_value)

    elif args.spec._version:
        log.info('version %s' % spec.version)
        release = binstar.release(spec.user, spec.package, spec.version)
        for dist in release['distributions']:
            log.info('   + %(basename)s' % dist)
        log.info('%s' % release.get('public_attrs', {}).get('description'))

    elif args.spec._package:
        package = binstar.package(spec.user, spec.package)
        package['access'] = 'published' if package.get(
            'published') else 'public' if package['public'] else 'private'
        log.info('Name:    %(name)s' % package)
        log.info('Summary: %(summary)s' % package)
        log.info('Access:  %(access)s' % package)
        log.info('Package Types:  %s' %
                 ', '.join(package.get('package_types')))
        log.info('Versions:' % package)
        for release in package['releases']:
            log.info('   + %(version)s' % release)

        log.info('')
        for package_type in package.get('package_types'):
            install_info(package, package_type)

        if not package['public']:
            log.info('To generate a $TOKEN run:')
            log.info('    TOKEN=$(binstar auth --create --name <TOKEN-NAME>)')

    elif args.spec._user:
        user_info = binstar.user(spec.user)
        pprint_user(user_info)
        pprint_packages(binstar.user_packages(spec.user))
        if user_info['user_type'] == 'user':
            pprint_orgs(binstar.user_orgs(spec.user))
        else:
            pprint_collections(binstar.collections(spec.user))

    else:
        log.info(args.spec)
예제 #2
0
def main(args):

    binstar = get_binstar(args)

    spec = args.spec
    if spec._basename:
        dist = binstar.distribution(spec.user, spec.package, spec.version, spec.basename)
        log.info(dist.pop('basename'))
        log.info(dist.pop('description') or 'no description')
        log.info('')
        metadata = dist.pop('attrs', {})
        for key_value in dist.items():
            log.info('%-25s: %r' % key_value)
        log.info('Metadata:')
        for key_value in metadata.items():
            log.info('    + %-25s: %r' % key_value)

    elif args.spec._version:
        log.info('version %s' % spec.version)
        release = binstar.release(spec.user, spec.package, spec.version)
        for dist in release['distributions']:
            log.info('   + %(basename)s' % dist)
        log.info('%s' % release.get('public_attrs', {}).get('description'))

    elif args.spec._package:
        package = binstar.package(spec.user, spec.package)
        package['access'] = 'published' if package.get('published') else 'public' if package['public'] else 'private'
        log.info('Name:    %(name)s' % package)
        log.info('Summary: %(summary)s' % package)
        log.info('Access:  %(access)s' % package)
        log.info('Package Types:  %s' % ', '.join(package.get('package_types')))
        log.info('Versions:' % package)
        for release in package['releases']:
            log.info('   + %(version)s' % release)

        log.info('')
        for package_type in package.get('package_types'):
            install_info(package, package_type)

        if not package['public']:
            log.info('To generate a $TOKEN run:')
            log.info('    TOKEN=$(binstar auth --create --name <TOKEN-NAME>)')



    elif args.spec._user:
        user_info = binstar.user(spec.user)
        pprint_user(user_info)
        pprint_packages(binstar.user_packages(spec.user))
        if user_info['user_type'] == 'user':
            pprint_orgs(binstar.user_orgs(spec.user))
        else:
            pprint_collections(binstar.collections(spec.user))

    else:
        log.info(args.spec)
예제 #3
0
def main(args):
    binstar = get_binstar(args)

    try:
        user = binstar.user()
    except Unauthorized:
        log.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #4
0
def main(args):
    binstar = get_binstar(args)

    try:
        user = binstar.user()
    except Unauthorized:
        print 'Anonymous User'
        return -1

    pprint_user(user)
예제 #5
0
def main(args):
    binstar = get_binstar(args)

    try:
        user = binstar.user()
    except Unauthorized:
        log.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #6
0
def main(args):
    aserver_api = get_server_api(args.token, args.site)

    try:
        user = aserver_api.user()
    except errors.Unauthorized as err:
        logger.debug(err)
        logger.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #7
0
파일: whoami.py 프로젝트: menghaozhu/hat
def main(args):
    aserver_api = get_binstar(args)

    try:
        user = aserver_api.user()
    except errors.Unauthorized as err:
        log.debug(err)
        log.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #8
0
파일: whoami.py 프로젝트: Vasyka/hat
def main(args):
    aserver_api = get_binstar(args)

    try:
        user = aserver_api.user()
    except errors.Unauthorized as err:
        log.debug(err)
        log.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #9
0
def main(args):
    aserver_api = get_server_api(args.token, args.site)

    try:
        user = aserver_api.user()
    except errors.Unauthorized as err:
        logger.debug(err)
        logger.info('Anonymous User')
        return 1

    pprint_user(user)
예제 #10
0
def main(args):

    aserver_api = get_binstar(args)

    spec = args.spec
    if spec._basename:
        dist = aserver_api.distribution(spec.user, spec.package, spec.version, spec.basename)
        log.info(dist.pop("basename"))
        log.info(dist.pop("description") or "no description")
        log.info("")
        metadata = dist.pop("attrs", {})
        for key_value in dist.items():
            log.info("%-25s: %r" % key_value)
        log.info("Metadata:")
        for key_value in metadata.items():
            log.info("    + %-25s: %r" % key_value)

    elif args.spec._version:
        log.info("version %s" % spec.version)
        release = aserver_api.release(spec.user, spec.package, spec.version)
        for dist in release["distributions"]:
            log.info("   + %(basename)s" % dist)
        log.info("%s" % release.get("public_attrs", {}).get("description"))

    elif args.spec._package:
        package = aserver_api.package(spec.user, spec.package)
        package["access"] = "public" if package["public"] else "private"
        log.info("Name:    %(name)s" % package)
        log.info("Summary: %(summary)s" % package)
        log.info("Access:  %(access)s" % package)
        log.info("Package Types:  %s" % ", ".join(package.get("package_types")))
        log.info("Versions:" % package)
        for release in package["releases"]:
            log.info("   + %(version)s" % release)

        log.info("")
        for package_type in package.get("package_types"):
            install_info(package, package_type)

        if not package["public"]:
            log.info("To generate a $TOKEN run:")
            log.info("    TOKEN=$(anaconda auth --create --name <TOKEN-NAME>)")

    elif args.spec._user:
        user_info = aserver_api.user(spec.user)
        pprint_user(user_info)
        pprint_packages(aserver_api.user_packages(spec.user))
        if user_info["user_type"] == "user":
            pprint_orgs(aserver_api.user_orgs(spec.user))

    else:
        log.info(args.spec)
예제 #11
0
def main(args):

    binstar = get_binstar(args)

    spec = args.spec
    if spec._basename:
        dist = binstar.distribution(spec.user, spec.package, spec.version,
                                    spec.basename)
        log.info(dist.pop('basename'))
        log.info(dist.pop('description') or 'no description')
        log.info()
        metadata = dist.pop('attrs', {})
        for key_value in dist.items():
            log.info('%-25s: %r' % key_value)
        log.info('Metadata:')
        for key_value in metadata.items():
            log.info('    + %-25s: %r' % key_value)

    elif args.spec._version:
        log.info('version %s' % spec.version)
        release = binstar.release(spec.user, spec.package, spec.version)
        for dist in release['distributions']:
            log.info('   + %(basename)s' % dist)
        log.info()
        log.info('%(description)s' % release['public_attrs'])

    elif args.spec._package:
        package = binstar.package(spec.user, spec.package)
        package['permission'] = 'public' if package['public'] else 'private'
        log.info('- %(name)s: [%(permission)s] %(summary)s' % package)
        for release in package['releases']:
            log.info('   + %(version)s' % release)

    elif args.spec._user:
        user_info = binstar.user(spec.user)
        pprint_user(user_info)
        pprint_packages(binstar.user_packages(spec.user))
        if user_info['user_type'] == 'user':
            pprint_orgs(binstar.user_orgs(spec.user))
        else:
            pprint_collections(binstar.collections(spec.user))

    else:
        log.info(args.spec)
예제 #12
0
def main(args):

    binstar = get_binstar(args)

    spec = args.spec
    if spec._basename:
        dist = binstar.distribution(spec.user, spec.package, spec.version, spec.basename)
        log.info(dist.pop('basename'))
        log.info(dist.pop('description') or 'no description')
        log.info()
        metadata = dist.pop('attrs', {})
        for key_value in dist.items():
            log.info('%-25s: %r' % key_value)
        log.info('Metadata:')
        for key_value in metadata.items():
            log.info('    + %-25s: %r' % key_value)

    elif args.spec._version:
        log.info('version %s' % spec.version)
        release = binstar.release(spec.user, spec.package, spec.version)
        for dist in release['distributions']:
            log.info('   + %(basename)s' % dist)
        log.info()
        log.info('%(description)s' % release['public_attrs'])

    elif args.spec._package:
        package = binstar.package(spec.user, spec.package)
        package['permission'] = 'public' if package['public'] else 'private'
        log.info('- %(name)s: [%(permission)s] %(summary)s' % package)
        for release in package['releases']:
            log.info('   + %(version)s' % release)

    elif args.spec._user:
        user_info = binstar.user(spec.user)
        pprint_user(user_info)
        pprint_packages(binstar.user_packages(spec.user))
        if user_info['user_type'] == 'user':
            pprint_orgs(binstar.user_orgs(spec.user))
        else:
            pprint_collections(binstar.collections(spec.user))

    else:
        log.info(args.spec)