File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def get_nmap_path(path:str='') -> str:
3838 by calling which nmap
3939 If not found raises NmapNotInstalledError
4040 """
41- if (os .path .exists (path )):
41+ if path and (os .path .exists (path )):
4242 return path
4343
4444 os_type = sys .platform
@@ -49,17 +49,15 @@ def get_nmap_path(path:str='') -> str:
4949 args = shlex .split (cmd )
5050 sub_proc = subprocess .Popen (args , stdout = subprocess .PIPE )
5151
52- try :
53- output , _ = sub_proc .communicate (timeout = 15 )
54- except Exception as e :
52+ output , e = sub_proc .communicate (timeout = 15 )
53+ if e :
5554 print (e )
56- sub_proc .kill ()
55+
56+ if not output :
5757 raise NmapNotInstalledError (path = path )
58- else :
59- if os_type == 'win32' :
60- return output .decode ('utf8' ).strip ().replace ("\\ " , "/" )
61- else :
62- return output .decode ('utf8' ).strip ()
58+ if os_type == 'win32' :
59+ return output .decode ('utf8' ).strip ().replace ("\\ " , "/" )
60+ return output .decode ('utf8' ).strip ()
6361
6462def get_nmap_version ():
6563 nmap = get_nmap_path ()
You can’t perform that action at this time.
0 commit comments