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

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

def demo():
    """
    persistVariable demo script
        arg 1 is operation, read, update, verify, delete
        arg 2 is NAME, or NAME=VALUE
    """
    ret = os.system("persistVariable update pythonName=5")
    if ret:
        print "persistVariable failed save pythonName"
        addLogRecord(0,'persistVariableDemo.py', ERROR, 'persistVariable failed save pythonName')
    else:
        ret = os.system("persistVariable verify pythonName=5")
        if ret:
            print "persist pythonName variable failed to verify"
            addLogRecord(0,'persistVariableDemo.py', ERROR, 'pythonName failed to verify')
        else:
            ret = os.system("persistVariable read pythonName")
            print "persistVariable of variable 'pythonName' succeeded with value %x" % ret
        #cleanup demo variable
        os.system("persistVariable delete pythonName")

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