Best Python code snippet using localstack_python
perform_command_openocd.py
Source:perform_command_openocd.py  
...33    """34    Note: Missing some functions and program not working all the time.35    Probably will need --family arugment to determine which target/nrf5x.cfg script to use - until this is shared in openOCD.36    """37    def _create_shell_command(self, command):38        return [39            'sudo',40            'openocd',41            '-f',42            'interface/cmsis-dap.cfg',43            '-f',44            'target/nrf52.cfg',45            '-c',46            'init',47            '-c',48            command,49            '-c',50            'exit']51    def erase(self, args):52        command = 'nrf52 mass_erase'53        shell_command = self._create_shell_command(command)54        subprocess.check_call(55            shell_command,56            stdin=None,57            stdout=None,58            stderr=None,59            shell=False)60    def halt(self, args):61        command = 'halt'62        shell_command = self._create_shell_command(command)63        subprocess.check_call(64            shell_command,65            stdin=None,66            stdout=None,67            stderr=None,68            shell=False)69    def ids(self, args):70        command = 'targets'71        shell_command = self._create_shell_command(command)72        subprocess.check_call(73            shell_command,74            stdin=None,75            stdout=None,76            stderr=None,77            shell=False)78    def memrd(self, args):79        command = 'mdw ' + str(args.addr) + ' ' + str(args.length)80        shell_command = self._create_shell_command(command)81        subprocess.check_call(82            shell_command,83            stdin=None,84            stdout=None,85            stderr=None,86            shell=False)87    def memwr(self, args):88        """89        Not working.90        """91        command = 'mww ' + str(args.addr) + ' ' + str(args.val) + ' ' + str(1)92        shell_command = self._create_shell_command(command)93        subprocess.check_call(94            shell_command,95            stdin=None,96            stdout=None,97            stderr=None,98            shell=False)99    def program(self, args):100        command = 'program ' + args.file + ' verify reset'101        shell_command = self._create_shell_command(command)102        subprocess.check_call(103            shell_command,104            stdin=None,105            stdout=None,106            stderr=None,107            shell=False)108    def readregs(self, args):109        command = 'reg'110        shell_command = self._create_shell_command(command)111        subprocess.check_call(112            shell_command,113            stdin=None,114            stdout=None,115            stderr=None,116            shell=False)117    def reset(self, args):118        command = 'reset'119        shell_command = self._create_shell_command(command)120        subprocess.check_call(121            shell_command,122            stdin=None,123            stdout=None,124            stderr=None,125            shell=False)126    def run(self, args):127        command = 'resume ' + str(args.pc)128        shell_command = self._create_shell_command(command)129        subprocess.check_call(130            shell_command,131            stdin=None,132            stdout=None,133            stderr=None,134            shell=False)135    def version(self, args):136        print('nRFjprog version: {}'.format(nrfjprog_version.NRFJPROG_VERSION))137        command = 'version'138        shell_command = self._create_shell_command(command)139        subprocess.check_call(140            shell_command,141            stdin=None,142            stdout=None,143            stderr=None,...paris_traceroute.py
Source:paris_traceroute.py  
...10        self.options = ["--algo=exhaustive", "-p " + protocol.lower()]11        self.output = None12        self.errors = None13        super(ParisTraceroute, self).__init__()14    def _create_shell_command(self):15        return '{} {} {}'.format(16            'paris-traceroute',17            ' '.join(self.options),18            self.distant_host19        )20    def create_measurement(self):21        pt = shell.shell(self._create_shell_command())22        return pt.output(), pt.errors()23    def run(self):24        output, errors = self.create_measurement()25        self.output = output...mtr.py
Source:mtr.py  
...10        self.options = ["--report", "--csv", "--aslookup", "--mpls", "--show-ips"]11        self.output = None12        self.errors = None13        super(Mtr, self).__init__()14    def _create_shell_command(self):15        return '{} {} {}'.format(16            'mtr',17            self.distant_host,18            ' '.join(self.options)19        )20    def create_measurement(self):21        mtr = shell.shell(self._create_shell_command())22        return mtr.output(), mtr.errors()23    def run(self):24        output, errors = self.create_measurement()25        self.output = output...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!!
