コード例 #1
0
ファイル: local_base.py プロジェクト: xuedm2016/mobly
    def start_capture(self,
                      override_configs=None,
                      additional_args=None,
                      duration=None,
                      packet_count=None):
        """See base class documentation
        """
        if self._process is not None:
            raise sniffer.InvalidOperationError(
                "Trying to start a sniff while another is still running!")
        capture_dir = os.path.join(self._logger.log_path,
                                   "Sniffer-{}".format(self._interface))
        os.makedirs(capture_dir, exist_ok=True)
        self._capture_file_path = os.path.join(
            capture_dir,
            "capture_{}.pcap".format(logger.get_log_file_timestamp()))

        self._pre_capture_config(override_configs)
        _, self._temp_capture_file_path = tempfile.mkstemp(suffix=".pcap")

        cmd = self._get_command_line(additional_args=additional_args,
                                     duration=duration,
                                     packet_count=packet_count)

        self._process = utils.start_standing_subprocess(cmd)
        return sniffer.ActiveCaptureContext(self, duration)
コード例 #2
0
ファイル: local_base.py プロジェクト: xuedm2016/mobly
 def stop_capture(self):
     """See base class documentation
     """
     if self._process is None:
         raise sniffer.InvalidOperationError(
             "Trying to stop a non-started process")
     utils.stop_standing_subprocess(self._process)
     self._post_process()
コード例 #3
0
ファイル: local_base.py プロジェクト: xuedm2016/mobly
 def wait_for_capture(self, timeout=None):
     """See base class documentation
     """
     if self._process is None:
         raise sniffer.InvalidOperationError(
             "Trying to wait on a non-started process")
     try:
         utils.wait_for_standing_subprocess(self._process, timeout)
         self._post_process()
     except subprocess.TimeoutExpired:
         self.stop_capture()