Пример #1
0
def default() :
	
	# wait for a while here. To avoid errors.
	time.sleep(1)	
        #print functions.runThisCommand('pwd')print current working directory
	try:
		files = os.listdir('logs/')
		hostName = kernelVersionValue = ipAddressEth0 = netMaskAddr = nSizeofCurDisk ='na'
		nSizeUsed = nSizeNotUsed = 'na'
		#declaring default values...
	except:
		print ' logs/ , folder not found or not allowed to read and write. Please check its existence.'
		print sys.exc_info()
	try:
		CurTime = 'na'
		upSysTime = 'na'
		CurTime = functions.getRequiredFieldData('curtime')
		upSysTime = functions.getRequiredFieldData( 'upTime' )
	        CurTime = ': %s Hrs' %CurTime    
        	upSysTime = ": %s Hrs"%upSysTime
	except:
		print '   Something went wrong. Please check for curTime/Uptime parsing.'
		print sys.exc_info()		
        
	
	try:
		
	        hostName = functions.getRequiredFieldData( 'host' )        
	        kernelVersionValue =  functions.getRequiredFieldData( 'kernel')        
	        ipAddressEth0 = functions.getRequiredFieldData( 'ipaddr' )
	        netMaskAddr = functions.getRequiredFieldData( 'netMask' )        
	        nSizeofCurDisk = functions.getRequiredFieldData( 'totalSpace' )
        	nSizeUsed = functions.getRequiredFieldData( 'usedSpace' )
        	nSizeNotUsed = functions.getRequiredFieldData( 'freeSpace' )
		nSizeofCurDisk+="B"
        	nSizeUsed+="B"
        	nSizeNotUsed+="B"
	except:
		print ' Please check for parsing.host/kernel/ipaddr/netmask/totalspace parsing issue.'
		print sys.exc_info()

        
        
        return template('default',files=files, upTime=upSysTime, nowTime= CurTime, kerVer=kernelVersionValue, hostNameIs = hostName , ipAddrEth0 = ipAddressEth0, totalNetSpace = nSizeofCurDisk, notUsed = nSizeNotUsed, usedSpace = nSizeUsed , netMaskField = netMaskAddr )
Пример #2
0
def default():

    # files = os.listdir('dump/')
    print functions.runThisCommand("pwd")
    files = os.listdir("dump/")

    CurTime = functions.getRequiredFieldData("curtime")
    upSysTime = functions.getRequiredFieldData("upTime")
    CurTime = ": %s Hrs" % CurTime
    upSysTime = ": %s" % upSysTime

    if re.search("min", upSysTime) == None:
        upSysTime += " Hrs"

    hostName = functions.getRequiredFieldData("host")
    kernelVersionValue = functions.getRequiredFieldData("kernel")

    ipAddressEth0 = functions.getRequiredFieldData("ipaddr")
    netMaskAddr = functions.getRequiredFieldData("netMask")

    nSizeofCurDisk = functions.getRequiredFieldData("totalSpace")
    nSizeUsed = functions.getRequiredFieldData("usedSpace")
    nSizeNotUsed = functions.getRequiredFieldData("freeSpace")

    nSizeofCurDisk += "B"
    nSizeUsed += "B"
    nSizeNotUsed += "B"

    return template(
        "default",
        files=files,
        upTime=upSysTime,
        nowTime=CurTime,
        kerVer=kernelVersionValue,
        hostNameIs=hostName,
        ipAddrEth0=ipAddressEth0,
        totalNetSpace=nSizeofCurDisk,
        notUsed=nSizeNotUsed,
        usedSpace=nSizeUsed,
        netMaskField=netMaskAddr,
    )