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

Side by Side Diff: recipe_engine/stream.py

Issue 2332833003: Add better documentation, trigger namedtuple. (Closed)
Patch Set: More cleanups. Created 4 years, 3 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
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 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 """Abstract stream interface for representing recipe runs. 5 """Abstract stream interface for representing recipe runs.
6 6
7 We need to create streams for steps (and substeps) and also LOG_LINE steps. 7 We need to create streams for steps (and substeps) and also LOG_LINE steps.
8 LogDog will implement LOG_LINE steps as real logs (i.e. uniformly), but 8 LogDog will implement LOG_LINE steps as real logs (i.e. uniformly), but
9 annotations will implement them differently from normal logs, so we need 9 annotations will implement them differently from normal logs, so we need
10 a way to distinguish. 10 a way to distinguish.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 def set_build_property(self, key, value): 66 def set_build_property(self, key, value):
67 raise NotImplementedError() 67 raise NotImplementedError()
68 68
69 def trigger(self, trigger_spec): 69 def trigger(self, trigger_spec):
70 raise NotImplementedError() 70 raise NotImplementedError()
71 71
72 def make_step_stream(self, name, **kwargs): 72 def make_step_stream(self, name, **kwargs):
73 """Shorthand for creating a step stream from a step configuration dict.""" 73 """Shorthand for creating a step stream from a step configuration dict."""
74 kwargs['name'] = name 74 kwargs['name'] = name
75 return self.new_step_stream(recipe_api._make_step_config(**kwargs)) 75 return self.new_step_stream(recipe_api.StepConfig.create(**kwargs))
76 76
77 def new_step_stream(self, step_config): 77 def new_step_stream(self, step_config):
78 """Creates a new StepStream in this engine. 78 """Creates a new StepStream in this engine.
79 79
80 The step will be considered started at the moment this method is called. 80 The step will be considered started at the moment this method is called.
81 81
82 TODO(luqui): allow_subannotations is a bit of a hack, whether to allow 82 TODO(luqui): allow_subannotations is a bit of a hack, whether to allow
83 annotations that this step emits through to the annotator (True), or 83 annotations that this step emits through to the annotator (True), or
84 guard them by prefixing them with ! (False). The proper way to do this 84 guard them by prefixing them with ! (False). The proper way to do this
85 is to implement an annotations parser that converts to StreamEngine calls; 85 is to implement an annotations parser that converts to StreamEngine calls;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 string (which means it might not be valid ascii), we decode the string with 418 string (which means it might not be valid ascii), we decode the string with
419 the 'replace' error mode, which replaces invalid characters with a suitable 419 the 'replace' error mode, which replaces invalid characters with a suitable
420 replacement character. 420 replacement character.
421 """ 421 """
422 try: 422 try:
423 return str(s) 423 return str(s)
424 except UnicodeEncodeError: 424 except UnicodeEncodeError:
425 return s.encode('utf-8', 'replace') 425 return s.encode('utf-8', 'replace')
426 except UnicodeDecodeError: 426 except UnicodeDecodeError:
427 return s.decode('utf-8', 'replace') 427 return s.decode('utf-8', 'replace')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698