Skip to content

Commit 2cf9b37

Browse files
committed
symbol statuses for jobs
1 parent fe597de commit 2cf9b37

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

jenkins_cli/cli.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import socket
77
from xml.etree import ElementTree
88

9-
COLORS = {'blue': '\033[94m',
10-
'green': '\033[92m',
11-
'red': '\033[91m',
12-
'yellow': '\033[93m',
13-
'disabled': '\033[97m',
14-
'endcollor': '\033[0m',
15-
'aborted': '\033[97m(aborted)',
16-
'yellow_anime': '\033[93m(running)',
17-
'blue_anime': '\033[94m(running)',
18-
'red_anime': '\033[91m(running)'}
9+
STATUSES = {'blue': {'symbol': 'S',
10+
'color': '\033[94m'},
11+
'red': {'symbol': 'F',
12+
'color': '\033[91m'},
13+
'yellow': {'symbol': 'U',
14+
'color': '\033[93m'},
15+
'disabled': {'symbol': 'D',
16+
'color': '\033[97m'},
17+
'aborted': {'symbol': 'A',
18+
'color': '\033[97m'}
19+
}
20+
21+
#'green': '\033[92m',
22+
23+
24+
ENDCOLLOR = '\033[0m'
25+
ANIME_SYMBOL = ['..', '>>']
1926

2027

2128
class CliException(Exception):
@@ -77,7 +84,11 @@ def run_command(self, args):
7784
def jobs(self, args):
7885
jobs = self._get_jobs(args)
7986
for job in jobs:
80-
print("%s***%s %s" % (COLORS.get(job['color'], job['color']), COLORS['endcollor'], job['name']))
87+
color_status = job['color'].split('_')
88+
color = color_status[0]
89+
run_status = color_status[1] if len(color_status) == 2 else None
90+
status = STATUSES[color]
91+
print("%s%s%s%s %s" % (status['color'], status['symbol'], ANIME_SYMBOL[run_status == 'anime'], ENDCOLLOR, job['name']))
8192

8293
def _get_jobs(self, args):
8394
jobs = self.jenkins.get_jobs()

0 commit comments

Comments
 (0)