File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,17 @@ def attach(args: argparse.Namespace) -> None:
8787 pipe_name .unlink ()
8888
8989
90+ def microseconds (v : str ) -> int :
91+ try :
92+ if v .endswith ("ms" ):
93+ return int (v [:- 2 ]) * 1000
94+ if v .endswith ("s" ):
95+ return int (v [:- 1 ]) * 1000000
96+ return int (v )
97+ except Exception as e :
98+ raise ValueError ("Invalid interval: %s" % v ) from e
99+
100+
90101def main () -> None :
91102 parser = argparse .ArgumentParser (
92103 description = "In-process CPython frame stack sampler" ,
@@ -100,7 +111,7 @@ def main() -> None:
100111 "--interval" ,
101112 help = "sampling interval in microseconds" ,
102113 default = 1000 ,
103- type = int ,
114+ type = microseconds ,
104115 )
105116 parser .add_argument (
106117 "-c" ,
@@ -163,7 +174,13 @@ def main() -> None:
163174 action = "version" ,
164175 version = "%(prog)s " + __version__ ,
165176 )
166- args = parser .parse_args ()
177+
178+ try :
179+ args = parser .parse_args ()
180+ except Exception as e :
181+ print ("echion: %s" % e )
182+ parser .print_usage ()
183+ sys .exit (1 )
167184
168185 # TODO: Validate arguments
169186
Original file line number Diff line number Diff line change 22
33
44def test_echion ():
5- result , data = run_target ("target" )
5+ result , _ = run_target ("target" , "-i" , "10ms " )
66 assert result .returncode == 0 , result .stderr
77
88
You can’t perform that action at this time.
0 commit comments