@@ -105,6 +105,7 @@ def __init__(
105
105
self ._executor = Executor (self )
106
106
self ._dispatcher : typing .Optional [DispatcherBaseClass ] = None
107
107
self ._id : typing .Optional [str ] = None
108
+ self ._term_color : bool = True
108
109
self ._suppress_errors : bool = False
109
110
self ._queue_blocking : bool = False
110
111
self ._status : typing .Optional [
@@ -187,10 +188,10 @@ def __exit__(
187
188
if _error_msg :
188
189
_error_msg = f":\n { _error_msg } "
189
190
click .secho (
190
- "Simvue process executor terminated with non-zero exit status "
191
+ "[simvue] Process executor terminated with non-zero exit status "
191
192
f"{ _non_zero } { _error_msg } " ,
192
- fg = "red" ,
193
- bold = True ,
193
+ fg = "red" if self . _term_color else None ,
194
+ bold = self . _term_color ,
194
195
)
195
196
sys .exit (_non_zero )
196
197
@@ -478,6 +479,7 @@ def init(
478
479
visibility : typing .Union [
479
480
typing .Literal ["public" , "tenant" ], list [str ], None
480
481
] = None ,
482
+ no_color : bool = False ,
481
483
) -> bool :
482
484
"""Initialise a Simvue run
483
485
@@ -507,12 +509,15 @@ def init(
507
509
* public - run viewable to all.
508
510
* tenant - run viewable to all within the current tenant.
509
511
* A list of usernames with which to share this run
512
+ no_color : bool, optional
513
+ disable terminal colors. Default False.
510
514
511
515
Returns
512
516
-------
513
517
bool
514
518
whether the initialisation was successful
515
519
"""
520
+ self ._term_color = not no_color
516
521
517
522
if isinstance (visibility , str ) and visibility not in ("public" , "tenant" ):
518
523
self ._error (
@@ -594,11 +599,15 @@ def init(
594
599
self ._start ()
595
600
596
601
if self ._mode == "online" :
597
- click .secho (f"[simvue] Run { self ._name } created" , bold = True , fg = "green" )
602
+ click .secho (
603
+ f"[simvue] Run { self ._name } created" ,
604
+ bold = self ._term_color ,
605
+ fg = "green" if self ._term_color else None ,
606
+ )
598
607
click .secho (
599
608
f"[simvue] Monitor in the UI at { self ._url } /dashboard/runs/run/{ self ._id } " ,
600
- bold = True ,
601
- fg = "green" ,
609
+ bold = self . _term_color ,
610
+ fg = "green" if self . _term_color else None ,
602
611
)
603
612
604
613
return True
@@ -1205,9 +1214,9 @@ def save_file(
1205
1214
1206
1215
if not file_size :
1207
1216
click .secho (
1208
- "WARNING: saving zero-sized files not currently supported" ,
1209
- bold = True ,
1210
- fg = "yellow" ,
1217
+ "[simvue] WARNING: saving zero-sized files not currently supported" ,
1218
+ bold = self . _term_color ,
1219
+ fg = "yellow" if self . _term_color else None ,
1211
1220
)
1212
1221
return True
1213
1222
@@ -1393,10 +1402,10 @@ def close(self) -> bool:
1393
1402
if _error_msg :
1394
1403
_error_msg = f":\n { _error_msg } "
1395
1404
click .secho (
1396
- "Simvue process executor terminated with non-zero exit status "
1405
+ "[simvue] Process executor terminated with non-zero exit status "
1397
1406
f"{ _non_zero } { _error_msg } " ,
1398
- fg = "red" ,
1399
- bold = True ,
1407
+ fg = "red" if self . _term_color else None ,
1408
+ bold = self . _term_color ,
1400
1409
)
1401
1410
sys .exit (_non_zero )
1402
1411
0 commit comments