Example #1
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     async for chunk in client.tail_logs(
             stop=signal_handler_event("log"),
             arguments=self.normalise_log_arguments(args.log_arguments),
     ):
         print(chunk, end="")
     print("")
Example #2
0
 async def run_with_container(self, container: FileContainer,
                              args: Namespace, client: Client) -> None:
     async for data in client.tail(container=container,
                                   path=args.src,
                                   stop=signal_handler_event("tail")):
         sys.stdout.buffer.write(data)
         sys.stdout.flush()
Example #3
0
 async def run_with_client(self, args: Namespace, client: IdbClient) -> None:
     await client.launch(
         bundle_id=args.bundle_id,
         args=args.app_arguments,
         env=get_env_with_idb_prefix(),
         foreground_if_running=args.foreground_if_running,
         stop=signal_handler_event("launch") if args.wait_for else None,
     )
Example #4
0
 async def run_with_client(self, args: Namespace, client: Client) -> None:
     compression = (Compression[args.compression]
                    if args.compression is not None else None)
     stdStreams = await get_std_as_streams()
     await client.dap(
         dap_path=args.dap_pkg_path,
         input_stream=stdStreams.stdin,
         output_stream=stdStreams.stdout,
         stop=signal_handler_event("dap"),
         compression=compression,
     )
Example #5
0
    async def run_with_client(self, args: Namespace, client: Client) -> None:
        app_arguments = args.app_args

        app_environment = args.app_env
        # merge in special environment variables prefixed with 'IDB_'
        app_environment.update(get_env_with_idb_prefix())

        post_process_arguments = args.post_args

        timings = (
            InstrumentsTimings(
                terminate_timeout=args.terminate_timeout,
                launch_retry_timeout=args.launch_retry_timeout,
                launch_error_timeout=args.launch_error_timeout,
                operation_duration=args.operation_duration,
            )
            if (
                args.terminate_timeout
                or args.launch_retry_timeout
                or args.launch_error_timeout
                or args.operation_duration
            )
            else None
        )

        trace_extensions = ["trace"]
        trace_basename = args.output
        if trace_basename:
            if os.path.isdir(trace_basename):
                trace_basename = find_next_file_prefix(
                    os.path.join(trace_basename, "trace"), trace_extensions
                )
            else:
                # remove any user-specified file extension (e.g. 'foo.trace')
                trace_basename = os.path.splitext(trace_basename)[0]
        else:
            trace_basename = find_next_file_prefix("trace", trace_extensions)

        result = await client.run_instruments(
            stop=signal_handler_event("instruments"),
            trace_basename=trace_basename,
            template_name=args.template,
            app_bundle_id=args.app_bundle_id,
            app_environment=app_environment,
            app_arguments=app_arguments,
            tool_arguments=None,
            timings=timings,
            post_process_arguments=post_process_arguments,
        )

        print(result)
Example #6
0
    async def run_with_client(self, args: Namespace, client: Client) -> None:
        if args.append_run:
            self.logger.info(
                "The '--append-run' option will be ignored. It's not implemented."
            )
        if args.device:
            self.logger.info(
                "The '--device' option will be ignored. The target associated with "
                + "the companion will be used by default.")
        if args.target_stdin and args.target_stdin != "-":
            raise XctraceRecordException(
                'Only "-" is supported as a valid value for --target-stdin')
        if args.target_stdout and args.target_stdout != "-":
            raise XctraceRecordException(
                'Only "-" is supported as a valid value for --target-stdout')

        env = args.env
        # merge in special environment variables prefixed with 'IDB_'
        env.update(get_env_with_idb_prefix())

        trace_extensions = ["trace"]
        trace_basename = args.output
        if trace_basename:
            if os.path.isdir(trace_basename):
                trace_basename = find_next_file_prefix(
                    os.path.join(trace_basename, "trace"), trace_extensions)
            else:
                # remove any user-specified file extension (e.g. 'foo.trace')
                trace_basename = os.path.splitext(trace_basename)[0]
        else:
            trace_basename = find_next_file_prefix("trace", trace_extensions)

        result = await client.xctrace_record(
            stop=signal_handler_event("xctrace"),
            output=trace_basename,
            template_name=args.template,
            all_processes=args.all_processes,
            time_limit=formatted_time_to_seconds(args.time_limit),
            package=args.package,
            process_to_attach=args.attach,
            process_to_launch=args.launch,
            process_env=env,
            launch_args=args.launch_args,
            target_stdin=args.target_stdin,
            target_stdout=args.target_stdout,
            post_args=args.post_args,
            stop_timeout=formatted_time_to_seconds(args.stop_timeout),
        )

        print(result)
Example #7
0
 async def run_with_client(self, args: Namespace, client: IdbClient) -> None:
     trace_path = args.trace_path
     if trace_path is None:
         trace_path = f"{args.template}.trace"
     app_args = None if not args.app_args else args.app_args
     post_process_arguments = None if not args.post_args else args.post_args
     result = await client.run_instruments(
         stop=signal_handler_event("instruments"),
         template=args.template,
         app_bundle_id=args.app_bundle_id,
         post_process_arguments=post_process_arguments,
         env=get_env_with_idb_prefix(),
         app_args=app_args,
         trace_path=trace_path,
     )
     print(result)
Example #8
0
 async def run_with_client(self, args: Namespace,
                           client: IdbClient) -> None:
     await client.record_video(stop=signal_handler_event("video"),
                               output_file=args.output_file)
Example #9
0
 async def run_with_client(self, args: Namespace,
                           client: IdbClient) -> None:
     async for chunk in client.tail_companion_logs(
             stop=signal_handler_event("log")):
         print(chunk, end="")
     print("")