From 0d8dbe0fe4d0fdb5bdd40e030ab34365de8ee66f Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 5 Dec 2013 14:48:46 -0800 Subject: [PATCH] Provide reporting of what command failed when bigWigInfo isn't available. --- htsworkflow/util/ucsc.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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) + -- 2.30.2