From a498330bd3122b6abd150c543b89f22af85065bc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Nov 2012 09:32:44 +0100 Subject: [PATCH] remove _read_stdin and open stdin file in non-binary mode Signed-off-by: Nico Schottelius --- cdist/emulator.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index 53c6914d..b6ee5166 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -149,8 +149,6 @@ class Emulator(object): # Record / Append source self.cdist_object.source.append(self.object_source) - def _read_stdin(self): - return self.stdin.read() def save_stdin(self): """If something is written to stdin, save it in the object as $__object/stdin so it can be accessed in manifest and gencode-* @@ -160,12 +158,10 @@ class Emulator(object): try: # go directly to file instead of using CdistObject's api # as that does not support streaming + # FIXME: no streaming needed anymore path = os.path.join(self.cdist_object.absolute_path, 'stdin') - with open(path, 'wb') as fd: - chunk = self._read_stdin() - while chunk: - fd.write(chunk) - chunk = self._read_stdin() + with open(path, 'w') as fd: + fd.write(self.stdin.read()) except EnvironmentError as e: raise cdist.Error('Failed to read from stdin: %s' % e)