Skip to content

infomodule_writing

Pragmatismo edited this page Feb 25, 2023 · 1 revision

Info Module

Very simple scripts that are named info_.py, each has a single function of returning a piece of information when run. The script info_datetime.py for example simply prints the current output of the python datetime module - this can be viewed in the gui, integrated into datawalls or similar.

Coding an Info Module

An info module's first line must tell the system how to interpret the code, most likely this is with python.

 #!/usr/bin/python3 

The script requires a function called show_info() which performs whatever system calls are required then returns a text string of the requested information, this function is then run when the script is run from command line.

import datetime

def show_info():

    return str(datetime.datetime.now()).split(".")[0]


if __name__ == '__main__':
    print(show_info())

the format is for the script name to used as the title and the script to only output the data, for example info_datatime.py would show in the gui as;

 (put picture here)
Clone this wiki locally