:py:mod:`lager.factory` ======================= .. py:module:: lager.factory Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: lager.factory.MyEncoder lager.factory.Step Functions ~~~~~~~~~ .. autoapisummary:: lager.factory.hash_file lager.factory.get_secret lager.factory.get_default_gateway_linux lager.factory.expand_choices lager.factory.make_header lager.factory.start_data_session lager.factory.close_sock lager.factory.readexactly lager.factory.read_element lager.factory.send_thread_function lager.factory.recv_thread_function lager.factory.run Attributes ~~~~~~~~~~ .. autoapisummary:: lager.factory._STREAM_PORT .. py:data:: _STREAM_PORT :annotation: = 10120 .. py:exception:: Failure Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:function:: hash_file(path) .. py:function:: get_secret(name, default=None) .. py:function:: get_default_gateway_linux() .. py:class:: MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None) Bases: :py:obj:`json.JSONEncoder` Extensible JSON encoder for Python data structures. Supports the following objects and types by default: +-------------------+---------------+ | Python | JSON | +===================+===============+ | dict | object | +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ | str | string | +-------------------+---------------+ | int, float | number | +-------------------+---------------+ | True | true | +-------------------+---------------+ | False | false | +-------------------+---------------+ | None | null | +-------------------+---------------+ To extend this to recognize other objects, subclass and implement a ``.default()`` method with another method that returns a serializable object for ``o`` if possible, otherwise it should call the superclass implementation (to raise ``TypeError``). .. py:method:: default(obj) Implement this method in a subclass such that it returns a serializable object for ``o``, or calls the base implementation (to raise a ``TypeError``). For example, to support arbitrary iterators, you could implement default like this:: def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) .. py:function:: expand_choices(choices) .. py:class:: Step(state, recv_queue=None, send_queue=None) .. py:attribute:: StopOnFail :annotation: = True .. py:method:: output(event_type, event_data=None) .. py:method:: log(to_log, file=sys.stdout) .. py:method:: start() .. py:method:: done(result) .. py:method:: error(exc) .. py:method:: present_pass_fail_buttons(*, timeout=30) .. py:method:: present_buttons(buttons, *, timeout=30) .. py:method:: present_text_input(prompt, size=50, *, timeout=30) .. py:method:: update_heading(text) .. py:method:: present_select(label, choices, allow_multiple=False, *, timeout=30) .. py:method:: present_checkboxes(label, choices, *, timeout=30) .. py:method:: present_radios(label, choices, *, timeout=30) .. py:method:: present_link(url, text=None) .. py:method:: update_image(filename) .. py:method:: hide_image() .. py:method:: _read_response(timeout=30) .. py:function:: make_header(session_id, state) Create header for bridge .. py:function:: start_data_session(session_id) .. py:function:: close_sock(sock, session_id) .. py:function:: readexactly(sock, num_bytes) .. py:function:: read_element(sock) .. py:function:: send_thread_function(sock, send_queue) .. py:function:: recv_thread_function(session_id, recv_queue, send_queue) .. py:function:: run(steps, finalizer_cls=None)