How to use command_capabilities method in avocado

Best Python code snippet using avocado_python

git-remote-gemini

Source:git-remote-gemini Github

copy

Full Screen

...107 if not parts: error("malformed command input from git")108 if hasattr(self,f"command_{parts[0]}"):109 return getattr(self,f"command_{parts[0]}")(*parts[1:])110 else: error(f"unknown command '{parts[0]}' from git")111 def command_capabilities(self):112 """Returns the capabilities we provide. We only provide `fetch`, so... yeah."""113 yield 'fetch'114 yield ''115 def get_hash_algo(self,sample):116 if len(sample)==40:117 return hashlib.sha1118 if len(sample)==64:119 return hashlib.sha256120 return None121 def get_hash_algo_name(self,algo):122 return algo.__name__.rsplit("_",1)[1]123 def get_refs(self):124 info_refs = self.fetch("/info/refs")125 try:...

Full Screen

Full Screen

ova.py

Source:ova.py Github

copy

Full Screen

1# Copyright (c) 2018 Eaton. All rights reserved.2#3# This file is part of kiwi.4#5# kiwi is free software: you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation, either version 3 of the License, or8# (at your option) any later version.9#10# kiwi is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with kiwi. If not, see <http://www.gnu.org/licenses/>17#18import os19import stat20from textwrap import dedent21# project22from kiwi.storage.subformat.vmdk import DiskFormatVmdk23from kiwi.storage.subformat.base import DiskFormatBase24from kiwi.command import Command25from kiwi.utils.command_capabilities import CommandCapabilities26from kiwi.path import Path27from kiwi.system.result import Result28from kiwi.exceptions import (29 KiwiFormatSetupError,30 KiwiCommandNotFound31)32class DiskFormatOva(DiskFormatBase):33 """34 **Create ova disk format, based on vmdk**35 """36 def post_init(self, custom_args: dict) -> None:37 """38 vmdk disk format post initialization method39 Store qemu options as list from custom args dict40 :param dict custom_args: custom qemu arguments dictionary41 """42 ovftype = self.xml_state.get_build_type_machine_section().get_ovftype()43 if ovftype != 'vmware':44 raise KiwiFormatSetupError('Unsupported ovftype %s' % ovftype)45 self.image_format = 'ova'46 self.options = self.get_qemu_option_list(custom_args)47 self.vmdk = DiskFormatVmdk(48 self.xml_state, self.root_dir, self.target_dir, custom_args49 )50 def create_image_format(self) -> None:51 """52 Create ova disk format using ovftool from53 https://www.vmware.com/support/developer/ovf54 """55 # Check for required ovftool56 ovftool = Path.which(filename='ovftool', access_mode=os.X_OK)57 if not ovftool:58 tool_not_found_message = dedent('''\n59 Required tool {0} not found in PATH on the build host60 Building OVA images requires VMware's {0} tool which61 can be installed from the following location62 https://www.vmware.com/support/developer/ovf63 ''')64 raise KiwiCommandNotFound(65 tool_not_found_message.format(ovftool)66 )67 # Create the vmdk disk image and vmx config68 self.vmdk.create_image_format()69 # Convert to ova using ovftool70 vmx = self.get_target_file_path_for_format('vmx')71 ova = self.get_target_file_path_for_format('ova')72 try:73 os.unlink(ova)74 except OSError:75 pass76 ovftool_options = []77 if CommandCapabilities.has_option_in_help(78 ovftool, '--shaAlgorithm', raise_on_error=False79 ):80 ovftool_options.append('--shaAlgorithm=SHA1')81 Command.run(82 [ovftool] + ovftool_options + [vmx, ova]83 )84 # ovftool ignores the umask and creates files with 060085 # apply file permission bits set in the vmx file to the86 # ova file87 st = os.stat(vmx)88 os.chmod(ova, stat.S_IMODE(st.st_mode))89 def store_to_result(self, result: Result) -> None:90 """91 Store the resulting ova file into the provided result instance.92 :param object result: Instance of Result93 """94 result.add(95 key='disk_format_image',96 filename=self.get_target_file_path_for_format('ova'),97 use_for_bundle=True,98 compress=self.runtime_config.get_bundle_compression(99 default=False100 ),101 shasum=True...

Full Screen

Full Screen

loop_device.py

Source:loop_device.py Github

copy

Full Screen

1# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.2#3# This file is part of kiwi.4#5# kiwi is free software: you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation, either version 3 of the License, or8# (at your option) any later version.9#10# kiwi is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with kiwi. If not, see <http://www.gnu.org/licenses/>17#18import os19import logging20# project21from kiwi.command import Command22from kiwi.storage.device_provider import DeviceProvider23from kiwi.utils.command_capabilities import CommandCapabilities24from kiwi.exceptions import (25 KiwiLoopSetupError26)27log = logging.getLogger('kiwi')28class LoopDevice(DeviceProvider):29 """30 **Create and manage loop device file for block operations**31 :param string filename: loop file name to create32 :param int filesize_mbytes: size of the loop file33 :param int blocksize_bytes: blocksize used in loop driver34 """35 def __init__(36 self, filename: str, filesize_mbytes: int = None,37 blocksize_bytes: int = None38 ):39 self.node_name = ''40 if not os.path.exists(filename) and not filesize_mbytes:41 raise KiwiLoopSetupError(42 'Can not create loop file without a size'43 )44 self.filename = filename45 self.filesize_mbytes = filesize_mbytes46 self.blocksize_bytes = blocksize_bytes47 def get_device(self) -> str:48 """49 Device node name50 :return: device node name51 :rtype: str52 """53 return self.node_name54 def is_loop(self) -> bool:55 """56 Always True57 :return: True58 :rtype: bool59 """60 return True61 def create(self, overwrite: bool = True):62 """63 Setup a loop device of the blocksize given in the constructor64 The file to loop is created with the size specified in the65 constructor unless an existing one should not be overwritten66 :param bool overwrite: overwrite existing file to loop67 """68 if overwrite:69 qemu_img_size = format(self.filesize_mbytes) + 'M'70 Command.run(71 ['qemu-img', 'create', self.filename, qemu_img_size]72 )73 loop_options = []74 if self.blocksize_bytes and self.blocksize_bytes != 512:75 if CommandCapabilities.has_option_in_help(76 'losetup', '--sector-size', raise_on_error=False77 ):78 loop_options.append('--sector-size')79 else:80 loop_options.append('--logical-blocksize')81 loop_options.append(format(self.blocksize_bytes))82 loop_call = Command.run(83 ['losetup'] + loop_options + ['-f', '--show', self.filename]84 )85 self.node_name = loop_call.output.rstrip(os.linesep)86 def __del__(self):87 if self.node_name:88 log.info('Cleaning up %s instance', type(self).__name__)89 try:90 Command.run(['losetup', '-d', self.node_name])91 except Exception:92 log.warning(93 'loop device %s still busy', self.node_name...

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