Ejemplo n.º 1
0
def main():
    '''
    Script to deprecate any repositories that are older than n days, and have been empty since creation.
    '''
    parser = OptionParser()
    parser.add_option( "-d", "--days", dest="days", action="store", type="int", help="number of days (14)", default=14 )
    parser.add_option( "-i", "--info_only", action="store_true", dest="info_only", help="info about the requested action", default=False )
    parser.add_option( "-v", "--verbose", action="store_true", dest="verbose", help="verbose mode, print the name of each repository", default=False )
    ( options, args ) = parser.parse_args()
    try:
        ini_file = args[0]
    except IndexError:
        sys.exit( "Usage: python %s <tool shed .ini file> [options]" % sys.argv[ 0 ] )
    config_parser = ConfigParser.ConfigParser( {'here': os.getcwd()} )
    config_parser.read( ini_file )
    config_dict = {}
    for key, value in config_parser.items( "app:main" ):
        config_dict[key] = value
    config = tool_shed_config.Configuration( **config_dict )

    app = DeprecateRepositoriesApplication( config )
    cutoff_time = datetime.utcnow() - timedelta( days=options.days )
    now = strftime( "%Y-%m-%d %H:%M:%S" )
    print "\n####################################################################################"
    print "# %s - Handling stuff older than %i days" % ( now, options.days )

    if options.info_only:
        print "# Displaying info only ( --info_only )"

    deprecate_repositories( app, cutoff_time, days=options.days, info_only=options.info_only, verbose=options.verbose )
Ejemplo n.º 2
0
def main():
    '''Script that checks repositories to see if the tools contained within them have functional tests defined.'''
    parser = OptionParser()
    parser.add_option("-i",
                      "--info_only",
                      action="store_true",
                      dest="info_only",
                      help="info about the requested action",
                      default=False)
    parser.add_option(
        "-s",
        "--section",
        action="store",
        dest="section",
        default='server:main',
        help="which .ini file section to extract the host and port from")
    parser.add_option("-v",
                      "--verbose",
                      action="count",
                      dest="verbosity",
                      default=1,
                      help="Control the amount of detail in the log output.")
    parser.add_option(
        "--verbosity",
        action="store",
        dest="verbosity",
        metavar='VERBOSITY',
        type="int",
        help="Control the amount of detail in the log output. --verbosity=1 is "
        "the same as -v")
    (options, args) = parser.parse_args()
    try:
        ini_file = args[0]
    except IndexError:
        print "Usage: python %s <tool shed .ini file> [options]" % sys.argv[0]
        exit(127)
    config_parser = ConfigParser.ConfigParser({'here': os.getcwd()})
    config_parser.read(ini_file)
    config_dict = {}
    for key, value in config_parser.items("app:main"):
        config_dict[key] = value
    config = tool_shed_config.Configuration(**config_dict)

    config_section = options.section
    now = strftime("%Y-%m-%d %H:%M:%S")
    print "#############################################################################"
    print "# %s - Checking repositories for tools with functional tests." % now
    print "# This tool shed is configured to listen on %s:%s." % (
        config_parser.get(config_section,
                          'host'), config_parser.get(config_section, 'port'))
    app = FlagRepositoriesApplication(config)

    if options.info_only:
        print "# Displaying info only ( --info_only )"
    if options.verbosity:
        print "# Displaying extra information ( --verbosity = %d )" % options.verbosity

    check_and_flag_repositories(app,
                                info_only=options.info_only,
                                verbosity=options.verbosity)
Ejemplo n.º 3
0
def get_sa_session_and_needed_config_settings( path_to_tool_shed_config ):
    conf_parser = ConfigParser.ConfigParser( { 'here' : os.getcwd() } )
    conf_parser.read( path_to_tool_shed_config )
    kwds = dict()
    for key, value in conf_parser.items( "app:main" ):
        kwds[ key ] = value
    config_settings = config.Configuration( **kwds )
    db_con = config_settings.database_connection
    if not db_con:
        db_con = "sqlite:///%s?isolation_level=IMMEDIATE" % config_settings.database
    model = galaxy.webapps.tool_shed.model.mapping.init( config_settings.file_path, db_con, engine_options={}, create_tables=False )
    return model.context.current, config_settings
Ejemplo n.º 4
0
    """Validates the public username."""
    if len(username) < 3:
        return "Public name must be at least 3 characters in length"
    if len(username) > 255:
        return "Public name cannot be more than 255 characters in length"
    if not(VALID_PUBLICNAME_RE.match(username)):
        return "Public name must contain only lower-case letters, numbers and '-'"
    return ''


if __name__ == "__main__":
    parser = optparse.OptionParser(description='Create a user with API key.')
    parser.add_option('-c', dest='config', action='store', help='.ini file to retried toolshed configuration from')
    (args, options) = parser.parse_args()
    ini_file = args.config
    config_parser = ConfigParser.ConfigParser({'here': os.getcwd()})
    print "Reading ini file: ", ini_file
    config_parser.read(ini_file)
    config_dict = {}
    for key, value in config_parser.items("app:main"):
        config_dict[key] = value
    config = tool_shed_config.Configuration(**config_dict)
    app = BootstrapApplication(config)
    user = create_user(app)
    if user is not None:
        api_key = create_api_key(app, user)
        print "Created new user with public username '", user.username, ".  An API key was also created and associated with the user."
        sys.exit(0)
    else:
        sys.exit("Problem creating a new user and an associated API key.")
def main():
    '''Script that validates all repositories of type tool_dependency_definition.'''
    parser = OptionParser()
    parser.add_option("-i",
                      "--info_only",
                      action="store_true",
                      dest="info_only",
                      help="info about the requested action",
                      default=False)
    parser.add_option(
        "-s",
        "--section",
        action="store",
        dest="section",
        default='server:main',
        help=".ini file section from which to extract the host and port")
    parser.add_option("-v",
                      "--verbose",
                      action="count",
                      dest="verbosity",
                      default=1,
                      help="Control the amount of detail in the log output.")
    parser.add_option(
        "--verbosity",
        action="store",
        dest="verbosity",
        metavar='VERBOSITY',
        type="int",
        help=
        "Control the amount of detail in the log output, --verbosity=1 is the same as -v"
    )
    (options, args) = parser.parse_args()
    try:
        ini_file = args[0]
    except IndexError:
        print "Usage: python %s <tool shed .ini file> [options]" % sys.argv[0]
        exit(127)
    config_parser = ConfigParser.ConfigParser({'here': os.getcwd()})
    config_parser.read(ini_file)
    config_dict = {}
    for key, value in config_parser.items("app:main"):
        config_dict[key] = value
    config = tool_shed_config.Configuration(**config_dict)
    config_section = options.section

    now = strftime("%Y-%m-%d %H:%M:%S")
    print "#############################################################################"
    print "# %s - Validating repositories of type %s" % (
        now, TOOL_DEPENDENCY_DEFINITION)
    print "# This tool shed is configured to listen on %s:%s" % (
        config_parser.get(config_section,
                          'host'), config_parser.get(config_section, 'port'))

    app = RepositoryMetadataApplication(config)
    if options.info_only:
        print "# Displaying info only ( --info_only )"
    if options.verbosity:
        print "# Displaying extra information ( --verbosity = %d )" % options.verbosity
    validate_repositories(app,
                          info_only=options.info_only,
                          verbosity=options.verbosity)