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
StellarCN/py-stellar-base
stellar_base/operation.py
Operation.to_xdr_amount
def to_xdr_amount(value): """Converts an amount to the appropriate value to send over the network as a part of an XDR object. Each asset amount is encoded as a signed 64-bit integer in the XDR structures. An asset amount unit (that which is seen by end users) is scaled down by a...
python
def to_xdr_amount(value): """Converts an amount to the appropriate value to send over the network as a part of an XDR object. Each asset amount is encoded as a signed 64-bit integer in the XDR structures. An asset amount unit (that which is seen by end users) is scaled down by a...
[ "def", "to_xdr_amount", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "raise", "NotValidParamError", "(", "\"Value of type '{}' must be of type String, but got {}\"", ".", "format", "(", "value", ",", "type", "(", "value", ...
Converts an amount to the appropriate value to send over the network as a part of an XDR object. Each asset amount is encoded as a signed 64-bit integer in the XDR structures. An asset amount unit (that which is seen by end users) is scaled down by a factor of ten million (10,000,000) t...
[ "Converts", "an", "amount", "to", "the", "appropriate", "value", "to", "send", "over", "the", "network", "as", "a", "part", "of", "an", "XDR", "object", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/operation.py#L71-L105
train
StellarCN/py-stellar-base
stellar_base/memo.py
TextMemo.to_xdr_object
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_TEXT.""" return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text)
python
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_TEXT.""" return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text)
[ "def", "to_xdr_object", "(", "self", ")", ":", "return", "Xdr", ".", "types", ".", "Memo", "(", "type", "=", "Xdr", ".", "const", ".", "MEMO_TEXT", ",", "text", "=", "self", ".", "text", ")" ]
Creates an XDR Memo object for a transaction with MEMO_TEXT.
[ "Creates", "an", "XDR", "Memo", "object", "for", "a", "transaction", "with", "MEMO_TEXT", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/memo.py#L97-L99
train
StellarCN/py-stellar-base
stellar_base/memo.py
IdMemo.to_xdr_object
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_ID.""" return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id)
python
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_ID.""" return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id)
[ "def", "to_xdr_object", "(", "self", ")", ":", "return", "Xdr", ".", "types", ".", "Memo", "(", "type", "=", "Xdr", ".", "const", ".", "MEMO_ID", ",", "id", "=", "self", ".", "memo_id", ")" ]
Creates an XDR Memo object for a transaction with MEMO_ID.
[ "Creates", "an", "XDR", "Memo", "object", "for", "a", "transaction", "with", "MEMO_ID", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/memo.py#L112-L114
train
StellarCN/py-stellar-base
stellar_base/memo.py
HashMemo.to_xdr_object
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_HASH.""" return Xdr.types.Memo(type=Xdr.const.MEMO_HASH, hash=self.memo_hash)
python
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_HASH.""" return Xdr.types.Memo(type=Xdr.const.MEMO_HASH, hash=self.memo_hash)
[ "def", "to_xdr_object", "(", "self", ")", ":", "return", "Xdr", ".", "types", ".", "Memo", "(", "type", "=", "Xdr", ".", "const", ".", "MEMO_HASH", ",", "hash", "=", "self", ".", "memo_hash", ")" ]
Creates an XDR Memo object for a transaction with MEMO_HASH.
[ "Creates", "an", "XDR", "Memo", "object", "for", "a", "transaction", "with", "MEMO_HASH", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/memo.py#L127-L129
train
StellarCN/py-stellar-base
stellar_base/memo.py
RetHashMemo.to_xdr_object
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_RETURN.""" return Xdr.types.Memo( type=Xdr.const.MEMO_RETURN, retHash=self.memo_return)
python
def to_xdr_object(self): """Creates an XDR Memo object for a transaction with MEMO_RETURN.""" return Xdr.types.Memo( type=Xdr.const.MEMO_RETURN, retHash=self.memo_return)
[ "def", "to_xdr_object", "(", "self", ")", ":", "return", "Xdr", ".", "types", ".", "Memo", "(", "type", "=", "Xdr", ".", "const", ".", "MEMO_RETURN", ",", "retHash", "=", "self", ".", "memo_return", ")" ]
Creates an XDR Memo object for a transaction with MEMO_RETURN.
[ "Creates", "an", "XDR", "Memo", "object", "for", "a", "transaction", "with", "MEMO_RETURN", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/memo.py#L148-L151
train
StellarCN/py-stellar-base
stellar_base/builder.py
Builder.append_hashx_signer
def append_hashx_signer(self, hashx, signer_weight, source=None): """Add a HashX signer to an account. Add a HashX signer to an account via a :class:`SetOptions <stellar_base.operation.SetOptions` operation. This is a helper function for :meth:`append_set_options_op`. :param ha...
python
def append_hashx_signer(self, hashx, signer_weight, source=None): """Add a HashX signer to an account. Add a HashX signer to an account via a :class:`SetOptions <stellar_base.operation.SetOptions` operation. This is a helper function for :meth:`append_set_options_op`. :param ha...
[ "def", "append_hashx_signer", "(", "self", ",", "hashx", ",", "signer_weight", ",", "source", "=", "None", ")", ":", "return", "self", ".", "append_set_options_op", "(", "signer_address", "=", "hashx", ",", "signer_type", "=", "'hashX'", ",", "signer_weight", ...
Add a HashX signer to an account. Add a HashX signer to an account via a :class:`SetOptions <stellar_base.operation.SetOptions` operation. This is a helper function for :meth:`append_set_options_op`. :param hashx: The address of the new hashX signer. :type hashx: str, bytes ...
[ "Add", "a", "HashX", "signer", "to", "an", "account", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L323-L342
train
StellarCN/py-stellar-base
stellar_base/builder.py
Builder.append_pre_auth_tx_signer
def append_pre_auth_tx_signer(self, pre_auth_tx, signer_weight, source=None): """Add a PreAuthTx signer to an account. Add a PreAuthTx signer to an account via a :class:`SetOptions <stellar_bas...
python
def append_pre_auth_tx_signer(self, pre_auth_tx, signer_weight, source=None): """Add a PreAuthTx signer to an account. Add a PreAuthTx signer to an account via a :class:`SetOptions <stellar_bas...
[ "def", "append_pre_auth_tx_signer", "(", "self", ",", "pre_auth_tx", ",", "signer_weight", ",", "source", "=", "None", ")", ":", "return", "self", ".", "append_set_options_op", "(", "signer_address", "=", "pre_auth_tx", ",", "signer_type", "=", "'preAuthTx'", ",",...
Add a PreAuthTx signer to an account. Add a PreAuthTx signer to an account via a :class:`SetOptions <stellar_base.operation.SetOptions` operation. This is a helper function for :meth:`append_set_options_op`. :param pre_auth_tx: The address of the new preAuthTx signer - obtained by call...
[ "Add", "a", "PreAuthTx", "signer", "to", "an", "account", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L344-L366
train
StellarCN/py-stellar-base
stellar_base/builder.py
Builder.next_builder
def next_builder(self): """Create a new builder based off of this one with its sequence number incremented. :return: A new Builder instance :rtype: :class:`Builder` """ sequence = self.sequence + 1 next_builder = Builder( horizon_uri=self.horizon.hor...
python
def next_builder(self): """Create a new builder based off of this one with its sequence number incremented. :return: A new Builder instance :rtype: :class:`Builder` """ sequence = self.sequence + 1 next_builder = Builder( horizon_uri=self.horizon.hor...
[ "def", "next_builder", "(", "self", ")", ":", "sequence", "=", "self", ".", "sequence", "+", "1", "next_builder", "=", "Builder", "(", "horizon_uri", "=", "self", ".", "horizon", ".", "horizon_uri", ",", "address", "=", "self", ".", "address", ",", "netw...
Create a new builder based off of this one with its sequence number incremented. :return: A new Builder instance :rtype: :class:`Builder`
[ "Create", "a", "new", "builder", "based", "off", "of", "this", "one", "with", "its", "sequence", "number", "incremented", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L786-L802
train
StellarCN/py-stellar-base
stellar_base/builder.py
Builder.get_sequence
def get_sequence(self): """Get the sequence number for a given account via Horizon. :return: The current sequence number for a given account :rtype: int """ if not self.address: raise StellarAddressInvalidError('No address provided.') address = self.horizon....
python
def get_sequence(self): """Get the sequence number for a given account via Horizon. :return: The current sequence number for a given account :rtype: int """ if not self.address: raise StellarAddressInvalidError('No address provided.') address = self.horizon....
[ "def", "get_sequence", "(", "self", ")", ":", "if", "not", "self", ".", "address", ":", "raise", "StellarAddressInvalidError", "(", "'No address provided.'", ")", "address", "=", "self", ".", "horizon", ".", "account", "(", "self", ".", "address", ")", "retu...
Get the sequence number for a given account via Horizon. :return: The current sequence number for a given account :rtype: int
[ "Get", "the", "sequence", "number", "for", "a", "given", "account", "via", "Horizon", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L804-L814
train
StellarCN/py-stellar-base
stellar_base/asset.py
Asset.to_dict
def to_dict(self): """Generate a dict for this object's attributes. :return: A dict representing an :class:`Asset` """ rv = {'code': self.code} if not self.is_native(): rv['issuer'] = self.issuer rv['type'] = self.type else: rv['type']...
python
def to_dict(self): """Generate a dict for this object's attributes. :return: A dict representing an :class:`Asset` """ rv = {'code': self.code} if not self.is_native(): rv['issuer'] = self.issuer rv['type'] = self.type else: rv['type']...
[ "def", "to_dict", "(", "self", ")", ":", "rv", "=", "{", "'code'", ":", "self", ".", "code", "}", "if", "not", "self", ".", "is_native", "(", ")", ":", "rv", "[", "'issuer'", "]", "=", "self", ".", "issuer", "rv", "[", "'type'", "]", "=", "self...
Generate a dict for this object's attributes. :return: A dict representing an :class:`Asset`
[ "Generate", "a", "dict", "for", "this", "object", "s", "attributes", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/asset.py#L61-L72
train
StellarCN/py-stellar-base
stellar_base/stellarxdr/xdrgen.py
id_unique
def id_unique(dict_id, name, lineno): """Returns True if dict_id not already used. Otherwise, invokes error""" if dict_id in name_dict: global error_occurred error_occurred = True print( "ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}" .format(...
python
def id_unique(dict_id, name, lineno): """Returns True if dict_id not already used. Otherwise, invokes error""" if dict_id in name_dict: global error_occurred error_occurred = True print( "ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}" .format(...
[ "def", "id_unique", "(", "dict_id", ",", "name", ",", "lineno", ")", ":", "if", "dict_id", "in", "name_dict", ":", "global", "error_occurred", "error_occurred", "=", "True", "print", "(", "\"ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}\"", ".", "f...
Returns True if dict_id not already used. Otherwise, invokes error
[ "Returns", "True", "if", "dict_id", "not", "already", "used", ".", "Otherwise", "invokes", "error" ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/stellarxdr/xdrgen.py#L770-L780
train
StellarCN/py-stellar-base
stellar_base/base58.py
main
def main(): '''Base58 encode or decode FILE, or standard input, to standard output.''' import sys import argparse stdout = buffer(sys.stdout) parser = argparse.ArgumentParser(description=main.__doc__) parser.add_argument( 'file', metavar='FILE', nargs='?', type...
python
def main(): '''Base58 encode or decode FILE, or standard input, to standard output.''' import sys import argparse stdout = buffer(sys.stdout) parser = argparse.ArgumentParser(description=main.__doc__) parser.add_argument( 'file', metavar='FILE', nargs='?', type...
[ "def", "main", "(", ")", ":", "import", "sys", "import", "argparse", "stdout", "=", "buffer", "(", "sys", ".", "stdout", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "main", ".", "__doc__", ")", "parser", ".", "add_argu...
Base58 encode or decode FILE, or standard input, to standard output.
[ "Base58", "encode", "or", "decode", "FILE", "or", "standard", "input", "to", "standard", "output", "." ]
cce2e782064fb3955c85e1696e630d67b1010848
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/base58.py#L93-L134
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_11/utils.py
Utils._Dhcpcd
def _Dhcpcd(self, interfaces, logger): """Use dhcpcd to activate the interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. """ for interface in interfaces: dhcpcd = ['/sbin/dhcpcd'] try: ...
python
def _Dhcpcd(self, interfaces, logger): """Use dhcpcd to activate the interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. """ for interface in interfaces: dhcpcd = ['/sbin/dhcpcd'] try: ...
[ "def", "_Dhcpcd", "(", "self", ",", "interfaces", ",", "logger", ")", ":", "for", "interface", "in", "interfaces", ":", "dhcpcd", "=", "[", "'/sbin/dhcpcd'", "]", "try", ":", "subprocess", ".", "check_call", "(", "dhcpcd", "+", "[", "'-x'", ",", "interfa...
Use dhcpcd to activate the interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port.
[ "Use", "dhcpcd", "to", "activate", "the", "interfaces", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_11/utils.py#L44-L62
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_manager.py
_CreateTempDir
def _CreateTempDir(prefix, run_dir=None): """Context manager for creating a temporary directory. Args: prefix: string, the prefix for the temporary directory. run_dir: string, the base directory location of the temporary directory. Yields: string, the temporary directory created. """ temp_dir = ...
python
def _CreateTempDir(prefix, run_dir=None): """Context manager for creating a temporary directory. Args: prefix: string, the prefix for the temporary directory. run_dir: string, the base directory location of the temporary directory. Yields: string, the temporary directory created. """ temp_dir = ...
[ "def", "_CreateTempDir", "(", "prefix", ",", "run_dir", "=", "None", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "prefix", "+", "'-'", ",", "dir", "=", "run_dir", ")", "try", ":", "yield", "temp_dir", "finally", ":", "shu...
Context manager for creating a temporary directory. Args: prefix: string, the prefix for the temporary directory. run_dir: string, the base directory location of the temporary directory. Yields: string, the temporary directory created.
[ "Context", "manager", "for", "creating", "a", "temporary", "directory", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_manager.py#L31-L45
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_manager.py
ScriptManager._RunScripts
def _RunScripts(self, run_dir=None): """Retrieve metadata scripts and execute them. Args: run_dir: string, the base directory location of the temporary directory. """ with _CreateTempDir(self.script_type, run_dir=run_dir) as dest_dir: try: self.logger.info('Starting %s scripts.', se...
python
def _RunScripts(self, run_dir=None): """Retrieve metadata scripts and execute them. Args: run_dir: string, the base directory location of the temporary directory. """ with _CreateTempDir(self.script_type, run_dir=run_dir) as dest_dir: try: self.logger.info('Starting %s scripts.', se...
[ "def", "_RunScripts", "(", "self", ",", "run_dir", "=", "None", ")", ":", "with", "_CreateTempDir", "(", "self", ".", "script_type", ",", "run_dir", "=", "run_dir", ")", "as", "dest_dir", ":", "try", ":", "self", ".", "logger", ".", "info", "(", "'Star...
Retrieve metadata scripts and execute them. Args: run_dir: string, the base directory location of the temporary directory.
[ "Retrieve", "metadata", "scripts", "and", "execute", "them", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_manager.py#L71-L83
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py
InstanceSetup._GetInstanceConfig
def _GetInstanceConfig(self): """Get the instance configuration specified in metadata. Returns: string, the instance configuration data. """ try: instance_data = self.metadata_dict['instance']['attributes'] except KeyError: instance_data = {} self.logger.warning('Instance at...
python
def _GetInstanceConfig(self): """Get the instance configuration specified in metadata. Returns: string, the instance configuration data. """ try: instance_data = self.metadata_dict['instance']['attributes'] except KeyError: instance_data = {} self.logger.warning('Instance at...
[ "def", "_GetInstanceConfig", "(", "self", ")", ":", "try", ":", "instance_data", "=", "self", ".", "metadata_dict", "[", "'instance'", "]", "[", "'attributes'", "]", "except", "KeyError", ":", "instance_data", "=", "{", "}", "self", ".", "logger", ".", "wa...
Get the instance configuration specified in metadata. Returns: string, the instance configuration data.
[ "Get", "the", "instance", "configuration", "specified", "in", "metadata", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py#L72-L91
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py
InstanceSetup._GenerateSshKey
def _GenerateSshKey(self, key_type, key_dest): """Generate a new SSH key. Args: key_type: string, the type of the SSH key. key_dest: string, a file location to store the SSH key. """ # Create a temporary file to save the created RSA keys. with tempfile.NamedTemporaryFile(prefix=key_type...
python
def _GenerateSshKey(self, key_type, key_dest): """Generate a new SSH key. Args: key_type: string, the type of the SSH key. key_dest: string, a file location to store the SSH key. """ # Create a temporary file to save the created RSA keys. with tempfile.NamedTemporaryFile(prefix=key_type...
[ "def", "_GenerateSshKey", "(", "self", ",", "key_type", ",", "key_dest", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", "prefix", "=", "key_type", ",", "delete", "=", "True", ")", "as", "temp", ":", "temp_key", "=", "temp", ".", "name", "c...
Generate a new SSH key. Args: key_type: string, the type of the SSH key. key_dest: string, a file location to store the SSH key.
[ "Generate", "a", "new", "SSH", "key", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py#L119-L142
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py
InstanceSetup._StartSshd
def _StartSshd(self): """Initialize the SSH daemon.""" # Exit as early as possible. # Instance setup systemd scripts block sshd from starting. if os.path.exists(constants.LOCALBASE + '/bin/systemctl'): return elif (os.path.exists('/etc/init.d/ssh') or os.path.exists('/etc/init/ssh.co...
python
def _StartSshd(self): """Initialize the SSH daemon.""" # Exit as early as possible. # Instance setup systemd scripts block sshd from starting. if os.path.exists(constants.LOCALBASE + '/bin/systemctl'): return elif (os.path.exists('/etc/init.d/ssh') or os.path.exists('/etc/init/ssh.co...
[ "def", "_StartSshd", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "constants", ".", "LOCALBASE", "+", "'/bin/systemctl'", ")", ":", "return", "elif", "(", "os", ".", "path", ".", "exists", "(", "'/etc/init.d/ssh'", ")", "or", "os...
Initialize the SSH daemon.
[ "Initialize", "the", "SSH", "daemon", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py#L144-L157
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py
InstanceSetup._SetSshHostKeys
def _SetSshHostKeys(self, host_key_types=None): """Regenerates SSH host keys when the VM is restarted with a new IP address. Booting a VM from an image with a known SSH key allows a number of attacks. This function will regenerating the host key whenever the IP address changes. This applies the first t...
python
def _SetSshHostKeys(self, host_key_types=None): """Regenerates SSH host keys when the VM is restarted with a new IP address. Booting a VM from an image with a known SSH key allows a number of attacks. This function will regenerating the host key whenever the IP address changes. This applies the first t...
[ "def", "_SetSshHostKeys", "(", "self", ",", "host_key_types", "=", "None", ")", ":", "section", "=", "'Instance'", "instance_id", "=", "self", ".", "_GetInstanceId", "(", ")", "if", "instance_id", "!=", "self", ".", "instance_config", ".", "GetOptionString", "...
Regenerates SSH host keys when the VM is restarted with a new IP address. Booting a VM from an image with a known SSH key allows a number of attacks. This function will regenerating the host key whenever the IP address changes. This applies the first time the instance is booted, and each time the disk ...
[ "Regenerates", "SSH", "host", "keys", "when", "the", "VM", "is", "restarted", "with", "a", "new", "IP", "address", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py#L159-L185
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py
InstanceSetup._SetupBotoConfig
def _SetupBotoConfig(self): """Set the boto config so GSUtil works with provisioned service accounts.""" project_id = self._GetNumericProjectId() try: boto_config.BotoConfig(project_id, debug=self.debug) except (IOError, OSError) as e: self.logger.warning(str(e))
python
def _SetupBotoConfig(self): """Set the boto config so GSUtil works with provisioned service accounts.""" project_id = self._GetNumericProjectId() try: boto_config.BotoConfig(project_id, debug=self.debug) except (IOError, OSError) as e: self.logger.warning(str(e))
[ "def", "_SetupBotoConfig", "(", "self", ")", ":", "project_id", "=", "self", ".", "_GetNumericProjectId", "(", ")", "try", ":", "boto_config", ".", "BotoConfig", "(", "project_id", ",", "debug", "=", "self", ".", "debug", ")", "except", "(", "IOError", ","...
Set the boto config so GSUtil works with provisioned service accounts.
[ "Set", "the", "boto", "config", "so", "GSUtil", "works", "with", "provisioned", "service", "accounts", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/instance_setup/instance_setup.py#L199-L205
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py
ScriptRetriever._DownloadAuthUrl
def _DownloadAuthUrl(self, url, dest_dir): """Download a Google Storage URL using an authentication token. If the token cannot be fetched, fallback to unauthenticated download. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. ...
python
def _DownloadAuthUrl(self, url, dest_dir): """Download a Google Storage URL using an authentication token. If the token cannot be fetched, fallback to unauthenticated download. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. ...
[ "def", "_DownloadAuthUrl", "(", "self", ",", "url", ",", "dest_dir", ")", ":", "dest_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "dir", "=", "dest_dir", ",", "delete", "=", "False", ")", "dest_file", ".", "close", "(", ")", "dest", "=", "dest...
Download a Google Storage URL using an authentication token. If the token cannot be fetched, fallback to unauthenticated download. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storin...
[ "Download", "a", "Google", "Storage", "URL", "using", "an", "authentication", "token", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py#L48-L92
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py
ScriptRetriever._DownloadUrl
def _DownloadUrl(self, url, dest_dir): """Download a script from a given URL. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script. """ dest_file = tempfil...
python
def _DownloadUrl(self, url, dest_dir): """Download a script from a given URL. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script. """ dest_file = tempfil...
[ "def", "_DownloadUrl", "(", "self", ",", "url", ",", "dest_dir", ")", ":", "dest_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "dir", "=", "dest_dir", ",", "delete", "=", "False", ")", "dest_file", ".", "close", "(", ")", "dest", "=", "dest_fil...
Download a script from a given URL. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script.
[ "Download", "a", "script", "from", "a", "given", "URL", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py#L94-L116
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py
ScriptRetriever._DownloadScript
def _DownloadScript(self, url, dest_dir): """Download the contents of the URL to the destination. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script. """ ...
python
def _DownloadScript(self, url, dest_dir): """Download the contents of the URL to the destination. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script. """ ...
[ "def", "_DownloadScript", "(", "self", ",", "url", ",", "dest_dir", ")", ":", "if", "url", ".", "startswith", "(", "r'gs://'", ")", ":", "url", "=", "re", ".", "sub", "(", "'^gs://'", ",", "'https://storage.googleapis.com/'", ",", "url", ")", "return", "...
Download the contents of the URL to the destination. Args: url: string, the URL to download. dest_dir: string, the path to a directory for storing metadata scripts. Returns: string, the path to the file storing the metadata script.
[ "Download", "the", "contents", "of", "the", "URL", "to", "the", "destination", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py#L118-L168
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py
ScriptRetriever._GetAttributeScripts
def _GetAttributeScripts(self, attribute_data, dest_dir): """Retrieve the scripts from attribute metadata. Args: attribute_data: dict, the contents of the attributes metadata. dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping meta...
python
def _GetAttributeScripts(self, attribute_data, dest_dir): """Retrieve the scripts from attribute metadata. Args: attribute_data: dict, the contents of the attributes metadata. dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping meta...
[ "def", "_GetAttributeScripts", "(", "self", ",", "attribute_data", ",", "dest_dir", ")", ":", "script_dict", "=", "{", "}", "attribute_data", "=", "attribute_data", "or", "{", "}", "metadata_key", "=", "'%s-script'", "%", "self", ".", "script_type", "metadata_va...
Retrieve the scripts from attribute metadata. Args: attribute_data: dict, the contents of the attributes metadata. dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping metadata keys to files storing scripts.
[ "Retrieve", "the", "scripts", "from", "attribute", "metadata", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py#L170-L198
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py
ScriptRetriever.GetScripts
def GetScripts(self, dest_dir): """Retrieve the scripts to execute. Args: dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping set metadata keys with associated scripts. """ metadata_dict = self.watcher.GetMetadata() or {} try...
python
def GetScripts(self, dest_dir): """Retrieve the scripts to execute. Args: dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping set metadata keys with associated scripts. """ metadata_dict = self.watcher.GetMetadata() or {} try...
[ "def", "GetScripts", "(", "self", ",", "dest_dir", ")", ":", "metadata_dict", "=", "self", ".", "watcher", ".", "GetMetadata", "(", ")", "or", "{", "}", "try", ":", "instance_data", "=", "metadata_dict", "[", "'instance'", "]", "[", "'attributes'", "]", ...
Retrieve the scripts to execute. Args: dest_dir: string, the path to a directory for storing metadata scripts. Returns: dict, a dictionary mapping set metadata keys with associated scripts.
[ "Retrieve", "the", "scripts", "to", "execute", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py#L200-L224
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_executor.py
ScriptExecutor._MakeExecutable
def _MakeExecutable(self, metadata_script): """Add executable permissions to a file. Args: metadata_script: string, the path to the executable file. """ mode = os.stat(metadata_script).st_mode os.chmod(metadata_script, mode | stat.S_IEXEC)
python
def _MakeExecutable(self, metadata_script): """Add executable permissions to a file. Args: metadata_script: string, the path to the executable file. """ mode = os.stat(metadata_script).st_mode os.chmod(metadata_script, mode | stat.S_IEXEC)
[ "def", "_MakeExecutable", "(", "self", ",", "metadata_script", ")", ":", "mode", "=", "os", ".", "stat", "(", "metadata_script", ")", ".", "st_mode", "os", ".", "chmod", "(", "metadata_script", ",", "mode", "|", "stat", ".", "S_IEXEC", ")" ]
Add executable permissions to a file. Args: metadata_script: string, the path to the executable file.
[ "Add", "executable", "permissions", "to", "a", "file", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_executor.py#L38-L45
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_executor.py
ScriptExecutor.RunScripts
def RunScripts(self, script_dict): """Run the metadata scripts; execute a URL script first if one is provided. Args: script_dict: a dictionary mapping metadata keys to script files. """ metadata_types = ['%s-script-url', '%s-script'] metadata_keys = [key % self.script_type for key in metadata...
python
def RunScripts(self, script_dict): """Run the metadata scripts; execute a URL script first if one is provided. Args: script_dict: a dictionary mapping metadata keys to script files. """ metadata_types = ['%s-script-url', '%s-script'] metadata_keys = [key % self.script_type for key in metadata...
[ "def", "RunScripts", "(", "self", ",", "script_dict", ")", ":", "metadata_types", "=", "[", "'%s-script-url'", ",", "'%s-script'", "]", "metadata_keys", "=", "[", "key", "%", "self", ".", "script_type", "for", "key", "in", "metadata_types", "]", "metadata_keys...
Run the metadata scripts; execute a URL script first if one is provided. Args: script_dict: a dictionary mapping metadata keys to script files.
[ "Run", "the", "metadata", "scripts", ";", "execute", "a", "URL", "script", "first", "if", "one", "is", "provided", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_executor.py#L67-L81
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/config_manager.py
ConfigManager._AddHeader
def _AddHeader(self, fp): """Create a file header in the config. Args: fp: int, a file pointer for writing the header. """ text = textwrap.wrap( textwrap.dedent(self.config_header), break_on_hyphens=False) fp.write('\n'.join(['# ' + line for line in text])) fp.write('\n\n')
python
def _AddHeader(self, fp): """Create a file header in the config. Args: fp: int, a file pointer for writing the header. """ text = textwrap.wrap( textwrap.dedent(self.config_header), break_on_hyphens=False) fp.write('\n'.join(['# ' + line for line in text])) fp.write('\n\n')
[ "def", "_AddHeader", "(", "self", ",", "fp", ")", ":", "text", "=", "textwrap", ".", "wrap", "(", "textwrap", ".", "dedent", "(", "self", ".", "config_header", ")", ",", "break_on_hyphens", "=", "False", ")", "fp", ".", "write", "(", "'\\n'", ".", "j...
Create a file header in the config. Args: fp: int, a file pointer for writing the header.
[ "Create", "a", "file", "header", "in", "the", "config", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/config_manager.py#L43-L52
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/config_manager.py
ConfigManager.SetOption
def SetOption(self, section, option, value, overwrite=True): """Set the value of an option in the config file. Args: section: string, the section of the config file to check. option: string, the option to set the value of. value: string, the value to set the option. overwrite: bool, Tru...
python
def SetOption(self, section, option, value, overwrite=True): """Set the value of an option in the config file. Args: section: string, the section of the config file to check. option: string, the option to set the value of. value: string, the value to set the option. overwrite: bool, Tru...
[ "def", "SetOption", "(", "self", ",", "section", ",", "option", ",", "value", ",", "overwrite", "=", "True", ")", ":", "if", "not", "overwrite", "and", "self", ".", "config", ".", "has_option", "(", "section", ",", "option", ")", ":", "return", "if", ...
Set the value of an option in the config file. Args: section: string, the section of the config file to check. option: string, the option to set the value of. value: string, the value to set the option. overwrite: bool, True to overwrite an existing value in the config file.
[ "Set", "the", "value", "of", "an", "option", "in", "the", "config", "file", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/config_manager.py#L82-L95
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/config_manager.py
ConfigManager.WriteConfig
def WriteConfig(self, config_file=None): """Write the config values to a given file. Args: config_file: string, the file location of the config file to write. """ config_file = config_file or self.config_file config_name = os.path.splitext(os.path.basename(config_file))[0] config_lock = (...
python
def WriteConfig(self, config_file=None): """Write the config values to a given file. Args: config_file: string, the file location of the config file to write. """ config_file = config_file or self.config_file config_name = os.path.splitext(os.path.basename(config_file))[0] config_lock = (...
[ "def", "WriteConfig", "(", "self", ",", "config_file", "=", "None", ")", ":", "config_file", "=", "config_file", "or", "self", ".", "config_file", "config_name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "conf...
Write the config values to a given file. Args: config_file: string, the file location of the config file to write.
[ "Write", "the", "config", "values", "to", "a", "given", "file", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/config_manager.py#L97-L111
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/logger.py
Logger
def Logger(name, debug=False, facility=None): """Get a logging object with handlers for sending logs to SysLog. Args: name: string, the name of the logger which will be added to log entries. debug: bool, True if debug output should write to the console. facility: int, an encoding of the SysLog handler'...
python
def Logger(name, debug=False, facility=None): """Get a logging object with handlers for sending logs to SysLog. Args: name: string, the name of the logger which will be added to log entries. debug: bool, True if debug output should write to the console. facility: int, an encoding of the SysLog handler'...
[ "def", "Logger", "(", "name", ",", "debug", "=", "False", ",", "facility", "=", "None", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "handlers", "=", "[", "]", "logger", ".", "addHandler", "(", "logging", "."...
Get a logging object with handlers for sending logs to SysLog. Args: name: string, the name of the logger which will be added to log entries. debug: bool, True if debug output should write to the console. facility: int, an encoding of the SysLog handler's facility and priority. Returns: logging ob...
[ "Get", "a", "logging", "object", "with", "handlers", "for", "sending", "logs", "to", "SysLog", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/logger.py#L22-L55
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._CreateSudoersGroup
def _CreateSudoersGroup(self): """Create a Linux group for Google added sudo user accounts.""" if not self._GetGroup(self.google_sudoers_group): try: command = self.groupadd_cmd.format(group=self.google_sudoers_group) subprocess.check_call(command.split(' ')) except subprocess.Called...
python
def _CreateSudoersGroup(self): """Create a Linux group for Google added sudo user accounts.""" if not self._GetGroup(self.google_sudoers_group): try: command = self.groupadd_cmd.format(group=self.google_sudoers_group) subprocess.check_call(command.split(' ')) except subprocess.Called...
[ "def", "_CreateSudoersGroup", "(", "self", ")", ":", "if", "not", "self", ".", "_GetGroup", "(", "self", ".", "google_sudoers_group", ")", ":", "try", ":", "command", "=", "self", ".", "groupadd_cmd", ".", "format", "(", "group", "=", "self", ".", "googl...
Create a Linux group for Google added sudo user accounts.
[ "Create", "a", "Linux", "group", "for", "Google", "added", "sudo", "user", "accounts", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L92-L114
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._AddUser
def _AddUser(self, user): """Configure a Linux user account. Args: user: string, the name of the Linux user account to create. Returns: bool, True if user creation succeeded. """ self.logger.info('Creating a new user account for %s.', user) command = self.useradd_cmd.format(user=u...
python
def _AddUser(self, user): """Configure a Linux user account. Args: user: string, the name of the Linux user account to create. Returns: bool, True if user creation succeeded. """ self.logger.info('Creating a new user account for %s.', user) command = self.useradd_cmd.format(user=u...
[ "def", "_AddUser", "(", "self", ",", "user", ")", ":", "self", ".", "logger", ".", "info", "(", "'Creating a new user account for %s.'", ",", "user", ")", "command", "=", "self", ".", "useradd_cmd", ".", "format", "(", "user", "=", "user", ")", "try", ":...
Configure a Linux user account. Args: user: string, the name of the Linux user account to create. Returns: bool, True if user creation succeeded.
[ "Configure", "a", "Linux", "user", "account", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L130-L149
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._UpdateUserGroups
def _UpdateUserGroups(self, user, groups): """Update group membership for a Linux user. Args: user: string, the name of the Linux user account. groups: list, the group names to add the user as a member. Returns: bool, True if user update succeeded. """ groups = ','.join(groups) ...
python
def _UpdateUserGroups(self, user, groups): """Update group membership for a Linux user. Args: user: string, the name of the Linux user account. groups: list, the group names to add the user as a member. Returns: bool, True if user update succeeded. """ groups = ','.join(groups) ...
[ "def", "_UpdateUserGroups", "(", "self", ",", "user", ",", "groups", ")", ":", "groups", "=", "','", ".", "join", "(", "groups", ")", "self", ".", "logger", ".", "debug", "(", "'Updating user %s with groups %s.'", ",", "user", ",", "groups", ")", "command"...
Update group membership for a Linux user. Args: user: string, the name of the Linux user account. groups: list, the group names to add the user as a member. Returns: bool, True if user update succeeded.
[ "Update", "group", "membership", "for", "a", "Linux", "user", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L151-L171
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._UpdateAuthorizedKeys
def _UpdateAuthorizedKeys(self, user, ssh_keys): """Update the authorized keys file for a Linux user with a list of SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Raises: IOError, raised when there is an exc...
python
def _UpdateAuthorizedKeys(self, user, ssh_keys): """Update the authorized keys file for a Linux user with a list of SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Raises: IOError, raised when there is an exc...
[ "def", "_UpdateAuthorizedKeys", "(", "self", ",", "user", ",", "ssh_keys", ")", ":", "pw_entry", "=", "self", ".", "_GetUser", "(", "user", ")", "if", "not", "pw_entry", ":", "return", "uid", "=", "pw_entry", ".", "pw_uid", "gid", "=", "pw_entry", ".", ...
Update the authorized keys file for a Linux user with a list of SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Raises: IOError, raised when there is an exception updating a file. OSError, raised when setti...
[ "Update", "the", "authorized", "keys", "file", "for", "a", "Linux", "user", "with", "a", "list", "of", "SSH", "keys", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L173-L249
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._UpdateSudoer
def _UpdateSudoer(self, user, sudoer=False): """Update sudoer group membership for a Linux user account. Args: user: string, the name of the Linux user account. sudoer: bool, True if the user should be a sudoer. Returns: bool, True if user update succeeded. """ if sudoer: s...
python
def _UpdateSudoer(self, user, sudoer=False): """Update sudoer group membership for a Linux user account. Args: user: string, the name of the Linux user account. sudoer: bool, True if the user should be a sudoer. Returns: bool, True if user update succeeded. """ if sudoer: s...
[ "def", "_UpdateSudoer", "(", "self", ",", "user", ",", "sudoer", "=", "False", ")", ":", "if", "sudoer", ":", "self", ".", "logger", ".", "info", "(", "'Adding user %s to the Google sudoers group.'", ",", "user", ")", "command", "=", "self", ".", "gpasswd_ad...
Update sudoer group membership for a Linux user account. Args: user: string, the name of the Linux user account. sudoer: bool, True if the user should be a sudoer. Returns: bool, True if user update succeeded.
[ "Update", "sudoer", "group", "membership", "for", "a", "Linux", "user", "account", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L251-L277
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils._RemoveAuthorizedKeys
def _RemoveAuthorizedKeys(self, user): """Remove a Linux user account's authorized keys file to prevent login. Args: user: string, the Linux user account to remove access. """ pw_entry = self._GetUser(user) if not pw_entry: return home_dir = pw_entry.pw_dir authorized_keys_file...
python
def _RemoveAuthorizedKeys(self, user): """Remove a Linux user account's authorized keys file to prevent login. Args: user: string, the Linux user account to remove access. """ pw_entry = self._GetUser(user) if not pw_entry: return home_dir = pw_entry.pw_dir authorized_keys_file...
[ "def", "_RemoveAuthorizedKeys", "(", "self", ",", "user", ")", ":", "pw_entry", "=", "self", ".", "_GetUser", "(", "user", ")", "if", "not", "pw_entry", ":", "return", "home_dir", "=", "pw_entry", ".", "pw_dir", "authorized_keys_file", "=", "os", ".", "pat...
Remove a Linux user account's authorized keys file to prevent login. Args: user: string, the Linux user account to remove access.
[ "Remove", "a", "Linux", "user", "account", "s", "authorized", "keys", "file", "to", "prevent", "login", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L279-L296
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils.GetConfiguredUsers
def GetConfiguredUsers(self): """Retrieve the list of configured Google user accounts. Returns: list, the username strings of users congfigured by Google. """ if os.path.exists(self.google_users_file): users = open(self.google_users_file).readlines() else: users = [] return [u...
python
def GetConfiguredUsers(self): """Retrieve the list of configured Google user accounts. Returns: list, the username strings of users congfigured by Google. """ if os.path.exists(self.google_users_file): users = open(self.google_users_file).readlines() else: users = [] return [u...
[ "def", "GetConfiguredUsers", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "google_users_file", ")", ":", "users", "=", "open", "(", "self", ".", "google_users_file", ")", ".", "readlines", "(", ")", "else", ":", "use...
Retrieve the list of configured Google user accounts. Returns: list, the username strings of users congfigured by Google.
[ "Retrieve", "the", "list", "of", "configured", "Google", "user", "accounts", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L298-L308
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils.SetConfiguredUsers
def SetConfiguredUsers(self, users): """Set the list of configured Google user accounts. Args: users: list, the username strings of the Linux accounts. """ prefix = self.logger.name + '-' with tempfile.NamedTemporaryFile( mode='w', prefix=prefix, delete=True) as updated_users: u...
python
def SetConfiguredUsers(self, users): """Set the list of configured Google user accounts. Args: users: list, the username strings of the Linux accounts. """ prefix = self.logger.name + '-' with tempfile.NamedTemporaryFile( mode='w', prefix=prefix, delete=True) as updated_users: u...
[ "def", "SetConfiguredUsers", "(", "self", ",", "users", ")", ":", "prefix", "=", "self", ".", "logger", ".", "name", "+", "'-'", "with", "tempfile", ".", "NamedTemporaryFile", "(", "mode", "=", "'w'", ",", "prefix", "=", "prefix", ",", "delete", "=", "...
Set the list of configured Google user accounts. Args: users: list, the username strings of the Linux accounts.
[ "Set", "the", "list", "of", "configured", "Google", "user", "accounts", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L310-L327
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils.UpdateUser
def UpdateUser(self, user, ssh_keys): """Update a Linux user with authorized SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Returns: bool, True if the user account updated successfully. """ if not bo...
python
def UpdateUser(self, user, ssh_keys): """Update a Linux user with authorized SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Returns: bool, True if the user account updated successfully. """ if not bo...
[ "def", "UpdateUser", "(", "self", ",", "user", ",", "ssh_keys", ")", ":", "if", "not", "bool", "(", "USER_REGEX", ".", "match", "(", "user", ")", ")", ":", "self", ".", "logger", ".", "warning", "(", "'Invalid user account name %s.'", ",", "user", ")", ...
Update a Linux user with authorized SSH keys. Args: user: string, the name of the Linux user account. ssh_keys: list, the SSH key strings associated with the user. Returns: bool, True if the user account updated successfully.
[ "Update", "a", "Linux", "user", "with", "authorized", "SSH", "keys", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L329-L368
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py
AccountsUtils.RemoveUser
def RemoveUser(self, user): """Remove a Linux user account. Args: user: string, the Linux user account to remove. """ self.logger.info('Removing user %s.', user) if self.remove: command = self.userdel_cmd.format(user=user) try: subprocess.check_call(command.split(' ')) ...
python
def RemoveUser(self, user): """Remove a Linux user account. Args: user: string, the Linux user account to remove. """ self.logger.info('Removing user %s.', user) if self.remove: command = self.userdel_cmd.format(user=user) try: subprocess.check_call(command.split(' ')) ...
[ "def", "RemoveUser", "(", "self", ",", "user", ")", ":", "self", ".", "logger", ".", "info", "(", "'Removing user %s.'", ",", "user", ")", "if", "self", ".", "remove", ":", "command", "=", "self", ".", "userdel_cmd", ".", "format", "(", "user", "=", ...
Remove a Linux user account. Args: user: string, the Linux user account to remove.
[ "Remove", "a", "Linux", "user", "account", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_utils.py#L370-L386
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py
OsLoginUtils._RunOsLoginControl
def _RunOsLoginControl(self, params): """Run the OS Login control script. Args: params: list, the params to pass to the script Returns: int, the return code from the call, or None if the script is not found. """ try: return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT] + par...
python
def _RunOsLoginControl(self, params): """Run the OS Login control script. Args: params: list, the params to pass to the script Returns: int, the return code from the call, or None if the script is not found. """ try: return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT] + par...
[ "def", "_RunOsLoginControl", "(", "self", ",", "params", ")", ":", "try", ":", "return", "subprocess", ".", "call", "(", "[", "constants", ".", "OSLOGIN_CONTROL_SCRIPT", "]", "+", "params", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno...
Run the OS Login control script. Args: params: list, the params to pass to the script Returns: int, the return code from the call, or None if the script is not found.
[ "Run", "the", "OS", "Login", "control", "script", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py#L41-L56
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py
OsLoginUtils._GetStatus
def _GetStatus(self, two_factor=False): """Check whether OS Login is installed. Args: two_factor: bool, True if two factor should be enabled. Returns: bool, True if OS Login is installed. """ params = ['status'] if two_factor: params += ['--twofactor'] retcode = self._Run...
python
def _GetStatus(self, two_factor=False): """Check whether OS Login is installed. Args: two_factor: bool, True if two factor should be enabled. Returns: bool, True if OS Login is installed. """ params = ['status'] if two_factor: params += ['--twofactor'] retcode = self._Run...
[ "def", "_GetStatus", "(", "self", ",", "two_factor", "=", "False", ")", ":", "params", "=", "[", "'status'", "]", "if", "two_factor", ":", "params", "+=", "[", "'--twofactor'", "]", "retcode", "=", "self", ".", "_RunOsLoginControl", "(", "params", ")", "...
Check whether OS Login is installed. Args: two_factor: bool, True if two factor should be enabled. Returns: bool, True if OS Login is installed.
[ "Check", "whether", "OS", "Login", "is", "installed", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py#L58-L81
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py
OsLoginUtils._RunOsLoginNssCache
def _RunOsLoginNssCache(self): """Run the OS Login NSS cache binary. Returns: int, the return code from the call, or None if the script is not found. """ try: return subprocess.call([constants.OSLOGIN_NSS_CACHE_SCRIPT]) except OSError as e: if e.errno == errno.ENOENT: retu...
python
def _RunOsLoginNssCache(self): """Run the OS Login NSS cache binary. Returns: int, the return code from the call, or None if the script is not found. """ try: return subprocess.call([constants.OSLOGIN_NSS_CACHE_SCRIPT]) except OSError as e: if e.errno == errno.ENOENT: retu...
[ "def", "_RunOsLoginNssCache", "(", "self", ")", ":", "try", ":", "return", "subprocess", ".", "call", "(", "[", "constants", ".", "OSLOGIN_NSS_CACHE_SCRIPT", "]", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "ENO...
Run the OS Login NSS cache binary. Returns: int, the return code from the call, or None if the script is not found.
[ "Run", "the", "OS", "Login", "NSS", "cache", "binary", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py#L83-L95
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py
OsLoginUtils._RemoveOsLoginNssCache
def _RemoveOsLoginNssCache(self): """Remove the OS Login NSS cache file.""" if os.path.exists(constants.OSLOGIN_NSS_CACHE): try: os.remove(constants.OSLOGIN_NSS_CACHE) except OSError as e: if e.errno != errno.ENOENT: raise
python
def _RemoveOsLoginNssCache(self): """Remove the OS Login NSS cache file.""" if os.path.exists(constants.OSLOGIN_NSS_CACHE): try: os.remove(constants.OSLOGIN_NSS_CACHE) except OSError as e: if e.errno != errno.ENOENT: raise
[ "def", "_RemoveOsLoginNssCache", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "constants", ".", "OSLOGIN_NSS_CACHE", ")", ":", "try", ":", "os", ".", "remove", "(", "constants", ".", "OSLOGIN_NSS_CACHE", ")", "except", "OSError", "as...
Remove the OS Login NSS cache file.
[ "Remove", "the", "OS", "Login", "NSS", "cache", "file", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py#L97-L104
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py
OsLoginUtils.UpdateOsLogin
def UpdateOsLogin(self, oslogin_desired, two_factor_desired=False): """Update whether OS Login is enabled and update NSS cache if necessary. Args: oslogin_desired: bool, enable OS Login if True, disable if False. two_factor_desired: bool, enable two factor if True, disable if False. Returns: ...
python
def UpdateOsLogin(self, oslogin_desired, two_factor_desired=False): """Update whether OS Login is enabled and update NSS cache if necessary. Args: oslogin_desired: bool, enable OS Login if True, disable if False. two_factor_desired: bool, enable two factor if True, disable if False. Returns: ...
[ "def", "UpdateOsLogin", "(", "self", ",", "oslogin_desired", ",", "two_factor_desired", "=", "False", ")", ":", "oslogin_configured", "=", "self", ".", "_GetStatus", "(", "two_factor", "=", "False", ")", "if", "oslogin_configured", "is", "None", ":", "return", ...
Update whether OS Login is enabled and update NSS cache if necessary. Args: oslogin_desired: bool, enable OS Login if True, disable if False. two_factor_desired: bool, enable two factor if True, disable if False. Returns: int, the return code from updating OS Login, or None if not present.
[ "Update", "whether", "OS", "Login", "is", "enabled", "and", "update", "NSS", "cache", "if", "necessary", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/oslogin_utils.py#L106-L152
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
CallDhclient
def CallDhclient( interfaces, logger, dhclient_script=None): """Configure the network interfaces using dhclient. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. dhclient_script: string, the path to a dhclient scrip...
python
def CallDhclient( interfaces, logger, dhclient_script=None): """Configure the network interfaces using dhclient. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. dhclient_script: string, the path to a dhclient scrip...
[ "def", "CallDhclient", "(", "interfaces", ",", "logger", ",", "dhclient_script", "=", "None", ")", ":", "logger", ".", "info", "(", "'Enabling the Ethernet interfaces %s.'", ",", "interfaces", ")", "dhclient_command", "=", "[", "'dhclient'", "]", "if", "dhclient_s...
Configure the network interfaces using dhclient. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. dhclient_script: string, the path to a dhclient script used by dhclient.
[ "Configure", "the", "network", "interfaces", "using", "dhclient", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py#L22-L42
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
CallHwclock
def CallHwclock(logger): """Sync clock using hwclock. Args: logger: logger object, used to write to SysLog and serial port. """ command = ['/sbin/hwclock', '--hctosys'] try: subprocess.check_call(command) except subprocess.CalledProcessError: logger.warning('Failed to sync system time with hard...
python
def CallHwclock(logger): """Sync clock using hwclock. Args: logger: logger object, used to write to SysLog and serial port. """ command = ['/sbin/hwclock', '--hctosys'] try: subprocess.check_call(command) except subprocess.CalledProcessError: logger.warning('Failed to sync system time with hard...
[ "def", "CallHwclock", "(", "logger", ")", ":", "command", "=", "[", "'/sbin/hwclock'", ",", "'--hctosys'", "]", "try", ":", "subprocess", ".", "check_call", "(", "command", ")", "except", "subprocess", ".", "CalledProcessError", ":", "logger", ".", "warning", ...
Sync clock using hwclock. Args: logger: logger object, used to write to SysLog and serial port.
[ "Sync", "clock", "using", "hwclock", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py#L45-L57
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
CallNtpdate
def CallNtpdate(logger): """Sync clock using ntpdate. Args: logger: logger object, used to write to SysLog and serial port. """ ntpd_inactive = subprocess.call(['service', 'ntpd', 'status']) try: if not ntpd_inactive: subprocess.check_call(['service', 'ntpd', 'stop']) subprocess.check_call(...
python
def CallNtpdate(logger): """Sync clock using ntpdate. Args: logger: logger object, used to write to SysLog and serial port. """ ntpd_inactive = subprocess.call(['service', 'ntpd', 'status']) try: if not ntpd_inactive: subprocess.check_call(['service', 'ntpd', 'stop']) subprocess.check_call(...
[ "def", "CallNtpdate", "(", "logger", ")", ":", "ntpd_inactive", "=", "subprocess", ".", "call", "(", "[", "'service'", ",", "'ntpd'", ",", "'status'", "]", ")", "try", ":", "if", "not", "ntpd_inactive", ":", "subprocess", ".", "check_call", "(", "[", "'s...
Sync clock using ntpdate. Args: logger: logger object, used to write to SysLog and serial port.
[ "Sync", "clock", "using", "ntpdate", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py#L60-L77
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py
BotoConfig._GetNumericProjectId
def _GetNumericProjectId(self): """Get the numeric project ID for this VM. Returns: string, the numeric project ID if one is found. """ project_id = 'project/numeric-project-id' return self.watcher.GetMetadata(metadata_key=project_id, recursive=False)
python
def _GetNumericProjectId(self): """Get the numeric project ID for this VM. Returns: string, the numeric project ID if one is found. """ project_id = 'project/numeric-project-id' return self.watcher.GetMetadata(metadata_key=project_id, recursive=False)
[ "def", "_GetNumericProjectId", "(", "self", ")", ":", "project_id", "=", "'project/numeric-project-id'", "return", "self", ".", "watcher", ".", "GetMetadata", "(", "metadata_key", "=", "project_id", ",", "recursive", "=", "False", ")" ]
Get the numeric project ID for this VM. Returns: string, the numeric project ID if one is found.
[ "Get", "the", "numeric", "project", "ID", "for", "this", "VM", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py#L57-L64
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py
BotoConfig._CreateConfig
def _CreateConfig(self, project_id): """Create the boto config to support standalone GSUtil. Args: project_id: string, the project ID to use in the config file. """ project_id = project_id or self._GetNumericProjectId() # Our project doesn't support service accounts. if not project_id: ...
python
def _CreateConfig(self, project_id): """Create the boto config to support standalone GSUtil. Args: project_id: string, the project ID to use in the config file. """ project_id = project_id or self._GetNumericProjectId() # Our project doesn't support service accounts. if not project_id: ...
[ "def", "_CreateConfig", "(", "self", ",", "project_id", ")", ":", "project_id", "=", "project_id", "or", "self", ".", "_GetNumericProjectId", "(", ")", "if", "not", "project_id", ":", "return", "self", ".", "boto_config_header", "%=", "(", "self", ".", "boto...
Create the boto config to support standalone GSUtil. Args: project_id: string, the project ID to use in the config file.
[ "Create", "the", "boto", "config", "to", "support", "standalone", "GSUtil", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py#L66-L89
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py
IpForwardingUtilsIproute._CreateRouteOptions
def _CreateRouteOptions(self, **kwargs): """Create a dictionary of parameters to append to the ip route command. Args: **kwargs: dict, the string parameters to update in the ip route command. Returns: dict, the string parameters to append to the ip route command. """ options = { ...
python
def _CreateRouteOptions(self, **kwargs): """Create a dictionary of parameters to append to the ip route command. Args: **kwargs: dict, the string parameters to update in the ip route command. Returns: dict, the string parameters to append to the ip route command. """ options = { ...
[ "def", "_CreateRouteOptions", "(", "self", ",", "**", "kwargs", ")", ":", "options", "=", "{", "'proto'", ":", "self", ".", "proto_id", ",", "'scope'", ":", "'host'", ",", "}", "options", ".", "update", "(", "kwargs", ")", "return", "options" ]
Create a dictionary of parameters to append to the ip route command. Args: **kwargs: dict, the string parameters to update in the ip route command. Returns: dict, the string parameters to append to the ip route command.
[ "Create", "a", "dictionary", "of", "parameters", "to", "append", "to", "the", "ip", "route", "command", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py#L97-L111
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py
IpForwardingUtilsIproute._RunIpRoute
def _RunIpRoute(self, args=None, options=None): """Run a command with ip route and return the response. Args: args: list, the string ip route command args to execute. options: dict, the string parameters to append to the ip route command. Returns: string, the standard output from the ip ...
python
def _RunIpRoute(self, args=None, options=None): """Run a command with ip route and return the response. Args: args: list, the string ip route command args to execute. options: dict, the string parameters to append to the ip route command. Returns: string, the standard output from the ip ...
[ "def", "_RunIpRoute", "(", "self", ",", "args", "=", "None", ",", "options", "=", "None", ")", ":", "args", "=", "args", "or", "[", "]", "options", "=", "options", "or", "{", "}", "command", "=", "[", "'ip'", ",", "'route'", "]", "command", ".", ...
Run a command with ip route and return the response. Args: args: list, the string ip route command args to execute. options: dict, the string parameters to append to the ip route command. Returns: string, the standard output from the ip route command execution.
[ "Run", "a", "command", "with", "ip", "route", "and", "return", "the", "response", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py#L113-L141
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py
IpForwardingUtilsIfconfig.RemoveForwardedIp
def RemoveForwardedIp(self, address, interface): """Delete an IP address on the network interface. Args: address: string, the IP address to configure. interface: string, the output device to use. """ ip = netaddr.IPNetwork(address) self._RunIfconfig(args=[interface, '-alias', str(ip.ip)...
python
def RemoveForwardedIp(self, address, interface): """Delete an IP address on the network interface. Args: address: string, the IP address to configure. interface: string, the output device to use. """ ip = netaddr.IPNetwork(address) self._RunIfconfig(args=[interface, '-alias', str(ip.ip)...
[ "def", "RemoveForwardedIp", "(", "self", ",", "address", ",", "interface", ")", ":", "ip", "=", "netaddr", ".", "IPNetwork", "(", "address", ")", "self", ".", "_RunIfconfig", "(", "args", "=", "[", "interface", ",", "'-alias'", ",", "str", "(", "ip", "...
Delete an IP address on the network interface. Args: address: string, the IP address to configure. interface: string, the output device to use.
[ "Delete", "an", "IP", "address", "on", "the", "network", "interface", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py#L294-L302
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py
ComputeAuth._GetGsScopes
def _GetGsScopes(self): """Return all Google Storage scopes available on this VM.""" service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key) try: scopes = service_accounts[self.service_account]['scopes'] return list(GS_SCOPES.intersection(set(scopes))) if scopes else None ...
python
def _GetGsScopes(self): """Return all Google Storage scopes available on this VM.""" service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key) try: scopes = service_accounts[self.service_account]['scopes'] return list(GS_SCOPES.intersection(set(scopes))) if scopes else None ...
[ "def", "_GetGsScopes", "(", "self", ")", ":", "service_accounts", "=", "self", ".", "watcher", ".", "GetMetadata", "(", "metadata_key", "=", "self", ".", "metadata_key", ")", "try", ":", "scopes", "=", "service_accounts", "[", "self", ".", "service_account", ...
Return all Google Storage scopes available on this VM.
[ "Return", "all", "Google", "Storage", "scopes", "available", "on", "this", "VM", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py#L50-L57
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py
ComputeAuth._GetAccessToken
def _GetAccessToken(self): """Return an OAuth 2.0 access token for Google Storage.""" service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key) try: return service_accounts[self.service_account]['token']['access_token'] except KeyError: return None
python
def _GetAccessToken(self): """Return an OAuth 2.0 access token for Google Storage.""" service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key) try: return service_accounts[self.service_account]['token']['access_token'] except KeyError: return None
[ "def", "_GetAccessToken", "(", "self", ")", ":", "service_accounts", "=", "self", ".", "watcher", ".", "GetMetadata", "(", "metadata_key", "=", "self", ".", "metadata_key", ")", "try", ":", "return", "service_accounts", "[", "self", ".", "service_account", "]"...
Return an OAuth 2.0 access token for Google Storage.
[ "Return", "an", "OAuth", "2", ".", "0", "access", "token", "for", "Google", "Storage", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py#L59-L65
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/clock_skew/clock_skew_daemon.py
ClockSkewDaemon.HandleClockSync
def HandleClockSync(self, response): """Called when clock drift token changes. Args: response: string, the metadata response with the new drift token value. """ self.logger.info('Clock drift token has changed: %s.', response) self.distro_utils.HandleClockSync(self.logger)
python
def HandleClockSync(self, response): """Called when clock drift token changes. Args: response: string, the metadata response with the new drift token value. """ self.logger.info('Clock drift token has changed: %s.', response) self.distro_utils.HandleClockSync(self.logger)
[ "def", "HandleClockSync", "(", "self", ",", "response", ")", ":", "self", ".", "logger", ".", "info", "(", "'Clock drift token has changed: %s.'", ",", "response", ")", "self", ".", "distro_utils", ".", "HandleClockSync", "(", "self", ".", "logger", ")" ]
Called when clock drift token changes. Args: response: string, the metadata response with the new drift token value.
[ "Called", "when", "clock", "drift", "token", "changes", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/clock_skew/clock_skew_daemon.py#L56-L63
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py
Utils._DisableNetworkManager
def _DisableNetworkManager(self, interfaces, logger): """Disable network manager management on a list of network interfaces. Args: interfaces: list of string, the output device names enable. logger: logger object, used to write to SysLog and serial port. """ for interface in interfaces: ...
python
def _DisableNetworkManager(self, interfaces, logger): """Disable network manager management on a list of network interfaces. Args: interfaces: list of string, the output device names enable. logger: logger object, used to write to SysLog and serial port. """ for interface in interfaces: ...
[ "def", "_DisableNetworkManager", "(", "self", ",", "interfaces", ",", "logger", ")", ":", "for", "interface", "in", "interfaces", ":", "interface_config", "=", "os", ".", "path", ".", "join", "(", "self", ".", "network_path", ",", "'ifcfg-%s'", "%", "interfa...
Disable network manager management on a list of network interfaces. Args: interfaces: list of string, the output device names enable. logger: logger object, used to write to SysLog and serial port.
[ "Disable", "network", "manager", "management", "on", "a", "list", "of", "network", "interfaces", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py#L47-L75
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py
Utils._ModifyInterface
def _ModifyInterface( self, interface_config, config_key, config_value, replace=False): """Write a value to a config file if not already present. Args: interface_config: string, the path to a config file. config_key: string, the configuration key to set. config_value: string, the value ...
python
def _ModifyInterface( self, interface_config, config_key, config_value, replace=False): """Write a value to a config file if not already present. Args: interface_config: string, the path to a config file. config_key: string, the configuration key to set. config_value: string, the value ...
[ "def", "_ModifyInterface", "(", "self", ",", "interface_config", ",", "config_key", ",", "config_value", ",", "replace", "=", "False", ")", ":", "config_entry", "=", "'%s=%s'", "%", "(", "config_key", ",", "config_value", ")", "if", "not", "open", "(", "inte...
Write a value to a config file if not already present. Args: interface_config: string, the path to a config file. config_key: string, the configuration key to set. config_value: string, the value to set for the configuration key. replace: bool, replace the configuration option if already pr...
[ "Write", "a", "value", "to", "a", "config", "file", "if", "not", "already", "present", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py#L77-L93
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._HasExpired
def _HasExpired(self, key): """Check whether an SSH key has expired. Uses Google-specific semantics of the OpenSSH public key format's comment field to determine if an SSH key is past its expiration timestamp, and therefore no longer to be trusted. This format is still subject to change. Reliance o...
python
def _HasExpired(self, key): """Check whether an SSH key has expired. Uses Google-specific semantics of the OpenSSH public key format's comment field to determine if an SSH key is past its expiration timestamp, and therefore no longer to be trusted. This format is still subject to change. Reliance o...
[ "def", "_HasExpired", "(", "self", ",", "key", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Processing key: %s.'", ",", "key", ")", "try", ":", "schema", ",", "json_str", "=", "key", ".", "split", "(", "None", ",", "3", ")", "[", "2", ":",...
Check whether an SSH key has expired. Uses Google-specific semantics of the OpenSSH public key format's comment field to determine if an SSH key is past its expiration timestamp, and therefore no longer to be trusted. This format is still subject to change. Reliance on it in any way is at your own risk...
[ "Check", "whether", "an", "SSH", "key", "has", "expired", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L78-L128
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._ParseAccountsData
def _ParseAccountsData(self, account_data): """Parse the SSH key data into a user map. Args: account_data: string, the metadata server SSH key attributes data. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. """ if not account_data: return {} l...
python
def _ParseAccountsData(self, account_data): """Parse the SSH key data into a user map. Args: account_data: string, the metadata server SSH key attributes data. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. """ if not account_data: return {} l...
[ "def", "_ParseAccountsData", "(", "self", ",", "account_data", ")", ":", "if", "not", "account_data", ":", "return", "{", "}", "lines", "=", "[", "line", "for", "line", "in", "account_data", ".", "splitlines", "(", ")", "if", "line", "]", "user_map", "="...
Parse the SSH key data into a user map. Args: account_data: string, the metadata server SSH key attributes data. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
[ "Parse", "the", "SSH", "key", "data", "into", "a", "user", "map", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L130-L159
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._GetInstanceAndProjectAttributes
def _GetInstanceAndProjectAttributes(self, metadata_dict): """Get dictionaries for instance and project attributes. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: tuple, two dictionaries for instance and project attributes. """ metadata_dict = met...
python
def _GetInstanceAndProjectAttributes(self, metadata_dict): """Get dictionaries for instance and project attributes. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: tuple, two dictionaries for instance and project attributes. """ metadata_dict = met...
[ "def", "_GetInstanceAndProjectAttributes", "(", "self", ",", "metadata_dict", ")", ":", "metadata_dict", "=", "metadata_dict", "or", "{", "}", "try", ":", "instance_data", "=", "metadata_dict", "[", "'instance'", "]", "[", "'attributes'", "]", "except", "KeyError"...
Get dictionaries for instance and project attributes. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: tuple, two dictionaries for instance and project attributes.
[ "Get", "dictionaries", "for", "instance", "and", "project", "attributes", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L161-L184
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._GetAccountsData
def _GetAccountsData(self, metadata_dict): """Get the user accounts specified in metadata server contents. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. """ instance_data, pro...
python
def _GetAccountsData(self, metadata_dict): """Get the user accounts specified in metadata server contents. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. """ instance_data, pro...
[ "def", "_GetAccountsData", "(", "self", ",", "metadata_dict", ")", ":", "instance_data", ",", "project_data", "=", "self", ".", "_GetInstanceAndProjectAttributes", "(", "metadata_dict", ")", "valid_keys", "=", "[", "instance_data", ".", "get", "(", "'sshKeys'", ")...
Get the user accounts specified in metadata server contents. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
[ "Get", "the", "user", "accounts", "specified", "in", "metadata", "server", "contents", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L186-L203
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._UpdateUsers
def _UpdateUsers(self, update_users): """Provision and update Linux user accounts based on account metadata. Args: update_users: dict, authorized users mapped to their public SSH keys. """ for user, ssh_keys in update_users.items(): if not user or user in self.invalid_users: continu...
python
def _UpdateUsers(self, update_users): """Provision and update Linux user accounts based on account metadata. Args: update_users: dict, authorized users mapped to their public SSH keys. """ for user, ssh_keys in update_users.items(): if not user or user in self.invalid_users: continu...
[ "def", "_UpdateUsers", "(", "self", ",", "update_users", ")", ":", "for", "user", ",", "ssh_keys", "in", "update_users", ".", "items", "(", ")", ":", "if", "not", "user", "or", "user", "in", "self", ".", "invalid_users", ":", "continue", "configured_keys",...
Provision and update Linux user accounts based on account metadata. Args: update_users: dict, authorized users mapped to their public SSH keys.
[ "Provision", "and", "update", "Linux", "user", "accounts", "based", "on", "account", "metadata", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L205-L219
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._RemoveUsers
def _RemoveUsers(self, remove_users): """Deprovision Linux user accounts that do not appear in account metadata. Args: remove_users: list, the username strings of the Linux accounts to remove. """ for username in remove_users: self.utils.RemoveUser(username) self.user_ssh_keys.pop(use...
python
def _RemoveUsers(self, remove_users): """Deprovision Linux user accounts that do not appear in account metadata. Args: remove_users: list, the username strings of the Linux accounts to remove. """ for username in remove_users: self.utils.RemoveUser(username) self.user_ssh_keys.pop(use...
[ "def", "_RemoveUsers", "(", "self", ",", "remove_users", ")", ":", "for", "username", "in", "remove_users", ":", "self", ".", "utils", ".", "RemoveUser", "(", "username", ")", "self", ".", "user_ssh_keys", ".", "pop", "(", "username", ",", "None", ")", "...
Deprovision Linux user accounts that do not appear in account metadata. Args: remove_users: list, the username strings of the Linux accounts to remove.
[ "Deprovision", "Linux", "user", "accounts", "that", "do", "not", "appear", "in", "account", "metadata", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L221-L230
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon._GetEnableOsLoginValue
def _GetEnableOsLoginValue(self, metadata_dict): """Get the value of the enable-oslogin metadata key. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: bool, True if OS Login is enabled for VM access. """ instance_data, project_data = self._GetInstan...
python
def _GetEnableOsLoginValue(self, metadata_dict): """Get the value of the enable-oslogin metadata key. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: bool, True if OS Login is enabled for VM access. """ instance_data, project_data = self._GetInstan...
[ "def", "_GetEnableOsLoginValue", "(", "self", ",", "metadata_dict", ")", ":", "instance_data", ",", "project_data", "=", "self", ".", "_GetInstanceAndProjectAttributes", "(", "metadata_dict", ")", "instance_value", "=", "instance_data", ".", "get", "(", "'enable-oslog...
Get the value of the enable-oslogin metadata key. Args: metadata_dict: json, the deserialized contents of the metadata server. Returns: bool, True if OS Login is enabled for VM access.
[ "Get", "the", "value", "of", "the", "enable", "-", "oslogin", "metadata", "key", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L232-L247
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
AccountsDaemon.HandleAccounts
def HandleAccounts(self, result): """Called when there are changes to the contents of the metadata server. Args: result: json, the deserialized contents of the metadata server. """ self.logger.debug('Checking for changes to user accounts.') configured_users = self.utils.GetConfiguredUsers() ...
python
def HandleAccounts(self, result): """Called when there are changes to the contents of the metadata server. Args: result: json, the deserialized contents of the metadata server. """ self.logger.debug('Checking for changes to user accounts.') configured_users = self.utils.GetConfiguredUsers() ...
[ "def", "HandleAccounts", "(", "self", ",", "result", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Checking for changes to user accounts.'", ")", "configured_users", "=", "self", ".", "utils", ".", "GetConfiguredUsers", "(", ")", "enable_oslogin", "=", "...
Called when there are changes to the contents of the metadata server. Args: result: json, the deserialized contents of the metadata server.
[ "Called", "when", "there", "are", "changes", "to", "the", "contents", "of", "the", "metadata", "server", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L266-L285
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/file_utils.py
_SetSELinuxContext
def _SetSELinuxContext(path): """Set the appropriate SELinux context, if SELinux tools are installed. Calls /sbin/restorecon on the provided path to set the SELinux context as specified by policy. This call does not operate recursively. Only some OS configurations use SELinux. It is therefore acceptable for ...
python
def _SetSELinuxContext(path): """Set the appropriate SELinux context, if SELinux tools are installed. Calls /sbin/restorecon on the provided path to set the SELinux context as specified by policy. This call does not operate recursively. Only some OS configurations use SELinux. It is therefore acceptable for ...
[ "def", "_SetSELinuxContext", "(", "path", ")", ":", "restorecon", "=", "'/sbin/restorecon'", "if", "os", ".", "path", ".", "isfile", "(", "restorecon", ")", "and", "os", ".", "access", "(", "restorecon", ",", "os", ".", "X_OK", ")", ":", "subprocess", "....
Set the appropriate SELinux context, if SELinux tools are installed. Calls /sbin/restorecon on the provided path to set the SELinux context as specified by policy. This call does not operate recursively. Only some OS configurations use SELinux. It is therefore acceptable for restorecon to be missing, in which...
[ "Set", "the", "appropriate", "SELinux", "context", "if", "SELinux", "tools", "are", "installed", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L25-L39
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/file_utils.py
SetPermissions
def SetPermissions(path, mode=None, uid=None, gid=None, mkdir=False): """Set the permissions and ownership of a path. Args: path: string, the path for which owner ID and group ID needs to be setup. mode: octal string, the permissions to set on the path. uid: int, the owner ID to be set for the path. ...
python
def SetPermissions(path, mode=None, uid=None, gid=None, mkdir=False): """Set the permissions and ownership of a path. Args: path: string, the path for which owner ID and group ID needs to be setup. mode: octal string, the permissions to set on the path. uid: int, the owner ID to be set for the path. ...
[ "def", "SetPermissions", "(", "path", ",", "mode", "=", "None", ",", "uid", "=", "None", ",", "gid", "=", "None", ",", "mkdir", "=", "False", ")", ":", "if", "mkdir", "and", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "os", ...
Set the permissions and ownership of a path. Args: path: string, the path for which owner ID and group ID needs to be setup. mode: octal string, the permissions to set on the path. uid: int, the owner ID to be set for the path. gid: int, the group ID to be set for the path. mkdir: bool, True if t...
[ "Set", "the", "permissions", "and", "ownership", "of", "a", "path", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L42-L58
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/file_utils.py
Lock
def Lock(fd, path, blocking): """Lock the provided file descriptor. Args: fd: int, the file descriptor of the file to lock. path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Raises: IOError, raised from flock while attempting to lock a fi...
python
def Lock(fd, path, blocking): """Lock the provided file descriptor. Args: fd: int, the file descriptor of the file to lock. path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Raises: IOError, raised from flock while attempting to lock a fi...
[ "def", "Lock", "(", "fd", ",", "path", ",", "blocking", ")", ":", "operation", "=", "fcntl", ".", "LOCK_EX", "if", "blocking", "else", "fcntl", ".", "LOCK_EX", "|", "fcntl", ".", "LOCK_NB", "try", ":", "fcntl", ".", "flock", "(", "fd", ",", "operatio...
Lock the provided file descriptor. Args: fd: int, the file descriptor of the file to lock. path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Raises: IOError, raised from flock while attempting to lock a file.
[ "Lock", "the", "provided", "file", "descriptor", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L61-L79
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/file_utils.py
Unlock
def Unlock(fd, path): """Release the lock on the file. Args: fd: int, the file descriptor of the file to unlock. path: string, the name of the file to lock. Raises: IOError, raised from flock while attempting to release a file lock. """ try: fcntl.flock(fd, fcntl.LOCK_UN | fcntl.LOCK_NB) e...
python
def Unlock(fd, path): """Release the lock on the file. Args: fd: int, the file descriptor of the file to unlock. path: string, the name of the file to lock. Raises: IOError, raised from flock while attempting to release a file lock. """ try: fcntl.flock(fd, fcntl.LOCK_UN | fcntl.LOCK_NB) e...
[ "def", "Unlock", "(", "fd", ",", "path", ")", ":", "try", ":", "fcntl", ".", "flock", "(", "fd", ",", "fcntl", ".", "LOCK_UN", "|", "fcntl", ".", "LOCK_NB", ")", "except", "IOError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", ...
Release the lock on the file. Args: fd: int, the file descriptor of the file to unlock. path: string, the name of the file to lock. Raises: IOError, raised from flock while attempting to release a file lock.
[ "Release", "the", "lock", "on", "the", "file", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L82-L98
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/file_utils.py
LockFile
def LockFile(path, blocking=False): """Interface to flock-based file locking to prevent concurrent executions. Args: path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Yields: None, yields when a lock on the file is obtained. Raises: IO...
python
def LockFile(path, blocking=False): """Interface to flock-based file locking to prevent concurrent executions. Args: path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Yields: None, yields when a lock on the file is obtained. Raises: IO...
[ "def", "LockFile", "(", "path", ",", "blocking", "=", "False", ")", ":", "fd", "=", "os", ".", "open", "(", "path", ",", "os", ".", "O_CREAT", ")", "try", ":", "Lock", "(", "fd", ",", "path", ",", "blocking", ")", "yield", "finally", ":", "try", ...
Interface to flock-based file locking to prevent concurrent executions. Args: path: string, the name of the file to lock. blocking: bool, whether the function should return immediately. Yields: None, yields when a lock on the file is obtained. Raises: IOError, raised from flock locking operatio...
[ "Interface", "to", "flock", "-", "based", "file", "locking", "to", "prevent", "concurrent", "executions", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L102-L124
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
RetryOnUnavailable
def RetryOnUnavailable(func): """Function decorator to retry on a service unavailable exception.""" @functools.wraps(func) def Wrapper(*args, **kwargs): while True: try: response = func(*args, **kwargs) except (httpclient.HTTPException, socket.error, urlerror.URLError) as e: time....
python
def RetryOnUnavailable(func): """Function decorator to retry on a service unavailable exception.""" @functools.wraps(func) def Wrapper(*args, **kwargs): while True: try: response = func(*args, **kwargs) except (httpclient.HTTPException, socket.error, urlerror.URLError) as e: time....
[ "def", "RetryOnUnavailable", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "Wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "while", "True", ":", "try", ":", "response", "=", "func", "(", "*", "args", ",...
Function decorator to retry on a service unavailable exception.
[ "Function", "decorator", "to", "retry", "on", "a", "service", "unavailable", "exception", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L43-L64
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher._GetMetadataRequest
def _GetMetadataRequest(self, metadata_url, params=None, timeout=None): """Performs a GET request with the metadata headers. Args: metadata_url: string, the URL to perform a GET request on. params: dictionary, the query parameters in the GET request. timeout: int, timeout in seconds for metad...
python
def _GetMetadataRequest(self, metadata_url, params=None, timeout=None): """Performs a GET request with the metadata headers. Args: metadata_url: string, the URL to perform a GET request on. params: dictionary, the query parameters in the GET request. timeout: int, timeout in seconds for metad...
[ "def", "_GetMetadataRequest", "(", "self", ",", "metadata_url", ",", "params", "=", "None", ",", "timeout", "=", "None", ")", ":", "headers", "=", "{", "'Metadata-Flavor'", ":", "'Google'", "}", "params", "=", "urlparse", ".", "urlencode", "(", "params", "...
Performs a GET request with the metadata headers. Args: metadata_url: string, the URL to perform a GET request on. params: dictionary, the query parameters in the GET request. timeout: int, timeout in seconds for metadata requests. Returns: HTTP response from the GET request. Rais...
[ "Performs", "a", "GET", "request", "with", "the", "metadata", "headers", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L82-L102
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher._UpdateEtag
def _UpdateEtag(self, response): """Update the etag from an API response. Args: response: HTTP response with a header field. Returns: bool, True if the etag in the response header updated. """ etag = response.headers.get('etag', self.etag) etag_updated = self.etag != etag self....
python
def _UpdateEtag(self, response): """Update the etag from an API response. Args: response: HTTP response with a header field. Returns: bool, True if the etag in the response header updated. """ etag = response.headers.get('etag', self.etag) etag_updated = self.etag != etag self....
[ "def", "_UpdateEtag", "(", "self", ",", "response", ")", ":", "etag", "=", "response", ".", "headers", ".", "get", "(", "'etag'", ",", "self", ".", "etag", ")", "etag_updated", "=", "self", ".", "etag", "!=", "etag", "self", ".", "etag", "=", "etag",...
Update the etag from an API response. Args: response: HTTP response with a header field. Returns: bool, True if the etag in the response header updated.
[ "Update", "the", "etag", "from", "an", "API", "response", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L104-L116
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher._GetMetadataUpdate
def _GetMetadataUpdate( self, metadata_key='', recursive=True, wait=True, timeout=None): """Request the contents of metadata server and deserialize the response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadat...
python
def _GetMetadataUpdate( self, metadata_key='', recursive=True, wait=True, timeout=None): """Request the contents of metadata server and deserialize the response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadat...
[ "def", "_GetMetadataUpdate", "(", "self", ",", "metadata_key", "=", "''", ",", "recursive", "=", "True", ",", "wait", "=", "True", ",", "timeout", "=", "None", ")", ":", "metadata_key", "=", "os", ".", "path", ".", "join", "(", "metadata_key", ",", "''...
Request the contents of metadata server and deserialize the response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. wait: bool, True if we should wait for a metadata change. timeout: int, timeout...
[ "Request", "the", "contents", "of", "metadata", "server", "and", "deserialize", "the", "response", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L118-L153
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher._HandleMetadataUpdate
def _HandleMetadataUpdate( self, metadata_key='', recursive=True, wait=True, timeout=None, retry=True): """Wait for a successful metadata response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata change...
python
def _HandleMetadataUpdate( self, metadata_key='', recursive=True, wait=True, timeout=None, retry=True): """Wait for a successful metadata response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata change...
[ "def", "_HandleMetadataUpdate", "(", "self", ",", "metadata_key", "=", "''", ",", "recursive", "=", "True", ",", "wait", "=", "True", ",", "timeout", "=", "None", ",", "retry", "=", "True", ")", ":", "exception", "=", "None", "while", "True", ":", "try...
Wait for a successful metadata response. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. wait: bool, True if we should wait for a metadata change. timeout: int, timeout in seconds for returning met...
[ "Wait", "for", "a", "successful", "metadata", "response", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L155-L183
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher.WatchMetadata
def WatchMetadata( self, handler, metadata_key='', recursive=True, timeout=None): """Watch for changes to the contents of the metadata server. Args: handler: callable, a function to call with the updated metadata contents. metadata_key: string, the metadata key to watch for changes. rec...
python
def WatchMetadata( self, handler, metadata_key='', recursive=True, timeout=None): """Watch for changes to the contents of the metadata server. Args: handler: callable, a function to call with the updated metadata contents. metadata_key: string, the metadata key to watch for changes. rec...
[ "def", "WatchMetadata", "(", "self", ",", "handler", ",", "metadata_key", "=", "''", ",", "recursive", "=", "True", ",", "timeout", "=", "None", ")", ":", "while", "True", ":", "response", "=", "self", ".", "_HandleMetadataUpdate", "(", "metadata_key", "="...
Watch for changes to the contents of the metadata server. Args: handler: callable, a function to call with the updated metadata contents. metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. timeout: int, tim...
[ "Watch", "for", "changes", "to", "the", "contents", "of", "the", "metadata", "server", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L185-L202
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py
MetadataWatcher.GetMetadata
def GetMetadata( self, metadata_key='', recursive=True, timeout=None, retry=True): """Retrieve the contents of metadata server for a metadata key. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. ...
python
def GetMetadata( self, metadata_key='', recursive=True, timeout=None, retry=True): """Retrieve the contents of metadata server for a metadata key. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. ...
[ "def", "GetMetadata", "(", "self", ",", "metadata_key", "=", "''", ",", "recursive", "=", "True", ",", "timeout", "=", "None", ",", "retry", "=", "True", ")", ":", "return", "self", ".", "_HandleMetadataUpdate", "(", "metadata_key", "=", "metadata_key", ",...
Retrieve the contents of metadata server for a metadata key. Args: metadata_key: string, the metadata key to watch for changes. recursive: bool, True if we should recursively watch for metadata changes. timeout: int, timeout in seconds for returning metadata output. retry: bool, True if we ...
[ "Retrieve", "the", "contents", "of", "metadata", "server", "for", "a", "metadata", "key", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L204-L219
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py
IpForwarding._LogForwardedIpChanges
def _LogForwardedIpChanges( self, configured, desired, to_add, to_remove, interface): """Log the planned IP address changes. Args: configured: list, the IP address strings already configured. desired: list, the IP address strings that will be configured. to_add: list, the forwarded IP a...
python
def _LogForwardedIpChanges( self, configured, desired, to_add, to_remove, interface): """Log the planned IP address changes. Args: configured: list, the IP address strings already configured. desired: list, the IP address strings that will be configured. to_add: list, the forwarded IP a...
[ "def", "_LogForwardedIpChanges", "(", "self", ",", "configured", ",", "desired", ",", "to_add", ",", "to_remove", ",", "interface", ")", ":", "if", "not", "to_add", "and", "not", "to_remove", ":", "return", "self", ".", "logger", ".", "info", "(", "'Changi...
Log the planned IP address changes. Args: configured: list, the IP address strings already configured. desired: list, the IP address strings that will be configured. to_add: list, the forwarded IP address strings to configure. to_remove: list, the forwarded IP address strings to delete. ...
[ "Log", "the", "planned", "IP", "address", "changes", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L45-L61
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py
IpForwarding._AddForwardedIps
def _AddForwardedIps(self, forwarded_ips, interface): """Configure the forwarded IP address on the network interface. Args: forwarded_ips: list, the forwarded IP address strings to configure. interface: string, the output device to use. """ for address in forwarded_ips: self.ip_forwar...
python
def _AddForwardedIps(self, forwarded_ips, interface): """Configure the forwarded IP address on the network interface. Args: forwarded_ips: list, the forwarded IP address strings to configure. interface: string, the output device to use. """ for address in forwarded_ips: self.ip_forwar...
[ "def", "_AddForwardedIps", "(", "self", ",", "forwarded_ips", ",", "interface", ")", ":", "for", "address", "in", "forwarded_ips", ":", "self", ".", "ip_forwarding_utils", ".", "AddForwardedIp", "(", "address", ",", "interface", ")" ]
Configure the forwarded IP address on the network interface. Args: forwarded_ips: list, the forwarded IP address strings to configure. interface: string, the output device to use.
[ "Configure", "the", "forwarded", "IP", "address", "on", "the", "network", "interface", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L63-L71
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py
IpForwarding._RemoveForwardedIps
def _RemoveForwardedIps(self, forwarded_ips, interface): """Remove the forwarded IP addresses from the network interface. Args: forwarded_ips: list, the forwarded IP address strings to delete. interface: string, the output device to use. """ for address in forwarded_ips: self.ip_forwa...
python
def _RemoveForwardedIps(self, forwarded_ips, interface): """Remove the forwarded IP addresses from the network interface. Args: forwarded_ips: list, the forwarded IP address strings to delete. interface: string, the output device to use. """ for address in forwarded_ips: self.ip_forwa...
[ "def", "_RemoveForwardedIps", "(", "self", ",", "forwarded_ips", ",", "interface", ")", ":", "for", "address", "in", "forwarded_ips", ":", "self", ".", "ip_forwarding_utils", ".", "RemoveForwardedIp", "(", "address", ",", "interface", ")" ]
Remove the forwarded IP addresses from the network interface. Args: forwarded_ips: list, the forwarded IP address strings to delete. interface: string, the output device to use.
[ "Remove", "the", "forwarded", "IP", "addresses", "from", "the", "network", "interface", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L73-L81
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py
IpForwarding.HandleForwardedIps
def HandleForwardedIps(self, interface, forwarded_ips, interface_ip=None): """Handle changes to the forwarded IPs on a network interface. Args: interface: string, the output device to configure. forwarded_ips: list, the forwarded IP address strings desired. interface_ip: string, current inter...
python
def HandleForwardedIps(self, interface, forwarded_ips, interface_ip=None): """Handle changes to the forwarded IPs on a network interface. Args: interface: string, the output device to configure. forwarded_ips: list, the forwarded IP address strings desired. interface_ip: string, current inter...
[ "def", "HandleForwardedIps", "(", "self", ",", "interface", ",", "forwarded_ips", ",", "interface_ip", "=", "None", ")", ":", "desired", "=", "self", ".", "ip_forwarding_utils", ".", "ParseForwardedIps", "(", "forwarded_ips", ")", "configured", "=", "self", ".",...
Handle changes to the forwarded IPs on a network interface. Args: interface: string, the output device to configure. forwarded_ips: list, the forwarded IP address strings desired. interface_ip: string, current interface ip address.
[ "Handle", "changes", "to", "the", "forwarded", "IPs", "on", "a", "network", "interface", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L83-L99
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py
Utils._WriteIfcfg
def _WriteIfcfg(self, interfaces, logger): """Write ifcfg files for multi-NIC support. Overwrites the files. This allows us to update ifcfg-* in the future. Disable the network setup to override this behavior and customize the configurations. Args: interfaces: list of string, the output devi...
python
def _WriteIfcfg(self, interfaces, logger): """Write ifcfg files for multi-NIC support. Overwrites the files. This allows us to update ifcfg-* in the future. Disable the network setup to override this behavior and customize the configurations. Args: interfaces: list of string, the output devi...
[ "def", "_WriteIfcfg", "(", "self", ",", "interfaces", ",", "logger", ")", ":", "for", "interface", "in", "interfaces", ":", "interface_config", "=", "os", ".", "path", ".", "join", "(", "self", ".", "network_path", ",", "'ifcfg-%s'", "%", "interface", ")",...
Write ifcfg files for multi-NIC support. Overwrites the files. This allows us to update ifcfg-* in the future. Disable the network setup to override this behavior and customize the configurations. Args: interfaces: list of string, the output device names to enable. logger: logger object, u...
[ "Write", "ifcfg", "files", "for", "multi", "-", "NIC", "support", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L47-L71
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py
Utils._Ifup
def _Ifup(self, interfaces, logger): """Activate network interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. """ ifup = ['/usr/sbin/wicked', 'ifup', '--timeout', '1'] try: subprocess.check...
python
def _Ifup(self, interfaces, logger): """Activate network interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. """ ifup = ['/usr/sbin/wicked', 'ifup', '--timeout', '1'] try: subprocess.check...
[ "def", "_Ifup", "(", "self", ",", "interfaces", ",", "logger", ")", ":", "ifup", "=", "[", "'/usr/sbin/wicked'", ",", "'ifup'", ",", "'--timeout'", ",", "'1'", "]", "try", ":", "subprocess", ".", "check_call", "(", "ifup", "+", "interfaces", ")", "except...
Activate network interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port.
[ "Activate", "network", "interfaces", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L73-L84
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py
NetworkDaemon.HandleNetworkInterfaces
def HandleNetworkInterfaces(self, result): """Called when network interface metadata changes. Args: result: dict, the metadata response with the network interfaces. """ network_interfaces = self._ExtractInterfaceMetadata(result) if self.network_setup_enabled: self.network_setup.EnableN...
python
def HandleNetworkInterfaces(self, result): """Called when network interface metadata changes. Args: result: dict, the metadata response with the network interfaces. """ network_interfaces = self._ExtractInterfaceMetadata(result) if self.network_setup_enabled: self.network_setup.EnableN...
[ "def", "HandleNetworkInterfaces", "(", "self", ",", "result", ")", ":", "network_interfaces", "=", "self", ".", "_ExtractInterfaceMetadata", "(", "result", ")", "if", "self", ".", "network_setup_enabled", ":", "self", ".", "network_setup", ".", "EnableNetworkInterfa...
Called when network interface metadata changes. Args: result: dict, the metadata response with the network interfaces.
[ "Called", "when", "network", "interface", "metadata", "changes", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py#L84-L99
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py
NetworkDaemon._ExtractInterfaceMetadata
def _ExtractInterfaceMetadata(self, metadata): """Extracts network interface metadata. Args: metadata: dict, the metadata response with the new network interfaces. Returns: list, a list of NetworkInterface objects. """ interfaces = [] for network_interface in metadata: mac_ad...
python
def _ExtractInterfaceMetadata(self, metadata): """Extracts network interface metadata. Args: metadata: dict, the metadata response with the new network interfaces. Returns: list, a list of NetworkInterface objects. """ interfaces = [] for network_interface in metadata: mac_ad...
[ "def", "_ExtractInterfaceMetadata", "(", "self", ",", "metadata", ")", ":", "interfaces", "=", "[", "]", "for", "network_interface", "in", "metadata", ":", "mac_address", "=", "network_interface", ".", "get", "(", "'mac'", ")", "interface", "=", "self", ".", ...
Extracts network interface metadata. Args: metadata: dict, the metadata response with the new network interfaces. Returns: list, a list of NetworkInterface objects.
[ "Extracts", "network", "interface", "metadata", "." ]
53ea8cd069fb4d9a1984d1c167e54c133033f8da
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py#L101-L126
train
sendgrid/python-http-client
python_http_client/client.py
Client._build_url
def _build_url(self, query_params): """Build the final URL to be passed to urllib :param query_params: A dictionary of all the query parameters :type query_params: dictionary :return: string """ url = '' count = 0 while count < len(self._url_path): ...
python
def _build_url(self, query_params): """Build the final URL to be passed to urllib :param query_params: A dictionary of all the query parameters :type query_params: dictionary :return: string """ url = '' count = 0 while count < len(self._url_path): ...
[ "def", "_build_url", "(", "self", ",", "query_params", ")", ":", "url", "=", "''", "count", "=", "0", "while", "count", "<", "len", "(", "self", ".", "_url_path", ")", ":", "url", "+=", "'/{}'", ".", "format", "(", "self", ".", "_url_path", "[", "c...
Build the final URL to be passed to urllib :param query_params: A dictionary of all the query parameters :type query_params: dictionary :return: string
[ "Build", "the", "final", "URL", "to", "be", "passed", "to", "urllib" ]
fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d
https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L107-L132
train
sendgrid/python-http-client
python_http_client/client.py
Client._build_client
def _build_client(self, name=None): """Make a new Client object :param name: Name of the url segment :type name: string :return: A Client object """ url_path = self._url_path + [name] if name else self._url_path return Client(host=self.host, ...
python
def _build_client(self, name=None): """Make a new Client object :param name: Name of the url segment :type name: string :return: A Client object """ url_path = self._url_path + [name] if name else self._url_path return Client(host=self.host, ...
[ "def", "_build_client", "(", "self", ",", "name", "=", "None", ")", ":", "url_path", "=", "self", ".", "_url_path", "+", "[", "name", "]", "if", "name", "else", "self", ".", "_url_path", "return", "Client", "(", "host", "=", "self", ".", "host", ",",...
Make a new Client object :param name: Name of the url segment :type name: string :return: A Client object
[ "Make", "a", "new", "Client", "object" ]
fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d
https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L143-L156
train
sendgrid/python-http-client
python_http_client/client.py
Client._make_request
def _make_request(self, opener, request, timeout=None): """Make the API call and return the response. This is separated into it's own function, so we can mock it easily for testing. :param opener: :type opener: :param request: url payload to request :type request: url...
python
def _make_request(self, opener, request, timeout=None): """Make the API call and return the response. This is separated into it's own function, so we can mock it easily for testing. :param opener: :type opener: :param request: url payload to request :type request: url...
[ "def", "_make_request", "(", "self", ",", "opener", ",", "request", ",", "timeout", "=", "None", ")", ":", "timeout", "=", "timeout", "or", "self", ".", "timeout", "try", ":", "return", "opener", ".", "open", "(", "request", ",", "timeout", "=", "timeo...
Make the API call and return the response. This is separated into it's own function, so we can mock it easily for testing. :param opener: :type opener: :param request: url payload to request :type request: urllib.Request object :param timeout: timeout value or None ...
[ "Make", "the", "API", "call", "and", "return", "the", "response", ".", "This", "is", "separated", "into", "it", "s", "own", "function", "so", "we", "can", "mock", "it", "easily", "for", "testing", "." ]
fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d
https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L158-L176
train
junzis/pyModeS
pyModeS/decoder/bds/bds08.py
category
def category(msg): """Aircraft category number Args: msg (string): 28 bytes hexadecimal message string Returns: int: category number """ if common.typecode(msg) < 1 or common.typecode(msg) > 4: raise RuntimeError("%s: Not a identification message" % msg) msgbin = comm...
python
def category(msg): """Aircraft category number Args: msg (string): 28 bytes hexadecimal message string Returns: int: category number """ if common.typecode(msg) < 1 or common.typecode(msg) > 4: raise RuntimeError("%s: Not a identification message" % msg) msgbin = comm...
[ "def", "category", "(", "msg", ")", ":", "if", "common", ".", "typecode", "(", "msg", ")", "<", "1", "or", "common", ".", "typecode", "(", "msg", ")", ">", "4", ":", "raise", "RuntimeError", "(", "\"%s: Not a identification message\"", "%", "msg", ")", ...
Aircraft category number Args: msg (string): 28 bytes hexadecimal message string Returns: int: category number
[ "Aircraft", "category", "number" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds08.py#L26-L40
train
junzis/pyModeS
pyModeS/decoder/bds/bds05.py
airborne_position
def airborne_position(msg0, msg1, t0, t1): """Decode airborn position from a pair of even and odd position message Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string) t0 (int): timestamps for the even message t...
python
def airborne_position(msg0, msg1, t0, t1): """Decode airborn position from a pair of even and odd position message Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string) t0 (int): timestamps for the even message t...
[ "def", "airborne_position", "(", "msg0", ",", "msg1", ",", "t0", ",", "t1", ")", ":", "mb0", "=", "common", ".", "hex2bin", "(", "msg0", ")", "[", "32", ":", "]", "mb1", "=", "common", ".", "hex2bin", "(", "msg1", ")", "[", "32", ":", "]", "cpr...
Decode airborn position from a pair of even and odd position message Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string) t0 (int): timestamps for the even message t1 (int): timestamps for the odd message Retur...
[ "Decode", "airborn", "position", "from", "a", "pair", "of", "even", "and", "odd", "position", "message" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds05.py#L27-L85
train
junzis/pyModeS
pyModeS/decoder/bds/bds05.py
airborne_position_with_ref
def airborne_position_with_ref(msg, lat_ref, lon_ref): """Decode airborne position with only one message, knowing reference nearby location, such as previously calculated location, ground station, or airport location, etc. The reference position shall be with in 180NM of the true position. Args: ...
python
def airborne_position_with_ref(msg, lat_ref, lon_ref): """Decode airborne position with only one message, knowing reference nearby location, such as previously calculated location, ground station, or airport location, etc. The reference position shall be with in 180NM of the true position. Args: ...
[ "def", "airborne_position_with_ref", "(", "msg", ",", "lat_ref", ",", "lon_ref", ")", ":", "mb", "=", "common", ".", "hex2bin", "(", "msg", ")", "[", "32", ":", "]", "cprlat", "=", "common", ".", "bin2int", "(", "mb", "[", "22", ":", "39", "]", ")"...
Decode airborne position with only one message, knowing reference nearby location, such as previously calculated location, ground station, or airport location, etc. The reference position shall be with in 180NM of the true position. Args: msg (string): even message (28 bytes hexadecimal string)...
[ "Decode", "airborne", "position", "with", "only", "one", "message", "knowing", "reference", "nearby", "location", "such", "as", "previously", "calculated", "location", "ground", "station", "or", "airport", "location", "etc", ".", "The", "reference", "position", "s...
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds05.py#L88-L129
train
junzis/pyModeS
pyModeS/decoder/common.py
hex2bin
def hex2bin(hexstr): """Convert a hexdecimal string to binary string, with zero fillings. """ num_of_bits = len(hexstr) * 4 binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits)) return binstr
python
def hex2bin(hexstr): """Convert a hexdecimal string to binary string, with zero fillings. """ num_of_bits = len(hexstr) * 4 binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits)) return binstr
[ "def", "hex2bin", "(", "hexstr", ")", ":", "num_of_bits", "=", "len", "(", "hexstr", ")", "*", "4", "binstr", "=", "bin", "(", "int", "(", "hexstr", ",", "16", ")", ")", "[", "2", ":", "]", ".", "zfill", "(", "int", "(", "num_of_bits", ")", ")"...
Convert a hexdecimal string to binary string, with zero fillings.
[ "Convert", "a", "hexdecimal", "string", "to", "binary", "string", "with", "zero", "fillings", "." ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L4-L8
train
junzis/pyModeS
pyModeS/decoder/common.py
icao
def icao(msg): """Calculate the ICAO address from an Mode-S message with DF4, DF5, DF20, DF21 Args: msg (String): 28 bytes hexadecimal message string Returns: String: ICAO address in 6 bytes hexadecimal string """ DF = df(msg) if DF in (11, 17, 18): addr = msg[2:8...
python
def icao(msg): """Calculate the ICAO address from an Mode-S message with DF4, DF5, DF20, DF21 Args: msg (String): 28 bytes hexadecimal message string Returns: String: ICAO address in 6 bytes hexadecimal string """ DF = df(msg) if DF in (11, 17, 18): addr = msg[2:8...
[ "def", "icao", "(", "msg", ")", ":", "DF", "=", "df", "(", "msg", ")", "if", "DF", "in", "(", "11", ",", "17", ",", "18", ")", ":", "addr", "=", "msg", "[", "2", ":", "8", "]", "elif", "DF", "in", "(", "0", ",", "4", ",", "5", ",", "1...
Calculate the ICAO address from an Mode-S message with DF4, DF5, DF20, DF21 Args: msg (String): 28 bytes hexadecimal message string Returns: String: ICAO address in 6 bytes hexadecimal string
[ "Calculate", "the", "ICAO", "address", "from", "an", "Mode", "-", "S", "message", "with", "DF4", "DF5", "DF20", "DF21" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L79-L101
train
junzis/pyModeS
pyModeS/decoder/common.py
gray2int
def gray2int(graystr): """Convert greycode to binary""" num = bin2int(graystr) num ^= (num >> 8) num ^= (num >> 4) num ^= (num >> 2) num ^= (num >> 1) return num
python
def gray2int(graystr): """Convert greycode to binary""" num = bin2int(graystr) num ^= (num >> 8) num ^= (num >> 4) num ^= (num >> 2) num ^= (num >> 1) return num
[ "def", "gray2int", "(", "graystr", ")", ":", "num", "=", "bin2int", "(", "graystr", ")", "num", "^=", "(", "num", ">>", "8", ")", "num", "^=", "(", "num", ">>", "4", ")", "num", "^=", "(", "num", ">>", "2", ")", "num", "^=", "(", "num", ">>",...
Convert greycode to binary
[ "Convert", "greycode", "to", "binary" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L268-L275
train
junzis/pyModeS
pyModeS/decoder/common.py
allzeros
def allzeros(msg): """check if the data bits are all zeros Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ d = hex2bin(data(msg)) if bin2int(d) > 0: return False else: return True
python
def allzeros(msg): """check if the data bits are all zeros Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ d = hex2bin(data(msg)) if bin2int(d) > 0: return False else: return True
[ "def", "allzeros", "(", "msg", ")", ":", "d", "=", "hex2bin", "(", "data", "(", "msg", ")", ")", "if", "bin2int", "(", "d", ")", ">", "0", ":", "return", "False", "else", ":", "return", "True" ]
check if the data bits are all zeros Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
[ "check", "if", "the", "data", "bits", "are", "all", "zeros" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L283-L297
train
junzis/pyModeS
pyModeS/decoder/common.py
wrongstatus
def wrongstatus(data, sb, msb, lsb): """Check if the status bit and field bits are consistency. This Function is used for checking BDS code versions. """ # status bit, most significant bit, least significant bit status = int(data[sb-1]) value = bin2int(data[msb-1:lsb]) if not status: ...
python
def wrongstatus(data, sb, msb, lsb): """Check if the status bit and field bits are consistency. This Function is used for checking BDS code versions. """ # status bit, most significant bit, least significant bit status = int(data[sb-1]) value = bin2int(data[msb-1:lsb]) if not status: ...
[ "def", "wrongstatus", "(", "data", ",", "sb", ",", "msb", ",", "lsb", ")", ":", "status", "=", "int", "(", "data", "[", "sb", "-", "1", "]", ")", "value", "=", "bin2int", "(", "data", "[", "msb", "-", "1", ":", "lsb", "]", ")", "if", "not", ...
Check if the status bit and field bits are consistency. This Function is used for checking BDS code versions.
[ "Check", "if", "the", "status", "bit", "and", "field", "bits", "are", "consistency", ".", "This", "Function", "is", "used", "for", "checking", "BDS", "code", "versions", "." ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L300-L313
train
junzis/pyModeS
pyModeS/decoder/adsb.py
version
def version(msg): """ADS-B Version Args: msg (string): 28 bytes hexadecimal message string, TC = 31 Returns: int: version number """ tc = typecode(msg) if tc != 31: raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg) msgbin = common.h...
python
def version(msg): """ADS-B Version Args: msg (string): 28 bytes hexadecimal message string, TC = 31 Returns: int: version number """ tc = typecode(msg) if tc != 31: raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg) msgbin = common.h...
[ "def", "version", "(", "msg", ")", ":", "tc", "=", "typecode", "(", "msg", ")", "if", "tc", "!=", "31", ":", "raise", "RuntimeError", "(", "\"%s: Not a status operation message, expecting TC = 31\"", "%", "msg", ")", "msgbin", "=", "common", ".", "hex2bin", ...
ADS-B Version Args: msg (string): 28 bytes hexadecimal message string, TC = 31 Returns: int: version number
[ "ADS", "-", "B", "Version" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L194-L211
train
junzis/pyModeS
pyModeS/decoder/adsb.py
nic_v1
def nic_v1(msg, NICs): """Calculate NIC, navigation integrity category, for ADS-B version 1 Args: msg (string): 28 bytes hexadecimal message string NICs (int or string): NIC supplement Returns: int or string: Horizontal Radius of Containment int or string: Vertical Protecti...
python
def nic_v1(msg, NICs): """Calculate NIC, navigation integrity category, for ADS-B version 1 Args: msg (string): 28 bytes hexadecimal message string NICs (int or string): NIC supplement Returns: int or string: Horizontal Radius of Containment int or string: Vertical Protecti...
[ "def", "nic_v1", "(", "msg", ",", "NICs", ")", ":", "if", "typecode", "(", "msg", ")", "<", "5", "or", "typecode", "(", "msg", ")", ">", "22", ":", "raise", "RuntimeError", "(", "\"%s: Not a surface position message (5<TC<8), \\ airborne position messag...
Calculate NIC, navigation integrity category, for ADS-B version 1 Args: msg (string): 28 bytes hexadecimal message string NICs (int or string): NIC supplement Returns: int or string: Horizontal Radius of Containment int or string: Vertical Protection Limit
[ "Calculate", "NIC", "navigation", "integrity", "category", "for", "ADS", "-", "B", "version", "1" ]
8cd5655a04b08171a9ad5f1ffd232b7e0178ea53
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L278-L308
train