| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 def set_build_property(self, key, value): | 88 def set_build_property(self, key, value): |
| 89 raise NotImplementedError() | 89 raise NotImplementedError() |
| 90 | 90 |
| 91 def trigger(self, trigger_spec): | 91 def trigger(self, trigger_spec): |
| 92 raise NotImplementedError() | 92 raise NotImplementedError() |
| 93 | 93 |
| 94 def make_step_stream(self, name, **kwargs): | 94 def make_step_stream(self, name, **kwargs): |
| 95 """Shorthand for creating a step stream from a step configuration dict.""" | 95 """Shorthand for creating a step stream from a step configuration dict.""" |
| 96 kwargs['name'] = name | 96 kwargs['name'] = name |
| 97 return self.new_step_stream(recipe_api.StepConfig.create(**kwargs)) | 97 return self.new_step_stream(recipe_api.StepClient.StepConfig(**kwargs)) |
| 98 | 98 |
| 99 def new_step_stream(self, step_config): | 99 def new_step_stream(self, step_config): |
| 100 """Creates a new StepStream in this engine. | 100 """Creates a new StepStream in this engine. |
| 101 | 101 |
| 102 The step will be considered started at the moment this method is called. | 102 The step will be considered started at the moment this method is called. |
| 103 | 103 |
| 104 TODO(luqui): allow_subannotations is a bit of a hack, whether to allow | 104 TODO(luqui): allow_subannotations is a bit of a hack, whether to allow |
| 105 annotations that this step emits through to the annotator (True), or | 105 annotations that this step emits through to the annotator (True), or |
| 106 guard them by prefixing them with ! (False). The proper way to do this | 106 guard them by prefixing them with ! (False). The proper way to do this |
| 107 is to implement an annotations parser that converts to StreamEngine calls; | 107 is to implement an annotations parser that converts to StreamEngine calls; |
| 108 i.e. parse -> re-emit. | 108 i.e. parse -> re-emit. |
| 109 | 109 |
| 110 Args: | 110 Args: |
| 111 step_config (recipe_api.StepConfig): The step configuration. | 111 step_config (recipe_api.StepCleint.StepConfig): The step configuration. |
| 112 """ | 112 """ |
| 113 raise NotImplementedError() | 113 raise NotImplementedError() |
| 114 | 114 |
| 115 def open(self): | 115 def open(self): |
| 116 pass | 116 pass |
| 117 | 117 |
| 118 def close(self): | 118 def close(self): |
| 119 pass | 119 pass |
| 120 | 120 |
| 121 def __enter__(self): | 121 def __enter__(self): |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 string (which means it might not be valid ascii), we decode the string with | 530 string (which means it might not be valid ascii), we decode the string with |
| 531 the 'replace' error mode, which replaces invalid characters with a suitable | 531 the 'replace' error mode, which replaces invalid characters with a suitable |
| 532 replacement character. | 532 replacement character. |
| 533 """ | 533 """ |
| 534 try: | 534 try: |
| 535 return str(s) | 535 return str(s) |
| 536 except UnicodeEncodeError: | 536 except UnicodeEncodeError: |
| 537 return s.encode('utf-8', 'replace') | 537 return s.encode('utf-8', 'replace') |
| 538 except UnicodeDecodeError: | 538 except UnicodeDecodeError: |
| 539 return s.decode('utf-8', 'replace') | 539 return s.decode('utf-8', 'replace') |
| OLD | NEW |