1414class FormatDict (dict ):
1515 def __missing__ (self , key : str ) -> str :
1616 if key == "pid?" :
17- return f'{ self ["pid" ]} { "" if check_pid (self ["pid" ]) else "?👻 " } '
17+ return f'{ self ["pid" ]} { "" if check_pid (self ["pid" ]) else "?" } '
1818 elif key == "elapsed" :
1919 import time
2020
@@ -24,7 +24,7 @@ def __missing__(self, key: str) -> str:
2424 return self ["cmd" ]
2525 return join (self ["cmd" ])
2626 elif key == "pid_status" :
27- return "✅ Live " if check_pid (self ["pid" ]) else "❌ Gone "
27+ return "Running " if check_pid (self ["pid" ]) else "Stopped "
2828 raise KeyError (f"No { key !r} " )
2929
3030
@@ -37,11 +37,19 @@ def fn(x: Dict[str, Any]) -> str:
3737
3838
3939def no_record (name ):
40- print (f"🤷 No record of { name !r} " )
40+ try :
41+ print ("🤷 " , end = "" )
42+ except UnicodeEncodeError :
43+ pass
44+ print (f"No record of { name !r} " )
4145
4246
4347def ambiguous (name ):
44- print (f"⁉️ { name !r} is ambiguous" )
48+ try :
49+ print ("⁉️ " , end = "" )
50+ except UnicodeEncodeError :
51+ pass
52+ print (f"{ name !r} is ambiguous" )
4553
4654
4755class Clean (Main ):
@@ -58,7 +66,11 @@ def start(self) -> None:
5866 for d in sp .find_names (self .ids , ambiguous , no_record ):
5967 if check_pid (d ["pid" ]):
6068 continue
61- print (f"🧹 Cleaning { d ['pid' ]} { d ['name' ]} " )
69+ try :
70+ print ("🧹 " , end = "" )
71+ except UnicodeEncodeError :
72+ pass
73+ print (f"Cleaning { d ['pid' ]} { d ['name' ]} " )
6274 sp .drop (d )
6375
6476
@@ -78,6 +90,7 @@ def init_argparse(self, argp: ArgumentParser) -> None:
7890
7991 def start (self ) -> None :
8092 f = format_prep (self .format )
93+ e = ["✅" , "❌" ]
8194 for d in Manager ().find_names (self .ids , ambiguous , no_record ):
8295 print (f (d ))
8396
@@ -94,9 +107,9 @@ def init_argparse(self, argp: ArgumentParser) -> None:
94107 return super ().init_argparse (argp )
95108
96109 def start (self ) -> None :
97- _errdef = "❌ Error"
98- _noproc = "👻 No process"
99- _killed = "💀 Killed"
110+ _errdef = [ "❌" , " Error"]
111+ _noproc = [ "👻" , " No process"]
112+ _killed = [ "💀" , " Killed"]
100113 sp = Manager ()
101114 if self .ids :
102115 for x in sp .find_names (self .ids , ambiguous , no_record ):
@@ -109,8 +122,11 @@ def start(self) -> None:
109122 s = _killed
110123 else :
111124 s = _noproc
112-
113- print (f'{ s } PID={ x ["pid" ]} { x ["name" ]!r} ' )
125+ try :
126+ print (f"{ s [0 ]} " , end = "" )
127+ except UnicodeEncodeError :
128+ pass
129+ print (f'{ s [1 ]} PID={ x ["pid" ]} { x ["name" ]!r} ' )
114130 if not self .dry_run and self .remove :
115131 sp .drop (x )
116132
@@ -126,8 +142,8 @@ class Tail(Main):
126142 )
127143 tab : bool = flag ("t" , "tab" , "prefix tab space" , default = False )
128144 err : bool = flag ("e" , "err" , "output stderr" , default = False )
129- p_open : str = "📜 "
130- p_close : str = ""
145+ p_open : str = "=== "
146+ p_close : str = " === "
131147
132148 def start (self ) -> None :
133149 import sys
@@ -195,16 +211,20 @@ def start(self) -> None:
195211 # Check for existing process first
196212 e = sp .find_name (name ) if name else None
197213 if e :
198- hf = format_prep (r"🚨 Found: PID={pid} ({pid_status}) {name}" )
199- print (hf (e ), file = stderr )
214+ s = ["🚨" , r"Found: PID={pid} ({pid_status}) {name}" ]
200215 else :
201216 # Start new process
202217 e = sp .spawn (
203218 args , name , overwrite = self .overwrite , cwd = self .cwd , split = self .split
204219 )
205- hf = format_prep ("🚀 Started: PID={pid} ({pid_status}) {name}" )
206- print (hf (e ), file = stderr )
220+ s = ["🚀" , r"Started: PID={pid} ({pid_status}) {name}" ]
207221 assert e
222+ try :
223+ print (f"{ s [0 ]} " , end = "" )
224+ except UnicodeEncodeError :
225+ pass
226+ hf = format_prep (s [1 ])
227+ print (hf (e ), file = stderr )
208228
209229 # Handle tail output
210230 if self .tail :
0 commit comments