Ejemplo n.º 1
0
        for opt, arg in opts:
            if opt == '-h':
                console.error(HelpStr)
                sys.exit()
            elif opt in ("-a", "--address"):
                address = arg
            elif opt in ("-c", "--configpath"):
                ConfigFilePath = arg
                ConfigFilePath = ConfigFilePath.strip()

    except Exception as e1:
        console.error("Error : " + str(e1))
        sys.exit(1)

    try:
        port, loglocation = MySupport.GetGenmonInitInfo(ConfigFilePath,
                                                        log=console)
        log = SetupLogger("client", loglocation + "gengpio.log")
    except Exception as e1:
        console.error("Error : " + str(e1))
        sys.exit(1)
    try:
        # Set the signal handler
        signal.signal(signal.SIGINT, signal_handler)

        MyClientInterface = ClientInterface(host=address, port=port, log=log)

        #setup GPIO using Board numbering
        GPIO.setmode(GPIO.BOARD)

        console.info(GPIO.RPI_INFO)
Ejemplo n.º 2
0
        LogFile.flush()


#------------------- Command-line interface for genlog -------------------------
if __name__ == '__main__':

    address = ProgramDefaults.LocalHost
    fileName = ""

    HelpStr = '\npython genlog.py -a <IP Address or localhost> -f <outputfile> -c <config file path>\n'

    try:
        ConfigFilePath = ProgramDefaults.ConfPath
        console = SetupLogger("genlog_console", log_file="", stream=True)

        port, loglocation, multi_instance = MySupport.GetGenmonInitInfo(
            ConfigFilePath, log=console)

        if not MySupport.PermissionsOK():
            console.error(
                "You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting."
            )
            sys.exit(2)

        if MySupport.IsRunning(os.path.basename(__file__),
                               multi_instance=multi_instance):
            console.error("The program %s is already loaded" %
                          os.path.basename(__file__))
            sys.exit(2)

        opts, args = getopt.getopt(
            sys.argv[1:], "ha:f:c:",