Skip to content

Commit

Permalink
Fix jobs.py: list index out of range (#5340)
Browse files Browse the repository at this point in the history
* Update jobs.py

* Create fix-jobs-index.rst

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update fix-jobs-index.rst

* Update test_virtualenv_activator.py

* Update test_virtualenv_activator.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_virtualenv_activator.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: update venv activator test

* chore: update test xonsh

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
  • Loading branch information
3 people committed Apr 19, 2024
1 parent fde07cd commit 2419eaa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions news/fix-jobs-index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Jobs: fixed "index out of range" exception.

**Security:**

* <news item>
4 changes: 2 additions & 2 deletions xonsh/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ def format_job_string(num: int) -> str:
pos = "+" if tasks[0] == num else "-" if tasks[1] == num else " "
status = job["status"]
cmd = " ".join([" ".join(i) if isinstance(i, list) else i for i in job["cmds"]])
pid = job["pids"][-1]
pid = f"({job['pids'][-1]})" if job["pids"] else ""
bg = " &" if job["bg"] else ""
return f"[{num}]{pos} {status}: {cmd}{bg} ({pid})"
return f"[{num}]{pos} {status}: {cmd}{bg} {pid}"


def print_one_job(num, outfile=sys.stdout):
Expand Down

0 comments on commit 2419eaa

Please sign in to comment.