#!/usr/bin/python
# -*- coding: latin-1 -*-

import os, sys, logMgr
from systemMgr import queryProperty

def demo():
    """
    arg 1 is generally 0, for multiple log entries use the return value of logMgr.openSystemLog()
        e.g.:
        tok=logMgr.openSystemLog()
        logMgr.addLogRecord(tok, ...)
        logMgr.addLogRecord(tok, ...)
        logMgr.closeSystemLog(tok)
    arg 2 is SOURCE
    arg 3 is severity level [logMgr.CRITICAL,logMgr.ERROR,logMgr.WARNING,logMgr.INFO,logMgr.DEBUG]
    arg 4 is log message string
    """
    ret, value = queryProperty(0,'IntelBIOSID','BoardFamilyID','',{})
    if value and ret == 0:
        if value == 'S3000':
            logMgr.addLogRecord(0,'addLogRecordDemo.py', logMgr.INFO,'Deploying S3000 system')
        else:
            logMgr.addLogRecord(0,'addLogRecordDemo.py', logMgr.ERROR,'This script is looking for a S3000 system: Invalid system %s'%value)
    if ret:
        logMgr.addLogRecord(0,'addLogRecordDemo.py', logMgr.WARNING,'Intel board family query failed: status = 0x%x'%(ret))

if __name__ == '__main__':
    print "This Python script demonstrates how to detect a system board family and log the results of the detection."
    sys.exit(demo())
