Hello App: hello.py

Index Home Sample App > Hello App: hello.py

Contents

sys.path.insert(1, mae_python_path)
def init(argv):
def main():
def quit(rc= 0, msg= ''):
MAEApp(appname)
print('App done')

hello.py

#!/usr/bin/python3

hello.py - A sample Python program (Hello World) to demonstrate how the Python-MAE integration works.

Copyright (c) 2024 HanoverSoft

820 Churchill Drive, Chapel Hill, NC  27517

The app starting point, integrated with MAE.

# Written by Anthony V. Edwards

# ave@hanoversoft.net

import os

import sys

mae_python_path= '/usr/mae/python'

if 'MAE_PYTHON' in os.environ:

    mae_python_path= os.environ['MAE_PYTHON']

sys.path.insert(1, mae_python_path)

import HelloApp

import HelloCache

import msgHello

from MAEApp import *

from debug import *

appname= 'hello'

def init(argv):

    if not debug_on:

        MAE.toggleDebug()

    print(f'hello.py init({argv}) method; debug={debug_on}')

    HelloCache.cacheAlloc(appname)

def main():

    print(f'{appname} main() method')

def quit(rc= 0, msg= ''):

    sys.stderr.write(f'{appname}: quit({msg}) method\n')

    if rc:

        MAETask.failed(msg)

    else:

        if not msg:

            msg= 'Completed'

        MAETask.done(msg)

    if debug_on:

        dbgf.write("Done!")

        dbgf.close()

    exit(rc)

Tell MAE how we behave and what channel we listen on.

MAEDaemon means we're always running; we don't perform a task and exit.

If we optionally listened on more channels than just hello, we'd specify

that here (as second parameter).

See module MAE and MAETask for task-specific info and more.

Calling MAETask.getName() will return "hello".

When debug mode is enabled, the dbgf variable will append /usr/mae/log/hellodbg.log.

MAEApp(appname)

# Admittedly, program execution will never get here