Best Python code snippet using lisa_python
thermal_imaging.py
Source:thermal_imaging.py  
...399        if res == 0:400            return "{0:.2f}".format(value / 10.0 - 273.15)401        else:402            return "{0:.2f}".format(value / 100.0 - 273.15)403    def get_statistics_async(self, statistics):404        self.valid_resolution = statistics.resolution405        spot_mean = self.kelvin_to_degstr(statistics.spotmeter_statistics[0])406        spot_max = self.kelvin_to_degstr(statistics.spotmeter_statistics[1])407        spot_min = self.kelvin_to_degstr(statistics.spotmeter_statistics[2])408        spot_pix = str(statistics.spotmeter_statistics[3])409        self.spotmeter_mean_label.setText(spot_mean)410        self.spotmeter_minimum_label.setText(spot_min)411        self.spotmeter_maximum_label.setText(spot_max)412        self.spotmeter_pixel_count_label.setText(spot_pix)413        temp_fpa = self.kelvin_to_degstr(statistics.temperatures[0], 1)414        temp_fpa_ffc = self.kelvin_to_degstr(statistics.temperatures[1], 1)415        temp_housing = self.kelvin_to_degstr(statistics.temperatures[2], 1)416        temp_housing_ffc = self.kelvin_to_degstr(statistics.temperatures[3], 1)417        self.temp_fpa_label.setText(temp_fpa)...common.py
Source:common.py  
...178    for port in ports:179        client_netperf.run_as_client_async(server.internal_address, core_count, port)180    client_sar = client.tools[Sar]181    server_sar = server.tools[Sar]182    server_sar.get_statistics_async()183    result = client_sar.get_statistics()184    pps_message = client_sar.create_pps_performance_messages(185        result, inspect.stack()[1][3], test_type, test_result186    )187    notifier.notify(pps_message)188def perf_ntttcp(189    test_result: TestResult,190    server: Optional[RemoteNode] = None,191    client: Optional[RemoteNode] = None,192    udp_mode: bool = False,193    connections: Optional[List[int]] = None,194    test_case_name: str = "",195    server_nic_name: Optional[str] = None,196    client_nic_name: Optional[str] = None,...sar.py
Source:sar.py  
...29    def install(self) -> bool:30        posix_os: Posix = cast(Posix, self.node.os)31        posix_os.install_packages("sysstat")32        return self._check_exists()33    def get_statistics_async(34        self, key_word: str = "DEV", interval: int = 1, count: int = 12035    ) -> Process:36        # sar [ options ] [ <interval> [ <count> ] ]37        # -n { <keyword> [,...] | ALL }38        #     Network statistics39        #     Keywords are:40        #     DEV     Network interfaces41        #     EDEV    Network interfaces (errors)42        #     NFS     NFS client43        #     NFSD    NFS server44        #     SOCK    Sockets (v4)45        #     IP      IP traffic      (v4)46        #     EIP     IP traffic      (v4) (errors)47        #     ICMP    ICMP traffic    (v4)48        #     EICMP   ICMP traffic    (v4) (errors)49        #     TCP     TCP traffic     (v4)50        #     ETCP    TCP traffic     (v4) (errors)51        #     UDP     UDP traffic     (v4)52        #     SOCK6   Sockets (v6)53        #     IP6     IP traffic      (v6)54        #     EIP6    IP traffic      (v6) (errors)55        #     ICMP6   ICMP traffic    (v6)56        #     EICMP6  ICMP traffic    (v6) (errors)57        #     UDP6    UDP traffic     (v6)58        #     FC      Fibre channel HBAs59        #     SOFT    Software-based network processing60        cmd = f"{self.command} -n {key_word} {interval} {count}"61        process = self.node.execute_async(cmd)62        return process63    def get_statistics(64        self, key_word: str = "DEV", interval: int = 1, count: int = 12065    ) -> ExecutableResult:66        process = self.get_statistics_async(key_word, interval, count)67        return process.wait_result(68            expected_exit_code=0,69            expected_exit_code_failure_message="fail to run sar command",70        )71    def create_pps_performance_messages(72        self,73        result: ExecutableResult,74        test_case_name: str,75        test_type: str,76        test_result: "TestResult",77    ) -> NetworkPPSPerformanceMessage:78        # IFACE: Name of the network interface for which statistics are reported.79        # rxpck/s: packet receiving rate (unit: packets/second)80        # txpck/s: packet transmitting rate (unit: packets/second)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
