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

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

Issue 2835013002: Ensure raw_io creates all parent directories of the backing_dir. (Closed)
Patch Set: Created 3 years, 8 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 # -*- encoding: utf-8 -*- 1 # -*- encoding: utf-8 -*-
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 from recipe_engine import recipe_api 6 from recipe_engine import recipe_api
7 from recipe_engine import util as recipe_util 7 from recipe_engine import util as recipe_util
8 8
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 def backing_file(self): # pragma: no cover 131 def backing_file(self): # pragma: no cover
132 raise ValueError('Output dir placeholders can not be used for stdin, ' 132 raise ValueError('Output dir placeholders can not be used for stdin, '
133 'stdout or stderr') 133 'stdout or stderr')
134 134
135 def render(self, test): 135 def render(self, test):
136 assert not self._backing_dir, 'Placeholder can be used only once' 136 assert not self._backing_dir, 'Placeholder can be used only once'
137 if self.leak_to: 137 if self.leak_to:
138 self._backing_dir = str(self.leak_to) 138 self._backing_dir = str(self.leak_to)
139 if not test.enabled: # pragma: no cover 139 if not test.enabled: # pragma: no cover
140 if not os.path.exists(self._backing_dir): 140 if not os.path.exists(self._backing_dir):
141 os.mkdir(self._backing_dir) 141 os.makedirs(self._backing_dir)
142 else: 142 else:
143 if not test.enabled: # pragma: no cover 143 if not test.enabled: # pragma: no cover
144 self._backing_dir = tempfile.mkdtemp(suffix=self.suffix) 144 self._backing_dir = tempfile.mkdtemp(suffix=self.suffix)
145 else: 145 else:
146 self._backing_dir = '/path/to/tmp/' + self.suffix 146 self._backing_dir = '/path/to/tmp/' + self.suffix
147 147
148 return [self._backing_dir] 148 return [self._backing_dir]
149 149
150 def result(self, presentation, test): 150 def result(self, presentation, test):
151 assert self._backing_dir 151 assert self._backing_dir
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 """Returns a directory Placeholder for use as a step argument. 232 """Returns a directory Placeholder for use as a step argument.
233 233
234 If 'leak_to' is None, the placeholder is backed by a temporary dir with 234 If 'leak_to' is None, the placeholder is backed by a temporary dir with
235 a suffix 'suffix'. The dir is deleted when the step finishes. 235 a suffix 'suffix'. The dir is deleted when the step finishes.
236 236
237 If 'leak_to' is not None, then it should be a Path and placeholder 237 If 'leak_to' is not None, then it should be a Path and placeholder
238 redirects IO to a dir at that path. Once step finishes, the dir is 238 redirects IO to a dir at that path. Once step finishes, the dir is
239 NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case. 239 NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case.
240 """ 240 """
241 return OutputDataDirPlaceholder(suffix, leak_to, name=name) 241 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