How to use _get_service_result_parser method in autotest

Best Python code snippet using autotest_python

service.py

Source:service.py Github

copy

Full Screen

...557_result_parsers = {"init": sys_v_init_result_parser,558 "systemd": systemd_result_parser}559_service_managers = {"init": _SysVInitServiceManager,560 "systemd": _SystemdServiceManager}561def _get_service_result_parser(run=utils.run):562 """563 Get the ServiceResultParser using the auto-detect init command.564 :return: ServiceResultParser fro the current init command.565 :rtype: _ServiceResultParser566 """567 # pylint: disable=W0601568 global _service_result_parser569 try:570 return _service_result_parser571 except NameError:572 result_parser = _result_parsers[get_name_of_init(run)]573 _service_result_parser = _ServiceResultParser(result_parser)574 return _service_result_parser575def _get_service_command_generator(run=utils.run):576 """577 Lazy initializer for ServiceCommandGenerator using the auto-detect init command.578 :return: ServiceCommandGenerator for the current init command.579 :rtype: _ServiceCommandGenerator580 """581 # _service_command_generator is explicitly undefined so that we get the NameError on first access582 # pylint: disable=W0601583 global _service_command_generator584 try:585 return _service_command_generator586 except NameError:587 command_generator = _command_generators[get_name_of_init(run)]588 _service_command_generator = _ServiceCommandGenerator(589 command_generator)590 return _service_command_generator591def ServiceManager(run=utils.run):592 """593 Detect which init program is being used, init or systemd and return a594 class has methods to start/stop services.595 # Get the system service manager596 service_manager = ServiceManager()597 # Stating service/unit "sshd"598 service_manager.start("sshd")599 # Getting a list of available units600 units = service_manager.list()601 # Disabling and stopping a list of services602 services_to_disable = ['ntpd', 'httpd']603 for s in services_to_disable:604 service_manager.disable(s)605 service_manager.stop(s)606 :return: SysVInitServiceManager or SystemdServiceManager607 :rtype: _GenericServiceManager608 """609 service_manager = _service_managers[get_name_of_init(run)]610 # _service_command_generator is explicitly undefined so that we get the NameError on first access611 # pylint: disable=W0601612 global _service_manager613 try:614 return _service_manager615 except NameError:616 _service_manager = service_manager(_get_service_command_generator(run),617 _get_service_result_parser(run))618 return _service_manager619def _auto_create_specific_service_result_parser(run=utils.run):620 """621 Create a class that will create partial functions that generate result_parser622 for the current init command.623 :return: A ServiceResultParser for the auto-detected init command.624 :rtype: _ServiceResultParser625 """626 result_parser = _result_parsers[get_name_of_init(run)]627 # remove list method628 command_list = [c for c in COMMANDS if c not in ["list", "set_target"]]629 return _ServiceResultParser(result_parser, command_list)630def _auto_create_specific_service_command_generator(run=utils.run):631 """632 Create a class that will create partial functions that generate commands633 for the current init command.634 lldpad = SpecificServiceManager("lldpad",635 auto_create_specific_service_command_generator())636 lldpad.start()637 lldpad.stop()638 :return: A ServiceCommandGenerator for the auto-detected init command.639 :rtype: _ServiceCommandGenerator640 """641 command_generator = _command_generators[get_name_of_init(run)]642 # remove list method643 command_list = [c for c in COMMANDS if c not in ["list", "set_target"]]644 return _ServiceCommandGenerator(command_generator, command_list)645def SpecificServiceManager(service_name, run=utils.run):646 """647 # Get the specific service manager for sshd648 sshd = SpecificServiceManager("sshd")649 sshd.start()650 sshd.stop()651 sshd.reload()652 sshd.restart()653 sshd.condrestart()654 sshd.status()655 sshd.enable()656 sshd.disable()657 sshd.is_enabled()658 :param service_name: systemd unit or init.d service to manager659 :type service_name: str660 :return: SpecificServiceManager that has start/stop methods661 :rtype: _SpecificServiceManager662 """663 return _SpecificServiceManager(service_name,664 _auto_create_specific_service_command_generator(run),...

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 autotest 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