From: Diane Trout Date: Thu, 29 Jan 2015 19:43:59 +0000 (-0800) Subject: convert some print statements to logger messages X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=9704b8ada9851ba1cad71ccf3539a35ee460c766 convert some print statements to logger messages --- diff --git a/htsworkflow/util/hdquery.py b/htsworkflow/util/hdquery.py index 37fd555..b1ac611 100644 --- a/htsworkflow/util/hdquery.py +++ b/htsworkflow/util/hdquery.py @@ -1,5 +1,8 @@ import os import sys +import logging + +LOGGER = logging.getLogger(__name__) try: import py_sg @@ -24,7 +27,7 @@ try: return data.strip('\x00').split()[1] except ImportError as e: - print >>sys.stderr, "hdquery requires py_sg" + LOGGER.error("hdquery requires py_sg") def get_hd_serial_num(device): raise NotImplemented('get_hd_serial_num is not available for anything other than linux') diff --git a/htsworkflow/util/validate.py b/htsworkflow/util/validate.py index 959acc2..60566a7 100644 --- a/htsworkflow/util/validate.py +++ b/htsworkflow/util/validate.py @@ -1,9 +1,11 @@ #!/usr/bin/env python - from optparse import OptionParser import os import re import sys +import logging + +LOGGER = logging.getLogger(__name__) def main(cmdline=None): parser = make_parser() @@ -19,7 +21,7 @@ def main(cmdline=None): opts.uniform_lengths, opts.max_errors) if errors > 0: - print "%s failed validation" % (filename,) + LOGGER.error("%s failed validation", filename) error_happened = True stream.close() @@ -110,7 +112,7 @@ def validate_fastq(stream, format='phred33', uniform_length=False, max_errors=No def validate_re(pattern, line, line_number, errmsg): if pattern.match(line) is None: - print errmsg, "[%d]: %s" % (line_number, line) + LOGGER.error("%s [%d]: %s", errmsg, line_number, line) return 1 else: return 0 @@ -123,7 +125,7 @@ def validate_length(line, line_length, line_number, errmsg): if line_length is None: line_length = len(line) elif len(line) != line_length: - print errmsg, "%d: %s" %(line_number, line) + LOGGER.error("%s %d: %s", errmsg, line_number, line) error_count = 1 return line_length, error_count diff --git a/scripts/htsw-srf b/scripts/htsw-srf index d933b80..06ca25d 100755 --- a/scripts/htsw-srf +++ b/scripts/htsw-srf @@ -11,6 +11,8 @@ from htsworkflow.pipelines.srf import make_srf_commands, make_qseq_commands, \ run_commands, pathname_to_run_name from htsworkflow.pipelines.srf import ILLUMINA2SRF10, ILLUMINA2SRF11, SOLEXA2SRF +LOGGER = logging.getLogger(__name__) + def make_parser(): usage = '%prog: [options] runfolder -l 1,2,3 [runfolder -l 5,6 ...]' @@ -98,7 +100,7 @@ def main(cmdline=None): runs = runfolder.get_runs(runfolder_path) # give up if there are anything other than 1 run if len(runs) > 1: - print 'ERROR: Too many run directories in %s' %(runfolder_path,) + LOGGER.error('Too many run directories in %s', runfolder_path) return 1 elif len(runs) == 1: bustard_dir = runs[0].bustard.pathname @@ -109,7 +111,8 @@ def main(cmdline=None): opts.dest_dir, opts.runfolder_version) else: - print "ERROR: Couldn't find a bustard directory in", runfolder_path + LOGGER.error("Couldn't find a bustard directory in %s", + runfolder_path) return 1 if not opts.dry_run: