tagui.py
def send(tagui_instruction = None):
    """send next live mode instruction to tagui for processing if tagui is ready"""

    global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome

    if not _tagui_started:
        print('[TAGUI][ERROR] - use init() before using send()')
        return False

    if tagui_instruction is None or tagui_instruction == '': return True

    try:
        # failsafe exit if tagui process gets killed for whatever reason
        if _process.poll() is not None:
            print('[TAGUI][ERROR] - no active TagUI process to send()')
            _tagui_visual = False
            _tagui_chrome = False
            _tagui_started = False
            return False

        # escape special characters for them to reach tagui correctly
        tagui_instruction = tagui_instruction.replace('\\','\\\\')
        tagui_instruction = tagui_instruction.replace('\n','\\n')
        tagui_instruction = tagui_instruction.replace('\r','\\r')
        tagui_instruction = tagui_instruction.replace('\t','\\t')
        tagui_instruction = tagui_instruction.replace('\a','\\a')
        tagui_instruction = tagui_instruction.replace('\b','\\b')
        tagui_instruction = tagui_instruction.replace('\f','\\f')

        # special handling for single quote to work with _esq() for tagui
        tagui_instruction = tagui_instruction.replace('[BACKSLASH_QUOTE]','\\\'')

        # escape backslash to display source string correctly after echoing
        echo_safe_instruction = tagui_instruction.replace('\\','\\\\')

        # escape double quote because echo step below uses double quotes 
        echo_safe_instruction = echo_safe_instruction.replace('"','\\"')

        # echo live mode instruction, after preparing string to be echo-safe
        _tagui_write('echo "[TAGUI][' + str(_tagui_id) + '] - ' + echo_safe_instruction + '"\n')

        # send live mode instruction to be executed
        _tagui_write(tagui_instruction + '\n')

        # echo marker text to prepare for next instruction
        _tagui_write('echo "[TAGUI][' + str(_tagui_id) + '] - listening for inputs"\n')

        # loop until tagui live mode is ready and listening for inputs
        # also check _tagui_started to handle unexpected termination
        while _tagui_started and not _ready(): pass
        if not _tagui_started:
            print('[TAGUI][ERROR] - TagUI process ended unexpectedly')
            return False

        # increment id and prepare for next instruction
        _tagui_id = _tagui_id + 1

        return True

    except Exception as e:
        print('[TAGUI][ERROR] - ' + str(e))
        return False
send next live mode instruction to tagui for processing if tagui is ready
send next live mode instruction to tagui for processing if tagui is ready
send next live mode instruction to tagui for processing if tagui is ready
def send(tagui_instruction = None):
    global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome
    if not _tagui_started:
        print('[TAGUI][ERROR] - use init() before using send()')
        return False
    if tagui_instruction is None or tagui_instruction == '': return True
    try:
        if _process.poll() is not None:
            print('[TAGUI][ERROR] - no active TagUI process to send()')
            _tagui_visual = False
            _tagui_chrome = False
            _tagui_started = False
            return False
        tagui_instruction = tagui_instruction.replace('\\','\\\\')
        tagui_instruction = tagui_instruction.replace('\n','\\n')
        tagui_instruction = tagui_instruction.replace('\r','\\r')
        tagui_instruction = tagui_instruction.replace('\t','\\t')
        tagui_instruction = tagui_instruction.replace('\a','\\a')
        tagui_instruction = tagui_instruction.replace('\b','\\b')
        tagui_instruction = tagui_instruction.replace('\f','\\f')
        tagui_instruction = tagui_instruction.replace('[BACKSLASH_QUOTE]','\\\'')
        echo_safe_instruction = tagui_instruction.replace('\\','\\\\')
        echo_safe_instruction = echo_safe_instruction.replace('"','\\"')
        _tagui_write('echo "[TAGUI][' + str(_tagui_id) + '] - ' + echo_safe_instruction + '"\n')
        _tagui_write(tagui_instruction + '\n')
        _tagui_write('echo "[TAGUI][' + str(_tagui_id) + '] - listening for inputs"\n')
        while _tagui_started and not _ready(): pass
        if not _tagui_started:
            print('[TAGUI][ERROR] - TagUI process ended unexpectedly')
            return False
        _tagui_id = _tagui_id + 1
        return True
    except Exception as e:
        print('[TAGUI][ERROR] - ' + str(e))
        return False
def send ( tagui_instruction = None ) : global _process , _tagui_started , _tagui_id , _tagui_visual , _tagui_chrome if not _tagui_started : print ( '[TAGUI][ERROR] - use init() before using send()' ) return False if tagui_instruction is None or tagui_instruction == '' : return True try : if _process . poll ( ) is not None : print ( '[TAGUI][ERROR] - no active TagUI process to send()' ) _tagui_visual = False _tagui_chrome = False _tagui_started = False return False tagui_instruction = tagui_instruction . replace ( '\\' , '\\\\' ) tagui_instruction = tagui_instruction . replace ( '\n' , '\\n' ) tagui_instruction = tagui_instruction . replace ( '\r' , '\\r' ) tagui_instruction = tagui_instruction . replace ( '\t' , '\\t' ) tagui_instruction = tagui_instruction . replace ( '\a' , '\\a' ) tagui_instruction = tagui_instruction . replace ( '\b' , '\\b' ) tagui_instruction = tagui_instruction . replace ( '\f' , '\\f' ) tagui_instruction = tagui_instruction . replace ( '[BACKSLASH_QUOTE]' , '\\\'' ) echo_safe_instruction = tagui_instruction . replace ( '\\' , '\\\\' ) echo_safe_instruction = echo_safe_instruction . replace ( '"' , '\\"' ) _tagui_write ( 'echo "[TAGUI][' + str ( _tagui_id ) + '] - ' + echo_safe_instruction + '"\n' ) _tagui_write ( tagui_instruction + '\n' ) _tagui_write ( 'echo "[TAGUI][' + str ( _tagui_id ) + '] - listening for inputs"\n' ) while _tagui_started and not _ready ( ) : pass if not _tagui_started : print ( '[TAGUI][ERROR] - TagUI process ended unexpectedly' ) return False _tagui_id = _tagui_id + 1 return True except Exception as e : print ( '[TAGUI][ERROR] - ' + str ( e ) ) return False
send next live mode instruction to tagui for processing if tagui is ready
send next live mode instruction to tagui for processing if tagui is ready
"""send next live mode instruction to tagui for processing if tagui is ready""" # failsafe exit if tagui process gets killed for whatever reason # escape special characters for them to reach tagui correctly # special handling for single quote to work with _esq() for tagui # escape backslash to display source string correctly after echoing # escape double quote because echo step below uses double quotes  # echo live mode instruction, after preparing string to be echo-safe # send live mode instruction to be executed # echo marker text to prepare for next instruction # loop until tagui live mode is ready and listening for inputs # also check _tagui_started to handle unexpected termination # increment id and prepare for next instruction
tagui_instruction