Best Python code snippet using lisa_python
common.py
Source:common.py  
...863        sleep(2)864    if timeout_timer.elapsed() >= timeout:865        raise LisaException(f"wait copying VHD timeout: {vhd_path}")866    log.debug("vhd copied")867def get_share_service_client(868    credential: Any,869    subscription_id: str,870    account_name: str,871    resource_group_name: str,872) -> ShareServiceClient:873    shared_key_credential = get_storage_credential(874        credential=credential,875        subscription_id=subscription_id,876        account_name=account_name,877        resource_group_name=resource_group_name,878    )879    share_service_client = ShareServiceClient(880        f"https://{account_name}.file.core.windows.net",881        shared_key_credential,882    )883    return share_service_client884def get_or_create_file_share(885    credential: Any,886    subscription_id: str,887    account_name: str,888    file_share_name: str,889    resource_group_name: str,890    log: Logger,891    protocols: str = "SMB",892) -> str:893    """894    Create a Azure Storage file share if it does not exist.895    """896    share_service_client = get_share_service_client(897        credential, subscription_id, account_name, resource_group_name898    )899    all_shares = list(share_service_client.list_shares())900    if file_share_name not in (x.name for x in all_shares):901        log.debug(f"creating file share {file_share_name} with protocols {protocols}")902        share_service_client.create_share(file_share_name, protocols=protocols)903    return str("//" + share_service_client.primary_hostname + "/" + file_share_name)904def delete_file_share(905    credential: Any,906    subscription_id: str,907    account_name: str,908    file_share_name: str,909    resource_group_name: str,910    log: Logger,911) -> None:912    """913    Delete Azure Storage file share914    """915    share_service_client = get_share_service_client(916        credential, subscription_id, account_name, resource_group_name917    )918    log.debug(f"deleting file share {file_share_name}")919    share_service_client.delete_share(file_share_name)920def load_environment(921    platform: "AzurePlatform", resource_group_name: str, log: Logger922) -> Environment:923    """924    reverse load environment from a resource group.925    """926    # create mock environment from environments927    environment_runbook = schema.Environment()928    compute_client = get_compute_client(platform)929    vms = compute_client.virtual_machines.list(resource_group_name)...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!!
