How to use the urh.util.Logger.logger.info function in urh

To help you get started, we’ve selected a few urh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jopohl / urh / src / urh / util / SettingsProxy.py View on Github external
if resume_on_full_receive_buffer:
            if spectrum_mode:
                num_samples = constants.SPECTRUM_BUFFER_SIZE
            else:
                num_samples = constants.SNIFF_BUFFER_SIZE
        else:
            # Take 60% of avail memory
            threshold = constants.SETTINGS.value('ram_threshold', 0.6, float)
            num_samples = threshold * (psutil.virtual_memory().available / 8)

        # Do not let it allocate too much on 32 bit
        if 8*num_samples > sys.maxsize // 2:
            num_samples = sys.maxsize // (8 * 2)
            logger.info("Correcting buffer size to {}".format(num_samples))

        logger.info("Initializing receive buffer with size {0}B".format(Formatter.big_value_with_suffix(num_samples*8)))
        return int(num_samples)
github jopohl / urh / tests / docker / docker_util.py View on Github external
def run_image(imagename: str, rebuild=False):
    if not is_image_there(imagename) or rebuild:
        build_image(imagename)

    cmd = ["sudo"] if USE_SUDO else []
    call(cmd + ["xhost", "+"]) # Allow docker to connect to hosts X Server

    cmd.extend(["docker", "run", "-e", "DISPLAY=$DISPLAY", "-v", "/tmp/.X11-unix:/tmp/.X11-unix", "urh/"+imagename])
    logger.info("call {}".format(" ".join(cmd)))
    rc = call(" ".join(cmd), shell=True)
    return rc == 0
github jopohl / urh / src / urh / dev / gr / AbstractBaseThread.py View on Github external
def stop(self, msg: str):
        if msg and not msg.startswith("FIN"):
            self.requestInterruption()

        if self.tb_process:
            logger.info("Kill grc process")
            self.tb_process.kill()
            logger.info("Term grc process")
            self.tb_process.terminate()
            self.tb_process = None

        logger.info(msg)
        self.stopped.emit()
github jopohl / urh / src / urh / dev / gr / AbstractBaseThread.py View on Github external
def stop(self, msg: str):
        if msg and not msg.startswith("FIN"):
            self.requestInterruption()

        if self.tb_process:
            logger.info("Kill grc process")
            self.tb_process.kill()
            logger.info("Term grc process")
            self.tb_process.terminate()
            self.tb_process = None

        logger.info(msg)
        self.stopped.emit()
github jopohl / urh / src / urh / dev / native / Device.py View on Github external
def log_retcode(self, retcode: int, action: str, msg=""):
        msg = str(msg)
        error_code_msg = self.error_codes[retcode] if retcode in self.error_codes else "Error Code: " + str(retcode)

        if retcode == self.success:
            if msg:
                formatted_message = "{0}-{1} ({2}): Success".format(type(self).__name__, action, msg)
            else:
                formatted_message = "{0}-{1}: Success".format(type(self).__name__, action)
            logger.info(formatted_message)
        else:
            if msg:
                formatted_message = "{0}-{1} ({4}): {2} ({3})".format(type(self).__name__, action, error_code_msg,
                                                                      retcode, msg)
            else:
                formatted_message = "{0}-{1}: {2} ({3})".format(type(self).__name__, action, error_code_msg, retcode)
            logger.error(formatted_message)

        self.device_messages.append(formatted_message)
github jopohl / urh / src / urh / dev / native / RTLSDRTCP.py View on Github external
def set_parameter(self, param: str, value: int, ctrl_connection):  # returns error (True/False)
        if self.socket_is_open:
            msg = self.RTL_TCP_CONSTS.index(param).to_bytes(1, self.ENDIAN)  # Set param at bits 0-7
            msg += value.to_bytes(4, self.ENDIAN)  # Set value at bits 8-39
            try:
                self.sock.sendall(msg)  # Send data to rtl_tcp
            except OSError as e:
                self.sock.close()
                logger.info("Could not set parameter {0}:{1} ({2})".format(param, value, e))
                ctrl_connection.send("Could not set parameter {0} {1} ({2}):1".format(param, value, e))
                return True
        return False
github jopohl / urh / src / urh / dev / VirtualDevice.py View on Github external
def increase_gr_port(self):
        if self.backend == Backends.grc:
            self.__dev.gr_port += 1
            logger.info("Retry with port " + str(self.__dev.gr_port))
        else:
            raise ValueError("Only for GR backend")
github jopohl / urh / src / urh / dev / native / Device.py View on Github external
def stop_tx_mode(self, msg):
        try:
            self.parent_ctrl_conn.send(self.Command.STOP.name)
        except (BrokenPipeError, OSError) as e:
            logger.debug("Closing parent control connection: " + str(e))

        logger.info("{0}: Stopping TX Mode: {1}".format(self.__class__.__name__, msg))

        if hasattr(self, "transmit_process") and self.transmit_process.is_alive():
            self.transmit_process.join(self.JOIN_TIMEOUT)
            if self.transmit_process.is_alive():
                logger.warning("{0}: Transmit process is still alive, terminating it".format(self.__class__.__name__))
                self.transmit_process.terminate()
                self.transmit_process.join()

        self.is_transmitting = False
        try:
            self.parent_ctrl_conn.close()
        except OSError as e:
            logger.exception(e)

        try:
            self.child_ctrl_conn.close()
github jopohl / urh / src / urh / dev / native / Device.py View on Github external
while self.is_receiving:
            try:
                byte_buffer = self.parent_data_conn.recv_bytes()
                samples = self.unpack_complex(byte_buffer)
                n_samples = len(samples)
                if n_samples == 0:
                    continue

                if self.apply_dc_correction:
                    samples -= np.mean(samples)

            except OSError as e:
                logger.exception(e)
                continue
            except EOFError:
                logger.info("EOF Error: Ending receive thread")
                break

            if self.current_recv_index + n_samples >= len(self.receive_buffer):
                if self.resume_on_full_receive_buffer:
                    self.current_recv_index = 0
                    if n_samples >= len(self.receive_buffer):
                        n_samples = len(self.receive_buffer) - 1
                else:
                    self.stop_rx_mode(
                        "Receiving buffer is full {0}/{1}".format(self.current_recv_index + n_samples,
                                                                  len(self.receive_buffer)))
                    return

            self.receive_buffer[self.current_recv_index:self.current_recv_index + n_samples] = samples[:n_samples]
            self.current_recv_index += n_samples