commit/galaxy-central: greg: Utility code cleanup and import tweaking.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b96fe1d76b38/ changeset: b96fe1d76b38 user: greg date: 2012-12-13 17:41:31 summary: Utility code cleanup and import tweaking. affected #: 19 files diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/__init__.py --- a/lib/galaxy/tool_shed/__init__.py +++ b/lib/galaxy/tool_shed/__init__.py @@ -3,7 +3,7 @@ """ import os import galaxy.util.shed_util -from galaxy.model.orm import * +from galaxy.model.orm import and_ from galaxy import eggs import pkg_resources diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/common_util.py --- a/lib/galaxy/tool_shed/common_util.py +++ b/lib/galaxy/tool_shed/common_util.py @@ -1,7 +1,7 @@ import os, urllib2 from galaxy import util from galaxy.util.odict import odict -from galaxy.tool_shed.encoding_util import * +from galaxy.tool_shed.encoding_util import tool_shed_decode REPOSITORY_OWNER = 'devteam' diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/encoding_util.py --- a/lib/galaxy/tool_shed/encoding_util.py +++ b/lib/galaxy/tool_shed/encoding_util.py @@ -1,5 +1,5 @@ -import binascii -from galaxy.util.hash_util import * +import binascii, logging +from galaxy.util.hash_util import hmac_new from galaxy.util.json import json_fix from galaxy import eggs @@ -8,6 +8,8 @@ pkg_resources.require( "simplejson" ) import simplejson +log = logging.getLogger( __name__ ) + encoding_sep = '__esep__' def tool_shed_decode( value ): diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/migrate/check.py --- a/lib/galaxy/tool_shed/migrate/check.py +++ b/lib/galaxy/tool_shed/migrate/check.py @@ -5,7 +5,6 @@ from migrate.versioning import repository, schema from sqlalchemy import * -from common import * from galaxy.util.odict import odict log = logging.getLogger( __name__ ) diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/tool_dependencies/common_util.py --- a/lib/galaxy/tool_shed/tool_dependencies/common_util.py +++ b/lib/galaxy/tool_shed/tool_dependencies/common_util.py @@ -1,5 +1,5 @@ import os, shutil, tarfile, urllib2, zipfile -from galaxy.datatypes.checkers import * +from galaxy.datatypes import checkers def create_env_var_dict( elem, tool_dependency_install_dir=None, tool_shed_repository_install_dir=None ): env_var_name = elem.get( 'name', 'PATH' ) @@ -73,13 +73,13 @@ zip_archive.close() return True def isbz2( file_path ): - return is_bz2( file_path ) + return checkers.is_bz2( file_path ) def isgzip( file_path ): - return is_gzip( file_path ) + return checkers.is_gzip( file_path ) def istar( file_path ): return tarfile.is_tarfile( file_path ) def iszip( file_path ): - return check_zip( file_path ) + return checkers.check_zip( file_path ) def make_directory( full_path ): if not os.path.exists( full_path ): os.makedirs( full_path ) diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/tool_shed/tool_dependencies/install_util.py --- a/lib/galaxy/tool_shed/tool_dependencies/install_util.py +++ b/lib/galaxy/tool_shed/tool_dependencies/install_util.py @@ -1,8 +1,8 @@ import sys, os, subprocess, tempfile -from common_util import * -from fabric_util import * -from galaxy.tool_shed.encoding_util import * -from galaxy.model.orm import * +import common_util +import fabric_util +from galaxy.tool_shed.encoding_util import tool_shed_encode +from galaxy.model.orm import and_ from galaxy import eggs import pkg_resources @@ -166,7 +166,7 @@ env_var_dicts = [] for env_elem in action_elem: if env_elem.tag == 'environment_variable': - env_var_dict = create_env_var_dict( env_elem, tool_dependency_install_dir=install_dir ) + env_var_dict = common_util.create_env_var_dict( env_elem, tool_dependency_install_dir=install_dir ) if env_var_dict: env_var_dicts.append( env_var_dict ) if env_var_dicts: @@ -185,7 +185,7 @@ else: try: # There is currently only one fabric method. - install_and_build_package( app, tool_dependency, actions_dict ) + fabric_util.install_and_build_package( app, tool_dependency, actions_dict ) except Exception, e: tool_dependency.status = app.model.ToolDependency.installation_status.ERROR tool_dependency.error_message = str( e ) @@ -273,7 +273,7 @@ name=env_var_name, version=None ) tool_shed_repository_install_dir = get_tool_shed_repository_install_dir( app, tool_shed_repository ) - env_var_dict = create_env_var_dict( env_var_elem, tool_shed_repository_install_dir=tool_shed_repository_install_dir ) + env_var_dict = common_util.create_env_var_dict( env_var_elem, tool_shed_repository_install_dir=tool_shed_repository_install_dir ) if env_var_dict: if not os.path.exists( install_dir ): os.makedirs( install_dir ) @@ -284,10 +284,10 @@ type='set_environment', status=app.model.ToolDependency.installation_status.INSTALLING, set_status=True ) - cmd = create_or_update_env_shell_file( install_dir, env_var_dict ) + cmd = common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) if env_var_version == '1.0': # Handle setting environment variables using a fabric method. - handle_command( app, tool_dependency, install_dir, cmd ) + fabric_util.handle_command( app, tool_dependency, install_dir, cmd ) sa_session.refresh( tool_dependency ) if tool_dependency.status != app.model.ToolDependency.installation_status.ERROR: tool_dependency.status = app.model.ToolDependency.installation_status.INSTALLED diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/admin.py --- a/lib/galaxy/webapps/community/controllers/admin.py +++ b/lib/galaxy/webapps/community/controllers/admin.py @@ -1,12 +1,12 @@ from galaxy.web.base.controller import * from galaxy.web.base.controllers.admin import Admin from galaxy.webapps.community import model -from galaxy.model.orm import * +from galaxy.model.orm import and_ from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.web.form_builder import SelectField from galaxy.util import inflector import galaxy.util.shed_util_common as suc -from common import * +import common from repository import RepositoryGrid, CategoryGrid from galaxy import eggs @@ -474,7 +474,7 @@ if k.startswith( 'f-' ): del kwd[ k ] if 'user_id' in kwd: - user = get_user( trans, kwd[ 'user_id' ] ) + user = common.get_user( trans, kwd[ 'user_id' ] ) kwd[ 'f-email' ] = user.email del kwd[ 'user_id' ] else: @@ -489,7 +489,7 @@ if k.startswith( 'f-' ): del kwd[ k ] category_id = kwd.get( 'id', None ) - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) kwd[ 'f-Category.name' ] = category.name elif operation == "receive email alerts": if kwd[ 'id' ]: @@ -533,7 +533,7 @@ # The received id is a RepositoryMetadata object id, so we need to get the # associated Repository and redirect to view_or_manage_repository with the # changeset_revision. - repository_metadata = get_repository_metadata_by_id( trans, kwd[ 'id' ] ) + repository_metadata = common.get_repository_metadata_by_id( trans, kwd[ 'id' ] ) repository = repository_metadata.repository kwd[ 'id' ] = trans.security.encode_id( repository.id ) kwd[ 'changeset_revision' ] = repository_metadata.changeset_revision @@ -554,7 +554,7 @@ if not name or not description: message = 'Enter a valid name and a description' status = 'error' - elif get_category_by_name( trans, name ): + elif common.get_category_by_name( trans, name ): message = 'A category with that name already exists' status = 'error' else: @@ -615,7 +615,7 @@ ids = util.listify( id ) count = 0 for repository_metadata_id in ids: - repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, repository_metadata_id ) trans.sa_session.delete( repository_metadata ) trans.sa_session.flush() count += 1 @@ -641,7 +641,7 @@ action='manage_categories', message=message, status='error' ) ) - category = get_category( trans, id ) + category = common.get_category( trans, id ) if params.get( 'edit_category_button', False ): new_name = util.restore_text( params.get( 'name', '' ) ).strip() new_description = util.restore_text( params.get( 'description', '' ) ).strip() @@ -649,7 +649,7 @@ if not new_name: message = 'Enter a valid name' status = 'error' - elif category.name != new_name and get_category_by_name( trans, name ): + elif category.name != new_name and common.get_category_by_name( trans, name ): message = 'A category with that name already exists' status = 'error' else: @@ -772,7 +772,7 @@ ids = util.listify( id ) message = "Deleted %d categories: " % len( ids ) for category_id in ids: - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) category.deleted = True trans.sa_session.add( category ) trans.sa_session.flush() @@ -800,7 +800,7 @@ purged_categories = "" message = "Purged %d categories: " % len( ids ) for category_id in ids: - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) if category.deleted: # Delete RepositoryCategoryAssociations for rca in category.repositories: @@ -827,7 +827,7 @@ count = 0 undeleted_categories = "" for category_id in ids: - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) if category.deleted: category.deleted = False trans.sa_session.add( category ) diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -1,16 +1,13 @@ import os, string, socket, logging, simplejson, binascii, tempfile, filecmp -from time import strftime +from time import gmtime, strftime from datetime import * -from galaxy.datatypes.checkers import * from galaxy.tools import * from galaxy.util.odict import odict from galaxy.util.json import from_json_string, to_json_string -from galaxy.util.hash_util import * import galaxy.util.shed_util_common as suc -from galaxy.web.base.controller import * from galaxy.web.base.controllers.admin import * from galaxy.webapps.community import model -from galaxy.model.orm import * +from galaxy.model.orm import and_ from galaxy.model.item_attrs import UsesItemRatings from galaxy import eggs @@ -73,9 +70,6 @@ '${host}' """ -# States for passing messages -SUCCESS, INFO, WARNING, ERROR = "done", "info", "warning", "error" - malicious_error = " This changeset cannot be downloaded because it potentially produces malicious behavior or contains inappropriate content." malicious_error_can_push = " Correct this changeset as soon as possible, it potentially produces malicious behavior or contains inappropriate content." @@ -146,7 +140,6 @@ return False def changeset_revision_reviewed_by_user( trans, user, repository, changeset_revision ): """Determine if the current changeset revision has been reviewed by the current user.""" - changeset_revision_reviewed_by_user = False for review in repository.reviews: if review.changeset_revision == changeset_revision and review.user == user: return True @@ -162,34 +155,6 @@ if user_email in admin_users: return True return False -def copy_file_from_disk( filename, repo_dir, dir ): - file_path = None - found = False - for root, dirs, files in os.walk( repo_dir ): - if root.find( '.hg' ) < 0: - for name in files: - if name == filename: - file_path = os.path.abspath( os.path.join( root, name ) ) - found = True - break - if found: - break - if file_path: - tmp_filename = os.path.join( dir, filename ) - shutil.copy( file_path, tmp_filename ) - else: - tmp_filename = None - return tmp_filename -def generate_tool_guid( trans, repository, tool ): - """ - Generate a guid for the received tool. The form of the guid is - <tool shed host>/repos/<tool shed username>/<tool shed repo name>/<tool id>/<tool version> - """ - return '%s/repos/%s/%s/%s/%s' % ( trans.request.host, - repository.user.username, - repository.name, - tool.id, - tool.version ) def get_absolute_path_to_file_in_repository( repo_files_dir, file_name ): stripped_file_name = suc.strip_path( file_name ) file_path = None @@ -287,10 +252,6 @@ def get_repository_metadata_by_id( trans, id ): """Get repository metadata from the database""" return trans.sa_session.query( trans.model.RepositoryMetadata ).get( trans.security.decode_id( id ) ) -def get_repository_metadata_by_repository_id( trans, id ): - """Get all metadata records for a specified repository.""" - return trans.sa_session.query( trans.model.RepositoryMetadata ) \ - .filter( trans.model.RepositoryMetadata.table.c.repository_id == trans.security.decode_id( id ) ) def get_repository_metadata_revisions_for_review( repository, reviewed=True ): repository_metadata_revisions = [] metadata_changeset_revision_hashes = [] @@ -402,7 +363,7 @@ tip_changeset = repo.changelog.tip() ctx = repo.changectx( tip_changeset ) t, tz = ctx.date() - date = datetime( *time.gmtime( float( t ) - tz )[:6] ) + date = datetime( *gmtime( float( t ) - tz )[:6] ) display_date = date.strftime( "%Y-%m-%d" ) try: username = ctx.user().split()[0] diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -1,5 +1,5 @@ import os, logging, tempfile, shutil, ConfigParser -from time import strftime +from time import gmtime, strftime from datetime import date, datetime from galaxy import util from galaxy.web.base.controller import * @@ -8,10 +8,10 @@ from galaxy.webapps.community.model import directory_hash_id from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.util.json import from_json_string, to_json_string -from galaxy.model.orm import * +from galaxy.model.orm import and_ import galaxy.util.shed_util_common as suc -from galaxy.tool_shed.encoding_util import * -from common import * +from galaxy.tool_shed.encoding_util import tool_shed_encode +import common from galaxy import eggs eggs.require('mercurial') @@ -511,7 +511,7 @@ link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=False ) -class RepositoryController( BaseUIController, ItemRatings ): +class RepositoryController( BaseUIController, common.ItemRatings ): install_matched_repository_grid = InstallMatchedRepositoryGrid() matched_repository_grid = MatchedRepositoryGrid() @@ -535,7 +535,7 @@ # The value of 'id' has been set to the search string, which is a repository name. We'll try to get the desired encoded repository # id to pass on. try: - repository = get_repository_by_name( trans, kwd[ 'id' ] ) + repository = common.get_repository_by_name( trans, kwd[ 'id' ] ) kwd[ 'id' ] = trans.security.encode_id( repository.id ) except: pass @@ -610,7 +610,7 @@ if k.startswith( 'f-' ): del kwd[ k ] if 'user_id' in kwd: - user = get_user( trans, kwd[ 'user_id' ] ) + user = common.get_user( trans, kwd[ 'user_id' ] ) kwd[ 'f-email' ] = user.email del kwd[ 'user_id' ] else: @@ -650,7 +650,7 @@ if k.startswith( 'f-' ): del kwd[ k ] category_id = kwd.get( 'id', None ) - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) kwd[ 'f-Category.name' ] = category.name elif operation == "receive email alerts": if trans.user: @@ -691,7 +691,7 @@ repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) # Update repository files for browsing. suc.update_repository( repo ) - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) metadata = self.get_metadata( trans, id, repository.tip( trans.app ) ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repository=repository, @@ -716,7 +716,8 @@ # The value of 'id' has been set to the search string, which is a repository name. # We'll try to get the desired encoded repository id to pass on. try: - repository = get_repository_by_name( trans, kwd[ 'id' ] ) + name = kwd[ 'id' ] + repository = common.get_repository_by_name( trans, name ) kwd[ 'id' ] = trans.security.encode_id( repository.id ) except: pass @@ -739,7 +740,7 @@ if 'f-Category.name' in kwd: # The user browsed to a category and then entered a search string, so get the category associated with it's value. category_name = kwd[ 'f-Category.name' ] - category = get_category_by_name( trans, category_name ) + category = common.get_category_by_name( trans, category_name ) # Set the id value in kwd since it is required by the ValidRepositoryGrid.build_initial_query method. kwd[ 'id' ] = trans.security.encode_id( category.id ) if galaxy_url: @@ -749,7 +750,7 @@ if operation == "preview_tools_in_changeset": repository_id = kwd.get( 'id', None ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) - repository_metadata = get_latest_repository_metadata( trans, repository.id ) + repository_metadata = common.get_latest_repository_metadata( trans, repository.id ) latest_installable_changeset_revision = repository_metadata.changeset_revision return trans.response.send_redirect( web.url_for( controller='repository', action='preview_tools_in_changeset', @@ -761,7 +762,7 @@ if k.startswith( 'f-' ): del kwd[ k ] category_id = kwd.get( 'id', None ) - category = get_category( trans, category_id ) + category = common.get_category( trans, category_id ) kwd[ 'f-Category.name' ] = category.name # The changeset_revision_select_field in the ValidRepositoryGrid performs a refresh_on_change which sends in request parameters like # changeset_revison_1, changeset_revision_2, etc. One of the many select fields on the grid performed the refresh_on_change, so we loop @@ -921,7 +922,7 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - categories = get_categories( trans ) + categories = common.get_categories( trans ) if not categories: message = 'No categories have been configured in this instance of the Galaxy Tool Shed. ' + \ 'An administrator needs to create some via the Administrator control panel before creating repositories.', @@ -1018,11 +1019,11 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - repository, tool, message = load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) + repository, tool, message = common.load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) if message: status = 'error' tool_state = self.__new_state( trans ) - is_malicious = changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) metadata = self.get_metadata( trans, repository_id, changeset_revision ) try: return trans.fill_template( "/webapps/community/repository/tool_form.mako", @@ -1085,7 +1086,7 @@ is_admin = trans.user_is_admin() if operation == "view_or_manage_repository": # The received id is a RepositoryMetadata id, so we have to get the repository id. - repository_metadata = get_repository_metadata_by_id( trans, item_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, item_id ) repository_id = trans.security.encode_id( repository_metadata.repository.id ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) kwd[ 'id' ] = repository_id @@ -1102,7 +1103,7 @@ encoded_repository_ids = [] changeset_revisions = [] for repository_metadata_id in util.listify( item_id ): - repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, repository_metadata_id ) encoded_repository_ids.append( trans.security.encode_id( repository_metadata.repository.id ) ) changeset_revisions.append( repository_metadata.changeset_revision ) new_kwd[ 'repository_ids' ] = encoded_repository_ids @@ -1170,7 +1171,7 @@ is_admin = trans.user_is_admin() if operation == "view_or_manage_repository": # The received id is a RepositoryMetadata id, so we have to get the repository id. - repository_metadata = get_repository_metadata_by_id( trans, item_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, item_id ) repository_id = trans.security.encode_id( repository_metadata.repository.id ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) kwd[ 'id' ] = repository_id @@ -1187,7 +1188,7 @@ encoded_repository_ids = [] changeset_revisions = [] for repository_metadata_id in util.listify( item_id ): - repository_metadata = get_repository_metadata_by_id( trans, item_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, item_id ) encoded_repository_ids.append( trans.security.encode_id( repository_metadata.repository.id ) ) changeset_revisions.append( repository_metadata.changeset_revision ) new_kwd = {} @@ -1581,9 +1582,9 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'error' ) - repository, tool, error_message = load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) + repository, tool, error_message = common.load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) tool_state = self.__new_state( trans ) - is_malicious = changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) invalid_file_tups = [] if tool: invalid_file_tups = suc.check_tool_input_params( trans.app, @@ -1781,7 +1782,7 @@ selected_value=changeset_revision, add_id_to_name=False, downloadable=False ) - revision_label = get_revision_label( trans, repository, repository.tip( trans.app ) ) + revision_label = common.get_revision_label( trans, repository, repository.tip( trans.app ) ) repository_metadata = None repository_metadata_id = None metadata = None @@ -1790,7 +1791,7 @@ if changeset_revision != suc.INITIAL_CHANGELOG_HASH: repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, id, changeset_revision ) if repository_metadata: - revision_label = get_revision_label( trans, repository, changeset_revision ) + revision_label = common.get_revision_label( trans, repository, changeset_revision ) repository_metadata_id = trans.security.encode_id( repository_metadata.id ) metadata = repository_metadata.metadata is_malicious = repository_metadata.malicious @@ -1800,7 +1801,7 @@ if previous_changeset_revision != suc.INITIAL_CHANGELOG_HASH: repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, id, previous_changeset_revision ) if repository_metadata: - revision_label = get_revision_label( trans, repository, previous_changeset_revision ) + revision_label = common.get_revision_label( trans, repository, previous_changeset_revision ) repository_metadata_id = trans.security.encode_id( repository_metadata.id ) metadata = repository_metadata.metadata is_malicious = repository_metadata.malicious @@ -1815,20 +1816,17 @@ handled_key_rd_dicts=None ) if is_malicious: if trans.app.security_agent.can_push( trans.app, trans.user, repository ): - message += malicious_error_can_push + message += common.malicious_error_can_push else: - message += malicious_error + message += common.malicious_error status = 'error' malicious_check_box = CheckboxField( 'malicious', checked=is_malicious ) - categories = get_categories( trans ) + categories = common.get_categories( trans ) selected_categories = [ rca.category_id for rca in repository.categories ] # Determine if the current changeset revision has been reviewed by the current user. - reviewed_by_user = changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) + reviewed_by_user = common.changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) if reviewed_by_user: - review = get_review_by_repository_id_changeset_revision_user_id( trans, - id, - changeset_revision, - trans.security.encode_id( trans.user.id ) ) + review = common.get_review_by_repository_id_changeset_revision_user_id( trans, id, changeset_revision, trans.security.encode_id( trans.user.id ) ) review_id = trans.security.encode_id( review.id ) else: review_id = None @@ -1929,7 +1927,7 @@ repository_metadata_id = None metadata = None repository_dependencies = None - revision_label = get_revision_label( trans, repository, changeset_revision ) + revision_label = common.get_revision_label( trans, repository, changeset_revision ) changeset_revision_select_field = build_changeset_revision_select_field( trans, repository, selected_value=changeset_revision, @@ -2001,7 +1999,7 @@ avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) rra = self.get_user_item_rating( trans.sa_session, trans.user, repository, webapp_model=trans.model ) - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) metadata = self.get_metadata( trans, id, repository.tip( trans.app ) ) return trans.fill_template( '/webapps/community/repository/rate_repository.mako', repository=repository, @@ -2161,7 +2159,7 @@ if not commit_message: commit_message = 'Deleted selected files' commands.commit( repo.ui, repo, repo_dir, user=trans.user.username, message=commit_message ) - handle_email_alerts( trans, repository ) + common.handle_email_alerts( trans, repository ) # Update the repository files for browsing. suc.update_repository( repo ) # Get the new repository tip. @@ -2173,11 +2171,11 @@ else: message += 'The selected files were deleted from the repository. ' kwd[ 'message' ] = message - set_repository_metadata_due_to_new_tip( trans, repository, **kwd ) + common.set_repository_metadata_due_to_new_tip( trans, repository, **kwd ) else: message = "Select at least 1 file to delete from the repository before clicking <b>Delete selected files</b>." status = "error" - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repo=repo, repository=repository, @@ -2200,7 +2198,7 @@ # Get the name of the server hosting the tool shed instance. host = trans.request.host # Build the email message - body = string.Template( contact_owner_template ) \ + body = string.Template( common.contact_owner_template ) \ .safe_substitute( username=trans.user.username, repository_name=repository.name, email=trans.user.email, @@ -2319,7 +2317,7 @@ else: has_metadata = False t, tz = ctx.date() - date = datetime( *time.gmtime( float( t ) - tz )[:6] ) + date = datetime( *gmtime( float( t ) - tz )[:6] ) display_date = date.strftime( "%Y-%m-%d" ) change_dict = { 'ctx' : ctx, 'rev' : str( ctx.rev() ), @@ -2332,7 +2330,7 @@ 'has_metadata' : has_metadata } # Make sure we'll view latest changeset first. changesets.insert( 0, change_dict ) - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) metadata = self.get_metadata( trans, id, repository.tip( trans.app ) ) return trans.fill_template( '/webapps/community/repository/view_changelog.mako', repository=repository, @@ -2363,7 +2361,7 @@ diffs = [] for diff in patch.diff( repo, node1=ctx_parent.node(), node2=ctx.node() ): diffs.append( suc.to_safe_string( diff, to_html=True ) ) - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) metadata = self.get_metadata( trans, id, ctx_str ) return trans.fill_template( '/webapps/community/repository/view_changeset.mako', repository=repository, @@ -2433,7 +2431,7 @@ selected_value=changeset_revision, add_id_to_name=False, downloadable=False ) - revision_label = get_revision_label( trans, repository, changeset_revision ) + revision_label = common.get_revision_label( trans, repository, changeset_revision ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, id, changeset_revision ) if repository_metadata: repository_metadata_id = trans.security.encode_id( repository_metadata.id ) @@ -2449,20 +2447,17 @@ else: repository_metadata_id = None metadata = None - is_malicious = changeset_is_malicious( trans, id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, id, repository.tip( trans.app ) ) if is_malicious: if trans.app.security_agent.can_push( trans.app, trans.user, repository ): - message += malicious_error_can_push + message += common.malicious_error_can_push else: - message += malicious_error + message += common.malicious_error status = 'error' # Determine if the current changeset revision has been reviewed by the current user. - reviewed_by_user = changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) + reviewed_by_user = common.changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) if reviewed_by_user: - review = get_review_by_repository_id_changeset_revision_user_id( trans, - id, - changeset_revision, - trans.security.encode_id( trans.user.id ) ) + review = common.get_review_by_repository_id_changeset_revision_user_id( trans, id, changeset_revision, trans.security.encode_id( trans.user.id ) ) review_id = trans.security.encode_id( review.id ) else: review_id = None @@ -2499,7 +2494,7 @@ tool = None guid = None original_tool_data_path = trans.app.config.tool_data_path - revision_label = get_revision_label( trans, repository, changeset_revision ) + revision_label = common.get_revision_label( trans, repository, changeset_revision ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) if repository_metadata: metadata = repository_metadata.metadata @@ -2512,7 +2507,7 @@ guid = tool_metadata_dict[ 'guid' ] full_path_to_tool_config = os.path.abspath( relative_path_to_tool_config ) full_path_to_dir, tool_config_filename = os.path.split( full_path_to_tool_config ) - can_use_disk_file = can_use_tool_config_disk_file( trans, repository, repo, full_path_to_tool_config, changeset_revision ) + can_use_disk_file = common.can_use_tool_config_disk_file( trans, repository, repo, full_path_to_tool_config, changeset_revision ) if can_use_disk_file: trans.app.config.tool_data_path = work_dir tool, valid, message, sample_files = suc.handle_sample_files_and_load_tool_from_disk( trans, @@ -2534,19 +2529,16 @@ tool_lineage = self.get_versions_of_tool( trans, repository, repository_metadata, guid ) else: metadata = None - is_malicious = changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) + is_malicious = common.changeset_is_malicious( trans, repository_id, repository.tip( trans.app ) ) changeset_revision_select_field = build_changeset_revision_select_field( trans, repository, selected_value=changeset_revision, add_id_to_name=False, downloadable=False ) trans.app.config.tool_data_path = original_tool_data_path - reviewed_by_user = changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) + reviewed_by_user = common.changeset_revision_reviewed_by_user( trans, trans.user, repository, changeset_revision ) if reviewed_by_user: - review = get_review_by_repository_id_changeset_revision_user_id( trans, - id, - changeset_revision, - trans.security.encode_id( trans.user.id ) ) + review = common.get_review_by_repository_id_changeset_revision_user_id( trans, id, changeset_revision, trans.security.encode_id( trans.user.id ) ) review_id = trans.security.encode_id( review.id ) else: review_id = None @@ -2598,7 +2590,7 @@ # Restrict the options to all revisions that have associated metadata. repository_metadata_revisions = repository.metadata_revisions for repository_metadata in repository_metadata_revisions: - rev, label, changeset_revision = get_rev_label_changeset_revision_from_repository_metadata( trans, repository_metadata, repository=repository ) + rev, label, changeset_revision = common.get_rev_label_changeset_revision_from_repository_metadata( trans, repository_metadata, repository=repository ) changeset_tups.append( ( rev, label, changeset_revision ) ) refresh_on_change_values.append( changeset_revision ) # Sort options by the revision label. Even though the downloadable_revisions query sorts by update_time, diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/repository_review.py --- a/lib/galaxy/webapps/community/controllers/repository_review.py +++ b/lib/galaxy/webapps/community/controllers/repository_review.py @@ -6,7 +6,7 @@ from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.model.orm import and_ from sqlalchemy.sql.expression import func -from common import * +import common from galaxy.webapps.community.util.container_util import STRSEP from repository import RepositoryGrid import galaxy.util.shed_util_common as suc @@ -59,7 +59,7 @@ repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) for review in repository.reviews: changeset_revision = review.changeset_revision - rev, label = get_rev_label_from_changeset_revision( repo, changeset_revision ) + rev, label = common.get_rev_label_from_changeset_revision( repo, changeset_revision ) rval += '<a href="manage_repository_reviews_of_revision' rval += '?id=%s&changeset_revision=%s">%s</a><br/>' % ( trans.security.encode_id( repository.id ), changeset_revision, label ) return rval @@ -67,13 +67,13 @@ class WithoutReviewsRevisionColumn( grids.GridColumn ): def get_value( self, trans, grid, repository ): # Restrict the options to revisions that have not yet been reviewed. - repository_metadata_revisions = get_repository_metadata_revisions_for_review( repository, reviewed=False ) + repository_metadata_revisions = common.get_repository_metadata_revisions_for_review( repository, reviewed=False ) if repository_metadata_revisions: rval = '' for repository_metadata in repository_metadata_revisions: - rev, label, changeset_revision = get_rev_label_changeset_revision_from_repository_metadata( trans, - repository_metadata, - repository=repository ) + rev, label, changeset_revision = common.get_rev_label_changeset_revision_from_repository_metadata( trans, + repository_metadata, + repository=repository ) rval += '<a href="manage_repository_reviews_of_revision' rval += '?id=%s&changeset_revision=%s">%s</a><br/>' % ( trans.security.encode_id( repository.id ), changeset_revision, label ) return rval @@ -177,7 +177,7 @@ rval += 'edit_review' else: rval +='browse_review' - rval += '?id=%s">%s</a>' % ( encoded_review_id, get_revision_label( trans, review.repository, review.changeset_revision ) ) + rval += '?id=%s">%s</a>' % ( encoded_review_id, common.get_revision_label( trans, review.repository, review.changeset_revision ) ) return rval class RatingColumn( grids.TextColumn ): def get_value( self, trans, grid, review ): @@ -260,7 +260,7 @@ .outerjoin( ( model.ComponentReview.table, model.ComponentReview.table.c.repository_review_id == model.RepositoryReview.table.c.id ) ) \ .outerjoin( ( model.Component.table, model.Component.table.c.id == model.ComponentReview.table.c.component_id ) ) -class RepositoryReviewController( BaseUIController, ItemRatings ): +class RepositoryReviewController( BaseUIController, common.ItemRatings ): component_grid = ComponentGrid() repositories_reviewed_by_me_grid = RepositoriesReviewedByMeGrid() @@ -277,7 +277,7 @@ message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) encoded_review_id = kwd[ 'id' ] - review = get_review( trans, encoded_review_id ) + review = common.get_review( trans, encoded_review_id ) if kwd.get( 'approve_repository_review_button', False ): approved_select_field_name = '%s%sapproved' % ( encoded_review_id, STRSEP ) approved_select_field_value = str( kwd[ approved_select_field_name ] ) @@ -309,10 +309,10 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - review = get_review( trans, kwd[ 'id' ] ) + review = common.get_review( trans, kwd[ 'id' ] ) repository = review.repository repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) - rev, changeset_revision_label = get_rev_label_from_changeset_revision( repo, review.changeset_revision ) + rev, changeset_revision_label = common.get_rev_label_from_changeset_revision( repo, review.changeset_revision ) return trans.fill_template( '/webapps/community/repository_review/browse_review.mako', repository=repository, changeset_revision_label=changeset_revision_label, @@ -345,7 +345,7 @@ if not name or not description: message = 'Enter a valid name and a description' status = 'error' - elif get_component_by_name( trans, name ): + elif common.get_component_by_name( trans, name ): message = 'A component with that name already exists' status = 'error' else: @@ -377,16 +377,16 @@ if repository_id: if changeset_revision: # Make sure there is not already a review of the revision by the user. - if get_review_by_repository_id_changeset_revision_user_id( trans, - repository_id, - changeset_revision, - trans.security.encode_id( trans.user.id ) ): + if common.get_review_by_repository_id_changeset_revision_user_id( trans, + repository_id, + changeset_revision, + trans.security.encode_id( trans.user.id ) ): message = "You have already created a review for revision <b>%s</b> of repository <b>%s</b>." % ( changeset_revision, repository.name ) status = "error" else: repository = suc.get_repository_in_tool_shed( trans, repository_id ) # See if there are any reviews for previous changeset revisions that the user can copy. - if not create_without_copying and not previous_review_id and has_previous_repository_reviews( trans, repository, changeset_revision ): + if not create_without_copying and not previous_review_id and common.has_previous_repository_reviews( trans, repository, changeset_revision ): return trans.response.send_redirect( web.url_for( controller='repository_review', action='select_previous_review', **kwd ) ) @@ -404,7 +404,7 @@ trans.sa_session.add( review ) trans.sa_session.flush() if previous_review_id: - review_to_copy = get_review( trans, previous_review_id ) + review_to_copy = common.get_review( trans, previous_review_id ) self.copy_review( trans, review_to_copy, review ) review_id = trans.security.encode_id( review.id ) message = "Begin your review of revision <b>%s</b> of repository <b>%s</b>." \ @@ -440,7 +440,7 @@ action='manage_categories', message=message, status='error' ) ) - component = get_component( trans, id ) + component = common.get_component( trans, id ) if params.get( 'edit_component_button', False ): new_description = util.restore_text( params.get( 'description', '' ) ).strip() if component.description != new_description: @@ -465,9 +465,9 @@ message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) review_id = kwd.get( 'id', None ) - review = get_review( trans, review_id ) + review = common.get_review( trans, review_id ) components_dict = odict() - for component in get_components( trans ): + for component in common.get_components( trans ): components_dict[ component.name ] = dict( component=component, component_review=None ) repository = review.repository repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) @@ -517,8 +517,8 @@ approved = str( v ) elif component_review_attr == 'rating': rating = int( str( v ) ) - component = get_component( trans, component_id ) - component_review = get_component_review_by_repository_review_id_component_id( trans, review_id, component_id ) + component = common.get_component( trans, component_id ) + component_review = common.get_component_review_by_repository_review_id_component_id( trans, review_id, component_id ) if component_review: # See if the existing component review should be updated. if component_review.comment != comment or \ @@ -572,7 +572,7 @@ name='revision_approved', selected_value=selected_value, for_component=False ) - rev, changeset_revision_label = get_rev_label_from_changeset_revision( repo, review.changeset_revision ) + rev, changeset_revision_label = common.get_rev_label_from_changeset_revision( repo, review.changeset_revision ) return trans.fill_template( '/webapps/community/repository_review/edit_review.mako', repository=repository, review=review, @@ -659,14 +659,14 @@ metadata_revision_hashes = [ metadata_revision.changeset_revision for metadata_revision in repository.metadata_revisions ] reviewed_revision_hashes = [ review.changeset_revision for review in repository.reviews ] reviews_dict = odict() - for changeset in get_reversed_changelog_changesets( repo ): + for changeset in common.get_reversed_changelog_changesets( repo ): ctx = repo.changectx( changeset ) changeset_revision = str( ctx ) if changeset_revision in metadata_revision_hashes or changeset_revision in reviewed_revision_hashes: - rev, changeset_revision_label = get_rev_label_from_changeset_revision( repo, changeset_revision ) + rev, changeset_revision_label = common.get_rev_label_from_changeset_revision( repo, changeset_revision ) if changeset_revision in reviewed_revision_hashes: # Find the review for this changeset_revision - repository_reviews = get_reviews_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) + repository_reviews = common.get_reviews_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) # Determine if the current user can add a review to this revision. can_add_review = trans.user not in [ repository_review.user for repository_review in repository_reviews ] repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) @@ -704,8 +704,8 @@ repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) installable = changeset_revision in [ metadata_revision.changeset_revision for metadata_revision in repository.metadata_revisions ] - rev, changeset_revision_label = get_rev_label_from_changeset_revision( repo, changeset_revision ) - reviews = get_reviews_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) + rev, changeset_revision_label = common.get_rev_label_from_changeset_revision( repo, changeset_revision ) + reviews = common.get_reviews_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) return trans.fill_template( '/webapps/community/repository_review/reviews_of_changeset_revision.mako', repository=repository, changeset_revision=changeset_revision, @@ -724,7 +724,7 @@ if 'operation' in kwd: operation = kwd['operation'].lower() # The value of the received id is the encoded review id. - review = get_review( trans, kwd[ 'id' ] ) + review = common.get_review( trans, kwd[ 'id' ] ) repository = review.repository kwd[ 'id' ] = trans.security.encode_id( repository.id ) if operation == "inspect repository revisions": @@ -737,7 +737,7 @@ action='view_or_manage_repository', **kwd ) ) # The user may not be the current user. The value of the received id is the encoded user id. - user = get_user( trans, kwd[ 'id' ] ) + user = common.get_user( trans, kwd[ 'id' ] ) self.repository_reviews_by_user_grid.title = "All repository revision reviews for user '%s'" % user.username return self.repository_reviews_by_user_grid( trans, **kwd ) @web.expose @@ -768,8 +768,8 @@ repository = suc.get_repository_in_tool_shed( trans, kwd[ 'id' ] ) changeset_revision = kwd.get( 'changeset_revision', None ) repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) - previous_reviews_dict = get_previous_repository_reviews( trans, repository, changeset_revision ) - rev, changeset_revision_label = get_rev_label_from_changeset_revision( repo, changeset_revision ) + previous_reviews_dict = common.get_previous_repository_reviews( trans, repository, changeset_revision ) + rev, changeset_revision_label = common.get_rev_label_from_changeset_revision( repo, changeset_revision ) return trans.fill_template( '/webapps/community/repository_review/select_previous_review.mako', repository=repository, changeset_revision=changeset_revision, diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/upload.py --- a/lib/galaxy/webapps/community/controllers/upload.py +++ b/lib/galaxy/webapps/community/controllers/upload.py @@ -1,8 +1,7 @@ import sys, os, shutil, logging, tarfile, tempfile, urllib from galaxy.web.base.controller import * -from galaxy.model.orm import * -from galaxy.datatypes.checkers import * -from common import * +from galaxy.datatypes import checkers +import common import galaxy.util.shed_util_common as suc from galaxy import eggs @@ -13,8 +12,6 @@ undesirable_dirs = [ '.hg', '.svn', '.git', '.cvs' ] undesirable_files = [ '.hg_archival.txt', 'hgrc', '.DS_Store' ] -# States for passing messages -SUCCESS, INFO, WARNING, ERROR = "done", "info", "warning", "error" CHUNK_SIZE = 2**20 # 1Mb class UploadController( BaseUIController ): @@ -26,7 +23,7 @@ status = params.get( 'status', 'done' ) commit_message = util.restore_text( params.get( 'commit_message', 'Uploaded' ) ) category_ids = util.listify( params.get( 'category_id', '' ) ) - categories = get_categories( trans ) + categories = common.get_categories( trans ) repository_id = params.get( 'repository_id', '' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_dir = repository.repo_path( trans.app ) @@ -40,7 +37,7 @@ url = params.get( 'url', '' ) # Part of the upload process is sending email notification to those that have registered to # receive them. One scenario occurs when the first change set is produced for the repository. - # See the handle_email_alerts() method for the definition of the scenarios. + # See the common.handle_email_alerts() method for the definition of the scenarios. new_repo_alert = repository.is_new( trans.app ) uploaded_directory = None if params.get( 'upload_button', False ): @@ -85,9 +82,9 @@ isbz2 = False if uploaded_file: if uncompress_file: - isgzip = is_gzip( uploaded_file_name ) + isgzip = checkers.is_gzip( uploaded_file_name ) if not isgzip: - isbz2 = is_bz2( uploaded_file_name ) + isbz2 = checkers.is_bz2( uploaded_file_name ) if isempty: tar = None istar = False @@ -134,7 +131,7 @@ shutil.move( uploaded_file_name, full_path ) # See if any admin users have chosen to receive email alerts when a repository is # updated. If so, check every uploaded file to ensure content is appropriate. - check_contents = check_file_contents( trans ) + check_contents = common.check_file_contents( trans ) if check_contents and os.path.isfile( full_path ): content_alert_str = self.__check_file_content( full_path ) else: @@ -151,7 +148,7 @@ message = '%s<br/>%s' % ( message, error_message ) # See if the content of the change set was valid. admin_only = len( repository.downloadable_revisions ) != 1 - handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) + common.handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) if ok: # Update the repository files for browsing. suc.update_repository( repo ) @@ -180,7 +177,7 @@ else: message += " %d files were removed from the repository root. " % len( files_to_remove ) kwd[ 'message' ] = message - set_repository_metadata_due_to_new_tip( trans, repository, content_alert_str=content_alert_str, **kwd ) + common.set_repository_metadata_due_to_new_tip( trans, repository, content_alert_str=content_alert_str, **kwd ) # Provide a warning message if a tool_dependencies.xml file is provided, but tool dependencies weren't loaded due to e.g. a requirement tag mismatch if suc.get_config_from_disk( 'tool_dependencies.xml', repo_dir ): if repository.metadata_revisions: @@ -330,7 +327,7 @@ pass # See if any admin users have chosen to receive email alerts when a repository is # updated. If so, check every uploaded file to ensure content is appropriate. - check_contents = check_file_contents( trans ) + check_contents = common.check_file_contents( trans ) for filename_in_archive in filenames_in_archive: # Check file content to ensure it is appropriate. if check_contents and os.path.isfile( filename_in_archive ): @@ -344,7 +341,7 @@ return False, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) admin_only = len( repository.downloadable_revisions ) != 1 - handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) + common.handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) return True, '', files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed def uncompress( self, repository, uploaded_file_name, uploaded_file_filename, isgzip, isbz2 ): if isgzip: @@ -423,8 +420,8 @@ return True, '' def __check_file_content( self, file_path ): message = '' - if check_html( file_path ): + if checkers.check_html( file_path ): message = 'The file "%s" contains HTML content.\n' % str( file_path ) - elif check_image( file_path ): + elif checkers.check_image( file_path ): message = 'The file "%s" contains image content.\n' % str( file_path ) return message diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/controllers/workflow.py --- a/lib/galaxy/webapps/community/controllers/workflow.py +++ b/lib/galaxy/webapps/community/controllers/workflow.py @@ -6,12 +6,12 @@ from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.util.json import from_json_string, to_json_string from galaxy.workflow.modules import InputDataModule, ToolModule, WorkflowModuleFactory +from galaxy.web.base.controller import * from galaxy.tools import DefaultToolState from galaxy.webapps.galaxy.controllers.workflow import attach_ordered_steps -from galaxy.model.orm import * -from common import * +import common import galaxy.util.shed_util_common as suc -from galaxy.tool_shed.encoding_util import * +from galaxy.tool_shed.encoding_util import tool_shed_encode, tool_shed_decode class RepoInputDataModule( InputDataModule ): @@ -49,7 +49,7 @@ self.errors = None for tool_dict in tools_metadata: if self.tool_id in [ tool_dict[ 'id' ], tool_dict[ 'guid' ] ]: - repository, self.tool, message = load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_dict[ 'tool_config' ] ) + repository, self.tool, message = common.load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_dict[ 'tool_config' ] ) if message and self.tool is None: self.errors = 'unavailable' break @@ -144,7 +144,7 @@ workflow_name = tool_shed_decode( workflow_name ) message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) - repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, repository_metadata_id ) repository = suc.get_repository_in_tool_shed( trans, trans.security.encode_id( repository_metadata.repository_id ) ) return trans.fill_template( "/webapps/community/repository/view_workflow.mako", repository=repository, @@ -156,7 +156,7 @@ status=status ) @web.expose def generate_workflow_image( self, trans, repository_metadata_id, workflow_name ): - repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + repository_metadata = common.get_repository_metadata_by_id( trans, repository_metadata_id ) repository_id = trans.security.encode_id( repository_metadata.repository_id ) changeset_revision = repository_metadata.changeset_revision metadata = repository_metadata.metadata diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/model/__init__.py --- a/lib/galaxy/webapps/community/model/__init__.py +++ b/lib/galaxy/webapps/community/model/__init__.py @@ -7,7 +7,7 @@ import os.path, os, errno, sys, codecs, operator, logging, tarfile, mimetypes, ConfigParser from galaxy import util from galaxy.util.bunch import Bunch -from galaxy.util.hash_util import * +from galaxy.util.hash_util import new_secure_hash from galaxy.web.form_builder import * from galaxy import eggs diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/model/mapping.py --- a/lib/galaxy/webapps/community/model/mapping.py +++ b/lib/galaxy/webapps/community/model/mapping.py @@ -13,8 +13,8 @@ from galaxy.model.orm.ext.assignmapper import * from galaxy.model.custom_types import * from galaxy.util.bunch import Bunch -from galaxy.webapps.community.util.shed_statistics import * -from galaxy.webapps.community.util.hgweb_config import * +import galaxy.webapps.community.util.shed_statistics as shed_statistics +import galaxy.webapps.community.util.hgweb_config from galaxy.webapps.community.security import CommunityRBACAgent metadata = MetaData() @@ -318,6 +318,6 @@ result.create_tables = create_tables # Load local tool shed security policy result.security_agent = CommunityRBACAgent( result ) - result.shed_counter = ShedCounter( result ) - result.hgweb_config_manager = HgWebConfigManager() + result.shed_counter = shed_statistics.ShedCounter( result ) + result.hgweb_config_manager = galaxy.webapps.community.util.hgweb_config.HgWebConfigManager() return result diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/community/security/__init__.py --- a/lib/galaxy/webapps/community/security/__init__.py +++ b/lib/galaxy/webapps/community/security/__init__.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta from galaxy.util.bunch import Bunch from galaxy.util import listify -from galaxy.model.orm import * +from galaxy.model.orm import and_ log = logging.getLogger(__name__) diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/galaxy/controllers/admin.py --- a/lib/galaxy/webapps/galaxy/controllers/admin.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin.py @@ -10,7 +10,7 @@ from galaxy.web.params import QuotaParamParser from galaxy.exceptions import * from galaxy.util.odict import * -from galaxy.tool_shed.encoding_util import * +from galaxy.tool_shed.encoding_util import tool_shed_decode import galaxy.datatypes.registry import logging, imp, subprocess, urllib2 diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -3,7 +3,7 @@ from galaxy.util.json import from_json_string, to_json_string import galaxy.util.shed_util as shed_util import galaxy.util.shed_util_common as suc -from galaxy.tool_shed.encoding_util import * +from galaxy.tool_shed.encoding_util import tool_shed_encode, tool_shed_decode from galaxy import eggs, tools eggs.require( 'mercurial' ) diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -14,7 +14,7 @@ from galaxy.util.odict import odict from galaxy.util.sanitize_html import sanitize_html from galaxy.util.topsort import topsort, topsort_levels, CycleError -from galaxy.tool_shed.encoding_util import * +from galaxy.tool_shed.encoding_util import tool_shed_encode, tool_shed_decode from galaxy.workflow.modules import * from galaxy import model from galaxy import util diff -r c0c6cf9f5d6ee0a63d0c058439467c1340698930 -r b96fe1d76b383ef2a77ff76bdc6580362aab4f0d scripts/migrate_tools/migrate_tools.py --- a/scripts/migrate_tools/migrate_tools.py +++ b/scripts/migrate_tools/migrate_tools.py @@ -16,7 +16,7 @@ sys.path = new_path from galaxy import eggs -from galaxy.tool_shed.migrate.common import * +from galaxy.tool_shed.migrate.common import MigrateToolsApplication app = MigrateToolsApplication( sys.argv[ 1 ] ) non_shed_tool_confs = app.install_manager.proprietary_tool_confs 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.
participants (1)
-
Bitbucket