Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: recipe_modules/raw_io/api.py

Issue 2106333004: Fix raw_io input placeholders not using unicode. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from recipe_engine import recipe_api 5 from recipe_engine import recipe_api
6 from recipe_engine import util as recipe_util 6 from recipe_engine import util as recipe_util
7 7
8 import os 8 import os
9 import shutil 9 import shutil
10 import tempfile 10 import tempfile
(...skipping 12 matching lines...) Expand all
23 return self._backing_file 23 return self._backing_file
24 24
25 def render(self, test): 25 def render(self, test):
26 assert not self._backing_file, 'Placeholder can be used only once' 26 assert not self._backing_file, 'Placeholder can be used only once'
27 if test.enabled: 27 if test.enabled:
28 # cheat and pretend like we're going to pass the data on the 28 # cheat and pretend like we're going to pass the data on the
29 # cmdline for test expectation purposes. 29 # cmdline for test expectation purposes.
30 self._backing_file = self.data 30 self._backing_file = self.data
31 else: # pragma: no cover 31 else: # pragma: no cover
32 input_fd, self._backing_file = tempfile.mkstemp(suffix=self.suffix) 32 input_fd, self._backing_file = tempfile.mkstemp(suffix=self.suffix)
33 os.write(input_fd, self.data) 33 os.write(input_fd, self.data.encode('utf-8'))
34 os.close(input_fd) 34 os.close(input_fd)
35 return [self._backing_file] 35 return [self._backing_file]
36 36
37 def cleanup(self, test_enabled): 37 def cleanup(self, test_enabled):
38 assert self._backing_file is not None 38 assert self._backing_file is not None
39 exists = os.path.exists(self._backing_file) 39 exists = os.path.exists(self._backing_file)
40 if not test_enabled and exists: # pragma: no cover 40 if not test_enabled and exists: # pragma: no cover
41 os.unlink(self._backing_file) 41 os.unlink(self._backing_file)
42 self._backing_file = None 42 self._backing_file = None
43 43
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 """Returns a directory Placeholder for use as a step argument. 154 """Returns a directory Placeholder for use as a step argument.
155 155
156 If 'leak_to' is None, the placeholder is backed by a temporary dir with 156 If 'leak_to' is None, the placeholder is backed by a temporary dir with
157 a suffix 'suffix'. The dir is deleted when the step finishes. 157 a suffix 'suffix'. The dir is deleted when the step finishes.
158 158
159 If 'leak_to' is not None, then it should be a Path and placeholder 159 If 'leak_to' is not None, then it should be a Path and placeholder
160 redirects IO to a dir at that path. Once step finishes, the dir is 160 redirects IO to a dir at that path. Once step finishes, the dir is
161 NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case. 161 NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case.
162 """ 162 """
163 return OutputDataDirPlaceholder(suffix, leak_to, name=name) 163 return OutputDataDirPlaceholder(suffix, leak_to, name=name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698