hio.core

hio.core Package

Subpackages

Submodules

Package Contents

Classes

WireLog

For debugging of non-blocking transports, provides log files or in memory

WireLogDoer

Basic WireLog Doer

Functions

openWL(cls=None, name='test', temp=True, **kwa)

Context manager wrapper WireLog instances.

hio.core.openWL(cls=None, name='test', temp=True, **kwa)[source]

Context manager wrapper WireLog instances. Defaults to temporary wire logs. Context ‘with’ statements call .close on exit of ‘with’ block

Parameters
  • instance (cls is Class instance of subclass) –

  • wirelogs (name is str name of wirelog instance for filename so can have multiple) – at different paths thar each use different file name

  • Boolean (temp is) – Otherwise open in persistent directory, do not clear on close

  • directory (True means open in temporary) – Otherwise open in persistent directory, do not clear on close

  • close (clear on) – Otherwise open in persistent directory, do not clear on close

Usage:

with openWL(name=”bob”) as wl:

wl.writeRx ….

with openWL(name=”eve”, cls=SubclassedWireLog)

class hio.core.WireLog(rxed=True, txed=True, samed=False, filed=False, fmt=None, name='main', temp=False, prefix=None, headDirPath=None, reopen=False, clear=False)[source]

For debugging of non-blocking transports, provides log files or in memory buffers for logging ‘over the wire’ network tx and rx packets as bytes

Attributes:

.rxed is Boolean True means log rx .txed is Boolean True means log tx .samed is Boolean True means log both rx and tx to same file or buffer .filed is Boolean True means log to file False means log to memory buffer .fmt is io write bytes printf style format string

Default is b’

%(dx)b %(who)b: %(data)b ‘ where:

who is src or dst for rx tx respectively dx is the io direction and will be set to either b’tx’ or b’rx’ and data is the actual io data as bytes

to write io data without direction who or line feeds use fmt= b’%(data)b’

.name is str used in file name .temp is Boolean True means use /tmp directory .prefix is str used as part of path prefix and formating .headDirPath is str used as head of path .tailDirpath is str used as tail of path .altTailDirPath is str used a alternate tail of path .dirPath is full directory path .rxl is rx log io file or io buffer .txl is tx log io file or io buffer .opened is Boolean, True means file is opened Otherwise False

Prefix = hio
HeadDirPath = /usr/local/var
TailDirPath = wirelogs
AltHeadDirPath = ~
TempHeadDir = /tmp
TempPrefix = test_
TempSuffix = _temp
Format = b'\n%(dx)b %(who)b:\n%(data)b\n'
reopen(self, rxed=None, txed=None, samed=None, filed=None, fmt=None, name=None, temp=None, headDirPath=None, clear=False)

Use or Create if not preexistent, directory path for file .path First closes .path if already opened. If clear is True then also clears .path before reopening

Parameters
  • ignore. (fmt is optional bytes printf format If None or unchanged then) – Otherwise when creating io use .rxed if not provided

  • ignore. – Otherwise when creating io use .txed if not provided

  • ignore. – Otherwise when creating io use .same if not provided

  • ignore. – Otherwise when creating io use .filed if not provided

  • ignore. – Otherwise when creating io use .fmt if not provided

  • name (name is optional) –

    if None or unchanged then ignore otherwise recreate path

    When recreating path, If not provided use .name

  • boolean (temp is optional) –

    If None ignore Otherwise

    Assign to .temp If True then open in temporary directory and clear on close, If False then open persistent directory

  • database (headDirPath is optional str head directory pathname of main) –

    if None or unchanged then ignore otherwise recreate path

    When recreating path, If not provided use default .HeadDirpath

  • closing (clear is Boolean True means clear .path when) –

flush(self)

flush files if any and opened. A file flush only moves from program buffer to operating system buffer. A file fsync moves from operating system buffer to disk.

close(self, clear=False)

Close io logs. If clear or self.temp then remove directory at .dirPath :param clear is boolean: :param True means clear directory at .dirPath if any:

clearDirPath(self)

Remove logfile directory at .dirPath

readRx(self)

Returns rx string buffer value if .buffify else None

readTx(self)

Returns tx string buffer value if .buffify else None

writeRx(self, data, who=b'')

Write bytes data received from source host port address tuple,

writeTx(self, data, who=b'')

Write bytes data transmitted to destination address da,

class hio.core.WireLogDoer(wl, **kwa)[source]

Bases: hio.base.doing.Doer

Basic WireLog Doer

Inherited Attributes:
.done is Boolean completion state:

True means completed Otherwise incomplete. Incompletion maybe due to close or abort.

.wl is WireLog subclass
Inherited Properties:

.tyme is float ._tymist.tyme, relative cycle or artificial time .tock is float, desired time in seconds between runs or until next run,

non negative, zero means run asap

Properties:

.wind  injects ._tymist dependency
.__call__ makes instance callable

Appears as generator function that returns generator

.do is generator method that returns generator
.enter is enter context action method
.recur is recur context action method or generator method
.exit is exit context method
.close is close context method
.abort is abort context method
Hidden:

._tymist is Tymist instance reference ._tock is hidden attribute for .tock property

enter(self)
exit(self)