convert some print statements to logger messages
authorDiane Trout <diane@ghic.org>
Thu, 29 Jan 2015 19:43:59 +0000 (11:43 -0800)
committerDiane Trout <diane@ghic.org>
Thu, 29 Jan 2015 19:43:59 +0000 (11:43 -0800)
htsworkflow/util/hdquery.py
htsworkflow/util/validate.py
scripts/htsw-srf

index 37fd555d3fd6c0f55c2aba2676ceaf62425f309d..b1ac611a0a75b763ba561cb0bce40d0f6f399023 100644 (file)
@@ -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')
index 959acc281db0b951d0d0dc2dec17023eddc9be47..60566a7961b0e6ef10f0be8d947cd84ac70f81ee 100644 (file)
@@ -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
     
index d933b800c9018384629817a32a2f3bce60a2eb25..06ca25d8fb6c2d981c6ef6e035e2b4a07f126d5f 100755 (executable)
@@ -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: