#!/usr/local/bin/python2.7
#coding:utf-8
import os
import sys
import xml.etree.ElementTree as ET

maintag = sys.argv[1]
childtag = sys.argv[2]
attriname = sys.argv[3]

def getvalue():
    configpath = '/opt/huawei/deploy/etc/deployconfig.xml'
    et = ET.parse('/opt/huawei/deploy/etc/deployconfig.xml')
    rootty = et.getroot()
    itemList = rootty.findall(maintag)
    errCode = 0
    
    try:
        for item in itemList:
            paras = item.findall(childtag)
            for para in paras:
                itemName = para.attrib['name']
                itemValue = para.attrib['value']
                if itemName == attriname:
                     print(itemValue)
                     break
    except:
        errCode = 1
    else:
        errCode = 0
    finally:
        return(errCode)

getvalue()

