Skip to content

Commit

Permalink
Replace remaining print statements with log.*
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Oct 30, 2015
1 parent c8c2f96 commit 0e60332
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/app.py
Expand Up @@ -30,7 +30,7 @@
class UniverseApplication( object, config.ConfiguresGalaxyMixin ):
"""Encapsulates the state of a Universe application"""
def __init__( self, **kwargs ):
print >> sys.stderr, "python path is: " + ", ".join( sys.path )
log.debug( "python path is: %s", ", ".join( sys.path ) )
self.name = 'galaxy'
self.new_installation = False
# Read config file and check for errors
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/config.py
Expand Up @@ -201,7 +201,7 @@ def __init__( self, **kwargs ):
with open( self.blacklist_file ) as blacklist:
self.blacklist_content = [ line.rstrip() for line in blacklist.readlines() ]
except IOError:
print ( "CONFIGURATION ERROR: Can't open supplied blacklist file from path: " + str( self.blacklist_file ) )
log.error( "CONFIGURATION ERROR: Can't open supplied blacklist file from path: " + str( self.blacklist_file ) )
self.smtp_server = kwargs.get( 'smtp_server', None )
self.smtp_username = kwargs.get( 'smtp_username', None )
self.smtp_password = kwargs.get( 'smtp_password', None )
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Expand Up @@ -2927,7 +2927,7 @@ def clear( self, purge=False, delete_dataset=True ):
try:
os.unlink( self.file_name )
except Exception, e:
print "Failed to purge associated file (%s) from disk: %s" % ( self.file_name, e )
log.error( "Failed to purge associated file (%s) from disk: %s" % ( self.file_name, e ) )


