Best Python code snippet using autotest_python
samsung.py
Source:samsung.py  
...103    def get_serialnumber(self):104        raw = self.command(0x8A)105        data = self.get_answer_data(raw)106        return Tools.ascii_hex_list_to_string(data)107    def get_platform_label(self):108        raw = self.command(0x8A)109        data = self.get_answer_data(raw)110        return Tools.ascii_hex_list_to_string(data)111    def set_power_state(self, state):112        if state == self.POWER_STATE_ON:113            data = self.command(0x11, [0x01])114            return self.is_answer_ack(data)115        elif state == self.POWER_STATE_OFF:116            data = self.command(0x11, [0x02])117            return self.is_answer_ack(data)118        else:119            return False120    def set_input_channel(self, channel, visible=False):121        """ Set the input channel based on the local list """122        for key in self.input_channel_set:123            if self.input_channel_set[key] == channel:124                self.command(0x14, [int(key, 16)])125                data = self.get_input_channel()126                return key == data127        return False128# noinspection PyBroadException129class SamsungSerialDetector(object):130    def __init__(self):131        self._connection = SerialConnection()132        self._command = SamsungV065(self._connection)133        self._displays = []134    def detect_displays(self):135        print "Check Samsung Displays"136        for port in Tools.get_available_comports():137            print "  -> Trying to detect on port " + str(port)138            self._command.connection.port = port139            for i in range(0, 5):140                print "    -> For Display ID " + str(i)141                self._command.set_display_id(i)142                try:143                    state = self._command.get_power_state()144                    if state != DisplayGeneric.POWER_STATE_UNKNOWN:145                        power = 'unbek.'146                        try:147                            power = self._command.get_power_state_hr()148                        except Exception:149                            pass150                        serial = ''151                        try:152                            serial = self._command.get_serialnumber()153                        except Exception:154                            pass155                        source = 'unbek.'156                        try:157                            source = self._command.get_input_channel_hr()158                        except Exception:159                            pass160                        label = 'unbekt.'161                        try:162                            label = self._command.get_platform_label()163                        except Exception:164                            pass165                        sicp = ''166                        try:167                            sicp = self._command.get_control_software_version()168                        except Exception:169                            pass170                        newdisplay = {"port": port,171                                      "id": i,172                                      "key": "samsung_generic",173                                      "label": label,174                                      "power": power,175                                      "input": source,176                                      "serial": serial,...benq.py
Source:benq.py  
...69            self.command_with_response('sour=' + channel)70        else:71            raise CommandArgumentsNotSupportedError()72    def get_platform_version(self):73        return self.get_platform_label()74    def get_platform_label(self):75        return self.command_with_response('modelname=?')76    def get_firmware_version(self):77        return self.get_platform_label()78    def get_firmware_build_date(self):79        return self.get_platform_label()80    def get_modell_number(self):81        return self.get_platform_label()82    def get_operating_hours(self):83        return self.get_projector_lamp_hour()84    def get_projector_lamp_hour(self):85        return self.command_with_response('ltim=?')86    def get_freeze_status(self):87        current = self.command_with_response('freeze=?')88        return self.generic_enabled_result(current)89    def set_freeze_status(self, status):90        if status == self.GENERIC_ENABLED:91            self.command('freeze=on', None)92        elif status == self.GENERIC_DISABLED:93            self.command('freeze=off', None)94        else:95            raise CommandArgumentsNotSupportedError()...netpipe.py
Source:netpipe.py  
...8        server_label = 'net_server'9        server = hosts.create_host(pair[0])10        client = hosts.create_host(pair[1])11        # If client has the server_label, then swap server and client.12        platform_label = client.get_platform_label()13        if platform_label == server_label:14            (server, client) = (client, server)15        # Disable IP Filters if they are enabled.16        for m in [client, server]:17            status = m.run('iptables -L')18            if not status.exit_status:19                m.disable_ipfilters()20        server_at = autotest.Autotest(server)21        client_at = autotest.Autotest(client)22        template = ''.join(["job.run_test('netpipe', server_ip='%s', ",23                            "client_ip='%s', role='%s', bidirectional=True, ",24                            "buffer_size=%d, upper_bound=%d,"25                            "perturbation_size=%d)"])26        server_control_file = template % (server.ip, client.ip, 'server',...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!!
