def list_installed_tools(context,galaxy,name,toolshed,owner,list_tools, updateable): """ List installed tool repositories. Prints details of installed tool repositories in GALAXY instance. For each installed repository the details include: repository name, toolshed, owner, revision id and changeset, and installation status. Repository details are also preceeded by a single-character 'status' indicator ('D' = deprecated; '^' = newer revision installed; 'u' = update available but not installed; 'U' = upgrade available but not installed; '*' = latest revision). If the --list-tools option is specified then additionally after each repository the tools associated with the repository will be listed along with their descriptions and versions. """ # Get a Galaxy instance gi = context.galaxy_instance(galaxy) if gi is None: logger.critical("Failed to connect to Galaxy instance") return 1 # List repositories tools.list_installed_repositories(gi,name=name, toolshed=toolshed, owner=owner, list_tools=list_tools, only_updateable=updateable)
def list_repositories(context,galaxy,name,toolshed,owner,updateable): """ List installed tool repos for (re)install. Prints details of installed tool repositories in GALAXY instance in a format suitable for input into the 'install_repositories' command. The output is a set of tab-delimited values, with each line consisting of: TOOLSHED|OWNER|REPOSITORY|CHANGESET|TOOL_PANEL_SECTION TOOL_PANEL_SECTION will be empty if the repository was installed outside of any section in the tool panel. The repositories are ordered according to their position in the tool panel. Note that non-package and non-data-manager repositories which cannot be located within the tool panel will not be listed. """ # Get a Galaxy instance gi = context.galaxy_instance(galaxy) if gi is None: logger.critical("Failed to connect to Galaxy instance") return 1 # List repositories tools.list_installed_repositories(gi,name=name, toolshed=toolshed, owner=owner, only_updateable=updateable, tsv=True)
def manage_tools(args=None): """ Implements the 'manage_tools' utility """ deprecation_warning() if args is None: args = sys.argv[1:] p = base_parser(usage=\ "\n\t%prog list GALAXY_URL [options]" "\n\t%prog installed GALAXY_URL [options]" "\n\t%prog tool_panel GALAXY_URL [options]" "\n\t%prog install GALAXY_URL [options] SHED OWNER TOOL [REVISION]" "\n\t%prog update GALAXY_URL [options] SHED OWNER TOOL", description="Manage and install tools in a Galaxy " "instance") commands = ['list','installed','tool_panel','install','update'] # Get compulsory arguments if len(args) == 1: if args[0] == '-h' or args[0] == '--help': p.print_usage() elif args[0] == '--version': p.print_version() sys.exit(0) if len(args) < 2: p.error("need to supply a command and a Galaxy URL/alias") command = args[0] galaxy_url = args[1] # Setup additional command line options if command not in commands: p.error("unrecognised command: '%s'" % command) elif command == 'list': p.set_usage("%prog list GALAXY_URL [options]") p.add_option('--name',action='store',dest='name',default=None, help="specific tool name(s) to list") p.add_option('--installed',action='store_true', dest='installed_only',default=False, help="only list tools installed from a toolshed") elif command == 'installed': p.set_usage("%prog installed GALAXY_URL [options]") p.add_option('--name',action='store',dest='name',default=None, help="specific tool repository/ies to list") p.add_option('--toolshed',action='store',dest='toolshed',default=None, help="only list repositories from TOOLSHED") p.add_option('--owner',action='store',dest='owner',default=None, help="only list repositories owned by OWNER") p.add_option('--list-tools',action='store_true',dest='list_tools', default=None, help="list the associated tools for each repository") p.add_option('--updateable',action='store_true',dest='updateable', default=None, help="only show repositories with uninstalled updates " "or upgrades") elif command == 'tool_panel': p.set_usage("%prog tool_panel GALAXY_URL [options]") p.add_option('--name',action='store',dest='name',default=None, help="specific tool panel section(s) to list") p.add_option('--list-tools',action='store_true',dest='list_tools', default=None, help="list the associated tools for each section") elif command == 'install': p.set_usage("%prog install GALAXY_URL [options] SHED OWNER TOOL " "[REVISION]") p.add_option('--tool-panel-section',action='store', dest='tool_panel_section',default=None, help="tool panel section name or id to install the " "tool under") elif command == 'update': p.set_usage("%prog update GALAXY_URL [options] SHED OWNER TOOL") # Process remaining arguments on command line if args[1] in ('-h','--help','--version'): args = args[1:] else: args = args[2:] options,args = p.parse_args(args) handle_debug(debug=options.debug) handle_suppress_warnings(suppress_warnings=options.suppress_warnings) handle_ssl_warnings(verify=(not options.no_verify)) # Handle password if required email,password = handle_credentials(options.username, options.galaxy_password, prompt="Password for %s: " % galaxy_url) # Get a Galaxy instance gi = get_galaxy_instance(galaxy_url,api_key=options.api_key, email=email,password=password, verify_ssl=(not options.no_verify)) if gi is None: logger.critical("Failed to connect to Galaxy instance") sys.exit(1) # Execute command if command == 'list': tools.list_tools(gi,name=options.name, installed_only=options.installed_only) elif command == 'installed': tools.list_installed_repositories(gi,name=options.name, toolshed=options.toolshed, owner=options.owner, list_tools=options.list_tools, only_updateable=options.updateable) elif command == 'tool_panel': tools.list_tool_panel(gi,name=options.name, list_tools=options.list_tools) elif command == 'install': if len(args) < 3: p.error("Need to supply toolshed, owner, repo and optional " "revision") toolshed,owner,repo = args[:3] if len(args) == 4: revision = args[3] else: revision = None status = tools.install_tool( gi,toolshed,repo,owner,revision=revision, tool_panel_section=options.tool_panel_section) sys.exit(status) elif command == 'update': if len(args) != 3: p.error("Need to supply toolshed, owner and repo") toolshed,owner,repo = args[:3] status = tools.update_tool(gi,toolshed,repo,owner) sys.exit(status)