This is my code: def postoga(query: str): togadir = f"{TOGADIR.replace('NNNN',…
- User
This is my code:
def postoga(query: str): # togadir = f"{TOGADIR.replace('NNNN', ref)}/vs_{query}" togadir = "/home/alejandro/Documents/projects/hiller/bat" outdir = f"{Const.POSTOGA_OUT}/{query}" cmd = f"{Const.POSTOGA} --togadir {togadir} --outdir {Const.POSTOGA_OUT} -th {Const.Postoga.THRESHOLD} -par {Const.Postoga.PARALOG} -br {Const.Postoga.RELATION}"
codetry: shell(cmd) except Exception as e: print(f"Error: {e}") print(f"Command: {cmd}") exit(1)this is the output:
Error: Command '/home/alejandro/Documents/projects/hiller/champagne/pisco/postoga/postoga.py --togadir /home/alejandro/Documents/projects/hiller/bat --outdir /home/alejandro/Documents/projects/hiller/champagne/pisco/work/species -th 0.95 -par 0.4 -br o2o' returned non-zero exit status 2. Command: /home/alejandro/Documents/projects/hiller/champagne/pisco/postoga/postoga.py --togadir /home/alejandro/Documents/projects/hiller/bat --outdir /home/alejandro/Documents/projects/hiller/champagne/pisco/work/species -th 0.95 -par 0.4 -br o2o
but does not explain the real error. If I run only the command through cmd directly I get:
usage: postoga.py [-h] --togadir TOGADIR [-bc BY_CLASS] [-br BY_REL] [-th THRESHOLD] [-par PARALOG] [-iso ISOFORMS] --outdir OUTDIR --name NAME postoga.py: error: the following arguments are required: --name/-n
I want the real error to appear as the error message explaining what is happening. This is the shell function:
def shell(cmd: str) -> str: """ Run a shell command and return the output as a string
code@type cmd: str @param cmd: shell command """ result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=True) return result.stdout.strip() - Assistant