1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/080242921d9f/ changeset: 080242921d9f user: greg date: 2012-04-02 22:13:08 summary: Add a counter utility to the tool shed. affected #: 7 files diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -1,6 +1,6 @@ import os, tempfile, shutil, subprocess, logging, string from datetime import date, datetime, timedelta -from time import strftime +from time import strftime, gmtime from galaxy import util from galaxy.datatypes.checkers import * from galaxy.util.json import * @@ -21,6 +21,37 @@ '\'' : ''' } VALID_CHARS = set( string.letters + string.digits + "'\"-=_.()/+*^,:?!#[]%\\$@;{}" ) +class ShedCounter( object ): + def __init__( self, model ): + self.model = model + self.count_time = strftime( "%b %d, %Y", gmtime() ) + self.valid_tools = self.count_valid_tools() + @property + def sa_session( self ): + """Returns a SQLAlchemy session""" + return self.model.context + def count_valid_tools( self ): + valid_tools = 0 + processed_repository_ids = [] + for repository_metadata in self.sa_session.query( self.model.RepositoryMetadata ) \ + .filter( and_( self.model.RepositoryMetadata.table.c.malicious == False, + self.model.RepositoryMetadata.table.c.metadata is not None, + self.model.RepositoryMetadata.table.c.tool_versions is not None ) ): + processed_guids = [] + repository = repository_metadata.repository + if repository.id not in processed_repository_ids: + for revision_metadata in repository.downloadable_revisions: + metadata = revision_metadata.metadata + if 'tools' in metadata: + tool_dicts = metadata[ 'tools' ] + for tool_dict in tool_dicts: + guid = tool_dict[ 'guid' ] + if guid not in processed_guids: + valid_tools += 1 + processed_guids.append( guid ) + processed_repository_ids.append( repository.id ) + return valid_tools + def add_to_shed_tool_config( app, shed_tool_conf_dict, elem_list ): # A tool shed repository is being installed so change the shed_tool_conf file. Parse the config file to generate the entire list # of config_elems instead of using the in-memory list since it will be a subset of the entire list if one or more repositories have diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/webapps/community/app.py --- a/lib/galaxy/webapps/community/app.py +++ b/lib/galaxy/webapps/community/app.py @@ -43,6 +43,8 @@ # Load security policy self.security_agent = self.model.security_agent self.quota_agent = galaxy.quota.NoQuotaAgent( self.model ) - self.openid_providers = OpenIDProviders() #TODO: Add OpenID support + # TODO: Add OpenID support + self.openid_providers = OpenIDProviders() + self.shed_counter = self.model.shed_counter def shutdown( self ): pass diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/webapps/community/controllers/admin.py --- a/lib/galaxy/webapps/community/controllers/admin.py +++ b/lib/galaxy/webapps/community/controllers/admin.py @@ -321,7 +321,7 @@ def get_value( self, trans, grid, repository_metadata ): repository = repository_metadata.repository repo = hg.repository( get_configured_ui(), repository.repo_path ) - ctx = get_changectx_for_changeset( trans, repo, repository_metadata.changeset_revision ) + ctx = get_changectx_for_changeset( repo, repository_metadata.changeset_revision ) return "%s:%s" % ( str( ctx.rev() ), repository_metadata.changeset_revision ) class ToolsColumn( grids.TextColumn ): def get_value( self, trans, grid, repository_metadata ): diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -140,7 +140,7 @@ changeset rev and the changeset revision string. """ repo = hg.repository( get_configured_ui(), repository.repo_path ) - ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx: return "%s:%s" % ( str( ctx.rev() ), changeset_revision ) else: @@ -425,7 +425,7 @@ repository = get_repository( trans, id ) repo_dir = repository.repo_path repo = hg.repository( get_configured_ui(), repo_dir ) - ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) metadata_dict = {} invalid_files = [] if ctx is not None: @@ -514,7 +514,7 @@ ancestor_metadata_dict = None for changeset in repo.changelog: current_changeset_revision = str( repo.changectx( changeset ) ) - ctx = get_changectx_for_changeset( trans, repo, current_changeset_revision ) + ctx = get_changectx_for_changeset( repo, current_changeset_revision ) if current_changeset_revision == repository.tip: current_metadata_dict, invalid_files = generate_metadata_for_repository_tip( trans, id, ctx, current_changeset_revision, repo_dir ) else: @@ -740,7 +740,7 @@ def get_repository_by_name( trans, name ): """Get a repository from the database via name""" return trans.sa_session.query( trans.model.Repository ).filter_by( name=name ).one() -def get_changectx_for_changeset( trans, repo, changeset_revision, **kwd ): +def get_changectx_for_changeset( repo, changeset_revision, **kwd ): """Retrieve a specified changectx from a repository""" for changeset in repo.changelog: ctx = repo.changectx( changeset ) @@ -963,7 +963,7 @@ # Get the tool config file name from the hgweb url, something like: # /repos/test/convert_chars1/file/e58dcf0026c7/convert_characters.xml old_tool_config_file_name = tool_config.split( '/' )[ -1 ] - ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) fctx = None for filename in ctx: filename_head, filename_tail = os.path.split( filename ) @@ -1001,7 +1001,7 @@ refresh_on_change_values = [] for repository_metadata in repository.downloadable_revisions: changeset_revision = repository_metadata.changeset_revision - ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx: rev = '%04d' % ctx.rev() label = "%s:%s" % ( str( ctx.rev() ), changeset_revision ) diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -854,7 +854,7 @@ repo = hg.repository( get_configured_ui(), repo_dir ) # Load each tool in the repository's changeset_revision to generate a list of # tool guids, since guids differentiate tools by id and version. - ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx is not None: tool_guids = [] for filename in ctx: @@ -1579,7 +1579,7 @@ status = params.get( 'status', 'done' ) repository = get_repository( trans, id ) repo = hg.repository( get_configured_ui(), repository.repo_path ) - ctx = get_changectx_for_changeset( trans, repo, ctx_str ) + ctx = get_changectx_for_changeset( repo, ctx_str ) if ctx is None: message = "Repository does not include changeset revision '%s'." % str( ctx_str ) status = 'error' diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 lib/galaxy/webapps/community/model/mapping.py --- a/lib/galaxy/webapps/community/model/mapping.py +++ b/lib/galaxy/webapps/community/model/mapping.py @@ -13,6 +13,7 @@ from galaxy.model.orm.ext.assignmapper import * from galaxy.model.custom_types import * from galaxy.util.bunch import Bunch +from galaxy.util.shed_util import ShedCounter from galaxy.webapps.community.security import CommunityRBACAgent metadata = MetaData() @@ -247,4 +248,5 @@ result.create_tables = create_tables #load local galaxy security policy result.security_agent = CommunityRBACAgent( result ) + result.shed_counter = ShedCounter( result ) return result diff -r babda116a4c0193c2ee4941d09ac78940098fece -r 080242921d9fb538b280a31260c687a0053a3eb7 templates/webapps/community/index.mako --- a/templates/webapps/community/index.mako +++ b/templates/webapps/community/index.mako @@ -39,7 +39,7 @@ <%def name="left_panel()"><div class="unified-panel-header" unselectable="on"> - <div class='unified-panel-header-inner'>Galaxy Tool Shed</div> + <div class='unified-panel-header-inner'>${trans.app.shed_counter.valid_tools} valid tools on ${trans.app.shed_counter.count_time}</div></div><div class="page-container" style="padding: 10px;"><div class="toolMenu"> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.