Exemple #1
0
def updates_available(android, sdk, packages=None, options=None, verbose=False):
    print('Scanning', sdk, 'for installed packages...')
    installed = scan(sdk, verbose=verbose)
    print('   ', str(len(installed)), 'packages installed.')

    print('Querying update sites for available packages...')
    available = list_packages(android, options=options, verbose=verbose)
    print('   ', str(len(available)), 'packages available.')

    return compute_package_ops(packages, installed, available)
def updates_available(android, sdk, packages=None, options=None, verbose=False):
    print('Scanning', sdk, 'for installed packages...')
    installed = scan(sdk, verbose=verbose)
    print('   ', str(len(installed)), 'packages installed.')

    print('Querying update sites for available packages...')
    available = list_packages(android, options=options, verbose=verbose)
    print('   ', str(len(available)), 'packages available.')

    return compute_package_ops(packages, installed, available)
def main(sdk, req=None):
    if req is None:
        req = []

    android = os.path.join(sdk, 'tools', 'android')

    print('Scanning', sdk, 'for installed packages...')
    installed = scan(sdk)
    print('   ', str(len(installed)), 'packages installed.')

    # Remove requested package names we already have
    if len(req) > 0:
        remove_packages(installed, req)

    print('Querying update sites for available packages...')
    available = list_packages(android)
    print('   ', str(len(available)), 'packages available.')

    requests = compute_requests(req, available)
    updates = compute_updates(installed, available)

    for r in requests:
        print('Installing: {:s}'.format(str(r)))
    for u in updates:
        print('Updating:   {:s}'.format(str(u)))

    nums = combine_updates(requests, updates)
    if len(nums) == 0:
        print("All packages are up-to-date.")
        exit(0)

    package_filter = ','.join(nums)

    installer = pexpect.spawn('{:s} update sdk --no-ui --all --filter {:s}'.format(android, package_filter))
    installer.logfile = sys.stdout.buffer
    eof = False
    while not eof:
        i = installer.expect([r"Do you accept the license '.+' \[y/n\]:", pexpect.EOF])
        if i == 0:
            installer.sendline('y')
        else:
            eof = True

    print('Done; installed {:d} packages.'.format(len(nums)))