From: Diane Trout Date: Thu, 5 Dec 2013 22:48:46 +0000 (-0800) Subject: Provide reporting of what command failed when bigWigInfo isn't available. X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=0d8dbe0fe4d0fdb5bdd40e030ab34365de8ee66f Provide reporting of what command failed when bigWigInfo isn't available. --- diff --git a/htsworkflow/util/ucsc.py b/htsworkflow/util/ucsc.py index e9ff77e..b96c46a 100644 --- a/htsworkflow/util/ucsc.py +++ b/htsworkflow/util/ucsc.py @@ -3,6 +3,7 @@ import logging import os +import sys from subprocess import Popen, PIPE LOGGER = logging.getLogger(__name__) @@ -51,17 +52,22 @@ class bigWigInfo: def scan_file(self, filename): cmd = ['bigWigInfo', filename] - p = Popen(cmd, stdout=PIPE) - stdout, _ = p.communicate() - for line in stdout.split(os.linesep): - if len(line) > 0: - term, value = line.split(': ') - if term in ('isCompressed', 'isSwapped'): - value = parseBoolean(value) - else: - value = parseNumber(value) - LOGGER.debug('%s: %s', term, str(value)) - setattr(self, term, value) + try: + p = Popen(cmd, stdout=PIPE) + stdout, _ = p.communicate() + for line in stdout.split(os.linesep): + if len(line) > 0: + term, value = line.split(': ') + if term in ('isCompressed', 'isSwapped'): + value = parseBoolean(value) + else: + value = parseNumber(value) + LOGGER.debug('%s: %s', term, str(value)) + setattr(self, term, value) + except OSError as e: + LOGGER.error("Exception %s trying to run: %s", str(e), ' '.join(cmd)) + sys.exit(-1) +