@@ -106,6 +106,7 @@ def __init__(
106
106
self ._executor = Executor (self )
107
107
self ._dispatcher : typing .Optional [DispatcherBaseClass ] = None
108
108
self ._id : typing .Optional [str ] = None
109
+ self ._term_color : bool = True
109
110
self ._suppress_errors : bool = False
110
111
self ._queue_blocking : bool = False
111
112
self ._status : typing .Optional [
@@ -191,8 +192,8 @@ def __exit__(
191
192
click .secho (
192
193
"[simvue] Process executor terminated with non-zero exit status "
193
194
f"{ _non_zero } { _error_msg } " ,
194
- fg = "red" ,
195
- bold = True ,
195
+ fg = "red" if self . _term_color else None ,
196
+ bold = self . _term_color ,
196
197
)
197
198
sys .exit (_non_zero )
198
199
@@ -504,6 +505,7 @@ def init(
504
505
visibility : typing .Union [
505
506
typing .Literal ["public" , "tenant" ], list [str ], None
506
507
] = None ,
508
+ no_color : bool = False ,
507
509
) -> bool :
508
510
"""Initialise a Simvue run
509
511
@@ -531,12 +533,15 @@ def init(
531
533
* public - run viewable to all.
532
534
* tenant - run viewable to all within the current tenant.
533
535
* A list of usernames with which to share this run
536
+ no_color : bool, optional
537
+ disable terminal colors. Default False.
534
538
535
539
Returns
536
540
-------
537
541
bool
538
542
whether the initialisation was successful
539
543
"""
544
+ self ._term_color = not no_color
540
545
541
546
if isinstance (visibility , str ) and visibility not in ("public" , "tenant" ):
542
547
self ._error (
@@ -616,11 +621,15 @@ def init(
616
621
self ._start ()
617
622
618
623
if self ._mode == "online" :
619
- click .secho (f"[simvue] Run { self ._name } created" , bold = True , fg = "green" )
624
+ click .secho (
625
+ f"[simvue] Run { self ._name } created" ,
626
+ bold = self ._term_color ,
627
+ fg = "green" if self ._term_color else None ,
628
+ )
620
629
click .secho (
621
630
f"[simvue] Monitor in the UI at { self ._url } /dashboard/runs/run/{ self ._id } " ,
622
- bold = True ,
623
- fg = "green" ,
631
+ bold = self . _term_color ,
632
+ fg = "green" if self . _term_color else None ,
624
633
)
625
634
626
635
return True
@@ -631,9 +640,9 @@ def add_process(
631
640
self ,
632
641
identifier : str ,
633
642
* cmd_args ,
634
- executable : typing .Optional [str ] = None ,
635
- script : typing .Optional [str ] = None ,
636
- input_file : typing .Optional [str ] = None ,
643
+ executable : typing .Optional [typing . Union [ str ] ] = None ,
644
+ script : typing .Optional [pydantic . FilePath ] = None ,
645
+ input_file : typing .Optional [pydantic . FilePath ] = None ,
637
646
completion_callback : typing .Optional [
638
647
typing .Callable [[int , str , str ], None ]
639
648
] = None ,
@@ -1234,8 +1243,8 @@ def save_file(
1234
1243
if not file_size :
1235
1244
click .secho (
1236
1245
"[simvue] WARNING: saving zero-sized files not currently supported" ,
1237
- bold = True ,
1238
- fg = "yellow" ,
1246
+ bold = self . _term_color ,
1247
+ fg = "yellow" if self . _term_color else None ,
1239
1248
)
1240
1249
return True
1241
1250
@@ -1423,8 +1432,8 @@ def close(self) -> bool:
1423
1432
click .secho (
1424
1433
"[simvue] Process executor terminated with non-zero exit status "
1425
1434
f"{ _non_zero } { _error_msg } " ,
1426
- fg = "red" ,
1427
- bold = True ,
1435
+ fg = "red" if self . _term_color else None ,
1436
+ bold = self . _term_color ,
1428
1437
)
1429
1438
sys .exit (_non_zero )
1430
1439
0 commit comments