aiomas.util¶
This module contains some utility functions.
-
aiomas.util.arrow_serializer()[source]¶ Return a serializer for arrow dates.
The return value is an argument tuple for
aiomas.codecs.Codec.add_serializer().
-
aiomas.util.run(until=None, loop=None)[source]¶ Run the event loop forever or until the task/future until is finished.
This is an alias to asyncio’s
run_forever()if until isNoneand torun_until_complete()if not.
-
aiomas.util.make_ssl_server_context(cafile, certfile, keyfile)[source]¶ Return an
ssl.SSLContextthat can be used by a server socket.The server will use the certificate in certfile and private key in keyfile (both in PEM format) to authenticate itself.
It requires clients to also authenticate themselves. Their certificates will be validated with the root CA certificate in cafile.
It will use TLS 1.2 with ECDH+AESGCM encryption. ECDH keys won’t be reused in distinct SSL sessions. Compression is disabled.
-
aiomas.util.make_ssl_client_context(cafile, certfile, keyfile)[source]¶ Return an
ssl.SSLContextthat can be used by a client socket.It uses the root CA certificate in cafile to validate the server’s certificate. It will also check the server’s hostname.
The client will use the certificate in certfile and private key in keyfile (both in PEM format) to authenticate itself.
It will use TLS 1.2 with ECDH+AESGCM encryption.
-
aiomas.util.obj_from_str(obj_path)[source]¶ Return the object that the string obj_path points to.
The format of obj_path is
mod:objwhere mod is a (possibly nested) module name and obj is an.separate object path, for example:module:Class module:Class.function package.module:Class package.module:Class.function
Raise a
ValueErrorif the obj_path is malformed, anImportErrorif the module cannot be imported or anAttributeErrorif an object does not exist.