repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
juju/python-libjuju | juju/model.py | Model.upgrade_juju | def upgrade_juju(
self, dry_run=False, reset_previous_upgrade=False,
upload_tools=False, version=None):
"""Upgrade Juju on all machines in a model.
:param bool dry_run: Don't do the actual upgrade
:param bool reset_previous_upgrade: Clear the previous (incomplete)
... | python | def upgrade_juju(
self, dry_run=False, reset_previous_upgrade=False,
upload_tools=False, version=None):
"""Upgrade Juju on all machines in a model.
:param bool dry_run: Don't do the actual upgrade
:param bool reset_previous_upgrade: Clear the previous (incomplete)
... | [
"def",
"upgrade_juju",
"(",
"self",
",",
"dry_run",
"=",
"False",
",",
"reset_previous_upgrade",
"=",
"False",
",",
"upload_tools",
"=",
"False",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Upgrade Juju on all machines in a model.
:param bool dry_run: Don't do the actual upgrade
:param bool reset_previous_upgrade: Clear the previous (incomplete)
upgrade status
:param bool upload_tools: Upload local version of tools
:param str version: Upgrade to a specific vers... | [
"Upgrade",
"Juju",
"on",
"all",
"machines",
"in",
"a",
"model",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L1822-L1834 | train |
juju/python-libjuju | juju/model.py | Model.get_metrics | async def get_metrics(self, *tags):
"""Retrieve metrics.
:param str *tags: Tags of entities from which to retrieve metrics.
No tags retrieves the metrics of all units in the model.
:return: Dictionary of unit_name:metrics
"""
log.debug("Retrieving metrics for %s",
... | python | async def get_metrics(self, *tags):
"""Retrieve metrics.
:param str *tags: Tags of entities from which to retrieve metrics.
No tags retrieves the metrics of all units in the model.
:return: Dictionary of unit_name:metrics
"""
log.debug("Retrieving metrics for %s",
... | [
"async",
"def",
"get_metrics",
"(",
"self",
",",
"*",
"tags",
")",
":",
"log",
".",
"debug",
"(",
"\"Retrieving metrics for %s\"",
",",
"', '",
".",
"join",
"(",
"tags",
")",
"if",
"tags",
"else",
"\"all units\"",
")",
"metrics_facade",
"=",
"client",
".",... | Retrieve metrics.
:param str *tags: Tags of entities from which to retrieve metrics.
No tags retrieves the metrics of all units in the model.
:return: Dictionary of unit_name:metrics | [
"Retrieve",
"metrics",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L1848-L1878 | train |
juju/python-libjuju | juju/model.py | BundleHandler.scale | async def scale(self, application, scale):
"""
Handle a change of scale to a k8s application.
:param string application:
Application holds the application placeholder name for which a unit
is added.
:param int scale:
New scale value to use.
"... | python | async def scale(self, application, scale):
"""
Handle a change of scale to a k8s application.
:param string application:
Application holds the application placeholder name for which a unit
is added.
:param int scale:
New scale value to use.
"... | [
"async",
"def",
"scale",
"(",
"self",
",",
"application",
",",
"scale",
")",
":",
"application",
"=",
"self",
".",
"resolve",
"(",
"application",
")",
"return",
"await",
"self",
".",
"model",
".",
"applications",
"[",
"application",
"]",
".",
"scale",
"(... | Handle a change of scale to a k8s application.
:param string application:
Application holds the application placeholder name for which a unit
is added.
:param int scale:
New scale value to use. | [
"Handle",
"a",
"change",
"of",
"scale",
"to",
"a",
"k8s",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2194-L2206 | train |
juju/python-libjuju | juju/model.py | CharmArchiveGenerator.make_archive | def make_archive(self, path):
"""Create archive of directory and write to ``path``.
:param path: Path to archive
Ignored::
* build/* - This is used for packing the charm itself and any
similar tasks.
* */.* - Hidden files are all ignored fo... | python | def make_archive(self, path):
"""Create archive of directory and write to ``path``.
:param path: Path to archive
Ignored::
* build/* - This is used for packing the charm itself and any
similar tasks.
* */.* - Hidden files are all ignored fo... | [
"def",
"make_archive",
"(",
"self",
",",
"path",
")",
":",
"zf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"path",
",",
"'w'",
",",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"se... | Create archive of directory and write to ``path``.
:param path: Path to archive
Ignored::
* build/* - This is used for packing the charm itself and any
similar tasks.
* */.* - Hidden files are all ignored for now. This will most
... | [
"Create",
"archive",
"of",
"directory",
"and",
"write",
"to",
"path",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2281-L2312 | train |
juju/python-libjuju | juju/model.py | CharmArchiveGenerator._check_type | def _check_type(self, path):
"""Check the path
"""
s = os.stat(path)
if stat.S_ISDIR(s.st_mode) or stat.S_ISREG(s.st_mode):
return path
raise ValueError("Invalid Charm at % %s" % (
path, "Invalid file type for a charm")) | python | def _check_type(self, path):
"""Check the path
"""
s = os.stat(path)
if stat.S_ISDIR(s.st_mode) or stat.S_ISREG(s.st_mode):
return path
raise ValueError("Invalid Charm at % %s" % (
path, "Invalid file type for a charm")) | [
"def",
"_check_type",
"(",
"self",
",",
"path",
")",
":",
"s",
"=",
"os",
".",
"stat",
"(",
"path",
")",
"if",
"stat",
".",
"S_ISDIR",
"(",
"s",
".",
"st_mode",
")",
"or",
"stat",
".",
"S_ISREG",
"(",
"s",
".",
"st_mode",
")",
":",
"return",
"p... | Check the path | [
"Check",
"the",
"path"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2314-L2321 | train |
juju/python-libjuju | juju/model.py | CharmArchiveGenerator._write_symlink | def _write_symlink(self, zf, link_target, link_path):
"""Package symlinks with appropriate zipfile metadata."""
info = zipfile.ZipInfo()
info.filename = link_path
info.create_system = 3
# Magic code for symlinks / py2/3 compat
# 27166663808 = (stat.S_IFLNK | 0755) << 16
... | python | def _write_symlink(self, zf, link_target, link_path):
"""Package symlinks with appropriate zipfile metadata."""
info = zipfile.ZipInfo()
info.filename = link_path
info.create_system = 3
# Magic code for symlinks / py2/3 compat
# 27166663808 = (stat.S_IFLNK | 0755) << 16
... | [
"def",
"_write_symlink",
"(",
"self",
",",
"zf",
",",
"link_target",
",",
"link_path",
")",
":",
"info",
"=",
"zipfile",
".",
"ZipInfo",
"(",
")",
"info",
".",
"filename",
"=",
"link_path",
"info",
".",
"create_system",
"=",
"3",
"info",
".",
"external_a... | Package symlinks with appropriate zipfile metadata. | [
"Package",
"symlinks",
"with",
"appropriate",
"zipfile",
"metadata",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2336-L2344 | train |
juju/python-libjuju | juju/user.py | User.set_password | async def set_password(self, password):
"""Update this user's password.
"""
await self.controller.change_user_password(self.username, password)
self._user_info.password = password | python | async def set_password(self, password):
"""Update this user's password.
"""
await self.controller.change_user_password(self.username, password)
self._user_info.password = password | [
"async",
"def",
"set_password",
"(",
"self",
",",
"password",
")",
":",
"await",
"self",
".",
"controller",
".",
"change_user_password",
"(",
"self",
".",
"username",
",",
"password",
")",
"self",
".",
"_user_info",
".",
"password",
"=",
"password"
] | Update this user's password. | [
"Update",
"this",
"user",
"s",
"password",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L56-L60 | train |
juju/python-libjuju | juju/user.py | User.grant | async def grant(self, acl='login'):
"""Set access level of this user on the controller.
:param str acl: Access control ('login', 'add-model', or 'superuser')
"""
if await self.controller.grant(self.username, acl):
self._user_info.access = acl | python | async def grant(self, acl='login'):
"""Set access level of this user on the controller.
:param str acl: Access control ('login', 'add-model', or 'superuser')
"""
if await self.controller.grant(self.username, acl):
self._user_info.access = acl | [
"async",
"def",
"grant",
"(",
"self",
",",
"acl",
"=",
"'login'",
")",
":",
"if",
"await",
"self",
".",
"controller",
".",
"grant",
"(",
"self",
".",
"username",
",",
"acl",
")",
":",
"self",
".",
"_user_info",
".",
"access",
"=",
"acl"
] | Set access level of this user on the controller.
:param str acl: Access control ('login', 'add-model', or 'superuser') | [
"Set",
"access",
"level",
"of",
"this",
"user",
"on",
"the",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L62-L68 | train |
juju/python-libjuju | juju/user.py | User.revoke | async def revoke(self):
"""Removes all access rights for this user from the controller.
"""
await self.controller.revoke(self.username)
self._user_info.access = '' | python | async def revoke(self):
"""Removes all access rights for this user from the controller.
"""
await self.controller.revoke(self.username)
self._user_info.access = '' | [
"async",
"def",
"revoke",
"(",
"self",
")",
":",
"await",
"self",
".",
"controller",
".",
"revoke",
"(",
"self",
".",
"username",
")",
"self",
".",
"_user_info",
".",
"access",
"=",
"''"
] | Removes all access rights for this user from the controller. | [
"Removes",
"all",
"access",
"rights",
"for",
"this",
"user",
"from",
"the",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L70-L74 | train |
juju/python-libjuju | juju/user.py | User.disable | async def disable(self):
"""Disable this user.
"""
await self.controller.disable_user(self.username)
self._user_info.disabled = True | python | async def disable(self):
"""Disable this user.
"""
await self.controller.disable_user(self.username)
self._user_info.disabled = True | [
"async",
"def",
"disable",
"(",
"self",
")",
":",
"await",
"self",
".",
"controller",
".",
"disable_user",
"(",
"self",
".",
"username",
")",
"self",
".",
"_user_info",
".",
"disabled",
"=",
"True"
] | Disable this user. | [
"Disable",
"this",
"user",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L76-L80 | train |
juju/python-libjuju | juju/user.py | User.enable | async def enable(self):
"""Re-enable this user.
"""
await self.controller.enable_user(self.username)
self._user_info.disabled = False | python | async def enable(self):
"""Re-enable this user.
"""
await self.controller.enable_user(self.username)
self._user_info.disabled = False | [
"async",
"def",
"enable",
"(",
"self",
")",
":",
"await",
"self",
".",
"controller",
".",
"enable_user",
"(",
"self",
".",
"username",
")",
"self",
".",
"_user_info",
".",
"disabled",
"=",
"False"
] | Re-enable this user. | [
"Re",
"-",
"enable",
"this",
"user",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L82-L86 | train |
juju/python-libjuju | juju/machine.py | Machine.destroy | async def destroy(self, force=False):
"""Remove this machine from the model.
Blocks until the machine is actually removed.
"""
facade = client.ClientFacade.from_connection(self.connection)
log.debug(
'Destroying machine %s', self.id)
await facade.DestroyMa... | python | async def destroy(self, force=False):
"""Remove this machine from the model.
Blocks until the machine is actually removed.
"""
facade = client.ClientFacade.from_connection(self.connection)
log.debug(
'Destroying machine %s', self.id)
await facade.DestroyMa... | [
"async",
"def",
"destroy",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"facade",
"=",
"client",
".",
"ClientFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Destroying machine %s'",
",",
"self",
".",
... | Remove this machine from the model.
Blocks until the machine is actually removed. | [
"Remove",
"this",
"machine",
"from",
"the",
"model",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/machine.py#L99-L112 | train |
juju/python-libjuju | juju/machine.py | Machine.scp_to | async def scp_to(self, source, destination, user='ubuntu', proxy=False,
scp_opts=''):
"""Transfer files to this machine.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote user... | python | async def scp_to(self, source, destination, user='ubuntu', proxy=False,
scp_opts=''):
"""Transfer files to this machine.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote user... | [
"async",
"def",
"scp_to",
"(",
"self",
",",
"source",
",",
"destination",
",",
"user",
"=",
"'ubuntu'",
",",
"proxy",
"=",
"False",
",",
"scp_opts",
"=",
"''",
")",
":",
"if",
"proxy",
":",
"raise",
"NotImplementedError",
"(",
"'proxy option is not implement... | Transfer files to this machine.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote username
:param bool proxy: Proxy through the Juju API server
:param scp_opts: Additional options to the `... | [
"Transfer",
"files",
"to",
"this",
"machine",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/machine.py#L140-L156 | train |
juju/python-libjuju | juju/machine.py | Machine._scp | async def _scp(self, source, destination, scp_opts):
""" Execute an scp command. Requires a fully qualified source and
destination.
"""
cmd = [
'scp',
'-i', os.path.expanduser('~/.local/share/juju/ssh/juju_id_rsa'),
'-o', 'StrictHostKeyChecking=no',
... | python | async def _scp(self, source, destination, scp_opts):
""" Execute an scp command. Requires a fully qualified source and
destination.
"""
cmd = [
'scp',
'-i', os.path.expanduser('~/.local/share/juju/ssh/juju_id_rsa'),
'-o', 'StrictHostKeyChecking=no',
... | [
"async",
"def",
"_scp",
"(",
"self",
",",
"source",
",",
"destination",
",",
"scp_opts",
")",
":",
"cmd",
"=",
"[",
"'scp'",
",",
"'-i'",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.local/share/juju/ssh/juju_id_rsa'",
")",
",",
"'-o'",
",",
"'St... | Execute an scp command. Requires a fully qualified source and
destination. | [
"Execute",
"an",
"scp",
"command",
".",
"Requires",
"a",
"fully",
"qualified",
"source",
"and",
"destination",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/machine.py#L176-L193 | train |
juju/python-libjuju | juju/machine.py | Machine.agent_version | def agent_version(self):
"""Get the version of the Juju machine agent.
May return None if the agent is not yet available.
"""
version = self.safe_data['agent-status']['version']
if version:
return client.Number.from_json(version)
else:
return None | python | def agent_version(self):
"""Get the version of the Juju machine agent.
May return None if the agent is not yet available.
"""
version = self.safe_data['agent-status']['version']
if version:
return client.Number.from_json(version)
else:
return None | [
"def",
"agent_version",
"(",
"self",
")",
":",
"version",
"=",
"self",
".",
"safe_data",
"[",
"'agent-status'",
"]",
"[",
"'version'",
"]",
"if",
"version",
":",
"return",
"client",
".",
"Number",
".",
"from_json",
"(",
"version",
")",
"else",
":",
"retu... | Get the version of the Juju machine agent.
May return None if the agent is not yet available. | [
"Get",
"the",
"version",
"of",
"the",
"Juju",
"machine",
"agent",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/machine.py#L231-L240 | train |
juju/python-libjuju | juju/machine.py | Machine.dns_name | def dns_name(self):
"""Get the DNS name for this machine. This is a best guess based on the
addresses available in current data.
May return None if no suitable address is found.
"""
for scope in ['public', 'local-cloud']:
addresses = self.safe_data['addresses'] or []... | python | def dns_name(self):
"""Get the DNS name for this machine. This is a best guess based on the
addresses available in current data.
May return None if no suitable address is found.
"""
for scope in ['public', 'local-cloud']:
addresses = self.safe_data['addresses'] or []... | [
"def",
"dns_name",
"(",
"self",
")",
":",
"for",
"scope",
"in",
"[",
"'public'",
",",
"'local-cloud'",
"]",
":",
"addresses",
"=",
"self",
".",
"safe_data",
"[",
"'addresses'",
"]",
"or",
"[",
"]",
"addresses",
"=",
"[",
"address",
"for",
"address",
"i... | Get the DNS name for this machine. This is a best guess based on the
addresses available in current data.
May return None if no suitable address is found. | [
"Get",
"the",
"DNS",
"name",
"for",
"this",
"machine",
".",
"This",
"is",
"a",
"best",
"guess",
"based",
"on",
"the",
"addresses",
"available",
"in",
"current",
"data",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/machine.py#L264-L276 | train |
juju/python-libjuju | juju/client/_client.py | TypeFactory.from_connection | def from_connection(cls, connection):
"""
Given a connected Connection object, return an initialized and
connected instance of an API Interface matching the name of
this class.
@param connection: initialized Connection object.
"""
facade_name = cls.__name__
... | python | def from_connection(cls, connection):
"""
Given a connected Connection object, return an initialized and
connected instance of an API Interface matching the name of
this class.
@param connection: initialized Connection object.
"""
facade_name = cls.__name__
... | [
"def",
"from_connection",
"(",
"cls",
",",
"connection",
")",
":",
"facade_name",
"=",
"cls",
".",
"__name__",
"if",
"not",
"facade_name",
".",
"endswith",
"(",
"'Facade'",
")",
":",
"raise",
"TypeError",
"(",
"'Unexpected class name: {}'",
".",
"format",
"(",... | Given a connected Connection object, return an initialized and
connected instance of an API Interface matching the name of
this class.
@param connection: initialized Connection object. | [
"Given",
"a",
"connected",
"Connection",
"object",
"return",
"an",
"initialized",
"and",
"connected",
"instance",
"of",
"an",
"API",
"Interface",
"matching",
"the",
"name",
"of",
"this",
"class",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client.py#L42-L64 | train |
juju/python-libjuju | juju/utils.py | execute_process | async def execute_process(*cmd, log=None, loop=None):
'''
Wrapper around asyncio.create_subprocess_exec.
'''
p = await asyncio.create_subprocess_exec(
*cmd,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
loop=loop)
... | python | async def execute_process(*cmd, log=None, loop=None):
'''
Wrapper around asyncio.create_subprocess_exec.
'''
p = await asyncio.create_subprocess_exec(
*cmd,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
loop=loop)
... | [
"async",
"def",
"execute_process",
"(",
"*",
"cmd",
",",
"log",
"=",
"None",
",",
"loop",
"=",
"None",
")",
":",
"p",
"=",
"await",
"asyncio",
".",
"create_subprocess_exec",
"(",
"*",
"cmd",
",",
"stdin",
"=",
"asyncio",
".",
"subprocess",
".",
"PIPE",... | Wrapper around asyncio.create_subprocess_exec. | [
"Wrapper",
"around",
"asyncio",
".",
"create_subprocess_exec",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/utils.py#L11-L29 | train |
juju/python-libjuju | juju/utils.py | _read_ssh_key | def _read_ssh_key():
'''
Inner function for read_ssh_key, suitable for passing to our
Executor.
'''
default_data_dir = Path(Path.home(), ".local", "share", "juju")
juju_data = os.environ.get("JUJU_DATA", default_data_dir)
ssh_key_path = Path(juju_data, 'ssh', 'juju_id_rsa.pub')
with ssh... | python | def _read_ssh_key():
'''
Inner function for read_ssh_key, suitable for passing to our
Executor.
'''
default_data_dir = Path(Path.home(), ".local", "share", "juju")
juju_data = os.environ.get("JUJU_DATA", default_data_dir)
ssh_key_path = Path(juju_data, 'ssh', 'juju_id_rsa.pub')
with ssh... | [
"def",
"_read_ssh_key",
"(",
")",
":",
"default_data_dir",
"=",
"Path",
"(",
"Path",
".",
"home",
"(",
")",
",",
"\".local\"",
",",
"\"share\"",
",",
"\"juju\"",
")",
"juju_data",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"JUJU_DATA\"",
",",
"default... | Inner function for read_ssh_key, suitable for passing to our
Executor. | [
"Inner",
"function",
"for",
"read_ssh_key",
"suitable",
"for",
"passing",
"to",
"our",
"Executor",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/utils.py#L32-L43 | train |
juju/python-libjuju | juju/utils.py | run_with_interrupt | async def run_with_interrupt(task, *events, loop=None):
"""
Awaits a task while allowing it to be interrupted by one or more
`asyncio.Event`s.
If the task finishes without the events becoming set, the results of the
task will be returned. If the event become set, the task will be cancelled
``N... | python | async def run_with_interrupt(task, *events, loop=None):
"""
Awaits a task while allowing it to be interrupted by one or more
`asyncio.Event`s.
If the task finishes without the events becoming set, the results of the
task will be returned. If the event become set, the task will be cancelled
``N... | [
"async",
"def",
"run_with_interrupt",
"(",
"task",
",",
"*",
"events",
",",
"loop",
"=",
"None",
")",
":",
"loop",
"=",
"loop",
"or",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"asyncio",
".",
"ensure_future",
"(",
"task",
",",
"loop",
"=... | Awaits a task while allowing it to be interrupted by one or more
`asyncio.Event`s.
If the task finishes without the events becoming set, the results of the
task will be returned. If the event become set, the task will be cancelled
``None`` will be returned.
:param task: Task to run
:param eve... | [
"Awaits",
"a",
"task",
"while",
"allowing",
"it",
"to",
"be",
"interrupted",
"by",
"one",
"or",
"more",
"asyncio",
".",
"Event",
"s",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/utils.py#L88-L115 | train |
juju/python-libjuju | juju/client/gocookies.py | go_to_py_cookie | def go_to_py_cookie(go_cookie):
'''Convert a Go-style JSON-unmarshaled cookie into a Python cookie'''
expires = None
if go_cookie.get('Expires') is not None:
t = pyrfc3339.parse(go_cookie['Expires'])
expires = t.timestamp()
return cookiejar.Cookie(
version=0,
name=go_cook... | python | def go_to_py_cookie(go_cookie):
'''Convert a Go-style JSON-unmarshaled cookie into a Python cookie'''
expires = None
if go_cookie.get('Expires') is not None:
t = pyrfc3339.parse(go_cookie['Expires'])
expires = t.timestamp()
return cookiejar.Cookie(
version=0,
name=go_cook... | [
"def",
"go_to_py_cookie",
"(",
"go_cookie",
")",
":",
"expires",
"=",
"None",
"if",
"go_cookie",
".",
"get",
"(",
"'Expires'",
")",
"is",
"not",
"None",
":",
"t",
"=",
"pyrfc3339",
".",
"parse",
"(",
"go_cookie",
"[",
"'Expires'",
"]",
")",
"expires",
... | Convert a Go-style JSON-unmarshaled cookie into a Python cookie | [
"Convert",
"a",
"Go",
"-",
"style",
"JSON",
"-",
"unmarshaled",
"cookie",
"into",
"a",
"Python",
"cookie"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/gocookies.py#L45-L75 | train |
juju/python-libjuju | juju/client/gocookies.py | py_to_go_cookie | def py_to_go_cookie(py_cookie):
'''Convert a python cookie to the JSON-marshalable Go-style cookie form.'''
# TODO (perhaps):
# HttpOnly
# Creation
# LastAccess
# Updated
# not done properly: CanonicalHost.
go_cookie = {
'Name': py_cookie.name,
'Value': py_cookie.... | python | def py_to_go_cookie(py_cookie):
'''Convert a python cookie to the JSON-marshalable Go-style cookie form.'''
# TODO (perhaps):
# HttpOnly
# Creation
# LastAccess
# Updated
# not done properly: CanonicalHost.
go_cookie = {
'Name': py_cookie.name,
'Value': py_cookie.... | [
"def",
"py_to_go_cookie",
"(",
"py_cookie",
")",
":",
"go_cookie",
"=",
"{",
"'Name'",
":",
"py_cookie",
".",
"name",
",",
"'Value'",
":",
"py_cookie",
".",
"value",
",",
"'Domain'",
":",
"py_cookie",
".",
"domain",
",",
"'HostOnly'",
":",
"not",
"py_cooki... | Convert a python cookie to the JSON-marshalable Go-style cookie form. | [
"Convert",
"a",
"python",
"cookie",
"to",
"the",
"JSON",
"-",
"marshalable",
"Go",
"-",
"style",
"cookie",
"form",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/gocookies.py#L78-L102 | train |
juju/python-libjuju | juju/client/gocookies.py | GoCookieJar._really_load | def _really_load(self, f, filename, ignore_discard, ignore_expires):
'''Implement the _really_load method called by FileCookieJar
to implement the actual cookie loading'''
data = json.load(f) or []
now = time.time()
for cookie in map(go_to_py_cookie, data):
if not ign... | python | def _really_load(self, f, filename, ignore_discard, ignore_expires):
'''Implement the _really_load method called by FileCookieJar
to implement the actual cookie loading'''
data = json.load(f) or []
now = time.time()
for cookie in map(go_to_py_cookie, data):
if not ign... | [
"def",
"_really_load",
"(",
"self",
",",
"f",
",",
"filename",
",",
"ignore_discard",
",",
"ignore_expires",
")",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
")",
"or",
"[",
"]",
"now",
"=",
"time",
".",
"time",
"(",
")",
"for",
"cookie",
"in"... | Implement the _really_load method called by FileCookieJar
to implement the actual cookie loading | [
"Implement",
"the",
"_really_load",
"method",
"called",
"by",
"FileCookieJar",
"to",
"implement",
"the",
"actual",
"cookie",
"loading"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/gocookies.py#L13-L21 | train |
juju/python-libjuju | juju/client/gocookies.py | GoCookieJar.save | def save(self, filename=None, ignore_discard=False, ignore_expires=False):
'''Implement the FileCookieJar abstract method.'''
if filename is None:
if self.filename is not None:
filename = self.filename
else:
raise ValueError(cookiejar.MISSING_FILEN... | python | def save(self, filename=None, ignore_discard=False, ignore_expires=False):
'''Implement the FileCookieJar abstract method.'''
if filename is None:
if self.filename is not None:
filename = self.filename
else:
raise ValueError(cookiejar.MISSING_FILEN... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"ignore_discard",
"=",
"False",
",",
"ignore_expires",
"=",
"False",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"self",
".",
"filename",
"is",
"not",
"None",
":",
"filename",
"=",... | Implement the FileCookieJar abstract method. | [
"Implement",
"the",
"FileCookieJar",
"abstract",
"method",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/gocookies.py#L23-L42 | train |
juju/python-libjuju | juju/controller.py | Controller.connect | async def connect(self, *args, **kwargs):
"""Connect to a Juju controller.
This supports two calling conventions:
The controller and (optionally) authentication information can be
taken from the data files created by the Juju CLI. This convention
will be used if a ``controller... | python | async def connect(self, *args, **kwargs):
"""Connect to a Juju controller.
This supports two calling conventions:
The controller and (optionally) authentication information can be
taken from the data files created by the Juju CLI. This convention
will be used if a ``controller... | [
"async",
"def",
"connect",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"await",
"self",
".",
"disconnect",
"(",
")",
"if",
"'endpoint'",
"not",
"in",
"kwargs",
"and",
"len",
"(",
"args",
")",
"<",
"2",
":",
"if",
"args",
"and",
... | Connect to a Juju controller.
This supports two calling conventions:
The controller and (optionally) authentication information can be
taken from the data files created by the Juju CLI. This convention
will be used if a ``controller_name`` is specified, or if the
``endpoint`` ... | [
"Connect",
"to",
"a",
"Juju",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L54-L133 | train |
juju/python-libjuju | juju/controller.py | Controller.add_credential | async def add_credential(self, name=None, credential=None, cloud=None,
owner=None, force=False):
"""Add or update a credential to the controller.
:param str name: Name of new credential. If None, the default
local credential is used. Name must be provided if a ... | python | async def add_credential(self, name=None, credential=None, cloud=None,
owner=None, force=False):
"""Add or update a credential to the controller.
:param str name: Name of new credential. If None, the default
local credential is used. Name must be provided if a ... | [
"async",
"def",
"add_credential",
"(",
"self",
",",
"name",
"=",
"None",
",",
"credential",
"=",
"None",
",",
"cloud",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"cloud",
":",
"cloud",
"=",
"await",
"... | Add or update a credential to the controller.
:param str name: Name of new credential. If None, the default
local credential is used. Name must be provided if a credential
is given.
:param CloudCredential credential: Credential to add. If not given,
it will attempt ... | [
"Add",
"or",
"update",
"a",
"credential",
"to",
"the",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L172-L236 | train |
juju/python-libjuju | juju/controller.py | Controller.add_model | async def add_model(
self, model_name, cloud_name=None, credential_name=None,
owner=None, config=None, region=None):
"""Add a model to this controller.
:param str model_name: Name to give the new model.
:param str cloud_name: Name of the cloud in which to create the
... | python | async def add_model(
self, model_name, cloud_name=None, credential_name=None,
owner=None, config=None, region=None):
"""Add a model to this controller.
:param str model_name: Name to give the new model.
:param str cloud_name: Name of the cloud in which to create the
... | [
"async",
"def",
"add_model",
"(",
"self",
",",
"model_name",
",",
"cloud_name",
"=",
"None",
",",
"credential_name",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"config",
"=",
"None",
",",
"region",
"=",
"None",
")",
":",
"model_facade",
"=",
"client",
... | Add a model to this controller.
:param str model_name: Name to give the new model.
:param str cloud_name: Name of the cloud in which to create the
model, e.g. 'aws'. Defaults to same cloud as controller.
:param str credential_name: Name of the credential to use when
crea... | [
"Add",
"a",
"model",
"to",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L238-L301 | train |
juju/python-libjuju | juju/controller.py | Controller.destroy_models | async def destroy_models(self, *models, destroy_storage=False):
"""Destroy one or more models.
:param str *models: Names or UUIDs of models to destroy
:param bool destroy_storage: Whether or not to destroy storage when
destroying the models. Defaults to false.
"""
u... | python | async def destroy_models(self, *models, destroy_storage=False):
"""Destroy one or more models.
:param str *models: Names or UUIDs of models to destroy
:param bool destroy_storage: Whether or not to destroy storage when
destroying the models. Defaults to false.
"""
u... | [
"async",
"def",
"destroy_models",
"(",
"self",
",",
"*",
"models",
",",
"destroy_storage",
"=",
"False",
")",
":",
"uuids",
"=",
"await",
"self",
".",
"model_uuids",
"(",
")",
"models",
"=",
"[",
"uuids",
"[",
"model",
"]",
"if",
"model",
"in",
"uuids"... | Destroy one or more models.
:param str *models: Names or UUIDs of models to destroy
:param bool destroy_storage: Whether or not to destroy storage when
destroying the models. Defaults to false. | [
"Destroy",
"one",
"or",
"more",
"models",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L303-L332 | train |
juju/python-libjuju | juju/controller.py | Controller.add_user | async def add_user(self, username, password=None, display_name=None):
"""Add a user to this controller.
:param str username: Username
:param str password: Password
:param str display_name: Display name
:returns: A :class:`~juju.user.User` instance
"""
if not disp... | python | async def add_user(self, username, password=None, display_name=None):
"""Add a user to this controller.
:param str username: Username
:param str password: Password
:param str display_name: Display name
:returns: A :class:`~juju.user.User` instance
"""
if not disp... | [
"async",
"def",
"add_user",
"(",
"self",
",",
"username",
",",
"password",
"=",
"None",
",",
"display_name",
"=",
"None",
")",
":",
"if",
"not",
"display_name",
":",
"display_name",
"=",
"username",
"user_facade",
"=",
"client",
".",
"UserManagerFacade",
"."... | Add a user to this controller.
:param str username: Username
:param str password: Password
:param str display_name: Display name
:returns: A :class:`~juju.user.User` instance | [
"Add",
"a",
"user",
"to",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L335-L352 | train |
juju/python-libjuju | juju/controller.py | Controller.remove_user | async def remove_user(self, username):
"""Remove a user from this controller.
"""
client_facade = client.UserManagerFacade.from_connection(
self.connection())
user = tag.user(username)
await client_facade.RemoveUser([client.Entity(user)]) | python | async def remove_user(self, username):
"""Remove a user from this controller.
"""
client_facade = client.UserManagerFacade.from_connection(
self.connection())
user = tag.user(username)
await client_facade.RemoveUser([client.Entity(user)]) | [
"async",
"def",
"remove_user",
"(",
"self",
",",
"username",
")",
":",
"client_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"user",
"=",
"tag",
".",
"user",
"(",
"username",
")",
... | Remove a user from this controller. | [
"Remove",
"a",
"user",
"from",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L354-L360 | train |
juju/python-libjuju | juju/controller.py | Controller.change_user_password | async def change_user_password(self, username, password):
"""Change the password for a user in this controller.
:param str username: Username
:param str password: New password
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
ent... | python | async def change_user_password(self, username, password):
"""Change the password for a user in this controller.
:param str username: Username
:param str password: New password
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
ent... | [
"async",
"def",
"change_user_password",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"user_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"entity",
"=",
"client",
".",
"Ent... | Change the password for a user in this controller.
:param str username: Username
:param str password: New password | [
"Change",
"the",
"password",
"for",
"a",
"user",
"in",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L362-L372 | train |
juju/python-libjuju | juju/controller.py | Controller.reset_user_password | async def reset_user_password(self, username):
"""Reset user password.
:param str username: Username
:returns: A :class:`~juju.user.User` instance
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(u... | python | async def reset_user_password(self, username):
"""Reset user password.
:param str username: Username
:returns: A :class:`~juju.user.User` instance
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(u... | [
"async",
"def",
"reset_user_password",
"(",
"self",
",",
"username",
")",
":",
"user_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"entity",
"=",
"client",
".",
"Entity",
"(",
"tag",
... | Reset user password.
:param str username: Username
:returns: A :class:`~juju.user.User` instance | [
"Reset",
"user",
"password",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L374-L385 | train |
juju/python-libjuju | juju/controller.py | Controller.destroy | async def destroy(self, destroy_all_models=False):
"""Destroy this controller.
:param bool destroy_all_models: Destroy all hosted models in the
controller.
"""
controller_facade = client.ControllerFacade.from_connection(
self.connection())
return await c... | python | async def destroy(self, destroy_all_models=False):
"""Destroy this controller.
:param bool destroy_all_models: Destroy all hosted models in the
controller.
"""
controller_facade = client.ControllerFacade.from_connection(
self.connection())
return await c... | [
"async",
"def",
"destroy",
"(",
"self",
",",
"destroy_all_models",
"=",
"False",
")",
":",
"controller_facade",
"=",
"client",
".",
"ControllerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"return",
"await",
"controller_facade",... | Destroy this controller.
:param bool destroy_all_models: Destroy all hosted models in the
controller. | [
"Destroy",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L387-L396 | train |
juju/python-libjuju | juju/controller.py | Controller.disable_user | async def disable_user(self, username):
"""Disable a user.
:param str username: Username
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(username))
return await user_facade.DisableUser([entity]) | python | async def disable_user(self, username):
"""Disable a user.
:param str username: Username
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(username))
return await user_facade.DisableUser([entity]) | [
"async",
"def",
"disable_user",
"(",
"self",
",",
"username",
")",
":",
"user_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"entity",
"=",
"client",
".",
"Entity",
"(",
"tag",
".",
... | Disable a user.
:param str username: Username | [
"Disable",
"a",
"user",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L398-L407 | train |
juju/python-libjuju | juju/controller.py | Controller.enable_user | async def enable_user(self, username):
"""Re-enable a previously disabled user.
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(username))
return await user_facade.EnableUser([entity]) | python | async def enable_user(self, username):
"""Re-enable a previously disabled user.
"""
user_facade = client.UserManagerFacade.from_connection(
self.connection())
entity = client.Entity(tag.user(username))
return await user_facade.EnableUser([entity]) | [
"async",
"def",
"enable_user",
"(",
"self",
",",
"username",
")",
":",
"user_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"entity",
"=",
"client",
".",
"Entity",
"(",
"tag",
".",
... | Re-enable a previously disabled user. | [
"Re",
"-",
"enable",
"a",
"previously",
"disabled",
"user",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L409-L416 | train |
juju/python-libjuju | juju/controller.py | Controller.get_cloud | async def get_cloud(self):
"""
Get the name of the cloud that this controller lives on.
"""
cloud_facade = client.CloudFacade.from_connection(self.connection())
result = await cloud_facade.Clouds()
cloud = list(result.clouds.keys())[0] # only lives on one cloud
... | python | async def get_cloud(self):
"""
Get the name of the cloud that this controller lives on.
"""
cloud_facade = client.CloudFacade.from_connection(self.connection())
result = await cloud_facade.Clouds()
cloud = list(result.clouds.keys())[0] # only lives on one cloud
... | [
"async",
"def",
"get_cloud",
"(",
"self",
")",
":",
"cloud_facade",
"=",
"client",
".",
"CloudFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"result",
"=",
"await",
"cloud_facade",
".",
"Clouds",
"(",
")",
"cloud",
"=",
"... | Get the name of the cloud that this controller lives on. | [
"Get",
"the",
"name",
"of",
"the",
"cloud",
"that",
"this",
"controller",
"lives",
"on",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L425-L433 | train |
juju/python-libjuju | juju/controller.py | Controller.model_uuids | async def model_uuids(self):
"""Return a mapping of model names to UUIDs.
"""
controller_facade = client.ControllerFacade.from_connection(
self.connection())
for attempt in (1, 2, 3):
try:
response = await controller_facade.AllModels()
... | python | async def model_uuids(self):
"""Return a mapping of model names to UUIDs.
"""
controller_facade = client.ControllerFacade.from_connection(
self.connection())
for attempt in (1, 2, 3):
try:
response = await controller_facade.AllModels()
... | [
"async",
"def",
"model_uuids",
"(",
"self",
")",
":",
"controller_facade",
"=",
"client",
".",
"ControllerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"for",
"attempt",
"in",
"(",
"1",
",",
"2",
",",
"3",
")",
":",
"t... | Return a mapping of model names to UUIDs. | [
"Return",
"a",
"mapping",
"of",
"model",
"names",
"to",
"UUIDs",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L451-L466 | train |
juju/python-libjuju | juju/controller.py | Controller.get_model | async def get_model(self, model):
"""Get a model by name or UUID.
:param str model: Model name or UUID
:returns Model: Connected Model instance.
"""
uuids = await self.model_uuids()
if model in uuids:
uuid = uuids[model]
else:
uuid = model... | python | async def get_model(self, model):
"""Get a model by name or UUID.
:param str model: Model name or UUID
:returns Model: Connected Model instance.
"""
uuids = await self.model_uuids()
if model in uuids:
uuid = uuids[model]
else:
uuid = model... | [
"async",
"def",
"get_model",
"(",
"self",
",",
"model",
")",
":",
"uuids",
"=",
"await",
"self",
".",
"model_uuids",
"(",
")",
"if",
"model",
"in",
"uuids",
":",
"uuid",
"=",
"uuids",
"[",
"model",
"]",
"else",
":",
"uuid",
"=",
"model",
"from",
"j... | Get a model by name or UUID.
:param str model: Model name or UUID
:returns Model: Connected Model instance. | [
"Get",
"a",
"model",
"by",
"name",
"or",
"UUID",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L509-L526 | train |
juju/python-libjuju | juju/controller.py | Controller.get_user | async def get_user(self, username, secret_key=None):
"""Get a user by name.
:param str username: Username
:param str secret_key: Issued by juju when add or reset user
password
:returns: A :class:`~juju.user.User` instance
"""
client_facade = client.UserManage... | python | async def get_user(self, username, secret_key=None):
"""Get a user by name.
:param str username: Username
:param str secret_key: Issued by juju when add or reset user
password
:returns: A :class:`~juju.user.User` instance
"""
client_facade = client.UserManage... | [
"async",
"def",
"get_user",
"(",
"self",
",",
"username",
",",
"secret_key",
"=",
"None",
")",
":",
"client_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"user",
"=",
"tag",
".",
... | Get a user by name.
:param str username: Username
:param str secret_key: Issued by juju when add or reset user
password
:returns: A :class:`~juju.user.User` instance | [
"Get",
"a",
"user",
"by",
"name",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L528-L550 | train |
juju/python-libjuju | juju/controller.py | Controller.get_users | async def get_users(self, include_disabled=False):
"""Return list of users that can connect to this controller.
:param bool include_disabled: Include disabled users
:returns: A list of :class:`~juju.user.User` instances
"""
client_facade = client.UserManagerFacade.from_connectio... | python | async def get_users(self, include_disabled=False):
"""Return list of users that can connect to this controller.
:param bool include_disabled: Include disabled users
:returns: A list of :class:`~juju.user.User` instances
"""
client_facade = client.UserManagerFacade.from_connectio... | [
"async",
"def",
"get_users",
"(",
"self",
",",
"include_disabled",
"=",
"False",
")",
":",
"client_facade",
"=",
"client",
".",
"UserManagerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"response",
"=",
"await",
"client_facade... | Return list of users that can connect to this controller.
:param bool include_disabled: Include disabled users
:returns: A list of :class:`~juju.user.User` instances | [
"Return",
"list",
"of",
"users",
"that",
"can",
"connect",
"to",
"this",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L552-L561 | train |
juju/python-libjuju | juju/controller.py | Controller.revoke | async def revoke(self, username, acl='login'):
"""Removes some or all access of a user to from a controller
If 'login' access is revoked, the user will no longer have any
permissions on the controller. Revoking a higher privilege from
a user without that privilege will have no effect.
... | python | async def revoke(self, username, acl='login'):
"""Removes some or all access of a user to from a controller
If 'login' access is revoked, the user will no longer have any
permissions on the controller. Revoking a higher privilege from
a user without that privilege will have no effect.
... | [
"async",
"def",
"revoke",
"(",
"self",
",",
"username",
",",
"acl",
"=",
"'login'",
")",
":",
"controller_facade",
"=",
"client",
".",
"ControllerFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"user",
"=",
"tag",
".",
"us... | Removes some or all access of a user to from a controller
If 'login' access is revoked, the user will no longer have any
permissions on the controller. Revoking a higher privilege from
a user without that privilege will have no effect.
:param str username: username
:param str ac... | [
"Removes",
"some",
"or",
"all",
"access",
"of",
"a",
"user",
"to",
"from",
"a",
"controller",
"If",
"login",
"access",
"is",
"revoked",
"the",
"user",
"will",
"no",
"longer",
"have",
"any",
"permissions",
"on",
"the",
"controller",
".",
"Revoking",
"a",
... | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L586-L599 | train |
juju/python-libjuju | juju/client/jujudata.py | FileJujuData.current_model | def current_model(self, controller_name=None, model_only=False):
'''Return the current model, qualified by its controller name.
If controller_name is specified, the current model for
that controller will be returned.
If model_only is true, only the model name, not qualified by
i... | python | def current_model(self, controller_name=None, model_only=False):
'''Return the current model, qualified by its controller name.
If controller_name is specified, the current model for
that controller will be returned.
If model_only is true, only the model name, not qualified by
i... | [
"def",
"current_model",
"(",
"self",
",",
"controller_name",
"=",
"None",
",",
"model_only",
"=",
"False",
")",
":",
"if",
"not",
"controller_name",
":",
"controller_name",
"=",
"self",
".",
"current_controller",
"(",
")",
"if",
"not",
"controller_name",
":",
... | Return the current model, qualified by its controller name.
If controller_name is specified, the current model for
that controller will be returned.
If model_only is true, only the model name, not qualified by
its controller name, will be returned. | [
"Return",
"the",
"current",
"model",
"qualified",
"by",
"its",
"controller",
"name",
".",
"If",
"controller_name",
"is",
"specified",
"the",
"current",
"model",
"for",
"that",
"controller",
"will",
"be",
"returned",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/jujudata.py#L139-L157 | train |
juju/python-libjuju | juju/client/jujudata.py | FileJujuData.load_credential | def load_credential(self, cloud, name=None):
"""Load a local credential.
:param str cloud: Name of cloud to load credentials from.
:param str name: Name of credential. If None, the default credential
will be used, if available.
:return: A CloudCredential instance, or None.
... | python | def load_credential(self, cloud, name=None):
"""Load a local credential.
:param str cloud: Name of cloud to load credentials from.
:param str name: Name of credential. If None, the default credential
will be used, if available.
:return: A CloudCredential instance, or None.
... | [
"def",
"load_credential",
"(",
"self",
",",
"cloud",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"cloud",
"=",
"tag",
".",
"untag",
"(",
"'cloud-'",
",",
"cloud",
")",
"creds_data",
"=",
"self",
".",
"credentials",
"(",
")",
"[",
"cloud",
"]",
... | Load a local credential.
:param str cloud: Name of cloud to load credentials from.
:param str name: Name of credential. If None, the default credential
will be used, if available.
:return: A CloudCredential instance, or None. | [
"Load",
"a",
"local",
"credential",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/jujudata.py#L159-L186 | train |
juju/python-libjuju | juju/client/connection.py | _macaroons_for_domain | def _macaroons_for_domain(cookies, domain):
'''Return any macaroons from the given cookie jar that
apply to the given domain name.'''
req = urllib.request.Request('https://' + domain + '/')
cookies.add_cookie_header(req)
return httpbakery.extract_macaroons(req) | python | def _macaroons_for_domain(cookies, domain):
'''Return any macaroons from the given cookie jar that
apply to the given domain name.'''
req = urllib.request.Request('https://' + domain + '/')
cookies.add_cookie_header(req)
return httpbakery.extract_macaroons(req) | [
"def",
"_macaroons_for_domain",
"(",
"cookies",
",",
"domain",
")",
":",
"req",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"'https://'",
"+",
"domain",
"+",
"'/'",
")",
"cookies",
".",
"add_cookie_header",
"(",
"req",
")",
"return",
"httpbakery",
... | Return any macaroons from the given cookie jar that
apply to the given domain name. | [
"Return",
"any",
"macaroons",
"from",
"the",
"given",
"cookie",
"jar",
"that",
"apply",
"to",
"the",
"given",
"domain",
"name",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L596-L601 | train |
juju/python-libjuju | juju/client/connection.py | Monitor.status | def status(self):
"""
Determine the status of the connection and receiver, and return
ERROR, CONNECTED, or DISCONNECTED as appropriate.
For simplicity, we only consider ourselves to be connected
after the Connection class has setup a receiver task. This
only happens afte... | python | def status(self):
"""
Determine the status of the connection and receiver, and return
ERROR, CONNECTED, or DISCONNECTED as appropriate.
For simplicity, we only consider ourselves to be connected
after the Connection class has setup a receiver task. This
only happens afte... | [
"def",
"status",
"(",
"self",
")",
":",
"connection",
"=",
"self",
".",
"connection",
"(",
")",
"if",
"not",
"connection",
":",
"return",
"self",
".",
"DISCONNECTED",
"if",
"not",
"connection",
".",
"ws",
":",
"return",
"self",
".",
"DISCONNECTED",
"if",... | Determine the status of the connection and receiver, and return
ERROR, CONNECTED, or DISCONNECTED as appropriate.
For simplicity, we only consider ourselves to be connected
after the Connection class has setup a receiver task. This
only happens after the websocket is open, and the conne... | [
"Determine",
"the",
"status",
"of",
"the",
"connection",
"and",
"receiver",
"and",
"return",
"ERROR",
"CONNECTED",
"or",
"DISCONNECTED",
"as",
"appropriate",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L46-L78 | train |
juju/python-libjuju | juju/client/connection.py | Connection._pinger | async def _pinger(self):
'''
A Controller can time us out if we are silent for too long. This
is especially true in JaaS, which has a fairly strict timeout.
To prevent timing out, we send a ping every ten seconds.
'''
async def _do_ping():
try:
... | python | async def _pinger(self):
'''
A Controller can time us out if we are silent for too long. This
is especially true in JaaS, which has a fairly strict timeout.
To prevent timing out, we send a ping every ten seconds.
'''
async def _do_ping():
try:
... | [
"async",
"def",
"_pinger",
"(",
"self",
")",
":",
"async",
"def",
"_do_ping",
"(",
")",
":",
"try",
":",
"await",
"pinger_facade",
".",
"Ping",
"(",
")",
"await",
"asyncio",
".",
"sleep",
"(",
"10",
",",
"loop",
"=",
"self",
".",
"loop",
")",
"exce... | A Controller can time us out if we are silent for too long. This
is especially true in JaaS, which has a fairly strict timeout.
To prevent timing out, we send a ping every ten seconds. | [
"A",
"Controller",
"can",
"time",
"us",
"out",
"if",
"we",
"are",
"silent",
"for",
"too",
"long",
".",
"This",
"is",
"especially",
"true",
"in",
"JaaS",
"which",
"has",
"a",
"fairly",
"strict",
"timeout",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L250-L278 | train |
juju/python-libjuju | juju/client/connection.py | Connection._http_headers | def _http_headers(self):
"""Return dictionary of http headers necessary for making an http
connection to the endpoint of this Connection.
:return: Dictionary of headers
"""
if not self.usertag:
return {}
creds = u'{}:{}'.format(
self.usertag,
... | python | def _http_headers(self):
"""Return dictionary of http headers necessary for making an http
connection to the endpoint of this Connection.
:return: Dictionary of headers
"""
if not self.usertag:
return {}
creds = u'{}:{}'.format(
self.usertag,
... | [
"def",
"_http_headers",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"usertag",
":",
"return",
"{",
"}",
"creds",
"=",
"u'{}:{}'",
".",
"format",
"(",
"self",
".",
"usertag",
",",
"self",
".",
"password",
"or",
"''",
")",
"token",
"=",
"base64",
... | Return dictionary of http headers necessary for making an http
connection to the endpoint of this Connection.
:return: Dictionary of headers | [
"Return",
"dictionary",
"of",
"http",
"headers",
"necessary",
"for",
"making",
"an",
"http",
"connection",
"to",
"the",
"endpoint",
"of",
"this",
"Connection",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L350-L367 | train |
juju/python-libjuju | juju/client/connection.py | Connection.https_connection | def https_connection(self):
"""Return an https connection to this Connection's endpoint.
Returns a 3-tuple containing::
1. The :class:`HTTPSConnection` instance
2. Dictionary of auth headers to be used with the connection
3. The root url path (str) to be used for re... | python | def https_connection(self):
"""Return an https connection to this Connection's endpoint.
Returns a 3-tuple containing::
1. The :class:`HTTPSConnection` instance
2. Dictionary of auth headers to be used with the connection
3. The root url path (str) to be used for re... | [
"def",
"https_connection",
"(",
"self",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoint",
"host",
",",
"remainder",
"=",
"endpoint",
".",
"split",
"(",
"':'",
",",
"1",
")",
"port",
"=",
"remainder",
"if",
"'/'",
"in",
"remainder",
":",
"port",
",",
... | Return an https connection to this Connection's endpoint.
Returns a 3-tuple containing::
1. The :class:`HTTPSConnection` instance
2. Dictionary of auth headers to be used with the connection
3. The root url path (str) to be used for requests. | [
"Return",
"an",
"https",
"connection",
"to",
"this",
"Connection",
"s",
"endpoint",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L369-L394 | train |
juju/python-libjuju | juju/client/connection.py | Connection.connect_params | def connect_params(self):
"""Return a tuple of parameters suitable for passing to
Connection.connect that can be used to make a new connection
to the same controller (and model if specified. The first
element in the returned tuple holds the endpoint argument;
the other holds a di... | python | def connect_params(self):
"""Return a tuple of parameters suitable for passing to
Connection.connect that can be used to make a new connection
to the same controller (and model if specified. The first
element in the returned tuple holds the endpoint argument;
the other holds a di... | [
"def",
"connect_params",
"(",
"self",
")",
":",
"return",
"{",
"'endpoint'",
":",
"self",
".",
"endpoint",
",",
"'uuid'",
":",
"self",
".",
"uuid",
",",
"'username'",
":",
"self",
".",
"username",
",",
"'password'",
":",
"self",
".",
"password",
",",
"... | Return a tuple of parameters suitable for passing to
Connection.connect that can be used to make a new connection
to the same controller (and model if specified. The first
element in the returned tuple holds the endpoint argument;
the other holds a dict of the keyword args. | [
"Return",
"a",
"tuple",
"of",
"parameters",
"suitable",
"for",
"passing",
"to",
"Connection",
".",
"connect",
"that",
"can",
"be",
"used",
"to",
"make",
"a",
"new",
"connection",
"to",
"the",
"same",
"controller",
"(",
"and",
"model",
"if",
"specified",
".... | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L403-L419 | train |
juju/python-libjuju | juju/client/connection.py | Connection.controller | async def controller(self):
"""Return a Connection to the controller at self.endpoint
"""
return await Connection.connect(
self.endpoint,
username=self.username,
password=self.password,
cacert=self.cacert,
bakery_client=self.bakery_clie... | python | async def controller(self):
"""Return a Connection to the controller at self.endpoint
"""
return await Connection.connect(
self.endpoint,
username=self.username,
password=self.password,
cacert=self.cacert,
bakery_client=self.bakery_clie... | [
"async",
"def",
"controller",
"(",
"self",
")",
":",
"return",
"await",
"Connection",
".",
"connect",
"(",
"self",
".",
"endpoint",
",",
"username",
"=",
"self",
".",
"username",
",",
"password",
"=",
"self",
".",
"password",
",",
"cacert",
"=",
"self",
... | Return a Connection to the controller at self.endpoint | [
"Return",
"a",
"Connection",
"to",
"the",
"controller",
"at",
"self",
".",
"endpoint"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L421-L432 | train |
juju/python-libjuju | juju/client/connection.py | Connection.reconnect | async def reconnect(self):
""" Force a reconnection.
"""
monitor = self.monitor
if monitor.reconnecting.locked() or monitor.close_called.is_set():
return
async with monitor.reconnecting:
await self.close()
await self._connect_with_login([(self.... | python | async def reconnect(self):
""" Force a reconnection.
"""
monitor = self.monitor
if monitor.reconnecting.locked() or monitor.close_called.is_set():
return
async with monitor.reconnecting:
await self.close()
await self._connect_with_login([(self.... | [
"async",
"def",
"reconnect",
"(",
"self",
")",
":",
"monitor",
"=",
"self",
".",
"monitor",
"if",
"monitor",
".",
"reconnecting",
".",
"locked",
"(",
")",
"or",
"monitor",
".",
"close_called",
".",
"is_set",
"(",
")",
":",
"return",
"async",
"with",
"m... | Force a reconnection. | [
"Force",
"a",
"reconnection",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L434-L442 | train |
juju/python-libjuju | juju/client/connector.py | Connector.connect | async def connect(self, **kwargs):
"""Connect to an arbitrary Juju model.
kwargs are passed through to Connection.connect()
"""
kwargs.setdefault('loop', self.loop)
kwargs.setdefault('max_frame_size', self.max_frame_size)
kwargs.setdefault('bakery_client', self.bakery_cl... | python | async def connect(self, **kwargs):
"""Connect to an arbitrary Juju model.
kwargs are passed through to Connection.connect()
"""
kwargs.setdefault('loop', self.loop)
kwargs.setdefault('max_frame_size', self.max_frame_size)
kwargs.setdefault('bakery_client', self.bakery_cl... | [
"async",
"def",
"connect",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'loop'",
",",
"self",
".",
"loop",
")",
"kwargs",
".",
"setdefault",
"(",
"'max_frame_size'",
",",
"self",
".",
"max_frame_size",
")",
"kwargs",
"."... | Connect to an arbitrary Juju model.
kwargs are passed through to Connection.connect() | [
"Connect",
"to",
"an",
"arbitrary",
"Juju",
"model",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connector.py#L52-L68 | train |
juju/python-libjuju | juju/client/connector.py | Connector.connect_controller | async def connect_controller(self, controller_name=None):
"""Connect to a controller by name. If the name is empty, it
connect to the current controller.
"""
if not controller_name:
controller_name = self.jujudata.current_controller()
if not controller_name:
... | python | async def connect_controller(self, controller_name=None):
"""Connect to a controller by name. If the name is empty, it
connect to the current controller.
"""
if not controller_name:
controller_name = self.jujudata.current_controller()
if not controller_name:
... | [
"async",
"def",
"connect_controller",
"(",
"self",
",",
"controller_name",
"=",
"None",
")",
":",
"if",
"not",
"controller_name",
":",
"controller_name",
"=",
"self",
".",
"jujudata",
".",
"current_controller",
"(",
")",
"if",
"not",
"controller_name",
":",
"r... | Connect to a controller by name. If the name is empty, it
connect to the current controller. | [
"Connect",
"to",
"a",
"controller",
"by",
"name",
".",
"If",
"the",
"name",
"is",
"empty",
"it",
"connect",
"to",
"the",
"current",
"controller",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connector.py#L78-L101 | train |
juju/python-libjuju | juju/client/connector.py | Connector.bakery_client_for_controller | def bakery_client_for_controller(self, controller_name):
'''Make a copy of the bakery client with a the appropriate controller's
cookiejar in it.
'''
bakery_client = self.bakery_client
if bakery_client:
bakery_client = copy.copy(bakery_client)
else:
... | python | def bakery_client_for_controller(self, controller_name):
'''Make a copy of the bakery client with a the appropriate controller's
cookiejar in it.
'''
bakery_client = self.bakery_client
if bakery_client:
bakery_client = copy.copy(bakery_client)
else:
... | [
"def",
"bakery_client_for_controller",
"(",
"self",
",",
"controller_name",
")",
":",
"bakery_client",
"=",
"self",
".",
"bakery_client",
"if",
"bakery_client",
":",
"bakery_client",
"=",
"copy",
".",
"copy",
"(",
"bakery_client",
")",
"else",
":",
"bakery_client"... | Make a copy of the bakery client with a the appropriate controller's
cookiejar in it. | [
"Make",
"a",
"copy",
"of",
"the",
"bakery",
"client",
"with",
"a",
"the",
"appropriate",
"controller",
"s",
"cookiejar",
"in",
"it",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connector.py#L145-L156 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner._get_ssh_client | def _get_ssh_client(self, host, user, key):
"""Return a connected Paramiko ssh object.
:param str host: The host to connect to.
:param str user: The user to connect as.
:param str key: The private key to authenticate with.
:return: object: A paramiko.SSHClient
:raises: ... | python | def _get_ssh_client(self, host, user, key):
"""Return a connected Paramiko ssh object.
:param str host: The host to connect to.
:param str user: The user to connect as.
:param str key: The private key to authenticate with.
:return: object: A paramiko.SSHClient
:raises: ... | [
"def",
"_get_ssh_client",
"(",
"self",
",",
"host",
",",
"user",
",",
"key",
")",
":",
"ssh",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"ssh",
".",
"set_missing_host_key_policy",
"(",
"paramiko",
".",
"AutoAddPolicy",
"(",
")",
")",
"pkey",
"=",
"None... | Return a connected Paramiko ssh object.
:param str host: The host to connect to.
:param str user: The user to connect as.
:param str key: The private key to authenticate with.
:return: object: A paramiko.SSHClient
:raises: :class:`paramiko.ssh_exception.SSHException` if the
... | [
"Return",
"a",
"connected",
"Paramiko",
"ssh",
"object",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L72-L117 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner._run_command | def _run_command(self, ssh, cmd, pty=True):
"""Run a command remotely via SSH.
:param object ssh: The SSHClient
:param str cmd: The command to execute
:param list cmd: The `shlex.split` command to execute
:param bool pty: Whether to allocate a pty
:return: tuple: The st... | python | def _run_command(self, ssh, cmd, pty=True):
"""Run a command remotely via SSH.
:param object ssh: The SSHClient
:param str cmd: The command to execute
:param list cmd: The `shlex.split` command to execute
:param bool pty: Whether to allocate a pty
:return: tuple: The st... | [
"def",
"_run_command",
"(",
"self",
",",
"ssh",
",",
"cmd",
",",
"pty",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"str",
")",
":",
"cmd",
"=",
"shlex",
".",
"split",
"(",
"cmd",
")",
"if",
"type",
"(",
"cmd",
")",
"is",
"not",... | Run a command remotely via SSH.
:param object ssh: The SSHClient
:param str cmd: The command to execute
:param list cmd: The `shlex.split` command to execute
:param bool pty: Whether to allocate a pty
:return: tuple: The stdout and stderr of the command execution
:raise... | [
"Run",
"a",
"command",
"remotely",
"via",
"SSH",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L119-L148 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner._init_ubuntu_user | def _init_ubuntu_user(self):
"""Initialize the ubuntu user.
:return: bool: If the initialization was successful
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the authentication fails
"""
# TODO: Test this on an image without the ubuntu user set... | python | def _init_ubuntu_user(self):
"""Initialize the ubuntu user.
:return: bool: If the initialization was successful
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the authentication fails
"""
# TODO: Test this on an image without the ubuntu user set... | [
"def",
"_init_ubuntu_user",
"(",
"self",
")",
":",
"auth_user",
"=",
"self",
".",
"user",
"ssh",
"=",
"None",
"try",
":",
"ssh",
"=",
"self",
".",
"_get_ssh_client",
"(",
"self",
".",
"host",
",",
"\"ubuntu\"",
",",
"self",
".",
"private_key_path",
",",
... | Initialize the ubuntu user.
:return: bool: If the initialization was successful
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the authentication fails | [
"Initialize",
"the",
"ubuntu",
"user",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L150-L212 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner._detect_hardware_and_os | def _detect_hardware_and_os(self, ssh):
"""Detect the target hardware capabilities and OS series.
:param object ssh: The SSHClient
:return: str: A raw string containing OS and hardware information.
"""
info = {
'series': '',
'arch': '',
'cpu-... | python | def _detect_hardware_and_os(self, ssh):
"""Detect the target hardware capabilities and OS series.
:param object ssh: The SSHClient
:return: str: A raw string containing OS and hardware information.
"""
info = {
'series': '',
'arch': '',
'cpu-... | [
"def",
"_detect_hardware_and_os",
"(",
"self",
",",
"ssh",
")",
":",
"info",
"=",
"{",
"'series'",
":",
"''",
",",
"'arch'",
":",
"''",
",",
"'cpu-cores'",
":",
"''",
",",
"'mem'",
":",
"''",
",",
"}",
"stdout",
",",
"stderr",
"=",
"self",
".",
"_r... | Detect the target hardware capabilities and OS series.
:param object ssh: The SSHClient
:return: str: A raw string containing OS and hardware information. | [
"Detect",
"the",
"target",
"hardware",
"capabilities",
"and",
"OS",
"series",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L214-L258 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner.provision_machine | def provision_machine(self):
"""Perform the initial provisioning of the target machine.
:return: bool: The client.AddMachineParams
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails
"""
params = client.AddMachineParams()
if ... | python | def provision_machine(self):
"""Perform the initial provisioning of the target machine.
:return: bool: The client.AddMachineParams
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails
"""
params = client.AddMachineParams()
if ... | [
"def",
"provision_machine",
"(",
"self",
")",
":",
"params",
"=",
"client",
".",
"AddMachineParams",
"(",
")",
"if",
"self",
".",
"_init_ubuntu_user",
"(",
")",
":",
"try",
":",
"ssh",
"=",
"self",
".",
"_get_ssh_client",
"(",
"self",
".",
"host",
",",
... | Perform the initial provisioning of the target machine.
:return: bool: The client.AddMachineParams
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails | [
"Perform",
"the",
"initial",
"provisioning",
"of",
"the",
"target",
"machine",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L260-L301 | train |
juju/python-libjuju | juju/provisioner.py | SSHProvisioner._run_configure_script | def _run_configure_script(self, script):
"""Run the script to install the Juju agent on the target machine.
:param str script: The script returned by the ProvisioningScript API
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails
"""
... | python | def _run_configure_script(self, script):
"""Run the script to install the Juju agent on the target machine.
:param str script: The script returned by the ProvisioningScript API
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails
"""
... | [
"def",
"_run_configure_script",
"(",
"self",
",",
"script",
")",
":",
"_",
",",
"tmpFile",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"with",
"open",
"(",
"tmpFile",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"script",
")",
"try",
":"... | Run the script to install the Juju agent on the target machine.
:param str script: The script returned by the ProvisioningScript API
:raises: :class:`paramiko.ssh_exception.AuthenticationException`
if the upload fails | [
"Run",
"the",
"script",
"to",
"install",
"the",
"Juju",
"agent",
"on",
"the",
"target",
"machine",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/provisioner.py#L329-L366 | train |
juju/python-libjuju | juju/annotationhelper.py | _get_annotations | async def _get_annotations(entity_tag, connection):
"""Get annotations for the specified entity
:return dict: The annotations for the entity
"""
facade = client.AnnotationsFacade.from_connection(connection)
result = (await facade.Get([{"tag": entity_tag}])).results[0]
if result.error is not Non... | python | async def _get_annotations(entity_tag, connection):
"""Get annotations for the specified entity
:return dict: The annotations for the entity
"""
facade = client.AnnotationsFacade.from_connection(connection)
result = (await facade.Get([{"tag": entity_tag}])).results[0]
if result.error is not Non... | [
"async",
"def",
"_get_annotations",
"(",
"entity_tag",
",",
"connection",
")",
":",
"facade",
"=",
"client",
".",
"AnnotationsFacade",
".",
"from_connection",
"(",
"connection",
")",
"result",
"=",
"(",
"await",
"facade",
".",
"Get",
"(",
"[",
"{",
"\"tag\""... | Get annotations for the specified entity
:return dict: The annotations for the entity | [
"Get",
"annotations",
"for",
"the",
"specified",
"entity"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/annotationhelper.py#L9-L18 | train |
juju/python-libjuju | juju/annotationhelper.py | _set_annotations | async def _set_annotations(entity_tag, annotations, connection):
"""Set annotations on the specified entity.
:param annotations map[string]string: the annotations as key/value
pairs.
"""
# TODO: ensure annotations is dict with only string keys
# and values.
log.debug('Updating annotatio... | python | async def _set_annotations(entity_tag, annotations, connection):
"""Set annotations on the specified entity.
:param annotations map[string]string: the annotations as key/value
pairs.
"""
# TODO: ensure annotations is dict with only string keys
# and values.
log.debug('Updating annotatio... | [
"async",
"def",
"_set_annotations",
"(",
"entity_tag",
",",
"annotations",
",",
"connection",
")",
":",
"log",
".",
"debug",
"(",
"'Updating annotations on %s'",
",",
"entity_tag",
")",
"facade",
"=",
"client",
".",
"AnnotationsFacade",
".",
"from_connection",
"("... | Set annotations on the specified entity.
:param annotations map[string]string: the annotations as key/value
pairs. | [
"Set",
"annotations",
"on",
"the",
"specified",
"entity",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/annotationhelper.py#L21-L35 | train |
juju/python-libjuju | juju/relation.py | Relation.matches | def matches(self, *specs):
"""
Check if this relation matches relationship specs.
Relation specs are strings that would be given to Juju to establish a
relation, and should be in the form ``<application>[:<endpoint_name>]``
where the ``:<endpoint_name>`` suffix is optional. If ... | python | def matches(self, *specs):
"""
Check if this relation matches relationship specs.
Relation specs are strings that would be given to Juju to establish a
relation, and should be in the form ``<application>[:<endpoint_name>]``
where the ``:<endpoint_name>`` suffix is optional. If ... | [
"def",
"matches",
"(",
"self",
",",
"*",
"specs",
")",
":",
"for",
"spec",
"in",
"specs",
":",
"if",
"':'",
"in",
"spec",
":",
"app_name",
",",
"endpoint_name",
"=",
"spec",
".",
"split",
"(",
"':'",
")",
"else",
":",
"app_name",
",",
"endpoint_name"... | Check if this relation matches relationship specs.
Relation specs are strings that would be given to Juju to establish a
relation, and should be in the form ``<application>[:<endpoint_name>]``
where the ``:<endpoint_name>`` suffix is optional. If the suffix is
omitted, this relation wi... | [
"Check",
"if",
"this",
"relation",
"matches",
"relationship",
"specs",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/relation.py#L84-L112 | train |
juju/python-libjuju | juju/client/overrides.py | ResourcesFacade.AddPendingResources | async def AddPendingResources(self, application_tag, charm_url, resources):
"""Fix the calling signature of AddPendingResources.
The ResourcesFacade doesn't conform to the standard facade pattern in
the Juju source, which leads to the schemagened code not matching up
properly with the a... | python | async def AddPendingResources(self, application_tag, charm_url, resources):
"""Fix the calling signature of AddPendingResources.
The ResourcesFacade doesn't conform to the standard facade pattern in
the Juju source, which leads to the schemagened code not matching up
properly with the a... | [
"async",
"def",
"AddPendingResources",
"(",
"self",
",",
"application_tag",
",",
"charm_url",
",",
"resources",
")",
":",
"_params",
"=",
"dict",
"(",
")",
"msg",
"=",
"dict",
"(",
"type",
"=",
"'Resources'",
",",
"request",
"=",
"'AddPendingResources'",
","... | Fix the calling signature of AddPendingResources.
The ResourcesFacade doesn't conform to the standard facade pattern in
the Juju source, which leads to the schemagened code not matching up
properly with the actual calling convention in the API. There is work
planned to fix this in Juju... | [
"Fix",
"the",
"calling",
"signature",
"of",
"AddPendingResources",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/overrides.py#L65-L89 | train |
juju/python-libjuju | juju/cloud.py | Cloud.bootstrap | def bootstrap(
self, controller_name, region=None, agent_version=None,
auto_upgrade=False, bootstrap_constraints=None,
bootstrap_series=None, config=None, constraints=None,
credential=None, default_model=None, keep_broken=False,
metadata_source=None, no_gui=Fa... | python | def bootstrap(
self, controller_name, region=None, agent_version=None,
auto_upgrade=False, bootstrap_constraints=None,
bootstrap_series=None, config=None, constraints=None,
credential=None, default_model=None, keep_broken=False,
metadata_source=None, no_gui=Fa... | [
"def",
"bootstrap",
"(",
"self",
",",
"controller_name",
",",
"region",
"=",
"None",
",",
"agent_version",
"=",
"None",
",",
"auto_upgrade",
"=",
"False",
",",
"bootstrap_constraints",
"=",
"None",
",",
"bootstrap_series",
"=",
"None",
",",
"config",
"=",
"N... | Initialize a cloud environment.
:param str controller_name: Name of controller to create
:param str region: Cloud region in which to bootstrap
:param str agent_version: Version of tools to use for Juju agents
:param bool auto_upgrade: Upgrade to latest path release tools on first
... | [
"Initialize",
"a",
"cloud",
"environment",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/cloud.py#L29-L65 | train |
juju/python-libjuju | juju/unit.py | Unit.machine | def machine(self):
"""Get the machine object for this unit.
"""
machine_id = self.safe_data['machine-id']
if machine_id:
return self.model.machines.get(machine_id, None)
else:
return None | python | def machine(self):
"""Get the machine object for this unit.
"""
machine_id = self.safe_data['machine-id']
if machine_id:
return self.model.machines.get(machine_id, None)
else:
return None | [
"def",
"machine",
"(",
"self",
")",
":",
"machine_id",
"=",
"self",
".",
"safe_data",
"[",
"'machine-id'",
"]",
"if",
"machine_id",
":",
"return",
"self",
".",
"model",
".",
"machines",
".",
"get",
"(",
"machine_id",
",",
"None",
")",
"else",
":",
"ret... | Get the machine object for this unit. | [
"Get",
"the",
"machine",
"object",
"for",
"this",
"unit",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/unit.py#L56-L64 | train |
juju/python-libjuju | juju/unit.py | Unit.run | async def run(self, command, timeout=None):
"""Run command on this unit.
:param str command: The command to run
:param int timeout: Time, in seconds, to wait before command is
considered failed
:returns: A :class:`juju.action.Action` instance.
"""
action = clien... | python | async def run(self, command, timeout=None):
"""Run command on this unit.
:param str command: The command to run
:param int timeout: Time, in seconds, to wait before command is
considered failed
:returns: A :class:`juju.action.Action` instance.
"""
action = clien... | [
"async",
"def",
"run",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"None",
")",
":",
"action",
"=",
"client",
".",
"ActionFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Running `%s` on %s'",
",",
"... | Run command on this unit.
:param str command: The command to run
:param int timeout: Time, in seconds, to wait before command is
considered failed
:returns: A :class:`juju.action.Action` instance. | [
"Run",
"command",
"on",
"this",
"unit",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/unit.py#L122-L147 | train |
juju/python-libjuju | juju/unit.py | Unit.run_action | async def run_action(self, action_name, **params):
"""Run an action on this unit.
:param str action_name: Name of action to run
:param **params: Action parameters
:returns: A :class:`juju.action.Action` instance.
Note that this only enqueues the action. You will need to call
... | python | async def run_action(self, action_name, **params):
"""Run an action on this unit.
:param str action_name: Name of action to run
:param **params: Action parameters
:returns: A :class:`juju.action.Action` instance.
Note that this only enqueues the action. You will need to call
... | [
"async",
"def",
"run_action",
"(",
"self",
",",
"action_name",
",",
"**",
"params",
")",
":",
"action_facade",
"=",
"client",
".",
"ActionFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Starting action `%s` on ... | Run an action on this unit.
:param str action_name: Name of action to run
:param **params: Action parameters
:returns: A :class:`juju.action.Action` instance.
Note that this only enqueues the action. You will need to call
``action.wait()`` on the resulting `Action` instance if... | [
"Run",
"an",
"action",
"on",
"this",
"unit",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/unit.py#L149-L181 | train |
juju/python-libjuju | juju/unit.py | Unit.scp_to | async def scp_to(self, source, destination, user='ubuntu', proxy=False,
scp_opts=''):
"""Transfer files to this unit.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote usernam... | python | async def scp_to(self, source, destination, user='ubuntu', proxy=False,
scp_opts=''):
"""Transfer files to this unit.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote usernam... | [
"async",
"def",
"scp_to",
"(",
"self",
",",
"source",
",",
"destination",
",",
"user",
"=",
"'ubuntu'",
",",
"proxy",
"=",
"False",
",",
"scp_opts",
"=",
"''",
")",
":",
"await",
"self",
".",
"machine",
".",
"scp_to",
"(",
"source",
",",
"destination",... | Transfer files to this unit.
:param str source: Local path of file(s) to transfer
:param str destination: Remote destination of transferred files
:param str user: Remote username
:param bool proxy: Proxy through the Juju API server
:param scp_opts: Additional options to the `scp... | [
"Transfer",
"files",
"to",
"this",
"unit",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/unit.py#L183-L195 | train |
juju/python-libjuju | juju/unit.py | Unit.get_metrics | async def get_metrics(self):
"""Get metrics for the unit.
:return: Dictionary of metrics for this unit.
"""
metrics = await self.model.get_metrics(self.tag)
return metrics[self.name] | python | async def get_metrics(self):
"""Get metrics for the unit.
:return: Dictionary of metrics for this unit.
"""
metrics = await self.model.get_metrics(self.tag)
return metrics[self.name] | [
"async",
"def",
"get_metrics",
"(",
"self",
")",
":",
"metrics",
"=",
"await",
"self",
".",
"model",
".",
"get_metrics",
"(",
"self",
".",
"tag",
")",
"return",
"metrics",
"[",
"self",
".",
"name",
"]"
] | Get metrics for the unit.
:return: Dictionary of metrics for this unit. | [
"Get",
"metrics",
"for",
"the",
"unit",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/unit.py#L275-L282 | train |
juju/python-libjuju | juju/constraints.py | parse | def parse(constraints):
"""
Constraints must be expressed as a string containing only spaces
and key value pairs joined by an '='.
"""
if not constraints:
return None
if type(constraints) is dict:
# Fowards compatibilty: already parsed
return constraints
constraint... | python | def parse(constraints):
"""
Constraints must be expressed as a string containing only spaces
and key value pairs joined by an '='.
"""
if not constraints:
return None
if type(constraints) is dict:
# Fowards compatibilty: already parsed
return constraints
constraint... | [
"def",
"parse",
"(",
"constraints",
")",
":",
"if",
"not",
"constraints",
":",
"return",
"None",
"if",
"type",
"(",
"constraints",
")",
"is",
"dict",
":",
"return",
"constraints",
"constraints",
"=",
"{",
"normalize_key",
"(",
"k",
")",
":",
"(",
"normal... | Constraints must be expressed as a string containing only spaces
and key value pairs joined by an '='. | [
"Constraints",
"must",
"be",
"expressed",
"as",
"a",
"string",
"containing",
"only",
"spaces",
"and",
"key",
"value",
"pairs",
"joined",
"by",
"an",
"=",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/constraints.py#L38-L57 | train |
juju/python-libjuju | juju/application.py | Application.add_relation | async def add_relation(self, local_relation, remote_relation):
"""Add a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation_name>]... | python | async def add_relation(self, local_relation, remote_relation):
"""Add a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation_name>]... | [
"async",
"def",
"add_relation",
"(",
"self",
",",
"local_relation",
",",
"remote_relation",
")",
":",
"if",
"':'",
"not",
"in",
"local_relation",
":",
"local_relation",
"=",
"'{}:{}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"local_relation",
")",
"ret... | Add a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation_name>]' | [
"Add",
"a",
"relation",
"to",
"another",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L91-L102 | train |
juju/python-libjuju | juju/application.py | Application.add_unit | async def add_unit(self, count=1, to=None):
"""Add one or more units to this application.
:param int count: Number of units to add
:param str to: Placement directive, e.g.::
'23' - machine 23
'lxc:7' - new lxc container on machine 7
'24/lxc/3' - lxc container... | python | async def add_unit(self, count=1, to=None):
"""Add one or more units to this application.
:param int count: Number of units to add
:param str to: Placement directive, e.g.::
'23' - machine 23
'lxc:7' - new lxc container on machine 7
'24/lxc/3' - lxc container... | [
"async",
"def",
"add_unit",
"(",
"self",
",",
"count",
"=",
"1",
",",
"to",
"=",
"None",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Adding %s u... | Add one or more units to this application.
:param int count: Number of units to add
:param str to: Placement directive, e.g.::
'23' - machine 23
'lxc:7' - new lxc container on machine 7
'24/lxc/3' - lxc container 3 or machine 24
If None, a new machine is... | [
"Add",
"one",
"or",
"more",
"units",
"to",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L104-L131 | train |
juju/python-libjuju | juju/application.py | Application.destroy_relation | async def destroy_relation(self, local_relation, remote_relation):
"""Remove a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation... | python | async def destroy_relation(self, local_relation, remote_relation):
"""Remove a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation... | [
"async",
"def",
"destroy_relation",
"(",
"self",
",",
"local_relation",
",",
"remote_relation",
")",
":",
"if",
"':'",
"not",
"in",
"local_relation",
":",
"local_relation",
"=",
"'{}:{}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"local_relation",
")",
... | Remove a relation to another application.
:param str local_relation: Name of relation on this application
:param str remote_relation: Name of relation on the other
application in the form '<application>[:<relation_name>]' | [
"Remove",
"a",
"relation",
"to",
"another",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L184-L201 | train |
juju/python-libjuju | juju/application.py | Application.destroy | async def destroy(self):
"""Remove this application from the model.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Destroying %s', self.name)
return await app_facade.Destroy(self.name) | python | async def destroy(self):
"""Remove this application from the model.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Destroying %s', self.name)
return await app_facade.Destroy(self.name) | [
"async",
"def",
"destroy",
"(",
"self",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Destroying %s'",
",",
"self",
".",
"name",
")",
"return",
"awa... | Remove this application from the model. | [
"Remove",
"this",
"application",
"from",
"the",
"model",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L211-L220 | train |
juju/python-libjuju | juju/application.py | Application.expose | async def expose(self):
"""Make this application publicly available over the network.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Exposing %s', self.name)
return await app_facade.Expose(self.name) | python | async def expose(self):
"""Make this application publicly available over the network.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Exposing %s', self.name)
return await app_facade.Expose(self.name) | [
"async",
"def",
"expose",
"(",
"self",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Exposing %s'",
",",
"self",
".",
"name",
")",
"return",
"await"... | Make this application publicly available over the network. | [
"Make",
"this",
"application",
"publicly",
"available",
"over",
"the",
"network",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L223-L232 | train |
juju/python-libjuju | juju/application.py | Application.get_config | async def get_config(self):
"""Return the configuration settings dict for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Getting config for %s', self.name)
return (await app_facade.Get(self.name)).config | python | async def get_config(self):
"""Return the configuration settings dict for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Getting config for %s', self.name)
return (await app_facade.Get(self.name)).config | [
"async",
"def",
"get_config",
"(",
"self",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Getting config for %s'",
",",
"self",
".",
"name",
")",
"retu... | Return the configuration settings dict for this application. | [
"Return",
"the",
"configuration",
"settings",
"dict",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L234-L243 | train |
juju/python-libjuju | juju/application.py | Application.get_constraints | async def get_constraints(self):
"""Return the machine constraints dict for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Getting constraints for %s', self.name)
result = (await app_facade.Get(self.name)).c... | python | async def get_constraints(self):
"""Return the machine constraints dict for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Getting constraints for %s', self.name)
result = (await app_facade.Get(self.name)).c... | [
"async",
"def",
"get_constraints",
"(",
"self",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Getting constraints for %s'",
",",
"self",
".",
"name",
")... | Return the machine constraints dict for this application. | [
"Return",
"the",
"machine",
"constraints",
"dict",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L245-L255 | train |
juju/python-libjuju | juju/application.py | Application.get_actions | async def get_actions(self, schema=False):
"""Get actions defined for this application.
:param bool schema: Return the full action schema
:return dict: The charms actions, empty dict if none are defined.
"""
actions = {}
entity = [{"tag": self.tag}]
action_facade... | python | async def get_actions(self, schema=False):
"""Get actions defined for this application.
:param bool schema: Return the full action schema
:return dict: The charms actions, empty dict if none are defined.
"""
actions = {}
entity = [{"tag": self.tag}]
action_facade... | [
"async",
"def",
"get_actions",
"(",
"self",
",",
"schema",
"=",
"False",
")",
":",
"actions",
"=",
"{",
"}",
"entity",
"=",
"[",
"{",
"\"tag\"",
":",
"self",
".",
"tag",
"}",
"]",
"action_facade",
"=",
"client",
".",
"ActionFacade",
".",
"from_connecti... | Get actions defined for this application.
:param bool schema: Return the full action schema
:return dict: The charms actions, empty dict if none are defined. | [
"Get",
"actions",
"defined",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L257-L274 | train |
juju/python-libjuju | juju/application.py | Application.get_resources | async def get_resources(self):
"""Return resources for this application.
Returns a dict mapping resource name to
:class:`~juju._definitions.CharmResource` instances.
"""
facade = client.ResourcesFacade.from_connection(self.connection)
response = await facade.ListResource... | python | async def get_resources(self):
"""Return resources for this application.
Returns a dict mapping resource name to
:class:`~juju._definitions.CharmResource` instances.
"""
facade = client.ResourcesFacade.from_connection(self.connection)
response = await facade.ListResource... | [
"async",
"def",
"get_resources",
"(",
"self",
")",
":",
"facade",
"=",
"client",
".",
"ResourcesFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"response",
"=",
"await",
"facade",
".",
"ListResources",
"(",
"[",
"client",
".",
"Entity",... | Return resources for this application.
Returns a dict mapping resource name to
:class:`~juju._definitions.CharmResource` instances. | [
"Return",
"resources",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L276-L293 | train |
juju/python-libjuju | juju/application.py | Application.run | async def run(self, command, timeout=None):
"""Run command on all units for this application.
:param str command: The command to run
:param int timeout: Time to wait before command is considered failed
"""
action = client.ActionFacade.from_connection(self.connection)
l... | python | async def run(self, command, timeout=None):
"""Run command on all units for this application.
:param str command: The command to run
:param int timeout: Time to wait before command is considered failed
"""
action = client.ActionFacade.from_connection(self.connection)
l... | [
"async",
"def",
"run",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"None",
")",
":",
"action",
"=",
"client",
".",
"ActionFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Running `%s` on all units of %s'... | Run command on all units for this application.
:param str command: The command to run
:param int timeout: Time to wait before command is considered failed | [
"Run",
"command",
"on",
"all",
"units",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L295-L314 | train |
juju/python-libjuju | juju/application.py | Application.set_config | async def set_config(self, config):
"""Set configuration options for this application.
:param config: Dict of configuration to set
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Setting config for %s: %s', self.name, config)
... | python | async def set_config(self, config):
"""Set configuration options for this application.
:param config: Dict of configuration to set
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Setting config for %s: %s', self.name, config)
... | [
"async",
"def",
"set_config",
"(",
"self",
",",
"config",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Setting config for %s: %s'",
",",
"self",
".",
... | Set configuration options for this application.
:param config: Dict of configuration to set | [
"Set",
"configuration",
"options",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L332-L342 | train |
juju/python-libjuju | juju/application.py | Application.reset_config | async def reset_config(self, to_default):
"""
Restore application config to default values.
:param list to_default: A list of config options to be reset to their
default value.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(... | python | async def reset_config(self, to_default):
"""
Restore application config to default values.
:param list to_default: A list of config options to be reset to their
default value.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(... | [
"async",
"def",
"reset_config",
"(",
"self",
",",
"to_default",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Restoring default config for %s: %s'",
",",
... | Restore application config to default values.
:param list to_default: A list of config options to be reset to their
default value. | [
"Restore",
"application",
"config",
"to",
"default",
"values",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L344-L356 | train |
juju/python-libjuju | juju/application.py | Application.set_constraints | async def set_constraints(self, constraints):
"""Set machine constraints for this application.
:param dict constraints: Dict of machine constraints
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Setting constraints for %s: %s... | python | async def set_constraints(self, constraints):
"""Set machine constraints for this application.
:param dict constraints: Dict of machine constraints
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Setting constraints for %s: %s... | [
"async",
"def",
"set_constraints",
"(",
"self",
",",
"constraints",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Setting constraints for %s: %s'",
",",
"... | Set machine constraints for this application.
:param dict constraints: Dict of machine constraints | [
"Set",
"machine",
"constraints",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L358-L369 | train |
juju/python-libjuju | juju/application.py | Application.unexpose | async def unexpose(self):
"""Remove public availability over the network for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Unexposing %s', self.name)
return await app_facade.Unexpose(self.name) | python | async def unexpose(self):
"""Remove public availability over the network for this application.
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
log.debug(
'Unexposing %s', self.name)
return await app_facade.Unexpose(self.name) | [
"async",
"def",
"unexpose",
"(",
"self",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Unexposing %s'",
",",
"self",
".",
"name",
")",
"return",
"aw... | Remove public availability over the network for this application. | [
"Remove",
"public",
"availability",
"over",
"the",
"network",
"for",
"this",
"application",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L388-L397 | train |
juju/python-libjuju | juju/client/facade.py | write_client | def write_client(captures, options):
"""
Write the TypeFactory classes to _client.py, along with some
imports and tables so that we can look up versioned Facades.
"""
with open("{}/_client.py".format(options.output_dir), "w") as f:
f.write(HEADER)
f.write("from juju.client._definiti... | python | def write_client(captures, options):
"""
Write the TypeFactory classes to _client.py, along with some
imports and tables so that we can look up versioned Facades.
"""
with open("{}/_client.py".format(options.output_dir), "w") as f:
f.write(HEADER)
f.write("from juju.client._definiti... | [
"def",
"write_client",
"(",
"captures",
",",
"options",
")",
":",
"with",
"open",
"(",
"\"{}/_client.py\"",
".",
"format",
"(",
"options",
".",
"output_dir",
")",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"HEADER",
")",
"f",
".",
"wr... | Write the TypeFactory classes to _client.py, along with some
imports and tables so that we can look up versioned Facades. | [
"Write",
"the",
"TypeFactory",
"classes",
"to",
"_client",
".",
"py",
"along",
"with",
"some",
"imports",
"and",
"tables",
"so",
"that",
"we",
"can",
"look",
"up",
"versioned",
"Facades",
"."
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/facade.py#L733-L749 | train |
juju/python-libjuju | juju/client/facade.py | KindRegistry.lookup | def lookup(self, name, version=None):
"""If version is omitted, max version is used"""
versions = self.get(name)
if not versions:
return None
if version:
return versions[version]
return versions[max(versions)] | python | def lookup(self, name, version=None):
"""If version is omitted, max version is used"""
versions = self.get(name)
if not versions:
return None
if version:
return versions[version]
return versions[max(versions)] | [
"def",
"lookup",
"(",
"self",
",",
"name",
",",
"version",
"=",
"None",
")",
":",
"versions",
"=",
"self",
".",
"get",
"(",
"name",
")",
"if",
"not",
"versions",
":",
"return",
"None",
"if",
"version",
":",
"return",
"versions",
"[",
"version",
"]",
... | If version is omitted, max version is used | [
"If",
"version",
"is",
"omitted",
"max",
"version",
"is",
"used"
] | 58f0011f4c57cd68830258952fa952eaadca6b38 | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/facade.py#L110-L117 | train |
cloudify-cosmo/wagon | wagon.py | install_package | def install_package(package,
wheels_path,
venv=None,
requirement_files=None,
upgrade=False,
install_args=None):
"""Install a Python package.
Can specify a specific version.
Can specify a prerelease.
Can ... | python | def install_package(package,
wheels_path,
venv=None,
requirement_files=None,
upgrade=False,
install_args=None):
"""Install a Python package.
Can specify a specific version.
Can specify a prerelease.
Can ... | [
"def",
"install_package",
"(",
"package",
",",
"wheels_path",
",",
"venv",
"=",
"None",
",",
"requirement_files",
"=",
"None",
",",
"upgrade",
"=",
"False",
",",
"install_args",
"=",
"None",
")",
":",
"requirement_files",
"=",
"requirement_files",
"or",
"[",
... | Install a Python package.
Can specify a specific version.
Can specify a prerelease.
Can specify a venv to install in.
Can specify a list of paths or urls to requirement txt files.
Can specify a local wheels_path to use for offline installation.
Can request an upgrade. | [
"Install",
"a",
"Python",
"package",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L247-L282 | train |
cloudify-cosmo/wagon | wagon.py | _get_platform_for_set_of_wheels | def _get_platform_for_set_of_wheels(wheels_path):
"""For any set of wheel files, extracts a single platform.
Since a set of wheels created or downloaded on one machine can only
be for a single platform, if any wheel in the set has a platform
which is not `any`, it will be used with one exception:
... | python | def _get_platform_for_set_of_wheels(wheels_path):
"""For any set of wheel files, extracts a single platform.
Since a set of wheels created or downloaded on one machine can only
be for a single platform, if any wheel in the set has a platform
which is not `any`, it will be used with one exception:
... | [
"def",
"_get_platform_for_set_of_wheels",
"(",
"wheels_path",
")",
":",
"real_platform",
"=",
"''",
"for",
"wheel",
"in",
"_get_downloaded_wheels",
"(",
"wheels_path",
")",
":",
"platform",
"=",
"_get_platform_from_wheel_name",
"(",
"os",
".",
"path",
".",
"join",
... | For any set of wheel files, extracts a single platform.
Since a set of wheels created or downloaded on one machine can only
be for a single platform, if any wheel in the set has a platform
which is not `any`, it will be used with one exception:
In Linux, a wagon can contain wheels for both manylinux1 ... | [
"For",
"any",
"set",
"of",
"wheel",
"files",
"extracts",
"a",
"single",
"platform",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L377-L404 | train |
cloudify-cosmo/wagon | wagon.py | _get_os_properties | def _get_os_properties():
"""Retrieve distribution properties.
**Note that platform.linux_distribution and platform.dist are deprecated
and will be removed in Python 3.7. By that time, distro will become
mandatory.
"""
if IS_DISTRO_INSTALLED:
return distro.linux_distribution(full_distri... | python | def _get_os_properties():
"""Retrieve distribution properties.
**Note that platform.linux_distribution and platform.dist are deprecated
and will be removed in Python 3.7. By that time, distro will become
mandatory.
"""
if IS_DISTRO_INSTALLED:
return distro.linux_distribution(full_distri... | [
"def",
"_get_os_properties",
"(",
")",
":",
"if",
"IS_DISTRO_INSTALLED",
":",
"return",
"distro",
".",
"linux_distribution",
"(",
"full_distribution_name",
"=",
"False",
")",
"return",
"platform",
".",
"linux_distribution",
"(",
"full_distribution_name",
"=",
"False",... | Retrieve distribution properties.
**Note that platform.linux_distribution and platform.dist are deprecated
and will be removed in Python 3.7. By that time, distro will become
mandatory. | [
"Retrieve",
"distribution",
"properties",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L416-L425 | train |
cloudify-cosmo/wagon | wagon.py | _get_env_bin_path | def _get_env_bin_path(env_path):
"""Return the bin path for a virtualenv
This provides a fallback for a situation in which you're trying
to use the script and create a virtualenv from within
a virtualenv in which virtualenv isn't installed and so
is not importable.
"""
if IS_VIRTUALENV_INST... | python | def _get_env_bin_path(env_path):
"""Return the bin path for a virtualenv
This provides a fallback for a situation in which you're trying
to use the script and create a virtualenv from within
a virtualenv in which virtualenv isn't installed and so
is not importable.
"""
if IS_VIRTUALENV_INST... | [
"def",
"_get_env_bin_path",
"(",
"env_path",
")",
":",
"if",
"IS_VIRTUALENV_INSTALLED",
":",
"path",
"=",
"virtualenv",
".",
"path_locations",
"(",
"env_path",
")",
"[",
"3",
"]",
"else",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"env_path",
... | Return the bin path for a virtualenv
This provides a fallback for a situation in which you're trying
to use the script and create a virtualenv from within
a virtualenv in which virtualenv isn't installed and so
is not importable. | [
"Return",
"the",
"bin",
"path",
"for",
"a",
"virtualenv"
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L428-L440 | train |
cloudify-cosmo/wagon | wagon.py | _generate_metadata_file | def _generate_metadata_file(workdir,
archive_name,
platform,
python_versions,
package_name,
package_version,
build_tag,
pack... | python | def _generate_metadata_file(workdir,
archive_name,
platform,
python_versions,
package_name,
package_version,
build_tag,
pack... | [
"def",
"_generate_metadata_file",
"(",
"workdir",
",",
"archive_name",
",",
"platform",
",",
"python_versions",
",",
"package_name",
",",
"package_version",
",",
"build_tag",
",",
"package_source",
",",
"wheels",
")",
":",
"logger",
".",
"debug",
"(",
"'Generating... | Generate a metadata file for the package. | [
"Generate",
"a",
"metadata",
"file",
"for",
"the",
"package",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L513-L556 | train |
cloudify-cosmo/wagon | wagon.py | _set_archive_name | def _set_archive_name(package_name,
package_version,
python_versions,
platform,
build_tag=''):
"""Set the format of the output archive file.
We should aspire for the name of the archive to be
as compatible as possible w... | python | def _set_archive_name(package_name,
package_version,
python_versions,
platform,
build_tag=''):
"""Set the format of the output archive file.
We should aspire for the name of the archive to be
as compatible as possible w... | [
"def",
"_set_archive_name",
"(",
"package_name",
",",
"package_version",
",",
"python_versions",
",",
"platform",
",",
"build_tag",
"=",
"''",
")",
":",
"package_name",
"=",
"package_name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"python_versions",
"=",
"... | Set the format of the output archive file.
We should aspire for the name of the archive to be
as compatible as possible with the wheel naming convention
described here:
https://www.python.org/dev/peps/pep-0491/#file-name-convention,
as we're basically providing a "wheel" of our package. | [
"Set",
"the",
"format",
"of",
"the",
"output",
"archive",
"file",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L559-L587 | train |
cloudify-cosmo/wagon | wagon.py | get_source_name_and_version | def get_source_name_and_version(source):
"""Retrieve the source package's name and version.
If the source is a path, the name and version will be retrieved
by querying the setup.py file in the path.
If the source is PACKAGE_NAME==PACKAGE_VERSION, they will be used as
the name and version.
If ... | python | def get_source_name_and_version(source):
"""Retrieve the source package's name and version.
If the source is a path, the name and version will be retrieved
by querying the setup.py file in the path.
If the source is PACKAGE_NAME==PACKAGE_VERSION, they will be used as
the name and version.
If ... | [
"def",
"get_source_name_and_version",
"(",
"source",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"source",
",",
"'setup.py'",
")",
")",
":",
"package_name",
",",
"package_version",
"=",
"_get_name_and_version_f... | Retrieve the source package's name and version.
If the source is a path, the name and version will be retrieved
by querying the setup.py file in the path.
If the source is PACKAGE_NAME==PACKAGE_VERSION, they will be used as
the name and version.
If the source is PACKAGE_NAME, the version will be ... | [
"Retrieve",
"the",
"source",
"package",
"s",
"name",
"and",
"version",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L590-L614 | train |
cloudify-cosmo/wagon | wagon.py | get_source | def get_source(source):
"""Return a pip-installable source
If the source is a url to a package's tar file,
this will download the source and extract it to a temporary directory.
If the source is neither a url nor a local path, and is not provided
as PACKAGE_NAME==PACKAGE_VERSION, the provided sour... | python | def get_source(source):
"""Return a pip-installable source
If the source is a url to a package's tar file,
this will download the source and extract it to a temporary directory.
If the source is neither a url nor a local path, and is not provided
as PACKAGE_NAME==PACKAGE_VERSION, the provided sour... | [
"def",
"get_source",
"(",
"source",
")",
":",
"def",
"extract_source",
"(",
"source",
",",
"destination",
")",
":",
"if",
"tarfile",
".",
"is_tarfile",
"(",
"source",
")",
":",
"_untar",
"(",
"source",
",",
"destination",
")",
"elif",
"zipfile",
".",
"is... | Return a pip-installable source
If the source is a url to a package's tar file,
this will download the source and extract it to a temporary directory.
If the source is neither a url nor a local path, and is not provided
as PACKAGE_NAME==PACKAGE_VERSION, the provided source string
will be regarded ... | [
"Return",
"a",
"pip",
"-",
"installable",
"source"
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L628-L682 | train |
cloudify-cosmo/wagon | wagon.py | create | def create(source,
requirement_files=None,
force=False,
keep_wheels=False,
archive_destination_dir='.',
python_versions=None,
validate_archive=False,
wheel_args='',
archive_format='zip',
build_tag=''):
"""Create a Wag... | python | def create(source,
requirement_files=None,
force=False,
keep_wheels=False,
archive_destination_dir='.',
python_versions=None,
validate_archive=False,
wheel_args='',
archive_format='zip',
build_tag=''):
"""Create a Wag... | [
"def",
"create",
"(",
"source",
",",
"requirement_files",
"=",
"None",
",",
"force",
"=",
"False",
",",
"keep_wheels",
"=",
"False",
",",
"archive_destination_dir",
"=",
"'.'",
",",
"python_versions",
"=",
"None",
",",
"validate_archive",
"=",
"False",
",",
... | Create a Wagon archive and returns its path.
Package name and version are extracted from the setup.py file
of the `source` or from the PACKAGE_NAME==PACKAGE_VERSION if the source
is a PyPI package.
Supported `python_versions` must be in the format e.g [33, 27, 2, 3]..
`force` will remove any exce... | [
"Create",
"a",
"Wagon",
"archive",
"and",
"returns",
"its",
"path",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L691-L773 | train |
cloudify-cosmo/wagon | wagon.py | install | def install(source,
venv=None,
requirement_files=None,
upgrade=False,
ignore_platform=False,
install_args=''):
"""Install a Wagon archive.
This can install in a provided `venv` or in the current
virtualenv in case one is currently active.
`up... | python | def install(source,
venv=None,
requirement_files=None,
upgrade=False,
ignore_platform=False,
install_args=''):
"""Install a Wagon archive.
This can install in a provided `venv` or in the current
virtualenv in case one is currently active.
`up... | [
"def",
"install",
"(",
"source",
",",
"venv",
"=",
"None",
",",
"requirement_files",
"=",
"None",
",",
"upgrade",
"=",
"False",
",",
"ignore_platform",
"=",
"False",
",",
"install_args",
"=",
"''",
")",
":",
"requirement_files",
"=",
"requirement_files",
"or... | Install a Wagon archive.
This can install in a provided `venv` or in the current
virtualenv in case one is currently active.
`upgrade` is merely pip's upgrade.
`ignore_platform` will allow to ignore the platform check, meaning
that if an archive was created for a specific platform (e.g. win32),
... | [
"Install",
"a",
"Wagon",
"archive",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L791-L855 | train |
cloudify-cosmo/wagon | wagon.py | validate | def validate(source):
"""Validate a Wagon archive. Return True if succeeds, False otherwise.
It also prints a list of all validation errors.
This will test that some of the metadata is solid, that
the required wheels are present within the archives and that
the package is installable.
Note tha... | python | def validate(source):
"""Validate a Wagon archive. Return True if succeeds, False otherwise.
It also prints a list of all validation errors.
This will test that some of the metadata is solid, that
the required wheels are present within the archives and that
the package is installable.
Note tha... | [
"def",
"validate",
"(",
"source",
")",
":",
"_assert_virtualenv_is_installed",
"(",
")",
"logger",
".",
"info",
"(",
"'Validating %s'",
",",
"source",
")",
"processed_source",
"=",
"get_source",
"(",
"source",
")",
"metadata",
"=",
"_get_metadata",
"(",
"process... | Validate a Wagon archive. Return True if succeeds, False otherwise.
It also prints a list of all validation errors.
This will test that some of the metadata is solid, that
the required wheels are present within the archives and that
the package is installable.
Note that if the metadata file is cor... | [
"Validate",
"a",
"Wagon",
"archive",
".",
"Return",
"True",
"if",
"succeeds",
"False",
"otherwise",
".",
"It",
"also",
"prints",
"a",
"list",
"of",
"all",
"validation",
"errors",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L866-L914 | train |
cloudify-cosmo/wagon | wagon.py | show | def show(source):
"""Merely returns the metadata for the provided archive.
"""
if is_verbose():
logger.info('Retrieving Metadata for: %s', source)
processed_source = get_source(source)
metadata = _get_metadata(processed_source)
shutil.rmtree(processed_source)
return metadata | python | def show(source):
"""Merely returns the metadata for the provided archive.
"""
if is_verbose():
logger.info('Retrieving Metadata for: %s', source)
processed_source = get_source(source)
metadata = _get_metadata(processed_source)
shutil.rmtree(processed_source)
return metadata | [
"def",
"show",
"(",
"source",
")",
":",
"if",
"is_verbose",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Retrieving Metadata for: %s'",
",",
"source",
")",
"processed_source",
"=",
"get_source",
"(",
"source",
")",
"metadata",
"=",
"_get_metadata",
"(",
"pro... | Merely returns the metadata for the provided archive. | [
"Merely",
"returns",
"the",
"metadata",
"for",
"the",
"provided",
"archive",
"."
] | 9876d33a0aece01df2421a87e3b398d13f660fe6 | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L917-L925 | train |
scottjbarr/bitfinex | bitfinex/client.py | Client._convert_to_floats | def _convert_to_floats(self, data):
"""
Convert all values in a dict to floats
"""
for key, value in data.items():
data[key] = float(value)
return data | python | def _convert_to_floats(self, data):
"""
Convert all values in a dict to floats
"""
for key, value in data.items():
data[key] = float(value)
return data | [
"def",
"_convert_to_floats",
"(",
"self",
",",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"data",
"[",
"key",
"]",
"=",
"float",
"(",
"value",
")",
"return",
"data"
] | Convert all values in a dict to floats | [
"Convert",
"all",
"values",
"in",
"a",
"dict",
"to",
"floats"
] | 03f7c71615fe38c2e28be0ebb761d3106ef0a51a | https://github.com/scottjbarr/bitfinex/blob/03f7c71615fe38c2e28be0ebb761d3106ef0a51a/bitfinex/client.py#L497-L504 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.