| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import contextlib |
| 6 |
| 7 from recipe_engine import recipe_api |
| 8 from recipe_engine.config_types import Path |
| 9 |
| 10 class BlimpApi(recipe_api.RecipeApi): |
| 11 def get_config_defaults(self): |
| 12 return { |
| 13 'CHECKOUT_PATH': self.m.path['checkout'], |
| 14 } |
| 15 |
| 16 def _start_engine_forwarder(self, output_linux_dir, **kwargs): |
| 17 args = [ |
| 18 '-l', output_linux_dir, |
| 19 'run', |
| 20 ] |
| 21 self.m.python('[Blimp] Starting engine and forwarder', |
| 22 self.c.client_engine_integration_script, |
| 23 args, |
| 24 **kwargs) |
| 25 |
| 26 def _stop_engine_forwarder(self, output_linux_dir, **kwargs): |
| 27 args = [ |
| 28 '-l', output_linux_dir, |
| 29 'stop', |
| 30 ] |
| 31 self.m.python('[Blimp] Killing engine and forwarder', |
| 32 self.c.client_engine_integration_script, |
| 33 args, |
| 34 **kwargs) |
| 35 |
| 36 |
| 37 def load_client(self, output_linux_dir, apk_path, **kwargs): |
| 38 """Installs apk in client and runs blimp.""" |
| 39 args = [ |
| 40 '-l', output_linux_dir, |
| 41 'load', |
| 42 '--apk-path', apk_path, |
| 43 ] |
| 44 self.m.python('[Blimp] Installing apk and running blimp', |
| 45 self.c.client_engine_integration_script, |
| 46 args, |
| 47 **kwargs) |
| 48 |
| 49 @contextlib.contextmanager |
| 50 def engine_forwarder(self, output_linux_dir, **kwargs): |
| 51 try: |
| 52 self._start_engine_forwarder(output_linux_dir, **kwargs) |
| 53 yield |
| 54 finally: |
| 55 self._stop_engine_forwarder(output_linux_dir) |
| 56 |
| OLD | NEW |