hio.core package

Subpackages

Submodules

hio.core.coring module

hio.core.coring Module

hio.core.coring.arpCreate(ether, host, interface='en0', temp=True)

Create arp entry for ethernet mac address ether at ip address host on interface If temp is false then the entry is permanent otherwise its temporary

Assumes added /etc/sudoers entry to run arp with no password for user’s group $ sudo visudo

## Group to run arp as root with no password Cmnd_Alias ARP = /usr/sbin/arp %arp_group ALL=(ALL) NOPASSWD: ARP

hio.core.coring.arpDelete(host, interface='en0')

Delete arp entry for ip address host on interface

Assumes added /etc/sudoers entry to run arp with no password for user’s group $ sudo visudo

## Group to run arp as root with no password Cmnd_Alias ARP = /usr/sbin/arp %arp_group ALL=(ALL) NOPASSWD: ARP

hio.core.coring.normalizeHost(host)

Returns ip address host string in normalized dotted form or empty string converts host parameter which may be the dns name or ip address Prefers ipv4 addresses over ipv6 in that it will only return the ipv6 address if no ipv4 address equivalent is available

hio.core.wiring module

hio.help.wiring module

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

Bases: object

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

rxed

True means log rx

Type:

bool

txed

True means log tx

Type:

bool

samed

True means log both rx and tx to same file or buffer

Type:

bool

filed

True means log to file; False means log to memory buffer

Type:

bool

fmt

io write bytes printf style format string Default is:

b"\n%(dx)b %(who)b:\n%(data)b\n"

Placeholder semantics: who is src or dst for rx/tx, dx is the io direction (b’tx’ or b’rx’), and data is the actual io payload bytes. To write data without direction, who, or line feeds, use fmt=b'%(data)b'.

Type:

bytes

name

used in file name

Type:

str

temp

True means use /tmp directory

Type:

bool

prefix

used as part of path prefix and formatting

Type:

str

headDirPath

used as head of path

Type:

str

tailDirPath

used as tail of path

Type:

str

altTailDirPath

alternate tail of path

Type:

str

dirPath

full directory path

Type:

str

rxl

rx log file or memory buffer

Type:

io.IOBase | io.BytesIO | None

txl

tx log file or memory buffer

Type:

io.IOBase | io.BytesIO | None

opened

True means file/buffer is opened; False otherwise

Type:

bool

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

Init Loggery factory instance

Parameters:
  • bytes (txed is Boolean True means log tx transmitted)

  • bytes

  • buffer (filed is Boolean True means log file False means log to memory)

  • buffer

  • .byted (fmt is printf style format str or bytes converted based on)

  • name (name is application specific log file)

  • close (temp is Boolean True means use /tmp directory If .filed and clear on) – False means use headDirpath If .filed

  • template (prefix is str to include in path and logging)

  • file (headDirPath is str for custom headDirPath for log)

  • changed (reopen is Booblean True means reopen path if anything)

  • reopen (clear is Boolean True means clear .dirPath when closing in)

clearDirPath()

Remove logfile directory at .dirPath

close(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:

flush()

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.

readRx()

Returns rx string buffer value if .buffify else None

readTx()

Returns tx string buffer value if .buffify else None

reopen(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)

writeRx(data, who=b'')

Write bytes data received from source host port address tuple,

writeTx(data, who=b'')

Write bytes data transmitted to destination address da,

class hio.core.wiring.WireLogDoer(wl, **kwa)

Bases: Doer

Basic WireLog Doer

Inherited attributes: .done is Boolean completion state. True means completed. Otherwise incomplete. Incompletion maybe due to close or abort.

Attributes: .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.

Methods include .wind, .__call__, .do, .enter, .recur, .exit, .close, and .abort.

Hidden attributes: ._tymist and ._tock.

__init__(wl, **kwa)
Inherited Parameters:

tymist is Tymist instance tock is float seconds initial value of .tock

Parameters:

instance (keeper is Keeper)

enter(*, temp=None)

Do ‘enter’ context actions. Override in subclass. Not a generator method. Set up resources. Comparable to context manager enter.

Parameters:

temp (bool | None) – True means use temporary file resources if any None means ignore parameter value. Use self.temp

Inject temp or self.temp into file resources here if any

Doist or DoDoer winds its doers on enter

exit()
hio.core.wiring.openWL(cls=None, name='test', temp=True, **kwa)

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)

Module contents

hio.core Package