This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
def find_rp(provider_name, providers): | |
for entry in providers: | |
if entry["namespace"].lower() == provider_name.lower(): | |
return entry | |
def find_resource_type(provider_object, resource_type_name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
import importlib | |
import inspect | |
import logging | |
from pathlib import Path | |
import pkgutil | |
import shutil | |
import sys | |
import tempfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
from azure.mgmt.compute.v2017_12_01 import ComputeManagementClient | |
from devtools_testutils.mgmt_settings_real import SUBSCRIPTION_ID, get_credentials | |
async def test_vm_images_async(client): | |
result = [] | |
result_list = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import pytest | |
@pytest.mark.asyncio | |
async def test(): | |
iterator = iter([]) | |
return await asyncio.get_event_loop().run_in_executor( | |
None, | |
next, | |
iterator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from virtual_machine_py3 import VirtualMachine | |
except (SyntaxError, ImportError): # Catch SyntaxError if Py2 or ImportError if we decide to build wheel for Py2 without py3 files. | |
from virtual_machine import VirtualMachine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import re | |
from pathlib import Path | |
from packaging.version import parse as Version, InvalidVersion | |
root = Path() | |
package_list = [p.as_posix() for p in root.iterdir()] | |
filtered_package_list = [p for p in package_list if p.startswith("azure-mgmt-") and not p.endswith("nspkg")] | |
def extract_version(package_name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import requests | |
# These two lines enable debugging at httplib level (requests->urllib3->http.client) | |
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA. | |
# The only thing missing will be the response.body which is not logged. | |
try: | |
import http.client as http_client | |
except ImportError: | |
# Python 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This starts a poller, and you can call "result" on the poller to get the resource | |
poller = client.storage_accounts.create(parameters) | |
assert isinstance(poller, AzureOperationPoller) | |
account = poller.result() | |
assert isinstance(account, StorageAccount) | |
# This starts a poller, and you can call "result" on the poller to get the ClientRawResponse | |
# THIS IS A BREAKING CHANGE, but diferentiate the resource envelope (raw or not) from the polling | |
# This makes the return type consistent: whatever the value of "raw", return type is an AzureOperationPoller | |
poller = client.storage_accounts.create(parameters, raw=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def mymethod(): | |
account_name = self.get_resource_name('pyarmstorage18') | |
# Normal call, async is just HTTP I/O | |
result_check = await self.storage_client.storage_accounts.check_name_availability( | |
account_name | |
) | |
self.assertTrue(result_check.name_available) | |
params_create = models.StorageAccountCreateParameters( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncMixin: | |
async def async_get(self, url): | |
return "Async download: "+url |