repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
gbowerman/azurerm | azurerm/computerp.py | list_vmss | def list_vmss(access_token, subscription_id, resource_group):
'''List VM Scale Sets in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
Returns:
HTT... | python | def list_vmss(access_token, subscription_id, resource_group):
'''List VM Scale Sets in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
Returns:
HTT... | [
"def",
"list_vmss",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGroups/'",
",",
"resour... | List VM Scale Sets in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
Returns:
HTTP response. JSON body of a list of scale set model views. | [
"List",
"VM",
"Scale",
"Sets",
"in",
"a",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L655-L671 |
gbowerman/azurerm | azurerm/computerp.py | list_vmss_skus | def list_vmss_skus(access_token, subscription_id, resource_group, vmss_name):
'''List the VM skus available for a VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
... | python | def list_vmss_skus(access_token, subscription_id, resource_group, vmss_name):
'''List the VM skus available for a VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
... | [
"def",
"list_vmss_skus",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resource... | List the VM skus available for a VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of the virtual machine scale set.
Returns:
H... | [
"List",
"the",
"VM",
"skus",
"available",
"for",
"a",
"VM",
"Scale",
"Set",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L674-L692 |
gbowerman/azurerm | azurerm/computerp.py | list_vmss_sub | def list_vmss_sub(access_token, subscription_id):
'''List VM Scale Sets in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of VM scale sets.
'''
endpoint = ''.join(... | python | def list_vmss_sub(access_token, subscription_id):
'''List VM Scale Sets in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of VM scale sets.
'''
endpoint = ''.join(... | [
"def",
"list_vmss_sub",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/Microsoft.Compute/virtualMachineScaleSets'",
"... | List VM Scale Sets in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of VM scale sets. | [
"List",
"VM",
"Scale",
"Sets",
"in",
"a",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L695-L709 |
gbowerman/azurerm | azurerm/computerp.py | list_vmss_vm_instance_view_pg | def list_vmss_vm_instance_view_pg(access_token, subscription_id, resource_group, vmss_name,
link=None):
'''Gets one page of a paginated list of scale set VM instance views.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azu... | python | def list_vmss_vm_instance_view_pg(access_token, subscription_id, resource_group, vmss_name,
link=None):
'''Gets one page of a paginated list of scale set VM instance views.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azu... | [
"def",
"list_vmss_vm_instance_view_pg",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"link",
"=",
"None",
")",
":",
"if",
"link",
"is",
"None",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
... | Gets one page of a paginated list of scale set VM instance views.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of the virtual machine scale set.
... | [
"Gets",
"one",
"page",
"of",
"a",
"paginated",
"list",
"of",
"scale",
"set",
"VM",
"instance",
"views",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L733-L756 |
gbowerman/azurerm | azurerm/computerp.py | poweroff_vmss | def poweroff_vmss(access_token, subscription_id, resource_group, vmss_name):
'''Power off all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group na... | python | def poweroff_vmss(access_token, subscription_id, resource_group, vmss_name):
'''Power off all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group na... | [
"def",
"poweroff_vmss",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceG... | Power off all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of the virtual machine scale set.
Returns:
... | [
"Power",
"off",
"all",
"the",
"VMs",
"in",
"a",
"virtual",
"machine",
"scale",
"set",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L780-L798 |
gbowerman/azurerm | azurerm/computerp.py | poweroff_vmss_vms | def poweroff_vmss_vms(access_token, subscription_id, resource_group, vmss_name, instance_ids):
'''Poweroff all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure ... | python | def poweroff_vmss_vms(access_token, subscription_id, resource_group, vmss_name, instance_ids):
'''Poweroff all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure ... | [
"def",
"poweroff_vmss_vms",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"instance_ids",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscripti... | Poweroff all the VMs in a virtual machine scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of the virtual machine scale set.
instance_... | [
"Poweroff",
"all",
"the",
"VMs",
"in",
"a",
"virtual",
"machine",
"scale",
"set",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L801-L820 |
gbowerman/azurerm | azurerm/computerp.py | put_vmss | def put_vmss(access_token, subscription_id, resource_group, vmss_name, vmss_body):
'''Put VMSS body.
Can be used to create or update a scale set.
E.g. call get_vmss(), make changes to the body, call put_vmss().
Args:
access_token (str): A valid Azure authentication token.
subscription_... | python | def put_vmss(access_token, subscription_id, resource_group, vmss_name, vmss_body):
'''Put VMSS body.
Can be used to create or update a scale set.
E.g. call get_vmss(), make changes to the body, call put_vmss().
Args:
access_token (str): A valid Azure authentication token.
subscription_... | [
"def",
"put_vmss",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"vmss_body",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",... | Put VMSS body.
Can be used to create or update a scale set.
E.g. call get_vmss(), make changes to the body, call put_vmss().
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
... | [
"Put",
"VMSS",
"body",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L823-L845 |
gbowerman/azurerm | azurerm/computerp.py | put_vmss_vm | def put_vmss_vm(access_token, subscription_id, resource_group, vmss_name, vm_id, vm_body):
'''Update a VMSS VM. E.g. add/remove a data disk from a specifc VM in a scale set (preview).
Note: Only currently enabled for Azure Canary regions.
Args:
access_token (str): A valid Azure authentication to... | python | def put_vmss_vm(access_token, subscription_id, resource_group, vmss_name, vm_id, vm_body):
'''Update a VMSS VM. E.g. add/remove a data disk from a specifc VM in a scale set (preview).
Note: Only currently enabled for Azure Canary regions.
Args:
access_token (str): A valid Azure authentication to... | [
"def",
"put_vmss_vm",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"vm_id",
",",
"vm_body",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"sub... | Update a VMSS VM. E.g. add/remove a data disk from a specifc VM in a scale set (preview).
Note: Only currently enabled for Azure Canary regions.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure res... | [
"Update",
"a",
"VMSS",
"VM",
".",
"E",
".",
"g",
".",
"add",
"/",
"remove",
"a",
"data",
"disk",
"from",
"a",
"specifc",
"VM",
"in",
"a",
"scale",
"set",
"(",
"preview",
")",
".",
"Note",
":",
"Only",
"currently",
"enabled",
"for",
"Azure",
"Canary... | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L848-L870 |
gbowerman/azurerm | azurerm/computerp.py | scale_vmss | def scale_vmss(access_token, subscription_id, resource_group, vmss_name, capacity):
'''Change the instance count of an existing VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource ... | python | def scale_vmss(access_token, subscription_id, resource_group, vmss_name, capacity):
'''Change the instance count of an existing VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource ... | [
"def",
"scale_vmss",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"capacity",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
"... | Change the instance count of an existing VM Scale Set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of the virtual machine scale set.
capacit... | [
"Change",
"the",
"instance",
"count",
"of",
"an",
"existing",
"VM",
"Scale",
"Set",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L960-L978 |
gbowerman/azurerm | azurerm/computerp.py | start_vm | def start_vm(access_token, subscription_id, resource_group, vm_name):
'''Start a virtual machine.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vm_name (str): Name of t... | python | def start_vm(access_token, subscription_id, resource_group, vm_name):
'''Start a virtual machine.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vm_name (str): Name of t... | [
"def",
"start_vm",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vm_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGroups/'... | Start a virtual machine.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vm_name (str): Name of the virtual machine.
Returns:
HTTP response. | [
"Start",
"a",
"virtual",
"machine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L981-L1000 |
gbowerman/azurerm | azurerm/computerp.py | update_vm | def update_vm(access_token, subscription_id, resource_group, vm_name, body):
'''Update a virtual machine with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource... | python | def update_vm(access_token, subscription_id, resource_group, vm_name, body):
'''Update a virtual machine with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource... | [
"def",
"update_vm",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vm_name",
",",
"body",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"... | Update a virtual machine with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vm_name (str): Name of the virtual ... | [
"Update",
"a",
"virtual",
"machine",
"with",
"a",
"new",
"JSON",
"body",
".",
"E",
".",
"g",
".",
"do",
"a",
"GET",
"change",
"something",
"call",
"this",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L1111-L1129 |
gbowerman/azurerm | azurerm/computerp.py | update_vmss | def update_vmss(access_token, subscription_id, resource_group, vmss_name, body):
'''Update a VMSS with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group ... | python | def update_vmss(access_token, subscription_id, resource_group, vmss_name, body):
'''Update a VMSS with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group ... | [
"def",
"update_vmss",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"body",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",... | Update a VMSS with a new JSON body. E.g. do a GET, change something, call this.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vm_name (str): Name of the virtual machine.
... | [
"Update",
"a",
"VMSS",
"with",
"a",
"new",
"JSON",
"body",
".",
"E",
".",
"g",
".",
"do",
"a",
"GET",
"change",
"something",
"call",
"this",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L1132-L1150 |
gbowerman/azurerm | examples/vmssupgrade.py | get_vm_ids_by_ud | def get_vm_ids_by_ud(access_token, subscription_id, resource_group, vmssname, updatedomain):
'''look at VMSS VM instance view to get VM IDs by UD'''
instance_viewlist = azurerm.list_vmss_vm_instance_view(access_token, subscription_id,
resource_group, vm... | python | def get_vm_ids_by_ud(access_token, subscription_id, resource_group, vmssname, updatedomain):
'''look at VMSS VM instance view to get VM IDs by UD'''
instance_viewlist = azurerm.list_vmss_vm_instance_view(access_token, subscription_id,
resource_group, vm... | [
"def",
"get_vm_ids_by_ud",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"vmssname",
",",
"updatedomain",
")",
":",
"instance_viewlist",
"=",
"azurerm",
".",
"list_vmss_vm_instance_view",
"(",
"access_token",
",",
"subscription_id",
",",
"re... | look at VMSS VM instance view to get VM IDs by UD | [
"look",
"at",
"VMSS",
"VM",
"instance",
"view",
"to",
"get",
"VM",
"IDs",
"by",
"UD"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssupgrade.py#L10-L24 |
gbowerman/azurerm | examples/vmssupgrade.py | main | def main():
'''main routine'''
# create parser
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-s', required=True,
action='store', help='VM Scale Set name')
arg_parser.add_argument('--resourcegroup', '-r', required=True,
... | python | def main():
'''main routine'''
# create parser
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-s', required=True,
action='store', help='VM Scale Set name')
arg_parser.add_argument('--resourcegroup', '-r', required=True,
... | [
"def",
"main",
"(",
")",
":",
"# create parser",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-s'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
",",
"help",
... | main routine | [
"main",
"routine"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssupgrade.py#L27-L196 |
gbowerman/azurerm | azurerm/graphfns.py | get_graph_token_from_msi | def get_graph_token_from_msi():
'''get a Microsoft Graph access token using Azure Cloud Shell's MSI_ENDPOINT.
Notes:
The auth token returned by this function is not an Azure auth token. Use it for querying
the Microsoft Graph API.
This function only works in an Azure cloud shell or... | python | def get_graph_token_from_msi():
'''get a Microsoft Graph access token using Azure Cloud Shell's MSI_ENDPOINT.
Notes:
The auth token returned by this function is not an Azure auth token. Use it for querying
the Microsoft Graph API.
This function only works in an Azure cloud shell or... | [
"def",
"get_graph_token_from_msi",
"(",
")",
":",
"if",
"'ACC_CLOUD'",
"in",
"os",
".",
"environ",
"and",
"'MSI_ENDPOINT'",
"in",
"os",
".",
"environ",
":",
"endpoint",
"=",
"os",
".",
"environ",
"[",
"'MSI_ENDPOINT'",
"]",
"else",
":",
"return",
"None",
"... | get a Microsoft Graph access token using Azure Cloud Shell's MSI_ENDPOINT.
Notes:
The auth token returned by this function is not an Azure auth token. Use it for querying
the Microsoft Graph API.
This function only works in an Azure cloud shell or virtual machine.
Returns:
... | [
"get",
"a",
"Microsoft",
"Graph",
"access",
"token",
"using",
"Azure",
"Cloud",
"Shell",
"s",
"MSI_ENDPOINT",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/graphfns.py#L11-L30 |
gbowerman/azurerm | azurerm/graphfns.py | get_object_id_from_graph | def get_object_id_from_graph(access_token=None):
'''Return the object ID for the Graph user who owns the access token.
Args:
access_token (str): A Microsoft Graph access token. (Not an Azure access token.)
If not provided, attempt to get it from MSI_ENDPOINT.
Returns:
... | python | def get_object_id_from_graph(access_token=None):
'''Return the object ID for the Graph user who owns the access token.
Args:
access_token (str): A Microsoft Graph access token. (Not an Azure access token.)
If not provided, attempt to get it from MSI_ENDPOINT.
Returns:
... | [
"def",
"get_object_id_from_graph",
"(",
"access_token",
"=",
"None",
")",
":",
"if",
"access_token",
"is",
"None",
":",
"access_token",
"=",
"get_graph_token_from_msi",
"(",
")",
"endpoint",
"=",
"'https://'",
"+",
"GRAPH_RESOURCE_HOST",
"+",
"'/v1.0/me/'",
"headers... | Return the object ID for the Graph user who owns the access token.
Args:
access_token (str): A Microsoft Graph access token. (Not an Azure access token.)
If not provided, attempt to get it from MSI_ENDPOINT.
Returns:
An object ID string for a user or service princip... | [
"Return",
"the",
"object",
"ID",
"for",
"the",
"Graph",
"user",
"who",
"owns",
"the",
"access",
"token",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/graphfns.py#L33-L49 |
gbowerman/azurerm | azurerm/subfns.py | get_subscription_from_cli | def get_subscription_from_cli(name=None):
'''Get the default, or named, subscription id from CLI's local cache.
Args:
name (str): Optional subscription name. If this is set, the subscription id of the named
subscription is returned from the CLI cache if present. If not set, the subscription ... | python | def get_subscription_from_cli(name=None):
'''Get the default, or named, subscription id from CLI's local cache.
Args:
name (str): Optional subscription name. If this is set, the subscription id of the named
subscription is returned from the CLI cache if present. If not set, the subscription ... | [
"def",
"get_subscription_from_cli",
"(",
"name",
"=",
"None",
")",
":",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"azure_profile_path",
"=",
"home",
"+",
"os",
".",
"sep",
"+",
"'.azure'",
"+",
"os",
".",
"sep",
"+",
"'azurePr... | Get the default, or named, subscription id from CLI's local cache.
Args:
name (str): Optional subscription name. If this is set, the subscription id of the named
subscription is returned from the CLI cache if present. If not set, the subscription id
of the default subscription is retu... | [
"Get",
"the",
"default",
"or",
"named",
"subscription",
"id",
"from",
"CLI",
"s",
"local",
"cache",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/subfns.py#L10-L36 |
gbowerman/azurerm | azurerm/subfns.py | list_locations | def list_locations(access_token, subscription_id):
'''List available locations for a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of locations.
'''
endpoint = ''.j... | python | def list_locations(access_token, subscription_id):
'''List available locations for a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of locations.
'''
endpoint = ''.j... | [
"def",
"list_locations",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/locations?api-version='",
",",
"BASE_API",
"]",
"... | List available locations for a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of locations. | [
"List",
"available",
"locations",
"for",
"a",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/subfns.py#L39-L52 |
gbowerman/azurerm | examples/deploytemplate.py | main | def main():
'''Main routine.'''
# validate command line arguments
argparser = argparse.ArgumentParser()
argparser.add_argument('--uri', '-u', required=True,
action='store', help='Template URI')
argparser.add_argument('--params', '-f', required=True,
... | python | def main():
'''Main routine.'''
# validate command line arguments
argparser = argparse.ArgumentParser()
argparser.add_argument('--uri', '-u', required=True,
action='store', help='Template URI')
argparser.add_argument('--params', '-f', required=True,
... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"argparser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"argparser",
".",
"add_argument",
"(",
"'--uri'",
",",
"'-u'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
",",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/deploytemplate.py#L14-L131 |
gbowerman/azurerm | azurerm/cosmosdbrp.py | create_cosmosdb_account | def create_cosmosdb_account(access_token, subscription_id, rgname, account_name, location,
cosmosdb_kind):
'''Create a new Cosmos DB account in the named resource group, with the named location.
Args:
access_token (str): A valid Azure authentication token.
subscripti... | python | def create_cosmosdb_account(access_token, subscription_id, rgname, account_name, location,
cosmosdb_kind):
'''Create a new Cosmos DB account in the named resource group, with the named location.
Args:
access_token (str): A valid Azure authentication token.
subscripti... | [
"def",
"create_cosmosdb_account",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"account_name",
",",
"location",
",",
"cosmosdb_kind",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'... | Create a new Cosmos DB account in the named resource group, with the named location.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
account_name (str): Name of the new Cosmos DB acc... | [
"Create",
"a",
"new",
"Cosmos",
"DB",
"account",
"in",
"the",
"named",
"resource",
"group",
"with",
"the",
"named",
"location",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/cosmosdbrp.py#L8-L35 |
gbowerman/azurerm | azurerm/cosmosdbrp.py | get_cosmosdb_account_keys | def get_cosmosdb_account_keys(access_token, subscription_id, rgname, account_name):
'''Get the access keys for the specified Cosmos DB account.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group ... | python | def get_cosmosdb_account_keys(access_token, subscription_id, rgname, account_name):
'''Get the access keys for the specified Cosmos DB account.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group ... | [
"def",
"get_cosmosdb_account_keys",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"account_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/re... | Get the access keys for the specified Cosmos DB account.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
account_name (str): Name of the Cosmos DB account.
Returns:
HTTP... | [
"Get",
"the",
"access",
"keys",
"for",
"the",
"specified",
"Cosmos",
"DB",
"account",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/cosmosdbrp.py#L38-L56 |
gbowerman/azurerm | azurerm/keyvault.py | create_keyvault | def create_keyvault(access_token, subscription_id, rgname, vault_name, location,
template_deployment=True, tenant_id=None, object_id=None):
'''Create a new key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (s... | python | def create_keyvault(access_token, subscription_id, rgname, vault_name, location,
template_deployment=True, tenant_id=None, object_id=None):
'''Create a new key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (s... | [
"def",
"create_keyvault",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"vault_name",
",",
"location",
",",
"template_deployment",
"=",
"True",
",",
"tenant_id",
"=",
"None",
",",
"object_id",
"=",
"None",
")",
":",
"endpoint",
"=",
"''",
... | Create a new key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_name (str): Name of the new key vault.
location (str): Azure data ce... | [
"Create",
"a",
"new",
"key",
"vault",
"in",
"the",
"named",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L9-L56 |
gbowerman/azurerm | azurerm/keyvault.py | delete_keyvault | def delete_keyvault(access_token, subscription_id, rgname, vault_name):
'''Deletes a key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_... | python | def delete_keyvault(access_token, subscription_id, rgname, vault_name):
'''Deletes a key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_... | [
"def",
"delete_keyvault",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"vault_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups... | Deletes a key vault in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_name (str): Name of the new key vault.
Returns:
HTTP response. 200... | [
"Deletes",
"a",
"key",
"vault",
"in",
"the",
"named",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L59-L76 |
gbowerman/azurerm | azurerm/keyvault.py | get_keyvault | def get_keyvault(access_token, subscription_id, rgname, vault_name):
'''Gets details about the named key vault.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_name (str): ... | python | def get_keyvault(access_token, subscription_id, rgname, vault_name):
'''Gets details about the named key vault.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_name (str): ... | [
"def",
"get_keyvault",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"vault_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups/'"... | Gets details about the named key vault.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
vault_name (str): Name of the key vault.
Returns:
HTTP response. JSON body of key... | [
"Gets",
"details",
"about",
"the",
"named",
"key",
"vault",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L79-L96 |
gbowerman/azurerm | azurerm/keyvault.py | list_keyvaults | def list_keyvaults(access_token, subscription_id, rgname):
'''Lists key vaults in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP res... | python | def list_keyvaults(access_token, subscription_id, rgname):
'''Lists key vaults in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP res... | [
"def",
"list_keyvaults",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups/'",
",",
"rgname",
... | Lists key vaults in the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response. 200 OK. | [
"Lists",
"key",
"vaults",
"in",
"the",
"named",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L99-L115 |
gbowerman/azurerm | azurerm/keyvault.py | list_keyvaults_sub | def list_keyvaults_sub(access_token, subscription_id):
'''Lists key vaults belonging to this subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. 200 OK.
'''
endpoint = ''.join([get... | python | def list_keyvaults_sub(access_token, subscription_id):
'''Lists key vaults belonging to this subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. 200 OK.
'''
endpoint = ''.join([get... | [
"def",
"list_keyvaults_sub",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/Microsoft.KeyVault/vaults'",
",",
"'?ap... | Lists key vaults belonging to this subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. 200 OK. | [
"Lists",
"key",
"vaults",
"belonging",
"to",
"this",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L118-L132 |
gbowerman/azurerm | azurerm/keyvault.py | set_keyvault_secret | def set_keyvault_secret(access_token, vault_uri, secret_name, secret_value):
'''Adds a secret to a key vault using the key vault URI.
Creates a new version if the secret already exists.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https:/... | python | def set_keyvault_secret(access_token, vault_uri, secret_name, secret_value):
'''Adds a secret to a key vault using the key vault URI.
Creates a new version if the secret already exists.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https:/... | [
"def",
"set_keyvault_secret",
"(",
"access_token",
",",
"vault_uri",
",",
"secret_name",
",",
"secret_value",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"vault_uri",
",",
"'/secrets/'",
",",
"secret_name",
",",
"'?api-version='",
",",
"'7.0'",
"]"... | Adds a secret to a key vault using the key vault URI.
Creates a new version if the secret already exists.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https://myvault.vault.azure.net.
secret_name (str): Name of the secret to add.
... | [
"Adds",
"a",
"secret",
"to",
"a",
"key",
"vault",
"using",
"the",
"key",
"vault",
"URI",
".",
"Creates",
"a",
"new",
"version",
"if",
"the",
"secret",
"already",
"exists",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L135-L166 |
gbowerman/azurerm | azurerm/keyvault.py | delete_keyvault_secret | def delete_keyvault_secret(access_token, vault_uri, secret_name):
'''Deletes a secret from a key vault using the key vault URI.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https://myvault.azure.net.
secret_name (str): Name of the secret... | python | def delete_keyvault_secret(access_token, vault_uri, secret_name):
'''Deletes a secret from a key vault using the key vault URI.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https://myvault.azure.net.
secret_name (str): Name of the secret... | [
"def",
"delete_keyvault_secret",
"(",
"access_token",
",",
"vault_uri",
",",
"secret_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"vault_uri",
",",
"'/secrets/'",
",",
"secret_name",
",",
"'?api-version='",
",",
"'7.0'",
"]",
")",
"return",
... | Deletes a secret from a key vault using the key vault URI.
Args:
access_token (str): A valid Azure authentication token.
vault_uri (str): Vault URI e.g. https://myvault.azure.net.
secret_name (str): Name of the secret to add.
Returns:
HTTP response. 200 OK. | [
"Deletes",
"a",
"secret",
"from",
"a",
"key",
"vault",
"using",
"the",
"key",
"vault",
"URI",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L169-L183 |
gbowerman/azurerm | azurerm/insightsrp.py | create_autoscale_rule | def create_autoscale_rule(subscription_id, resource_group, vmss_name, metric_name, operator,
threshold, direction, change_count, time_grain='PT1M',
time_window='PT5M', cool_down='PT1M'):
'''Create a new autoscale rule - pass the output in a list to create_autoscal... | python | def create_autoscale_rule(subscription_id, resource_group, vmss_name, metric_name, operator,
threshold, direction, change_count, time_grain='PT1M',
time_window='PT5M', cool_down='PT1M'):
'''Create a new autoscale rule - pass the output in a list to create_autoscal... | [
"def",
"create_autoscale_rule",
"(",
"subscription_id",
",",
"resource_group",
",",
"vmss_name",
",",
"metric_name",
",",
"operator",
",",
"threshold",
",",
"direction",
",",
"change_count",
",",
"time_grain",
"=",
"'PT1M'",
",",
"time_window",
"=",
"'PT5M'",
",",... | Create a new autoscale rule - pass the output in a list to create_autoscale_setting().
Args:
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
vmss_name (str): Name of scale set to apply scale events to.
metric_name (str): Name of metric ... | [
"Create",
"a",
"new",
"autoscale",
"rule",
"-",
"pass",
"the",
"output",
"in",
"a",
"list",
"to",
"create_autoscale_setting",
"()",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L8-L46 |
gbowerman/azurerm | azurerm/insightsrp.py | create_autoscale_setting | def create_autoscale_setting(access_token, subscription_id, resource_group, setting_name,
vmss_name, location, minval, maxval, default, autoscale_rules,
notify=None):
'''Create a new autoscale setting for a scale set.
Args:
access_token (str): A... | python | def create_autoscale_setting(access_token, subscription_id, resource_group, setting_name,
vmss_name, location, minval, maxval, default, autoscale_rules,
notify=None):
'''Create a new autoscale setting for a scale set.
Args:
access_token (str): A... | [
"def",
"create_autoscale_setting",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"setting_name",
",",
"vmss_name",
",",
"location",
",",
"minval",
",",
"maxval",
",",
"default",
",",
"autoscale_rules",
",",
"notify",
"=",
"None",
")",
... | Create a new autoscale setting for a scale set.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
setting_name (str): Name of the autoscale setting.
vmss_name (str): Na... | [
"Create",
"a",
"new",
"autoscale",
"setting",
"for",
"a",
"scale",
"set",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L49-L97 |
gbowerman/azurerm | azurerm/insightsrp.py | list_autoscale_settings | def list_autoscale_settings(access_token, subscription_id):
'''List the autoscale settings in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of autoscale settings.
'''... | python | def list_autoscale_settings(access_token, subscription_id):
'''List the autoscale settings in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of autoscale settings.
'''... | [
"def",
"list_autoscale_settings",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/microsoft.insights/'",
",",
"'/aut... | List the autoscale settings in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of autoscale settings. | [
"List",
"the",
"autoscale",
"settings",
"in",
"a",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L100-L114 |
gbowerman/azurerm | azurerm/insightsrp.py | list_insights_components | def list_insights_components(access_token, subscription_id, resource_group):
'''List the Microsoft Insights components in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource gr... | python | def list_insights_components(access_token, subscription_id, resource_group):
'''List the Microsoft Insights components in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource gr... | [
"def",
"list_insights_components",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGroups/'",
... | List the Microsoft Insights components in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
Returns:
HTTP response. JSON body of components. | [
"List",
"the",
"Microsoft",
"Insights",
"components",
"in",
"a",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L117-L133 |
gbowerman/azurerm | azurerm/insightsrp.py | list_metric_defs_for_resource | def list_metric_defs_for_resource(access_token, subscription_id, resource_group,
resource_provider, resource_type, resource_name):
'''List the monitoring metric definitions for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscripti... | python | def list_metric_defs_for_resource(access_token, subscription_id, resource_group,
resource_provider, resource_type, resource_name):
'''List the monitoring metric definitions for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscripti... | [
"def",
"list_metric_defs_for_resource",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"resource_provider",
",",
"resource_type",
",",
"resource_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
"... | List the monitoring metric definitions for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
resource_provider (str): Type of resource provider.
resource_ty... | [
"List",
"the",
"monitoring",
"metric",
"definitions",
"for",
"a",
"resource",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L136-L159 |
gbowerman/azurerm | azurerm/insightsrp.py | get_metrics_for_resource | def get_metrics_for_resource(access_token, subscription_id, resource_group, resource_provider,
resource_type, resource_name):
'''Get the monitoring metrics for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure sub... | python | def get_metrics_for_resource(access_token, subscription_id, resource_group, resource_provider,
resource_type, resource_name):
'''Get the monitoring metrics for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure sub... | [
"def",
"get_metrics_for_resource",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"resource_provider",
",",
"resource_type",
",",
"resource_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
... | Get the monitoring metrics for a resource.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
resource_type (str): Type of resource.
resource_name (str): Name of resourc... | [
"Get",
"the",
"monitoring",
"metrics",
"for",
"a",
"resource",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L162-L184 |
gbowerman/azurerm | azurerm/insightsrp.py | get_events_for_subscription | def get_events_for_subscription(access_token, subscription_id, start_timestamp):
'''Get the insights evens for a subsctipion since the specific timestamp.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
start_timestamp (str): t... | python | def get_events_for_subscription(access_token, subscription_id, start_timestamp):
'''Get the insights evens for a subsctipion since the specific timestamp.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
start_timestamp (str): t... | [
"def",
"get_events_for_subscription",
"(",
"access_token",
",",
"subscription_id",
",",
"start_timestamp",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/micros... | Get the insights evens for a subsctipion since the specific timestamp.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
start_timestamp (str): timestamp to get events from. E.g. '2017-05-01T00:00:00.0000000Z'.
Returns:
H... | [
"Get",
"the",
"insights",
"evens",
"for",
"a",
"subsctipion",
"since",
"the",
"specific",
"timestamp",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/insightsrp.py#L187-L202 |
gbowerman/azurerm | examples/create_vm.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
help='Res... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
help='Res... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--name'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
","... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/create_vm.py#L10-L121 |
gbowerman/azurerm | examples/list_vms.py | main | def main():
'''Main routine.'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenant... | python | def main():
'''Main routine.'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenant... | [
"def",
"main",
"(",
")",
":",
"# Load Azure app defaults",
"try",
":",
"with",
"open",
"(",
"'azurermconfig.json'",
")",
"as",
"config_file",
":",
"config_data",
"=",
"json",
".",
"load",
"(",
"config_file",
")",
"except",
"FileNotFoundError",
":",
"sys",
".",... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vms.py#L8-L37 |
gbowerman/azurerm | azurerm/templates.py | deploy_template | def deploy_template(access_token, subscription_id, resource_group, deployment_name, template,
parameters):
'''Deploy a template referenced by a JSON string, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str):... | python | def deploy_template(access_token, subscription_id, resource_group, deployment_name, template,
parameters):
'''Deploy a template referenced by a JSON string, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str):... | [
"def",
"deploy_template",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"deployment_name",
",",
"template",
",",
"parameters",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'... | Deploy a template referenced by a JSON string, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
deployment_name (str): A name you give to the... | [
"Deploy",
"a",
"template",
"referenced",
"by",
"a",
"JSON",
"string",
"with",
"parameters",
"as",
"a",
"JSON",
"string",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/templates.py#L7-L32 |
gbowerman/azurerm | azurerm/templates.py | deploy_template_uri | def deploy_template_uri(access_token, subscription_id, resource_group, deployment_name,
template_uri, parameters):
'''Deploy a template referenced by a URI, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (s... | python | def deploy_template_uri(access_token, subscription_id, resource_group, deployment_name,
template_uri, parameters):
'''Deploy a template referenced by a URI, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (s... | [
"def",
"deploy_template_uri",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"deployment_name",
",",
"template_uri",
",",
"parameters",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscri... | Deploy a template referenced by a URI, with parameters as a JSON string.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
deployment_name (str): A name you give to the deploym... | [
"Deploy",
"a",
"template",
"referenced",
"by",
"a",
"URI",
"with",
"parameters",
"as",
"a",
"JSON",
"string",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/templates.py#L35-L60 |
gbowerman/azurerm | azurerm/templates.py | deploy_template_uri_param_uri | def deploy_template_uri_param_uri(access_token, subscription_id, resource_group, deployment_name,
template_uri, parameters_uri):
'''Deploy a template with both template and parameters referenced by URIs.
Args:
access_token (str): A valid Azure authentication token.
... | python | def deploy_template_uri_param_uri(access_token, subscription_id, resource_group, deployment_name,
template_uri, parameters_uri):
'''Deploy a template with both template and parameters referenced by URIs.
Args:
access_token (str): A valid Azure authentication token.
... | [
"def",
"deploy_template_uri_param_uri",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"deployment_name",
",",
"template_uri",
",",
"parameters_uri",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
","... | Deploy a template with both template and parameters referenced by URIs.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
deployment_name (str): A name you give to the deployme... | [
"Deploy",
"a",
"template",
"with",
"both",
"template",
"and",
"parameters",
"referenced",
"by",
"URIs",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/templates.py#L63-L88 |
gbowerman/azurerm | examples/vmssdisk_cliauth.py | attach_model | def attach_model(subscription, rgname, vmssvm_model, diskname, lun):
'''Attach a data disk to a VMSS VM model'''
disk_id = '/subscriptions/' + subscription + '/resourceGroups/' + rgname + \
'/providers/Microsoft.Compute/disks/' + diskname
disk_model = {'lun': lun, 'createOption': 'Attach', 'caching'... | python | def attach_model(subscription, rgname, vmssvm_model, diskname, lun):
'''Attach a data disk to a VMSS VM model'''
disk_id = '/subscriptions/' + subscription + '/resourceGroups/' + rgname + \
'/providers/Microsoft.Compute/disks/' + diskname
disk_model = {'lun': lun, 'createOption': 'Attach', 'caching'... | [
"def",
"attach_model",
"(",
"subscription",
",",
"rgname",
",",
"vmssvm_model",
",",
"diskname",
",",
"lun",
")",
":",
"disk_id",
"=",
"'/subscriptions/'",
"+",
"subscription",
"+",
"'/resourceGroups/'",
"+",
"rgname",
"+",
"'/providers/Microsoft.Compute/disks/'",
"... | Attach a data disk to a VMSS VM model | [
"Attach",
"a",
"data",
"disk",
"to",
"a",
"VMSS",
"VM",
"model"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssdisk_cliauth.py#L9-L17 |
gbowerman/azurerm | examples/vmssdisk_cliauth.py | detach_model | def detach_model(vmssvm_model, lun):
'''Detach a data disk from a VMSS VM model'''
data_disks = vmssvm_model['properties']['storageProfile']['dataDisks']
data_disks[:] = [disk for disk in data_disks if disk.get('lun') != lun]
vmssvm_model['properties']['storageProfile']['dataDisks'] = data_disks
ret... | python | def detach_model(vmssvm_model, lun):
'''Detach a data disk from a VMSS VM model'''
data_disks = vmssvm_model['properties']['storageProfile']['dataDisks']
data_disks[:] = [disk for disk in data_disks if disk.get('lun') != lun]
vmssvm_model['properties']['storageProfile']['dataDisks'] = data_disks
ret... | [
"def",
"detach_model",
"(",
"vmssvm_model",
",",
"lun",
")",
":",
"data_disks",
"=",
"vmssvm_model",
"[",
"'properties'",
"]",
"[",
"'storageProfile'",
"]",
"[",
"'dataDisks'",
"]",
"data_disks",
"[",
":",
"]",
"=",
"[",
"disk",
"for",
"disk",
"in",
"data_... | Detach a data disk from a VMSS VM model | [
"Detach",
"a",
"data",
"disk",
"from",
"a",
"VMSS",
"VM",
"model"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssdisk_cliauth.py#L20-L25 |
gbowerman/azurerm | examples/vmssdisk_cliauth.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True, action='store',
help='Scale set name')
arg_parser.add_argument('--rgname', '-g', required=True, action='sto... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True, action='store',
help='Scale set name')
arg_parser.add_argument('--rgname', '-g', required=True, action='sto... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssdisk_cliauth.py#L28-L82 |
gbowerman/azurerm | azurerm/adalfns.py | get_access_token | def get_access_token(tenant_id, application_id, application_secret):
'''get an Azure access token using the adal library.
Args:
tenant_id (str): Tenant id of the user's account.
application_id (str): Application id of a Service Principal account.
application_secret (str): Application se... | python | def get_access_token(tenant_id, application_id, application_secret):
'''get an Azure access token using the adal library.
Args:
tenant_id (str): Tenant id of the user's account.
application_id (str): Application id of a Service Principal account.
application_secret (str): Application se... | [
"def",
"get_access_token",
"(",
"tenant_id",
",",
"application_id",
",",
"application_secret",
")",
":",
"context",
"=",
"adal",
".",
"AuthenticationContext",
"(",
"get_auth_endpoint",
"(",
")",
"+",
"tenant_id",
",",
"api_version",
"=",
"None",
")",
"token_respon... | get an Azure access token using the adal library.
Args:
tenant_id (str): Tenant id of the user's account.
application_id (str): Application id of a Service Principal account.
application_secret (str): Application secret (password) of the Service Principal account.
Returns:
An A... | [
"get",
"an",
"Azure",
"access",
"token",
"using",
"the",
"adal",
"library",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/adalfns.py#L13-L28 |
gbowerman/azurerm | azurerm/adalfns.py | get_access_token_from_cli | def get_access_token_from_cli():
'''Get an Azure authentication token from CLI's cache.
Will only work if CLI local cache has an unexpired auth token (i.e. you ran 'az login'
recently), or if you are running in Azure Cloud Shell (aka cloud console)
Returns:
An Azure authentication token st... | python | def get_access_token_from_cli():
'''Get an Azure authentication token from CLI's cache.
Will only work if CLI local cache has an unexpired auth token (i.e. you ran 'az login'
recently), or if you are running in Azure Cloud Shell (aka cloud console)
Returns:
An Azure authentication token st... | [
"def",
"get_access_token_from_cli",
"(",
")",
":",
"# check if running in cloud shell, if so, pick up token from MSI_ENDPOINT",
"if",
"'ACC_CLOUD'",
"in",
"os",
".",
"environ",
"and",
"'MSI_ENDPOINT'",
"in",
"os",
".",
"environ",
":",
"endpoint",
"=",
"os",
".",
"enviro... | Get an Azure authentication token from CLI's cache.
Will only work if CLI local cache has an unexpired auth token (i.e. you ran 'az login'
recently), or if you are running in Azure Cloud Shell (aka cloud console)
Returns:
An Azure authentication token string. | [
"Get",
"an",
"Azure",
"authentication",
"token",
"from",
"CLI",
"s",
"cache",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/adalfns.py#L31-L105 |
gbowerman/azurerm | examples/list_vm_images.py | main | def main():
'''Main routine.'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenant... | python | def main():
'''Main routine.'''
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFoundError:
sys.exit('Error: Expecting azurermconfig.json in current folder')
tenant_id = config_data['tenant... | [
"def",
"main",
"(",
")",
":",
"# Load Azure app defaults",
"try",
":",
"with",
"open",
"(",
"'azurermconfig.json'",
")",
"as",
"config_file",
":",
"config_data",
"=",
"json",
".",
"load",
"(",
"config_file",
")",
"except",
"FileNotFoundError",
":",
"sys",
".",... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vm_images.py#L8-L36 |
gbowerman/azurerm | azurerm/vmimages.py | list_offers | def list_offers(access_token, subscription_id, location, publisher):
'''List available VM image offers from a publisher.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. westus.
... | python | def list_offers(access_token, subscription_id, location, publisher):
'''List available VM image offers from a publisher.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. westus.
... | [
"def",
"list_offers",
"(",
"access_token",
",",
"subscription_id",
",",
"location",
",",
"publisher",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/Microso... | List available VM image offers from a publisher.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. westus.
publisher (str): Publisher name, e.g. Canonical.
Returns:
... | [
"List",
"available",
"VM",
"image",
"offers",
"from",
"a",
"publisher",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/vmimages.py#L7-L25 |
gbowerman/azurerm | azurerm/vmimages.py | list_skus | def list_skus(access_token, subscription_id, location, publisher, offer):
'''List available VM image skus for a publisher offer.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. w... | python | def list_skus(access_token, subscription_id, location, publisher, offer):
'''List available VM image skus for a publisher offer.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. w... | [
"def",
"list_skus",
"(",
"access_token",
",",
"subscription_id",
",",
"location",
",",
"publisher",
",",
"offer",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/p... | List available VM image skus for a publisher offer.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. westus.
publisher (str): VM image publisher. E.g. MicrosoftWindowsServer.
... | [
"List",
"available",
"VM",
"image",
"skus",
"for",
"a",
"publisher",
"offer",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/vmimages.py#L47-L67 |
gbowerman/azurerm | azurerm/vmimages.py | list_sku_versions | def list_sku_versions(access_token, subscription_id, location, publisher, offer, sku):
'''List available versions for a given publisher's sku.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center lo... | python | def list_sku_versions(access_token, subscription_id, location, publisher, offer, sku):
'''List available versions for a given publisher's sku.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center lo... | [
"def",
"list_sku_versions",
"(",
"access_token",
",",
"subscription_id",
",",
"location",
",",
"publisher",
",",
"offer",
",",
"sku",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscri... | List available versions for a given publisher's sku.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
location (str): Azure data center location. E.g. westus.
publisher (str): VM image publisher. E.g. MicrosoftWindowsServer.... | [
"List",
"available",
"versions",
"for",
"a",
"given",
"publisher",
"s",
"sku",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/vmimages.py#L70-L92 |
gbowerman/azurerm | examples/vmssvmdisk.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True, action='store',
help='Scale set name')
arg_parser.add_argument('--rgname', '-g', required=True, action='sto... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True, action='store',
help='Scale set name')
arg_parser.add_argument('--rgname', '-g', required=True, action='sto... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vmssvmdisk.py#L27-L90 |
gbowerman/azurerm | examples/jumpbox.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmname', '-n', required=True, action='store', help='Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
help='R... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmname', '-n', required=True, action='store', help='Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
help='R... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
"... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/jumpbox.py#L12-L245 |
gbowerman/azurerm | examples/insights_metrics.py | main | def main():
'''Main routine.'''
# process arguments
if len(sys.argv) < 3:
usage()
rgname = sys.argv[1]
vmss = sys.argv[2]
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFound... | python | def main():
'''Main routine.'''
# process arguments
if len(sys.argv) < 3:
usage()
rgname = sys.argv[1]
vmss = sys.argv[2]
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotFound... | [
"def",
"main",
"(",
")",
":",
"# process arguments",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"3",
":",
"usage",
"(",
")",
"rgname",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"vmss",
"=",
"sys",
".",
"argv",
"[",
"2",
"]",
"# Load Azure app ... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/insights_metrics.py#L12-L48 |
gbowerman/azurerm | examples/list_vmss_pips.py | main | def main():
'''main reoutine'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True,
action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True,
... | python | def main():
'''main reoutine'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--vmssname', '-n', required=True,
action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True,
... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
... | main reoutine | [
"main",
"reoutine"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vmss_pips.py#L10-L51 |
gbowerman/azurerm | examples/list_rgs.py | main | def main():
'''Main routine.'''
# if in Azure cloud shell, authenticate using the MSI endpoint
if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ:
access_token = azurerm.get_access_token_from_cli()
subscription_id = azurerm.get_subscription_from_cli()
else: # load service prin... | python | def main():
'''Main routine.'''
# if in Azure cloud shell, authenticate using the MSI endpoint
if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ:
access_token = azurerm.get_access_token_from_cli()
subscription_id = azurerm.get_subscription_from_cli()
else: # load service prin... | [
"def",
"main",
"(",
")",
":",
"# if in Azure cloud shell, authenticate using the MSI endpoint",
"if",
"'ACC_CLOUD'",
"in",
"os",
".",
"environ",
"and",
"'MSI_ENDPOINT'",
"in",
"os",
".",
"environ",
":",
"access_token",
"=",
"azurerm",
".",
"get_access_token_from_cli",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_rgs.py#L8-L36 |
gbowerman/azurerm | azurerm/container.py | create_container_definition | def create_container_definition(container_name, image, port=80, cpu=1.0, memgb=1.5,
environment=None):
'''Makes a python dictionary of container properties.
Args:
container_name: The name of the container.
image (str): Container image string. E.g. nginx.
... | python | def create_container_definition(container_name, image, port=80, cpu=1.0, memgb=1.5,
environment=None):
'''Makes a python dictionary of container properties.
Args:
container_name: The name of the container.
image (str): Container image string. E.g. nginx.
... | [
"def",
"create_container_definition",
"(",
"container_name",
",",
"image",
",",
"port",
"=",
"80",
",",
"cpu",
"=",
"1.0",
",",
"memgb",
"=",
"1.5",
",",
"environment",
"=",
"None",
")",
":",
"container",
"=",
"{",
"'name'",
":",
"container_name",
"}",
"... | Makes a python dictionary of container properties.
Args:
container_name: The name of the container.
image (str): Container image string. E.g. nginx.
port (int): TCP port number. E.g. 8080.
cpu (float): Amount of CPU to allocate to container. E.g. 1.0.
memgb (float): Memory i... | [
"Makes",
"a",
"python",
"dictionary",
"of",
"container",
"properties",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L7-L33 |
gbowerman/azurerm | azurerm/container.py | create_container_instance_group | def create_container_instance_group(access_token, subscription_id, resource_group,
container_group_name, container_list, location,
ostype='Linux', port=80, iptype='public'):
'''Create a new container group with a list of containers specifified ... | python | def create_container_instance_group(access_token, subscription_id, resource_group,
container_group_name, container_list, location,
ostype='Linux', port=80, iptype='public'):
'''Create a new container group with a list of containers specifified ... | [
"def",
"create_container_instance_group",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"container_group_name",
",",
"container_list",
",",
"location",
",",
"ostype",
"=",
"'Linux'",
",",
"port",
"=",
"80",
",",
"iptype",
"=",
"'public'",
... | Create a new container group with a list of containers specifified by container_list.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
container_group_name (str): Name of cont... | [
"Create",
"a",
"new",
"container",
"group",
"with",
"a",
"list",
"of",
"containers",
"specifified",
"by",
"container_list",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L36-L72 |
gbowerman/azurerm | azurerm/container.py | delete_container_instance_group | def delete_container_instance_group(access_token, subscription_id, resource_group,
container_group_name):
'''Delete a container group from a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscriptio... | python | def delete_container_instance_group(access_token, subscription_id, resource_group,
container_group_name):
'''Delete a container group from a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscriptio... | [
"def",
"delete_container_instance_group",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"container_group_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscripti... | Delete a container group from a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
container_group_name (str): Name of container instance group.
Returns:
... | [
"Delete",
"a",
"container",
"group",
"from",
"a",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L75-L94 |
gbowerman/azurerm | azurerm/container.py | get_container_instance_group | def get_container_instance_group(access_token, subscription_id, resource_group,
container_group_name):
'''Get the JSON definition of a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
... | python | def get_container_instance_group(access_token, subscription_id, resource_group,
container_group_name):
'''Get the JSON definition of a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
... | [
"def",
"get_container_instance_group",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"container_group_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_... | Get the JSON definition of a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
container_group_name (str): Name of container instance group.
Returns:
... | [
"Get",
"the",
"JSON",
"definition",
"of",
"a",
"container",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L97-L116 |
gbowerman/azurerm | azurerm/container.py | get_container_instance_logs | def get_container_instance_logs(access_token, subscription_id, resource_group, container_group_name,
container_name=None):
'''Get the container logs for containers in a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id... | python | def get_container_instance_logs(access_token, subscription_id, resource_group, container_group_name,
container_name=None):
'''Get the container logs for containers in a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id... | [
"def",
"get_container_instance_logs",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"container_group_name",
",",
"container_name",
"=",
"None",
")",
":",
"if",
"container_name",
"is",
"None",
":",
"container_name",
"=",
"container_group_name",... | Get the container logs for containers in a container group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
container_group_name (str): Name of container instance group.
... | [
"Get",
"the",
"container",
"logs",
"for",
"containers",
"in",
"a",
"container",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L119-L141 |
gbowerman/azurerm | azurerm/container.py | list_container_instance_groups | def list_container_instance_groups(access_token, subscription_id, resource_group):
'''List the container groups in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group nam... | python | def list_container_instance_groups(access_token, subscription_id, resource_group):
'''List the container groups in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group nam... | [
"def",
"list_container_instance_groups",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups... | List the container groups in a resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
Returns:
HTTP response. JSON list of container groups and their properties... | [
"List",
"the",
"container",
"groups",
"in",
"a",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L144-L160 |
gbowerman/azurerm | azurerm/container.py | list_container_instance_groups_sub | def list_container_instance_groups_sub(access_token, subscription_id):
'''List the container groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of container groups a... | python | def list_container_instance_groups_sub(access_token, subscription_id):
'''List the container groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of container groups a... | [
"def",
"list_container_instance_groups_sub",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/Microsoft.ContainerInstance... | List the container groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON list of container groups and their properties. | [
"List",
"the",
"container",
"groups",
"in",
"a",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/container.py#L163-L177 |
gbowerman/azurerm | azurerm/resourcegroups.py | create_resource_group | def create_resource_group(access_token, subscription_id, rgname, location):
'''Create a resource group in the specified location.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
... | python | def create_resource_group(access_token, subscription_id, rgname, location):
'''Create a resource group in the specified location.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
... | [
"def",
"create_resource_group",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
",",
"location",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegr... | Create a resource group in the specified location.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
location (str): Azure data center location. E.g. westus.
Returns:
HTTP... | [
"Create",
"a",
"resource",
"group",
"in",
"the",
"specified",
"location",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/resourcegroups.py#L7-L25 |
gbowerman/azurerm | azurerm/resourcegroups.py | delete_resource_group | def delete_resource_group(access_token, subscription_id, rgname):
'''Delete the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response.... | python | def delete_resource_group(access_token, subscription_id, rgname):
'''Delete the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response.... | [
"def",
"delete_resource_group",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups/'",
",",
"rg... | Delete the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response. | [
"Delete",
"the",
"named",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/resourcegroups.py#L28-L43 |
gbowerman/azurerm | azurerm/resourcegroups.py | export_template | def export_template(access_token, subscription_id, rgname):
'''Capture the specified resource group as a template
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HT... | python | def export_template(access_token, subscription_id, rgname):
'''Capture the specified resource group as a template
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HT... | [
"def",
"export_template",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourcegroups/'",
",",
"rgname",... | Capture the specified resource group as a template
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response. JSON body. | [
"Capture",
"the",
"specified",
"resource",
"group",
"as",
"a",
"template"
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/resourcegroups.py#L46-L64 |
gbowerman/azurerm | azurerm/resourcegroups.py | get_resource_group | def get_resource_group(access_token, subscription_id, rgname):
'''Get details about the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP r... | python | def get_resource_group(access_token, subscription_id, rgname):
'''Get details about the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP r... | [
"def",
"get_resource_group",
"(",
"access_token",
",",
"subscription_id",
",",
"rgname",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGroups/'",
",",
"rgnam... | Get details about the named resource group.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
rgname (str): Azure resource group name.
Returns:
HTTP response. JSON body. | [
"Get",
"details",
"about",
"the",
"named",
"resource",
"group",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/resourcegroups.py#L67-L82 |
gbowerman/azurerm | azurerm/resourcegroups.py | list_resource_groups | def list_resource_groups(access_token, subscription_id):
'''List the resource groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response.
'''
endpoint = ''.join([get_rm_endpoin... | python | def list_resource_groups(access_token, subscription_id):
'''List the resource groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response.
'''
endpoint = ''.join([get_rm_endpoin... | [
"def",
"list_resource_groups",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGroups/'",
",",
"'?api-version='",
",... | List the resource groups in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. | [
"List",
"the",
"resource",
"groups",
"in",
"a",
"subscription",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/resourcegroups.py#L103-L117 |
gbowerman/azurerm | examples/get_vmss_rolling_cloudshell.py | main | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'--vmssname', '-n', required=True, action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
... | python | def main():
'''Main routine.'''
# validate command line arguments
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'--vmssname', '-n', required=True, action='store', help='VMSS Name')
arg_parser.add_argument('--rgname', '-g', required=True, action='store',
... | [
"def",
"main",
"(",
")",
":",
"# validate command line arguments",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'--vmssname'",
",",
"'-n'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
... | Main routine. | [
"Main",
"routine",
"."
] | train | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/get_vmss_rolling_cloudshell.py#L9-L39 |
byteweaver/django-coupons | coupons/south_migrations/0005_coupon_users.py | Migration.forwards | def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
for coupon in orm['coupons.Coupon']... | python | def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
for coupon in orm['coupons.Coupon']... | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Don't use \"from appname.models import ModelName\". ",
"# Use orm.ModelName to refer to models in this application,",
"# and orm['appname.ModelName'] for models in other applications.",
"for",
"coupon",
"in",
"orm",
"[",
... | Write your forwards methods here. | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | train | https://github.com/byteweaver/django-coupons/blob/27e15403b6aa99997a9e5239949b4c462c0ed2c2/coupons/south_migrations/0005_coupon_users.py#L9-L20 |
paylogic/pip-accel | pip_accel/caches/__init__.py | CacheManager.get | def get(self, requirement):
"""
Get a distribution archive from any of the available caches.
:param requirement: A :class:`.Requirement` object.
:returns: The absolute pathname of a local file or :data:`None` when the
distribution archive is missing from all available ... | python | def get(self, requirement):
"""
Get a distribution archive from any of the available caches.
:param requirement: A :class:`.Requirement` object.
:returns: The absolute pathname of a local file or :data:`None` when the
distribution archive is missing from all available ... | [
"def",
"get",
"(",
"self",
",",
"requirement",
")",
":",
"filename",
"=",
"self",
".",
"generate_filename",
"(",
"requirement",
")",
"for",
"backend",
"in",
"list",
"(",
"self",
".",
"backends",
")",
":",
"try",
":",
"pathname",
"=",
"backend",
".",
"g... | Get a distribution archive from any of the available caches.
:param requirement: A :class:`.Requirement` object.
:returns: The absolute pathname of a local file or :data:`None` when the
distribution archive is missing from all available caches. | [
"Get",
"a",
"distribution",
"archive",
"from",
"any",
"of",
"the",
"available",
"caches",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/caches/__init__.py#L159-L178 |
paylogic/pip-accel | pip_accel/caches/__init__.py | CacheManager.put | def put(self, requirement, handle):
"""
Store a distribution archive in all of the available caches.
:param requirement: A :class:`.Requirement` object.
:param handle: A file-like object that provides access to the
distribution archive.
"""
filenam... | python | def put(self, requirement, handle):
"""
Store a distribution archive in all of the available caches.
:param requirement: A :class:`.Requirement` object.
:param handle: A file-like object that provides access to the
distribution archive.
"""
filenam... | [
"def",
"put",
"(",
"self",
",",
"requirement",
",",
"handle",
")",
":",
"filename",
"=",
"self",
".",
"generate_filename",
"(",
"requirement",
")",
"for",
"backend",
"in",
"list",
"(",
"self",
".",
"backends",
")",
":",
"handle",
".",
"seek",
"(",
"0",... | Store a distribution archive in all of the available caches.
:param requirement: A :class:`.Requirement` object.
:param handle: A file-like object that provides access to the
distribution archive. | [
"Store",
"a",
"distribution",
"archive",
"in",
"all",
"of",
"the",
"available",
"caches",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/caches/__init__.py#L180-L198 |
paylogic/pip-accel | pip_accel/caches/__init__.py | CacheManager.generate_filename | def generate_filename(self, requirement):
"""
Generate a distribution archive filename for a package.
:param requirement: A :class:`.Requirement` object.
:returns: The filename of the distribution archive (a string)
including a single leading directory component to ind... | python | def generate_filename(self, requirement):
"""
Generate a distribution archive filename for a package.
:param requirement: A :class:`.Requirement` object.
:returns: The filename of the distribution archive (a string)
including a single leading directory component to ind... | [
"def",
"generate_filename",
"(",
"self",
",",
"requirement",
")",
":",
"return",
"FILENAME_PATTERN",
"%",
"(",
"self",
".",
"config",
".",
"cache_format_revision",
",",
"requirement",
".",
"name",
",",
"requirement",
".",
"version",
",",
"get_python_version",
"(... | Generate a distribution archive filename for a package.
:param requirement: A :class:`.Requirement` object.
:returns: The filename of the distribution archive (a string)
including a single leading directory component to indicate
the cache format revision. | [
"Generate",
"a",
"distribution",
"archive",
"filename",
"for",
"a",
"package",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/caches/__init__.py#L200-L211 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.install_dependencies | def install_dependencies(self, requirement):
"""
Install missing dependencies for the given requirement.
:param requirement: A :class:`.Requirement` object.
:returns: :data:`True` when missing system packages were installed,
:data:`False` otherwise.
:raises: :e... | python | def install_dependencies(self, requirement):
"""
Install missing dependencies for the given requirement.
:param requirement: A :class:`.Requirement` object.
:returns: :data:`True` when missing system packages were installed,
:data:`False` otherwise.
:raises: :e... | [
"def",
"install_dependencies",
"(",
"self",
",",
"requirement",
")",
":",
"install_timer",
"=",
"Timer",
"(",
")",
"missing_dependencies",
"=",
"self",
".",
"find_missing_dependencies",
"(",
"requirement",
")",
"if",
"missing_dependencies",
":",
"# Compose the command... | Install missing dependencies for the given requirement.
:param requirement: A :class:`.Requirement` object.
:returns: :data:`True` when missing system packages were installed,
:data:`False` otherwise.
:raises: :exc:`.DependencyInstallationRefused` when automatic
... | [
"Install",
"missing",
"dependencies",
"for",
"the",
"given",
"requirement",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L84-L144 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.find_missing_dependencies | def find_missing_dependencies(self, requirement):
"""
Find missing dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names.
"""
known_dependencies = self.find_known_dependencies(requireme... | python | def find_missing_dependencies(self, requirement):
"""
Find missing dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names.
"""
known_dependencies = self.find_known_dependencies(requireme... | [
"def",
"find_missing_dependencies",
"(",
"self",
",",
"requirement",
")",
":",
"known_dependencies",
"=",
"self",
".",
"find_known_dependencies",
"(",
"requirement",
")",
"if",
"known_dependencies",
":",
"installed_packages",
"=",
"self",
".",
"find_installed_packages",... | Find missing dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names. | [
"Find",
"missing",
"dependencies",
"of",
"a",
"Python",
"package",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L146-L164 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.find_known_dependencies | def find_known_dependencies(self, requirement):
"""
Find the known dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names.
"""
logger.info("Checking for known dependencies of %s ..", req... | python | def find_known_dependencies(self, requirement):
"""
Find the known dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names.
"""
logger.info("Checking for known dependencies of %s ..", req... | [
"def",
"find_known_dependencies",
"(",
"self",
",",
"requirement",
")",
":",
"logger",
".",
"info",
"(",
"\"Checking for known dependencies of %s ..\"",
",",
"requirement",
".",
"name",
")",
"known_dependencies",
"=",
"sorted",
"(",
"self",
".",
"dependencies",
".",... | Find the known dependencies of a Python package.
:param requirement: A :class:`.Requirement` object.
:returns: A list of strings with system package names. | [
"Find",
"the",
"known",
"dependencies",
"of",
"a",
"Python",
"package",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L166-L180 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.find_installed_packages | def find_installed_packages(self):
"""
Find the installed system packages.
:returns: A list of strings with system package names.
:raises: :exc:`.SystemDependencyError` when the command to list the
installed system packages fails.
"""
list_command = subp... | python | def find_installed_packages(self):
"""
Find the installed system packages.
:returns: A list of strings with system package names.
:raises: :exc:`.SystemDependencyError` when the command to list the
installed system packages fails.
"""
list_command = subp... | [
"def",
"find_installed_packages",
"(",
"self",
")",
":",
"list_command",
"=",
"subprocess",
".",
"Popen",
"(",
"self",
".",
"list_command",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"stdout",
",",
"stderr",
"=",
"list_c... | Find the installed system packages.
:returns: A list of strings with system package names.
:raises: :exc:`.SystemDependencyError` when the command to list the
installed system packages fails. | [
"Find",
"the",
"installed",
"system",
"packages",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L182-L197 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.installation_refused | def installation_refused(self, requirement, missing_dependencies, reason):
"""
Raise :exc:`.DependencyInstallationRefused` with a user friendly message.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
... | python | def installation_refused(self, requirement, missing_dependencies, reason):
"""
Raise :exc:`.DependencyInstallationRefused` with a user friendly message.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
... | [
"def",
"installation_refused",
"(",
"self",
",",
"requirement",
",",
"missing_dependencies",
",",
"reason",
")",
":",
"msg",
"=",
"\"Missing %s (%s) required by Python package %s (%s) but %s!\"",
"raise",
"DependencyInstallationRefused",
"(",
"msg",
"%",
"(",
"pluralize",
... | Raise :exc:`.DependencyInstallationRefused` with a user friendly message.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
:param reason: The reason why installation was refused (a string). | [
"Raise",
":",
"exc",
":",
".",
"DependencyInstallationRefused",
"with",
"a",
"user",
"friendly",
"message",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L199-L214 |
paylogic/pip-accel | pip_accel/deps/__init__.py | SystemPackageManager.confirm_installation | def confirm_installation(self, requirement, missing_dependencies, install_command):
"""
Ask the operator's permission to install missing system packages.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
... | python | def confirm_installation(self, requirement, missing_dependencies, install_command):
"""
Ask the operator's permission to install missing system packages.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
... | [
"def",
"confirm_installation",
"(",
"self",
",",
"requirement",
",",
"missing_dependencies",
",",
"install_command",
")",
":",
"try",
":",
"return",
"prompt_for_confirmation",
"(",
"format",
"(",
"\"Do you want me to install %s %s?\"",
",",
"\"this\"",
"if",
"len",
"(... | Ask the operator's permission to install missing system packages.
:param requirement: A :class:`.Requirement` object.
:param missing_dependencies: A list of strings with missing dependencies.
:param install_command: A list of strings with the command line needed
... | [
"Ask",
"the",
"operator",
"s",
"permission",
"to",
"install",
"missing",
"system",
"packages",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/deps/__init__.py#L216-L235 |
paylogic/pip-accel | pip_accel/utils.py | compact | def compact(text, **kw):
"""
Compact whitespace in a string and format any keyword arguments into the string.
:param text: The text to compact (a string).
:param kw: Any keyword arguments to apply using :func:`str.format()`.
:returns: The compacted, formatted string.
The whitespace compaction ... | python | def compact(text, **kw):
"""
Compact whitespace in a string and format any keyword arguments into the string.
:param text: The text to compact (a string).
:param kw: Any keyword arguments to apply using :func:`str.format()`.
:returns: The compacted, formatted string.
The whitespace compaction ... | [
"def",
"compact",
"(",
"text",
",",
"*",
"*",
"kw",
")",
":",
"return",
"'\\n\\n'",
".",
"join",
"(",
"' '",
".",
"join",
"(",
"p",
".",
"split",
"(",
")",
")",
"for",
"p",
"in",
"text",
".",
"split",
"(",
"'\\n\\n'",
")",
")",
".",
"format",
... | Compact whitespace in a string and format any keyword arguments into the string.
:param text: The text to compact (a string).
:param kw: Any keyword arguments to apply using :func:`str.format()`.
:returns: The compacted, formatted string.
The whitespace compaction preserves paragraphs. | [
"Compact",
"whitespace",
"in",
"a",
"string",
"and",
"format",
"any",
"keyword",
"arguments",
"into",
"the",
"string",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L41-L51 |
paylogic/pip-accel | pip_accel/utils.py | expand_path | def expand_path(pathname):
"""
Expand the home directory in a pathname based on the effective user id.
:param pathname: A pathname that may start with ``~/``, indicating the path
should be interpreted as being relative to the home
directory of the current (effectiv... | python | def expand_path(pathname):
"""
Expand the home directory in a pathname based on the effective user id.
:param pathname: A pathname that may start with ``~/``, indicating the path
should be interpreted as being relative to the home
directory of the current (effectiv... | [
"def",
"expand_path",
"(",
"pathname",
")",
":",
"# The following logic previously used regular expressions but that approach",
"# turned out to be very error prone, hence the current contraption based on",
"# direct string manipulation :-).",
"home_directory",
"=",
"find_home_directory",
"(... | Expand the home directory in a pathname based on the effective user id.
:param pathname: A pathname that may start with ``~/``, indicating the path
should be interpreted as being relative to the home
directory of the current (effective) user.
:returns: The (modified) p... | [
"Expand",
"the",
"home",
"directory",
"in",
"a",
"pathname",
"based",
"on",
"the",
"effective",
"user",
"id",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L54-L77 |
paylogic/pip-accel | pip_accel/utils.py | find_home_directory | def find_home_directory():
"""
Look up the home directory of the effective user id.
:returns: The pathname of the home directory (a string).
.. note:: On Windows this uses the ``%APPDATA%`` environment variable (if
available) and otherwise falls back to ``~/Application Data``.
"""
... | python | def find_home_directory():
"""
Look up the home directory of the effective user id.
:returns: The pathname of the home directory (a string).
.. note:: On Windows this uses the ``%APPDATA%`` environment variable (if
available) and otherwise falls back to ``~/Application Data``.
"""
... | [
"def",
"find_home_directory",
"(",
")",
":",
"if",
"WINDOWS",
":",
"directory",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'APPDATA'",
")",
"if",
"not",
"directory",
":",
"directory",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"r'~\\Application Data... | Look up the home directory of the effective user id.
:returns: The pathname of the home directory (a string).
.. note:: On Windows this uses the ``%APPDATA%`` environment variable (if
available) and otherwise falls back to ``~/Application Data``. | [
"Look",
"up",
"the",
"home",
"directory",
"of",
"the",
"effective",
"user",
"id",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L90-L110 |
paylogic/pip-accel | pip_accel/utils.py | makedirs | def makedirs(path, mode=0o777):
"""
Create a directory if it doesn't already exist (keeping concurrency in mind).
:param path: The pathname of the directory to create (a string).
:param mode: The mode to apply to newly created directories (an integer,
defaults to the octal number ``077... | python | def makedirs(path, mode=0o777):
"""
Create a directory if it doesn't already exist (keeping concurrency in mind).
:param path: The pathname of the directory to create (a string).
:param mode: The mode to apply to newly created directories (an integer,
defaults to the octal number ``077... | [
"def",
"makedirs",
"(",
"path",
",",
"mode",
"=",
"0o777",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
",",
"mode",
")",
"return",
"True",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errno",
".",
"EEXIST",
"... | Create a directory if it doesn't already exist (keeping concurrency in mind).
:param path: The pathname of the directory to create (a string).
:param mode: The mode to apply to newly created directories (an integer,
defaults to the octal number ``0777``).
:returns: :data:`True` when the di... | [
"Create",
"a",
"directory",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"(",
"keeping",
"concurrency",
"in",
"mind",
")",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L141-L162 |
paylogic/pip-accel | pip_accel/utils.py | same_directories | def same_directories(path1, path2):
"""
Check if two pathnames refer to the same directory.
:param path1: The first pathname (a string).
:param path2: The second pathname (a string).
:returns: :data:`True` if both pathnames refer to the same directory,
:data:`False` otherwise.
"""... | python | def same_directories(path1, path2):
"""
Check if two pathnames refer to the same directory.
:param path1: The first pathname (a string).
:param path2: The second pathname (a string).
:returns: :data:`True` if both pathnames refer to the same directory,
:data:`False` otherwise.
"""... | [
"def",
"same_directories",
"(",
"path1",
",",
"path2",
")",
":",
"if",
"all",
"(",
"os",
".",
"path",
".",
"isdir",
"(",
"p",
")",
"for",
"p",
"in",
"(",
"path1",
",",
"path2",
")",
")",
":",
"try",
":",
"return",
"os",
".",
"path",
".",
"samef... | Check if two pathnames refer to the same directory.
:param path1: The first pathname (a string).
:param path2: The second pathname (a string).
:returns: :data:`True` if both pathnames refer to the same directory,
:data:`False` otherwise. | [
"Check",
"if",
"two",
"pathnames",
"refer",
"to",
"the",
"same",
"directory",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L165-L181 |
paylogic/pip-accel | pip_accel/utils.py | hash_files | def hash_files(method, *files):
"""
Calculate the hexadecimal digest of one or more local files.
:param method: The hash method (a string, given to :func:`hashlib.new()`).
:param files: The pathname(s) of file(s) to hash (zero or more strings).
:returns: The calculated hex digest (a string).
""... | python | def hash_files(method, *files):
"""
Calculate the hexadecimal digest of one or more local files.
:param method: The hash method (a string, given to :func:`hashlib.new()`).
:param files: The pathname(s) of file(s) to hash (zero or more strings).
:returns: The calculated hex digest (a string).
""... | [
"def",
"hash_files",
"(",
"method",
",",
"*",
"files",
")",
":",
"context",
"=",
"hashlib",
".",
"new",
"(",
"method",
")",
"for",
"filename",
"in",
"files",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"handle",
":",
"while",
"True"... | Calculate the hexadecimal digest of one or more local files.
:param method: The hash method (a string, given to :func:`hashlib.new()`).
:param files: The pathname(s) of file(s) to hash (zero or more strings).
:returns: The calculated hex digest (a string). | [
"Calculate",
"the",
"hexadecimal",
"digest",
"of",
"one",
"or",
"more",
"local",
"files",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L184-L200 |
paylogic/pip-accel | pip_accel/utils.py | replace_file | def replace_file(src, dst):
"""
Overwrite a file (in an atomic fashion when possible).
:param src: The pathname of the source file (a string).
:param dst: The pathname of the destination file (a string).
"""
# Try os.replace() which was introduced in Python 3.3
# (this should work on POSIX ... | python | def replace_file(src, dst):
"""
Overwrite a file (in an atomic fashion when possible).
:param src: The pathname of the source file (a string).
:param dst: The pathname of the destination file (a string).
"""
# Try os.replace() which was introduced in Python 3.3
# (this should work on POSIX ... | [
"def",
"replace_file",
"(",
"src",
",",
"dst",
")",
":",
"# Try os.replace() which was introduced in Python 3.3",
"# (this should work on POSIX as well as Windows systems).",
"try",
":",
"os",
".",
"replace",
"(",
"src",
",",
"dst",
")",
"return",
"except",
"AttributeErro... | Overwrite a file (in an atomic fashion when possible).
:param src: The pathname of the source file (a string).
:param dst: The pathname of the destination file (a string). | [
"Overwrite",
"a",
"file",
"(",
"in",
"an",
"atomic",
"fashion",
"when",
"possible",
")",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L203-L228 |
paylogic/pip-accel | pip_accel/utils.py | requirement_is_installed | def requirement_is_installed(expr):
"""
Check whether a requirement is installed.
:param expr: A requirement specification similar to those used in pip
requirement files (a string).
:returns: :data:`True` if the requirement is available (installed),
:data:`False` otherwis... | python | def requirement_is_installed(expr):
"""
Check whether a requirement is installed.
:param expr: A requirement specification similar to those used in pip
requirement files (a string).
:returns: :data:`True` if the requirement is available (installed),
:data:`False` otherwis... | [
"def",
"requirement_is_installed",
"(",
"expr",
")",
":",
"required_dist",
"=",
"next",
"(",
"parse_requirements",
"(",
"expr",
")",
")",
"try",
":",
"installed_dist",
"=",
"get_distribution",
"(",
"required_dist",
".",
"key",
")",
"return",
"installed_dist",
"i... | Check whether a requirement is installed.
:param expr: A requirement specification similar to those used in pip
requirement files (a string).
:returns: :data:`True` if the requirement is available (installed),
:data:`False` otherwise. | [
"Check",
"whether",
"a",
"requirement",
"is",
"installed",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L263-L277 |
paylogic/pip-accel | pip_accel/utils.py | uninstall | def uninstall(*package_names):
"""
Uninstall one or more packages using the Python equivalent of ``pip uninstall --yes``.
The package(s) to uninstall must be installed, otherwise pip will raise an
``UninstallationError``. You can check for installed packages using
:func:`is_installed()`.
:para... | python | def uninstall(*package_names):
"""
Uninstall one or more packages using the Python equivalent of ``pip uninstall --yes``.
The package(s) to uninstall must be installed, otherwise pip will raise an
``UninstallationError``. You can check for installed packages using
:func:`is_installed()`.
:para... | [
"def",
"uninstall",
"(",
"*",
"package_names",
")",
":",
"command",
"=",
"UninstallCommand",
"(",
")",
"opts",
",",
"args",
"=",
"command",
".",
"parse_args",
"(",
"[",
"'--yes'",
"]",
"+",
"list",
"(",
"package_names",
")",
")",
"command",
".",
"run",
... | Uninstall one or more packages using the Python equivalent of ``pip uninstall --yes``.
The package(s) to uninstall must be installed, otherwise pip will raise an
``UninstallationError``. You can check for installed packages using
:func:`is_installed()`.
:param package_names: The names of one or more P... | [
"Uninstall",
"one",
"or",
"more",
"packages",
"using",
"the",
"Python",
"equivalent",
"of",
"pip",
"uninstall",
"--",
"yes",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L290-L302 |
paylogic/pip-accel | pip_accel/utils.py | match_option | def match_option(argument, short_option, long_option):
"""
Match a command line argument against a short and long option.
:param argument: The command line argument (a string).
:param short_option: The short option (a string).
:param long_option: The long option (a string).
:returns: :data:`Tru... | python | def match_option(argument, short_option, long_option):
"""
Match a command line argument against a short and long option.
:param argument: The command line argument (a string).
:param short_option: The short option (a string).
:param long_option: The long option (a string).
:returns: :data:`Tru... | [
"def",
"match_option",
"(",
"argument",
",",
"short_option",
",",
"long_option",
")",
":",
"return",
"short_option",
"[",
"1",
"]",
"in",
"argument",
"[",
"1",
":",
"]",
"if",
"is_short_option",
"(",
"argument",
")",
"else",
"argument",
"==",
"long_option"
] | Match a command line argument against a short and long option.
:param argument: The command line argument (a string).
:param short_option: The short option (a string).
:param long_option: The long option (a string).
:returns: :data:`True` if the argument matches, :data:`False` otherwise. | [
"Match",
"a",
"command",
"line",
"argument",
"against",
"a",
"short",
"and",
"long",
"option",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L305-L314 |
paylogic/pip-accel | pip_accel/utils.py | match_option_with_value | def match_option_with_value(arguments, option, value):
"""
Check if a list of command line options contains an option with a value.
:param arguments: The command line arguments (a list of strings).
:param option: The long option (a string).
:param value: The expected value (a string).
:returns:... | python | def match_option_with_value(arguments, option, value):
"""
Check if a list of command line options contains an option with a value.
:param arguments: The command line arguments (a list of strings).
:param option: The long option (a string).
:param value: The expected value (a string).
:returns:... | [
"def",
"match_option_with_value",
"(",
"arguments",
",",
"option",
",",
"value",
")",
":",
"return",
"(",
"'%s=%s'",
"%",
"(",
"option",
",",
"value",
")",
"in",
"arguments",
"or",
"contains_sublist",
"(",
"arguments",
",",
"[",
"option",
",",
"value",
"]"... | Check if a list of command line options contains an option with a value.
:param arguments: The command line arguments (a list of strings).
:param option: The long option (a string).
:param value: The expected value (a string).
:returns: :data:`True` if the command line contains the option/value pair,
... | [
"Check",
"if",
"a",
"list",
"of",
"command",
"line",
"options",
"contains",
"an",
"option",
"with",
"a",
"value",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L327-L338 |
paylogic/pip-accel | pip_accel/utils.py | contains_sublist | def contains_sublist(lst, sublst):
"""
Check if one list contains the items from another list (in the same order).
:param lst: The main list.
:param sublist: The sublist to check for.
:returns: :data:`True` if the main list contains the items from the
sublist in the same order, :data:... | python | def contains_sublist(lst, sublst):
"""
Check if one list contains the items from another list (in the same order).
:param lst: The main list.
:param sublist: The sublist to check for.
:returns: :data:`True` if the main list contains the items from the
sublist in the same order, :data:... | [
"def",
"contains_sublist",
"(",
"lst",
",",
"sublst",
")",
":",
"n",
"=",
"len",
"(",
"sublst",
")",
"return",
"any",
"(",
"(",
"sublst",
"==",
"lst",
"[",
"i",
":",
"i",
"+",
"n",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"lst",
... | Check if one list contains the items from another list (in the same order).
:param lst: The main list.
:param sublist: The sublist to check for.
:returns: :data:`True` if the main list contains the items from the
sublist in the same order, :data:`False` otherwise.
Based on `this StackOve... | [
"Check",
"if",
"one",
"list",
"contains",
"the",
"items",
"from",
"another",
"list",
"(",
"in",
"the",
"same",
"order",
")",
"."
] | train | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/utils.py#L341-L353 |
eyurtsev/fcsparser | fcsparser/api.py | fromfile | def fromfile(file, dtype, count, *args, **kwargs):
"""Wrapper around np.fromfile to support any file-like object."""
try:
return numpy.fromfile(file, dtype=dtype, count=count, *args, **kwargs)
except (TypeError, IOError):
return numpy.frombuffer(file.read(count * numpy.dtype(dtype).itemsize)... | python | def fromfile(file, dtype, count, *args, **kwargs):
"""Wrapper around np.fromfile to support any file-like object."""
try:
return numpy.fromfile(file, dtype=dtype, count=count, *args, **kwargs)
except (TypeError, IOError):
return numpy.frombuffer(file.read(count * numpy.dtype(dtype).itemsize)... | [
"def",
"fromfile",
"(",
"file",
",",
"dtype",
",",
"count",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"numpy",
".",
"fromfile",
"(",
"file",
",",
"dtype",
"=",
"dtype",
",",
"count",
"=",
"count",
",",
"*",
"args"... | Wrapper around np.fromfile to support any file-like object. | [
"Wrapper",
"around",
"np",
".",
"fromfile",
"to",
"support",
"any",
"file",
"-",
"like",
"object",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L29-L35 |
eyurtsev/fcsparser | fcsparser/api.py | parse | def parse(path, meta_data_only=False, compensate=False, channel_naming='$PnS',
reformat_meta=False, data_set=0, dtype='float32', encoding="utf-8"):
"""Parse an fcs file at the location specified by the path.
Parameters
----------
path: str
Path of .fcs file
meta_data_only: bool
... | python | def parse(path, meta_data_only=False, compensate=False, channel_naming='$PnS',
reformat_meta=False, data_set=0, dtype='float32', encoding="utf-8"):
"""Parse an fcs file at the location specified by the path.
Parameters
----------
path: str
Path of .fcs file
meta_data_only: bool
... | [
"def",
"parse",
"(",
"path",
",",
"meta_data_only",
"=",
"False",
",",
"compensate",
"=",
"False",
",",
"channel_naming",
"=",
"'$PnS'",
",",
"reformat_meta",
"=",
"False",
",",
"data_set",
"=",
"0",
",",
"dtype",
"=",
"'float32'",
",",
"encoding",
"=",
... | Parse an fcs file at the location specified by the path.
Parameters
----------
path: str
Path of .fcs file
meta_data_only: bool
If True, the parse_fcs only returns the meta_data (the TEXT segment of the FCS file)
output_format: 'DataFrame' | 'ndarray'
If set to 'DataFrame' t... | [
"Parse",
"an",
"fcs",
"file",
"at",
"the",
"location",
"specified",
"by",
"the",
"path",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L499-L573 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.load_file | def load_file(self, file_handle, data_set=0, read_data=True):
"""Load the requested parts of the file into memory."""
file_handle.seek(0, 2)
self._file_size = file_handle.tell()
file_handle.seek(0)
data_segments = 0
# seek the correct data set in fcs
nextdata_offs... | python | def load_file(self, file_handle, data_set=0, read_data=True):
"""Load the requested parts of the file into memory."""
file_handle.seek(0, 2)
self._file_size = file_handle.tell()
file_handle.seek(0)
data_segments = 0
# seek the correct data set in fcs
nextdata_offs... | [
"def",
"load_file",
"(",
"self",
",",
"file_handle",
",",
"data_set",
"=",
"0",
",",
"read_data",
"=",
"True",
")",
":",
"file_handle",
".",
"seek",
"(",
"0",
",",
"2",
")",
"self",
".",
"_file_size",
"=",
"file_handle",
".",
"tell",
"(",
")",
"file_... | Load the requested parts of the file into memory. | [
"Load",
"the",
"requested",
"parts",
"of",
"the",
"file",
"into",
"memory",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L113-L136 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.from_data | def from_data(cls, data):
"""Load an FCS file from a bytes-like object.
Args:
data: buffer containing contents of an FCS file.
Returns:
FCSParser instance with data loaded
"""
obj = cls()
with contextlib.closing(BytesIO(data)) as file_handle:
... | python | def from_data(cls, data):
"""Load an FCS file from a bytes-like object.
Args:
data: buffer containing contents of an FCS file.
Returns:
FCSParser instance with data loaded
"""
obj = cls()
with contextlib.closing(BytesIO(data)) as file_handle:
... | [
"def",
"from_data",
"(",
"cls",
",",
"data",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"with",
"contextlib",
".",
"closing",
"(",
"BytesIO",
"(",
"data",
")",
")",
"as",
"file_handle",
":",
"obj",
".",
"load_file",
"(",
"file_handle",
")",
"return",
"ob... | Load an FCS file from a bytes-like object.
Args:
data: buffer containing contents of an FCS file.
Returns:
FCSParser instance with data loaded | [
"Load",
"an",
"FCS",
"file",
"from",
"a",
"bytes",
"-",
"like",
"object",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L139-L151 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.read_header | def read_header(self, file_handle, nextdata_offset=0):
"""Read the header of the FCS file.
The header specifies where the annotation, data and analysis are located inside the binary
file.
Args:
file_handle: buffer containing FCS file.
nextdata_offset: byte offse... | python | def read_header(self, file_handle, nextdata_offset=0):
"""Read the header of the FCS file.
The header specifies where the annotation, data and analysis are located inside the binary
file.
Args:
file_handle: buffer containing FCS file.
nextdata_offset: byte offse... | [
"def",
"read_header",
"(",
"self",
",",
"file_handle",
",",
"nextdata_offset",
"=",
"0",
")",
":",
"header",
"=",
"{",
"'FCS format'",
":",
"file_handle",
".",
"read",
"(",
"6",
")",
"}",
"file_handle",
".",
"read",
"(",
"4",
")",
"# 4 space characters aft... | Read the header of the FCS file.
The header specifies where the annotation, data and analysis are located inside the binary
file.
Args:
file_handle: buffer containing FCS file.
nextdata_offset: byte offset of a set header from file start specified by $NEXTDATA | [
"Read",
"the",
"header",
"of",
"the",
"FCS",
"file",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L153-L195 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser._extract_text_dict | def _extract_text_dict(self, raw_text):
"""Parse the TEXT segment of the FCS file into a python dictionary."""
delimiter = raw_text[0]
if raw_text[-1] != delimiter:
raw_text = raw_text.strip()
if raw_text[-1] != delimiter:
msg = (u'The first two character... | python | def _extract_text_dict(self, raw_text):
"""Parse the TEXT segment of the FCS file into a python dictionary."""
delimiter = raw_text[0]
if raw_text[-1] != delimiter:
raw_text = raw_text.strip()
if raw_text[-1] != delimiter:
msg = (u'The first two character... | [
"def",
"_extract_text_dict",
"(",
"self",
",",
"raw_text",
")",
":",
"delimiter",
"=",
"raw_text",
"[",
"0",
"]",
"if",
"raw_text",
"[",
"-",
"1",
"]",
"!=",
"delimiter",
":",
"raw_text",
"=",
"raw_text",
".",
"strip",
"(",
")",
"if",
"raw_text",
"[",
... | Parse the TEXT segment of the FCS file into a python dictionary. | [
"Parse",
"the",
"TEXT",
"segment",
"of",
"the",
"FCS",
"file",
"into",
"a",
"python",
"dictionary",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L197-L224 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.read_text | def read_text(self, file_handle):
"""Parse the TEXT segment of the FCS file.
The TEXT segment contains meta data associated with the FCS file.
Converting all meta keywords to lower case.
"""
header = self.annotation['__header__'] # For convenience
#####
# Read ... | python | def read_text(self, file_handle):
"""Parse the TEXT segment of the FCS file.
The TEXT segment contains meta data associated with the FCS file.
Converting all meta keywords to lower case.
"""
header = self.annotation['__header__'] # For convenience
#####
# Read ... | [
"def",
"read_text",
"(",
"self",
",",
"file_handle",
")",
":",
"header",
"=",
"self",
".",
"annotation",
"[",
"'__header__'",
"]",
"# For convenience",
"#####",
"# Read in the TEXT segment of the FCS file",
"# There are some differences in how the",
"file_handle",
".",
"s... | Parse the TEXT segment of the FCS file.
The TEXT segment contains meta data associated with the FCS file.
Converting all meta keywords to lower case. | [
"Parse",
"the",
"TEXT",
"segment",
"of",
"the",
"FCS",
"file",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L226-L293 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.read_analysis | def read_analysis(self, file_handle):
"""Read the ANALYSIS segment of the FCS file and store it in self.analysis.
Warning: This has never been tested with an actual fcs file that contains an
analysis segment.
Args:
file_handle: buffer containing FCS data
"""
... | python | def read_analysis(self, file_handle):
"""Read the ANALYSIS segment of the FCS file and store it in self.analysis.
Warning: This has never been tested with an actual fcs file that contains an
analysis segment.
Args:
file_handle: buffer containing FCS data
"""
... | [
"def",
"read_analysis",
"(",
"self",
",",
"file_handle",
")",
":",
"start",
"=",
"self",
".",
"annotation",
"[",
"'__header__'",
"]",
"[",
"'analysis start'",
"]",
"end",
"=",
"self",
".",
"annotation",
"[",
"'__header__'",
"]",
"[",
"'analysis end'",
"]",
... | Read the ANALYSIS segment of the FCS file and store it in self.analysis.
Warning: This has never been tested with an actual fcs file that contains an
analysis segment.
Args:
file_handle: buffer containing FCS data | [
"Read",
"the",
"ANALYSIS",
"segment",
"of",
"the",
"FCS",
"file",
"and",
"store",
"it",
"in",
"self",
".",
"analysis",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L295-L310 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser._verify_assumptions | def _verify_assumptions(self):
"""Verify that all assumptions made by the parser hold."""
text = self.annotation
keys = text.keys()
if '$MODE' not in text or text['$MODE'] != 'L':
raise ParserFeatureNotImplementedError(u'Mode not implemented')
if '$P0B' in keys:
... | python | def _verify_assumptions(self):
"""Verify that all assumptions made by the parser hold."""
text = self.annotation
keys = text.keys()
if '$MODE' not in text or text['$MODE'] != 'L':
raise ParserFeatureNotImplementedError(u'Mode not implemented')
if '$P0B' in keys:
... | [
"def",
"_verify_assumptions",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"annotation",
"keys",
"=",
"text",
".",
"keys",
"(",
")",
"if",
"'$MODE'",
"not",
"in",
"text",
"or",
"text",
"[",
"'$MODE'",
"]",
"!=",
"'L'",
":",
"raise",
"ParserFeatureN... | Verify that all assumptions made by the parser hold. | [
"Verify",
"that",
"all",
"assumptions",
"made",
"by",
"the",
"parser",
"hold",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L312-L325 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.get_channel_names | def get_channel_names(self):
"""Get list of channel names. Raises a warning if the names are not unique."""
names_s, names_n = self.channel_names_s, self.channel_names_n
# Figure out which channel names to use
if self._channel_naming == '$PnS':
channel_names, channel_names_a... | python | def get_channel_names(self):
"""Get list of channel names. Raises a warning if the names are not unique."""
names_s, names_n = self.channel_names_s, self.channel_names_n
# Figure out which channel names to use
if self._channel_naming == '$PnS':
channel_names, channel_names_a... | [
"def",
"get_channel_names",
"(",
"self",
")",
":",
"names_s",
",",
"names_n",
"=",
"self",
".",
"channel_names_s",
",",
"self",
".",
"channel_names_n",
"# Figure out which channel names to use",
"if",
"self",
".",
"_channel_naming",
"==",
"'$PnS'",
":",
"channel_nam... | Get list of channel names. Raises a warning if the names are not unique. | [
"Get",
"list",
"of",
"channel",
"names",
".",
"Raises",
"a",
"warning",
"if",
"the",
"names",
"are",
"not",
"unique",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L327-L353 |
eyurtsev/fcsparser | fcsparser/api.py | FCSParser.read_data | def read_data(self, file_handle):
"""Read the DATA segment of the FCS file."""
self._verify_assumptions()
text = self.annotation
if (self._data_start > self._file_size) or (self._data_end > self._file_size):
raise ValueError(u'The FCS file "{}" is corrupted. Part of the data... | python | def read_data(self, file_handle):
"""Read the DATA segment of the FCS file."""
self._verify_assumptions()
text = self.annotation
if (self._data_start > self._file_size) or (self._data_end > self._file_size):
raise ValueError(u'The FCS file "{}" is corrupted. Part of the data... | [
"def",
"read_data",
"(",
"self",
",",
"file_handle",
")",
":",
"self",
".",
"_verify_assumptions",
"(",
")",
"text",
"=",
"self",
".",
"annotation",
"if",
"(",
"self",
".",
"_data_start",
">",
"self",
".",
"_file_size",
")",
"or",
"(",
"self",
".",
"_d... | Read the DATA segment of the FCS file. | [
"Read",
"the",
"DATA",
"segment",
"of",
"the",
"FCS",
"file",
"."
] | train | https://github.com/eyurtsev/fcsparser/blob/710e8e31d4b09ff6e73d47d86770be6ca2f4282c/fcsparser/api.py#L355-L433 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.