Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions bactopia/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import shlex
import subprocess
import sys
from pathlib import Path
Expand Down Expand Up @@ -33,7 +34,7 @@ def execute(
logging.debug(f"Working directory: {directory}")
try:
command = subprocess.run(
cmd.split(" "), # Replace with your command and arguments
shlex.split(cmd), # Replace with your command and arguments
cwd=directory,
capture_output=True,
text=True, # Decodes stdout/stderr as strings using default encoding
Expand All @@ -49,15 +50,18 @@ def execute(
return command.returncode
except subprocess.CalledProcessError as e:
if allow_fail:
logging.debug(f'"{cmd}" return exit code {e.returncode}')
logging.debug(e)
logger = logging.debug
else:
logger = logging.error
logger(f"STDOUT: \n{e.stdout}")
logger(f"STDERR:\n{e.stderr}")
logger(f'"{cmd}" return exit code {e.returncode}')
logger(e)
if allow_fail:
return None
else:
logging.error(f'"{cmd}" return exit code {e.returncode}')
logging.error(e)
sys.exit(e.returncode)


def pgzip(files: list, cpus: int) -> list:
"""
Parallel gzip a list of files
Expand Down
Loading