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

import os, sys, systemMgr
from logMgr import addLogRecord,CRITICAL,ERROR,WARNING,INFO,DEBUG

def demo():
    """
    arg 1 is generally 0, for multiple adds use the return value of systemMgr.openSysInfo()
        e.g.:
        tok=systemMgr.openSysInfo()
        systemMgr.addProperty(tok, ...)
        systemMgr.addProperty(tok, ...)
        systemMgr.closeSysInfo(tok)
    arg 2 is SOURCE
    arg 3 is NAME
    arg 4 is VALUE
    arg 5 is a dictionary of qualifying attributes
    """
    ret = systemMgr.addProperty(0,'Demo','demoName','demoValue',{})
    if ret:
        addLogRecord(0,__name__, ERROR,'Failed to add Demo record to SystemInfo data: status = 0x%x'%(ret))
    else:
        ret, value = systemMgr.queryProperty(0,'Demo','demoName','',{})
        if value and ret == 0:
            print "demoName is %s" % value
        if ret:
            addLogRecord(0,__name__, WARNING,'Failed to query Demo record: status = 0x%x'%(ret))
    return ret

if __name__ == '__main__':
    sys.exit(demo())
