Lines Matching +full:- +full:- +full:daemon
2 # Use of this source code is governed by a BSD-style license that can be
4 """Common methods and variables used by Cr-Fuchsia testing infrastructure."""
22 def _find_src_root() -> str:
32 # have folders like third_party/fuchsia-sdk in it.
34 IMAGES_ROOT = os.path.join(DIR_SRC_ROOT, 'third_party', 'fuchsia-sdk',
37 SDK_ROOT = os.path.join(DIR_SRC_ROOT, 'third_party', 'fuchsia-sdk', 'sdk')
42 def set_ffx_isolate_dir(isolate_dir: str) -> None:
85 """Determines daemon status via `ffx daemon socket`.
89 NotRunning to indicate if the daemon is running.
92 run_ffx_command(cmd=('daemon', 'socket'),
105 """Waits for daemon to reach desired state in a polling loop.
110 start: bool. Indicates to wait for daemon to start up. If False,
111 indicates waiting for daemon to die.
112 timeout_seconds: int. Number of seconds to wait for the daemon to reach
115 TimeoutError: if the daemon does not reach the desired state in time.
124 logging.info('Waiting for daemon to %s...', wanted_status)
127 raise TimeoutError(f'Daemon did not {wanted_status} in time.')
131 """Scans |output| for a self-repair command to run and, if found, runs it.
137 # "Run `ffx doctor --restart-daemon` for further diagnostics."
145 # Need the daemon to be up at the end of this.
155 """Starts the ffx daemon by using doctor --restart-daemon since daemon start
158 Note, doctor --restart-daemon usually fails since the timeout in ffx is
159 short and won't be sufficient to wait for the daemon to really start.
161 Also, doctor --restart-daemon always restarts the daemon, so this function
163 daemon by explicitly calling stop daemon first.
166 run_ffx_command(cmd=('doctor', '--restart-daemon'), check=False)
171 """Stops the ffx daemon"""
172 run_ffx_command(cmd=('daemon', 'stop'))
180 **kwargs) -> subprocess.CompletedProcess:
183 If `ffx` exits with a non-zero exit code, the output is scanned for a
184 recommended repair command (e.g., "Run `ffx doctor --restart-daemon` for
198 check: If True, CalledProcessError is raised if ffx returns a non-zero
209 # - Repair does not need to be suppressed
210 # - capture_output is Truthy
252 encoding: Optional[str] = 'utf-8',
253 **kwargs) -> subprocess.Popen:
270 ffx_cmd.extend(('--machine', 'json'))
272 ffx_cmd.extend(('--target', target_id))
275 ffx_cmd.extend(('--config', config))
281 def read_package_paths(out_dir: str, pkg_name: str) -> List[str]:
296 def register_common_args(parser: ArgumentParser) -> None:
300 '--out-dir',
301 '-C',
306 def register_device_args(parser: ArgumentParser) -> None:
309 device_args.add_argument('--target-id',
312 'a node-name (e.g. fuchsia-emulator) or an '
319 def register_log_args(parser: ArgumentParser) -> None:
323 log_args.add_argument('--logs-dir',
328 def get_component_uri(package: str) -> str:
330 return f'fuchsia-pkg://{REPO_ALIAS}/{package}#meta/{package}.cm'
333 def resolve_packages(packages: List[str], target_id: Optional[str]) -> None:
337 subprocess.run(ssh_prefix + ['--', 'pkgctl', 'gc'], check=False)
341 '--', 'pkgctl', 'resolve',
342 'fuchsia-pkg://%s/%s' % (REPO_ALIAS, package)
348 **kwargs) -> Optional[subprocess.CompletedProcess]:
352 if i == retries - 1:
362 def get_ssh_address(target_id: Optional[str]) -> str:
364 return run_ffx_command(cmd=('target', 'get-ssh-address'),
369 def find_in_dir(target_name: str, parent_dir: str) -> Optional[str]:
388 def find_image_in_sdk(product_name: str) -> Optional[str]:
404 def catch_sigterm() -> None:
412 def wait_for_sigterm(extra_msg: str = '') -> None:
414 Spin-wait for either ctrl+c or sigterm. Caller can use try-finally
426 logging.info('Ctrl-C received; %s', extra_msg)
431 def get_system_info(target: Optional[str] = None) -> Tuple[str, str]:
438 info_cmd = run_ffx_command(cmd=('target', 'show', '--json'),