remove _read_stdin and open stdin file in non-binary mode
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
03ec09c771
commit
a498330bd3
1 changed files with 3 additions and 7 deletions
|
@ -149,8 +149,6 @@ class Emulator(object):
|
||||||
# Record / Append source
|
# Record / Append source
|
||||||
self.cdist_object.source.append(self.object_source)
|
self.cdist_object.source.append(self.object_source)
|
||||||
|
|
||||||
def _read_stdin(self):
|
|
||||||
return self.stdin.read()
|
|
||||||
def save_stdin(self):
|
def save_stdin(self):
|
||||||
"""If something is written to stdin, save it in the object as
|
"""If something is written to stdin, save it in the object as
|
||||||
$__object/stdin so it can be accessed in manifest and gencode-*
|
$__object/stdin so it can be accessed in manifest and gencode-*
|
||||||
|
@ -160,12 +158,10 @@ class Emulator(object):
|
||||||
try:
|
try:
|
||||||
# go directly to file instead of using CdistObject's api
|
# go directly to file instead of using CdistObject's api
|
||||||
# as that does not support streaming
|
# as that does not support streaming
|
||||||
|
# FIXME: no streaming needed anymore
|
||||||
path = os.path.join(self.cdist_object.absolute_path, 'stdin')
|
path = os.path.join(self.cdist_object.absolute_path, 'stdin')
|
||||||
with open(path, 'wb') as fd:
|
with open(path, 'w') as fd:
|
||||||
chunk = self._read_stdin()
|
fd.write(self.stdin.read())
|
||||||
while chunk:
|
|
||||||
fd.write(chunk)
|
|
||||||
chunk = self._read_stdin()
|
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
raise cdist.Error('Failed to read from stdin: %s' % e)
|
raise cdist.Error('Failed to read from stdin: %s' % e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue