- class batou.utils.Address(connect_address, port=None, require_v4=<object object>, require_v6=<object object>)¶
An internet service address that can be listened and connected to.
The constructor address is expected to be the address that can be connected to. The listen address will be computed automatically.
>>> x = Address('localhost', 80) >>> str(x.connect) 'localhost:80' >>> str(x.listen) '127.0.0.1:80'
You can specify which IP versions are expected to be resolved for listen addresses in three ways with the require_v4/require_v6 flags:
False -> this version must not be used
True -> this version must be resolved properly
- ‘optional’ -> the listen/listen_v6 attribute will contain None if it does
- connect = None¶
The connect address as it should be used when configuring clients. This is a
- property listen¶
- class batou.utils.BagOfAttributes¶
Provide a dict-like object that can also be accessed using attributes.
It’s sometimes more convenient to write a.x instead of a[‘x’]. However, namespaces may require being able to also use non-Python-identifier keys.
- exception batou.utils.CmdExecutionError(cmd, returncode, stdout, stderr)¶
- exception batou.utils.CycleError¶
- class batou.utils.NetLoc(host, port=None)¶
A network location specified by host and port.
Network locations can automatically render an appropriate string representation:
>>> x = NetLoc('127.0.0.1') >>> x.host '127.0.0.1' >>> x.port None >>> str(x) '127.0.0.1' >>> y = NetLoc('127.0.0.1', 80) >>> str(y) '127.0.0.1:80'
- host = None¶
The host part of this network location. Can be a hostname or IP address.
- port = None¶
The port of this network location. Can be
Noneor an integer.
- batou.utils.call_with_optional_args(func, **kw)¶
Provide a way to perform backwards-compatible call, passing only arguments that the function actually expects.
- batou.utils.dict_merge(a, b)¶
recursively merges dict’s. not just simple a[‘key’] = b[‘key’], if both a and b have a key who’s value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. https://www.xormedia.com/recursively-merge-dictionaries-in-python/