コード例 #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)
コード例 #2
0
def list_local_modules(pattern=r'.*', types=[], include_hidden=False, tags=[], quiet=False, raw_bytes=False):
    if quiet:
        all_toks = []
    else:
        header = ['Name', 'Title', 'Type','Version','Data source ver','Size']
        all_toks = [header]
    for module_name in au.search_local(pattern):
        module_info = au.get_local_module_info(module_name)
        if len(types) > 0 and module_info.type not in types:
            continue
        if len(tags) > 0:
            if module_info.tags is None:
                continue
            if len(set(tags).intersection(module_info.tags)) == 0:
                continue
        if module_info.hidden and not include_hidden:
            continue
        if quiet:
            toks = [module_name]
        else:
            size = module_info.get_size()
            toks = [module_name, module_info.title, module_info.type, module_info.version, module_info.datasource]
            if raw_bytes:
                toks.append(size)
            else:
                toks.append(util.humanize_bytes(size))
        all_toks.append(toks)
    print_tabular_lines(all_toks)
コード例 #3
0
 def list_local_modules(pattern=r'.*', types=[]):
     header = ['Name', 'Type', 'Version', 'Size']
     all_toks = [header]
     for module_name in au.search_local(pattern):
         module_info = au.get_local_module_info(module_name)
         if len(types) > 0 and module_info.type not in types:
             continue
         size = module_info.get_size()
         toks = [
             module_name, module_info.type, module_info.version,
             humanize_bytes(size)
         ]
         all_toks.append(toks)
     print_tabular_lines(all_toks)
コード例 #4
0
def uninstall_modules(args):
    matching_names = au.search_local(*args.modules)
    if len(matching_names) > 0:
        print('Uninstalling: {:}'.format(', '.join(matching_names)))
        if not (args.yes):
            while True:
                resp = input('Proceed? (y/n) > ')
                if resp == 'y':
                    break
                elif resp == 'n':
                    exit()
                else:
                    print('Response \'{:}\' not one of (y/n).'.format(resp))
        for module_name in matching_names:
            au.uninstall_module(module_name)
            print('Uninstalled %s' % module_name)
    else:
        print('No modules to uninstall found')
コード例 #5
0
 def update_modules(args):
     if len(args.modules) == 0:
         requested_modules = au.list_local()
     else:
         requested_modules = au.search_local(*args.modules)
     print('Checking status')
     needs_update = []
     status_table = [['Name', 'Status']]
     for module_name in requested_modules:
         local_info = au.get_local_module_info(module_name)
         version = local_info.conf['version']
         if au.module_exists_remote(module_name):
             latest_version = au.get_remote_latest_version(module_name)
             if version == latest_version:
                 status = 'Up to date'
             else:
                 status = 'Requires update'
                 needs_update.append(module_name)
         else:
             status = 'No remote version'
         status_table.append([module_name, status])
     print_tabular_lines(status_table)
     if len(needs_update) == 0:
         print('All modules are up to date')
         exit()
     else:
         user_cont = input('Continue to update the following modules:\n%s\n<y/n>: '\
                           %','.join(needs_update))
         if user_cont.lower() not in ['y', 'yes']:
             print('Cancelling update')
             exit()
     args.modules = needs_update
     args.force_data = False
     args.version = None
     args.yes = True
     install_modules(args)