Skip to content

Commit

Permalink
Merge pull request #68 from rcarrillo/nmap_str_output
Browse files Browse the repository at this point in the history
Open stdout and stderr as text streams
  • Loading branch information
savon-noir committed Feb 28, 2016
2 parents 00ccad5 + cadfa06 commit ba1a068
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libnmap/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def run(self):
self.__nmap_proc = subprocess.Popen(args=_tmp_cmdline,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
bufsize=0)
self.__state = self.RUNNING
except OSError:
Expand All @@ -268,12 +269,12 @@ def run(self):

while self.__nmap_proc.poll() is None:
for streamline in iter(self.__nmap_proc.stdout.readline, ''):
self.__stdout += str(streamline)
self.__stdout += streamline
evnt = self.__process_event(streamline)
if self.__nmap_event_callback and evnt:
self.__nmap_event_callback(self)

self.__stderr += str(self.__nmap_proc.stderr.read().decode())
self.__stderr += self.__nmap_proc.stderr.read()

self.__nmap_rc = self.__nmap_proc.poll()
if self.rc is None:
Expand Down

0 comments on commit ba1a068

Please sign in to comment.