##
# other modules
import sub_process
import sys
import aosd
import ConfigParser


# our modules
import func_module


# =================================

class msg(func_module.FuncModule):

    version = "0.0.1"
    api_version = "0.0.1"
    description = "Display messages"

    def display (self,flags):
        """
        parse the msg for display.
        """
        try:
            text,config_section=flags.split("|")
            if config_section == '':
                config_section="default"
        except:
            text=flags
            config_section="default"

        cmd = sub_process.Popen("/usr/LH/bin/msg_client.py --msg \"%s\" " % flags,stdout=sub_process.PIPE,shell=True)
        data = cmd.communicate()[0]
    
        cmd = sub_process.Popen("/usr/bin/echo -e \"%s\" | /usr/bin/wall" % text, stdout=sub_process.PIPE,shell=True)
        data = cmd.communicate()[0]
        return ("Message delivered")