• Python/Term Emulation

    From DustCouncil@21:1/227 to All on Sunday, May 25, 2025 17:52:56
    I am currently working a job which leaves me all but useless at the end of the day. As a result, I decompress doing mundane tasks, and one of these is cleaning up the ASCII experience on my system, in hopes that people on retrocomputing platforms can telnet in with tcpser or whatever and have a usable experience.

    One of the scripts on my system is the popular IBOL (interBBS OneLiner) script. This will print an ANSI header regardless of terminal emulation, and embedded Python is not very well documented on the Mystic wiki. What I'd really like to do is detect terminal emulation and either print the .ANS if ANSI emulation is in effect, otherwise print the ASC, but I have no idea how to determine/IF-THEN this in Python.

    ibol.mpy:

    def dispfile(filename):
    global cfgtextpath
    if os.path.isfile(cfgtextpath+filename+".ans"):
    f=open(cfgtextpath+filename+".ans","r")
    ...

    This the function that checks if the header file (with the .ans extension) exists, and, if so, reads and prints it.

    What I want to do is determine the terminal emulation and put an if-then statement either selecting the .ANS or .ASC file accordingly.

    I am running v0.2 of this script.

    This is a nitpicky thing, but other than this my system does well filtering out the ANSI stuff except for this, with a few other exceptions.

    Does anyone know how to do this? One other possibility is to re-write the .ANS header using built-incodes rather than ANSI in hopes Mystic will fitler them.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Shipwrecks & Shibboleths [San Francisco, CA - USA] (21:1/227)
  • From opicron@21:3/126 to DustCouncil on Monday, May 26, 2025 18:32:40
    One of the scripts on my system is the popular IBOL (interBBS OneLiner) sc
    This will print an ANSI header regardless of terminal emulation, and embe Python is not very well documented on the Mystic wiki. What I'd really lik do is detect terminal emulation and either print the .ANS if ANSI emulatio in effect, otherwise print the ASC, but I have no idea how to determine/IF this in Python.

    This the function that checks if the header file (with the .ans extension) exists, and, if so, reads and prints it.

    What I want to do is determine the terminal emulation and put an if-then statement either selecting the .ANS or .ASC file accordingly.

    I am running v0.2 of this script.

    This is a nitpicky thing, but other than this my system does well filterin the ANSI stuff except for this, with a few other exceptions.

    Does anyone know how to do this? One other possibility is to re-write the header using built-incodes rather than ANSI in hopes Mystic will fitler th


    You might be lucky using find_display(). It will load the correct ANSI file for the current screen size 80x25 or 132x37 etc. I never tried, but I think it will also load the ASC instead of ANS when the emulation mode is set.

    Do note that find_display('filename') only works on the newer Mystic release.

    To determine yourself if you need ANS or ASC, you can use mci2str('SI') which will return ASCII or ANSI.

    oP!

    ... Join the Group Mind - become a Borg

    --- Mystic BBS v1.12 A49 2024/05/29 (Linux/64)
    * Origin: TheForze - bbs.theforze.eu:23 (21:3/126)
  • From DustCouncil@21:1/227 to opicron on Monday, May 26, 2025 20:42:21
    One of the scripts on my system is the popular IBOL (interBBS OneLine
    This will print an ANSI header regardless of terminal emulation, and Python is not very well documented on the Mystic wiki. What I'd reall do is detect terminal emulation and either print the .ANS if ANSI emu in effect, otherwise print the ASC, but I have no idea how to determi this in Python.

    What I want to do is determine the terminal emulation and put an if-t statement either selecting the .ANS or .ASC file accordingly.
    To determine yourself if you need ANS or ASC, you can use mci2str('SI') which will return ASCII or ANSI.
    * Origin: TheForze - bbs.theforze.eu:23 (21:3/126)

    Thanks for the response. It looks like the showfile() function has this capability built in, wherein you specify something like:

    showfile("filename") without an extension and Mystic applies the right one based on terminal emulation.

    Answering myself here in case anyone else searches on this.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Shipwrecks & Shibboleths [San Francisco, CA - USA] (21:1/227)