How to use _filter_ns_infoblock method in avocado

Best Python code snippet using avocado_python

pmem.py

Source:pmem.py Github

copy

Full Screen

...336 return " %s" % args_dict[key] % kwargs.pop(key)337 return " %s" % args_dict[key] % kwargs.get(key)338 return ""339 @staticmethod340 def _filter_ns_infoblock(namespace, args_dict, kwargs):341 args = ""342 if namespace == "all":343 for key in ['region', 'bus']:344 args += PMem._check_add_arg(args_dict, key, kwargs, pop=True)345 return args346 def write_infoblock(self, namespace='', stdout=False, output=None,347 **kwargs):348 """349 Write an infoblock to the specified medium.350 :param namespace: Write the infoblock to given namespace351 :param stdout: Write the infoblock to stdout if True352 :param output: Write the infoblock to the file path specified353 :param kwargs:354 Example:355 pmem.write_infoblock(namespace=ns_name, align=align,356 size=size, mode='devdax')357 :return: True if command succeeds358 :rtype: bool359 :raise: :class:`PMemException`, if command fails.360 """361 if not (namespace or stdout or output):362 raise PMemException("Specify at least one output medium")363 args_dict = {'region': '-r %s', 'bus': '-b %s', 'mode': '-m %s',364 'memmap': '-M %s', 'size': '-s %s', 'align': '-a %s',365 'uuid': '-u %s', 'parent_uuid': '-p %', 'offset': '-O %s'}366 if namespace:367 args = namespace368 elif stdout:369 args = "-c"370 elif output:371 args = "-o %s" % output372 args += self._filter_ns_infoblock(namespace, args_dict, kwargs)373 args += " %s" % args_dict['mode'] % kwargs.pop('mode', 'fsdax')374 args += " %s" % args_dict['memmap'] % kwargs.pop('memmap', 'dev')375 for key, value in kwargs.items():376 if not value:377 continue378 if key in args_dict:379 args += " %s" % args_dict[key] % value380 else:381 raise PMemException("Input not supported for write-infoblock")382 write_cmd = "%s write-infoblock %s" % (self.ndctl, args)383 if process.system(write_cmd, shell=True, ignore_status=True):384 raise PMemException("write-infoblock command failed")385 return True386 def read_infoblock(self, namespace='', inp_file='', **kwargs):387 """388 Read an infoblock from the specified medium389 :param namespace: Read the infoblock from given namespace390 :param inp_file: Input file to read the infoblock from391 :param kwargs:392 Example:393 self.plib.read_infoblock(namespace=ns_name, json_form=True)394 :return: By default return list of json objects, if json_form is True395 Return as raw data, if json_form is False396 Return file path if op_file is specified397 :raise: :class:`PMemException`, if command fails.398 """399 if not (namespace or inp_file):400 raise PMemException("Namespace or input file must be specified")401 args_dict = {"region": "-r %s", "bus": "-b %s", "op_file": "-o %s"}402 if namespace:403 args = namespace404 elif inp_file:405 args = "-i %s" % inp_file406 args += self._filter_ns_infoblock(namespace, args_dict, kwargs)407 args += self._check_add_arg(args_dict, 'op_file', kwargs)408 json_form = kwargs.pop('json_form', True)409 verify = kwargs.pop('verify', False)410 if verify:411 args += " -V"412 if json_form:413 args += " -j"414 read_cmd = "%s read-infoblock %s" % (self.ndctl, args)415 ret = process.run(read_cmd, shell=True, ignore_status=True)416 if ret.exit_status:417 raise PMemException("read-infoblock command failed")418 if self._check_arg('op_file', kwargs):419 return kwargs.get('op_file')420 read_op = ret.stdout.decode()...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful