Exemple #1
0
 def update_modules(args):
     if len(args.modules) > 0:
         requested_modules = au.search_local(*args.modules)
     else:
         requested_modules = []
     update_strategy = args.strategy
     status_table = [['Name', 'New Version', 'Size']]
     updates, _, reqs_failed = au.get_updatable(requested_modules,
                                                strategy=update_strategy)
     if reqs_failed:
         print('Newer versions of ({}) are available, but would break dependencies. You may use --strategy=force to force installation.'\
             .format(', '.join(reqs_failed.keys())))
     if not updates:
         print('No module updates are needed')
         exit()
     for mname, update_info in updates.items():
         version = update_info.version
         size = update_info.size
         status_table.append([mname, version, humanize_bytes(size)])
     print_tabular_lines(status_table)
     user_cont = input('Update the above modules? (y/n) > ')
     if user_cont.lower() not in ['y', 'yes']:
         exit()
     for mname, update_info in updates.items():
         args.modules = [mname]
         args.force_data = False
         args.version = update_info.version
         args.yes = True
         args.include_private = False
         args.skip_dependencies = False
         install_modules(args)
Exemple #2
0
async def get_module_updates (request):
    queries = request.rel_url.query
    smodules = queries.get('modules','')
    if smodules:
        modules = smodules.split(',')
    else:
        modules = []
    updates, _, conflicts = au.get_updatable(modules=modules)
    sconflicts = {}
    for mname, reqd in conflicts.items():
        sconflicts[mname] = {}
        for req_name, req in reqd.items():
            sconflicts[mname][req_name] = str(req)
    updatesd = {mname:{'version':info.version,'size':info.size} for mname, info in updates.items()}
    out = {'updates':updatesd,'conflicts':sconflicts}
    return web.json_response(out)