DEFAULT_COLLECTION_NAME = "Unnamed Collection"
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/util/__init__.py
Expand Up @@ -950,7 +950,7 @@ class DBNames( list ):
man_builds = [(build, name) for name, build in man_builds]
db_names = DBNames( db_names + man_builds )
except Exception, e:
print "ERROR: Unable to read builds file:", e
log.error( "ERROR: Unable to read builds file: %s", str( e ) )
if len(db_names) < 1:
db_names = DBNames( [( db_names.default_value, db_names.default_name )] )
return db_names
Expand All @@ -976,7 +976,7 @@ def read_build_sites( filename, check_builds=True ):
except:
continue
except:
print "ERROR: Unable to read builds for site file %s" % filename
log.error( "ERROR: Unable to read builds for site file %s", filename )
return build_sites


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/library_contents.py
Expand Up @@ -400,7 +400,7 @@ def delete( self, trans, library_id, id, **kwd ):
ld = self.get_library_dataset( trans, id, check_ownership=False, check_accessible=True )
user_is_admin = trans.user_is_admin()
can_modify = trans.app.security_agent.can_modify_library_item( trans.user.all_roles(), ld )
print 'is_admin: %s, can_modify: %s' % ( user_is_admin, can_modify )
log.debug( 'is_admin: %s, can_modify: %s', user_is_admin, can_modify )
if not ( user_is_admin or can_modify ):
trans.response.status = 403
rval.update({ 'error': 'Unauthorized to delete or purge this library dataset' })
Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy/webapps/galaxy/controllers/requests_common.py
Expand Up @@ -1212,8 +1212,8 @@ def __save_samples( self, trans, cntrller, request, sample_widgets, saving_new_s
redirect_action = 'edit_samples'
# Check for duplicate sample names within the request
self.__validate_sample_names( trans, cntrller, request, sample_widgets, **kwd )
print "SAVING SAMPLES!"
print "saving_new_samples is %s" % saving_new_samples
log.debug( "SAVING SAMPLES!" )
log.debug( "saving_new_samples is %s" % saving_new_samples )
if not saving_new_samples:
library = None
folder = None
Expand Down Expand Up @@ -1874,8 +1874,8 @@ def __validate_request( self, trans, cntrller, request ):
empty_sample_fields = []
for s in request.samples:
for field in request.type.sample_form.fields:
print "field:", field
print "svc:", s.values.content
log.debug("field: %s", field)
log.debug("svc: %s", s.values.content)
if field['required'] == 'required' and s.values.content[field['name']] in ['', None]:
empty_sample_fields.append((s.name, field['label']))
if empty_fields or empty_sample_fields:
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/webapps/reports/app.py
Expand Up @@ -4,12 +4,14 @@

import galaxy.model
from galaxy.web import security
import logging
log = logging.getLogger( __name__ )


class UniverseApplication( object ):
"""Encapsulates the state of a Universe application"""
def __init__( self, **kwargs ):
print >> sys.stderr, "python path is: " + ", ".join( sys.path )
log.debug( "python path is: %s", ", ".join( sys.path ) )
self.name = "reports"
# Read config file and check for errors
self.config = config.Configuration( **kwargs )
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/webapps/tool_shed/app.py
Expand Up @@ -13,13 +13,16 @@
import tool_shed.repository_registry
import tool_shed.repository_types.registry
from tool_shed.grids.repository_grid_filter_manager import RepositoryGridFilterManager
import logging
log = logging.getLogger( __name__ )



class UniverseApplication( object ):
"""Encapsulates the state of a Universe application"""

def __init__( self, **kwd ):
print >> sys.stderr, "python path is: " + ", ".join( sys.path )
log.debug( "python path is: %s", ", ".join( sys.path ) )
self.name = "tool_shed"
# Read the tool_shed.ini configuration file and check for errors.
self.config = config.Configuration( **kwd )
Expand Down Expand Up @@ -75,7 +78,7 @@ def __init__( self, **kwd ):
self.repository_registry = tool_shed.repository_registry.Registry( self )
# used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base.
self.server_starttime = int(time.time())
print >> sys.stderr, "Tool shed hgweb.config file is: ", self.hgweb_config_manager.hgweb_config
log.debug( "Tool shed hgweb.config file is: %s", self.hgweb_config_manager.hgweb_config )

def shutdown( self ):
pass
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/tool_shed/framework/middleware/hg.py
Expand Up @@ -25,7 +25,7 @@
class Hg( object ):

def __init__( self, app, config ):
print "mercurial version is:", mercurial.__version__.version
log.debug( "mercurial version is: %s", mercurial.__version__.version )
self.app = app
self.config = config
# Authenticate this mercurial request using basic authentication
Expand Down
Expand Up @@ -293,7 +293,7 @@ def get_repository_dependencies_for_installed_tool_shed_repository( self, app, r
try:
raw_text = common_util.tool_shed_get( app, tool_shed_url, pathspec=pathspec, params=params )
except Exception, e:
print "The URL\n%s\nraised the exception:\n%s\n" % ( common_util.url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) )
log.error("The URL\n%s\nraised the exception:\n%s\n", common_util.url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) )
return ''
if len( raw_text ) > 2:
encoded_text = json.loads( raw_text )
Expand Down
Expand Up @@ -96,7 +96,7 @@ def sync_database_with_file_system( self, app, tool_shed_repository, tool_depend
str( basic_util.INSTALLATION_LOG ) )
error_message += ' is missing. This indicates an installation error so the tool dependency is being'
error_message += ' prepared for re-installation.'
print error_message
log.error( error_message )
tool_dependency.status = app.install_model.ToolDependency.installation_status.NEVER_INSTALLED
basic_util.remove_dir( tool_dependency_install_dir )
can_install_tool_dependency = True
Expand Down Expand Up @@ -464,7 +464,7 @@ def handle_complex_repository_dependency_for_package( self, elem, package_name,
# required_repository.
if required_repository.is_deactivated_or_installed:
if not os.path.exists( required_repository_package_install_dir ):
print 'Missing required tool dependency directory %s' % str( required_repository_package_install_dir )
log.error( 'Missing required tool dependency directory %s' % str( required_repository_package_install_dir ) )
repo_files_dir = required_repository.repo_files_directory( self.app )
tool_dependencies_config = suc.get_absolute_path_to_file_in_repository( repo_files_dir, 'tool_dependencies.xml' )
if tool_dependencies_config:
Expand Down Expand Up @@ -518,7 +518,7 @@ def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem,
for rd_tool_dependency in rd_tool_dependencies:
if rd_tool_dependency.status == self.app.install_model.ToolDependency.installation_status.ERROR:
# We'll log the error here, but continue installing packages since some may not require this dependency.
print "Error installing tool dependency for required repository: %s" % str( rd_tool_dependency.error_message )
log.error( "Error installing tool dependency for required repository: %s" % str( rd_tool_dependency.error_message ) )
return tool_dependency, proceed_with_install, action_elem_tuples

def remove_file( self, file_name ):
Expand Down
24 changes: 13 additions & 11 deletions lib/tool_shed/galaxy_install/tool_migration_manager.py
Expand Up @@ -62,16 +62,16 @@ def __init__( self, app, latest_migration_script_number, tool_shed_install_confi
# setting from migrated_tools_config.
tree, error_message = xml_util.parse_xml( migrated_tools_config )
if tree is None:
print error_message
log.error( error_message )
else:
root = tree.getroot()
self.tool_path = root.get( 'tool_path' )
print "Repositories will be installed into configured tool_path location ", str( self.tool_path )
log.debug( "Repositories will be installed into configured tool_path location ", str( self.tool_path ) )
# Parse tool_shed_install_config to check each of the tools.
self.tool_shed_install_config = tool_shed_install_config
tree, error_message = xml_util.parse_xml( tool_shed_install_config )
if tree is None:
print error_message
log.error( error_message )
else:
root = tree.getroot()
defined_tool_shed_url = root.get( 'name' )
Expand Down Expand Up @@ -157,12 +157,12 @@ def __init__( self, app, latest_migration_script_number, tool_shed_install_confi
str( latest_migration_script_number )
message += "file%s named %s,\nso no repositories will be installed on disk.\n" % \
( plural, file_names )
print message
log.info( message )
else:
message = "\nThe main Galaxy tool shed is not currently available, so skipped migration stage %s.\n" % \
str( latest_migration_script_number )
message += "Try again later.\n"
print message
log.error( message )

def create_or_update_tool_shed_repository_record( self, name, owner, changeset_revision, description=None ):

Expand Down Expand Up @@ -403,8 +403,8 @@ def handle_repository_contents( self, tool_shed_repository, repository_clone_url
if tool_config not in tool_configs_to_filter:
tool_configs_to_filter.append( tool_config )
else:
print 'The tool "%s" (%s) has not been enabled because it is not defined in a proprietary tool config (%s).' \
% ( guid, tool_config, ", ".join( self.proprietary_tool_confs or [] ) )
log.error( 'The tool "%s" (%s) has not been enabled because it is not defined in a proprietary tool config (%s).' \
% ( guid, tool_config, ", ".join( self.proprietary_tool_confs or [] ) ) )
if tool_configs_to_filter:
lock = threading.Lock()
lock.acquire( True )
Expand Down Expand Up @@ -489,8 +489,9 @@ def handle_repository_contents( self, tool_shed_repository, repository_clone_url
from_tool_migration_manager=True )
for installed_tool_dependency in installed_tool_dependencies:
if installed_tool_dependency.status == self.app.install_model.ToolDependency.installation_status.ERROR:
print '\nThe ToolMigrationManager returned the following error while installing tool dependency ', installed_tool_dependency.name, ':'
print installed_tool_dependency.error_message, '\n\n'
log.error(
'The ToolMigrationManager returned the following error while installing tool dependency %s: %s',
installed_tool_dependency.name, installed_tool_dependency.error_message )
if 'datatypes' in irmm_metadata_dict:
cdl = custom_datatype_manager.CustomDatatypeLoader( self.app )
tool_shed_repository.status = self.app.install_model.ToolShedRepository.installation_status.LOADING_PROPRIETARY_DATATYPES
Expand Down Expand Up @@ -544,7 +545,8 @@ def install_repository( self, repository_elem, tool_shed_repository, install_dep
self.app.install_model.ToolShedRepository.installation_status.DEACTIVATED ]:
is_installed = True
if cloned_ok and is_installed:
print "Skipping automatic install of repository '", tool_shed_repository.name, "' because it has already been installed in location ", clone_dir
log.info( "Skipping automatic install of repository '%s' because it has already been installed in location %s",
tool_shed_repository.name, clone_dir )
else:
irm = install_manager.InstallRepositoryManager( self.app, self.tpm )
repository_clone_url = os.path.join( self.tool_shed_url, 'repos', tool_shed_repository.owner, tool_shed_repository.name )
Expand Down Expand Up @@ -614,7 +616,7 @@ def install_repository( self, repository_elem, tool_shed_repository, install_dep
irm.update_tool_shed_repository_status( tool_shed_repository,
self.app.install_model.ToolShedRepository.installation_status.INSTALLED )
else:
print 'Error attempting to clone repository %s: %s' % ( str( tool_shed_repository.name ), str( error_message ) )
log.error('Error attempting to clone repository %s: %s', str( tool_shed_repository.name ), str( error_message ) )
irm.update_tool_shed_repository_status( tool_shed_repository,
self.app.install_model.ToolShedRepository.installation_status.ERROR,
error_message=error_message )
Expand Down
4 changes: 2 additions & 2 deletions lib/tool_shed/util/common_util.py
Expand Up @@ -163,7 +163,7 @@ def get_repository_dependencies( app, tool_shed_url, repository_name, repository
tool_shed_accessible = True
except Exception, e:
tool_shed_accessible = False
print "The URL\n%s\nraised the exception:\n%s\n" % ( url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) )
log.warn( "The URL\n%s\nraised the exception:\n%s\n" % ( url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) ) )
if tool_shed_accessible:
if len( raw_text ) > 2:
encoded_text = json.loads( raw_text )
Expand Down Expand Up @@ -195,7 +195,7 @@ def get_tool_dependencies( app, tool_shed_url, repository_name, repository_owner
tool_shed_accessible = True
except Exception, e:
tool_shed_accessible = False
print "The URL\n%s\nraised the exception:\n%s\n" % ( url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) )
log.warn( "The URL\n%s\nraised the exception:\n%s\n" % ( url_join( tool_shed_url, pathspec=pathspec, params=params ), str( e ) ) )
if tool_shed_accessible:
if text:
tool_dependencies_dict = encoding_util.tool_shed_decode( text )
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/util/hg_util.py
Expand Up @@ -436,7 +436,7 @@ def unpack_patches( hg_unbundle10_obj, remaining ):
'blocklen': blocklen,
'block': block.encode( 'string_escape' ) }
if remaining > 0:
print remaining
log.error("Unexpected end of patch stream, %s remaining", remaining)
raise Exception( "unexpected end of patch stream" )


Expand Down

0 comments on commit 0e60332

Please sign in to comment.