Skip to content
Snippets Groups Projects
Commit cc0c837a authored by Filippo Cremonese's avatar Filippo Cremonese
Browse files

Set terminal title when executing jobs

parent 36a63b22
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import enlighten
from loguru import logger
from .actions.action import Action
from .util import set_terminal_title
class Executor:
......@@ -33,14 +34,17 @@ class Executor:
status_bar.color = "bright_white_on_lightslategray"
while self._running_actions:
running_jobs_str = ", ".join(a.name_for_graph for a in self._running_actions.values())
status_bar_args = {
"jobs": ", ".join(a.name_for_graph for a in self._running_actions.values()),
"jobs": running_jobs_str,
"current": total_pending - len(self._pending_actions),
"total": total_pending,
}
set_terminal_title(f"Running {running_jobs_str}")
status_bar.status_format = "[{current}/{total}] Running {jobs}"
status_bar.update(**status_bar_args)
status_bar.refresh()
done, not_done = futures.wait(self._running_actions, return_when=futures.FIRST_COMPLETED)
for d in done:
action = self._running_actions[d]
......
import json
import os.path
import re
import sys
from collections import OrderedDict
from typing import Union
......@@ -97,3 +98,8 @@ def export_environment(variables: OrderedDict):
for var, val in variables.items():
env += f'export {var}="{val}"\n'
return env
def set_terminal_title(title):
if sys.stdout.isatty():
sys.stdout.write(f"\x1b]2;{title}\x07")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment