All pastes #557331 Raw Edit

bw.py

public python v1 · immutable
·published 2007-06-10 23:09 UTC
rendered paste body
#!/usr/bin/python#-*- coding: ISO-8859-1 -*-#script escrito por Vinde__module_name__ = "Bandwidth Show"__module_version__ = "0.1"__module_description__ = "Exibe informacoes sobre consumo de banda"import commandsimport timeimport sysimport xchatdef bw(word, word_eol, userdata):	try:		iface = word[1]	except IndexError:		print 'Nenhuma interface foi especificada. Ex: eth0'		return xchat.EAT_ALL	try:		data = commands.getoutput("cat /proc/net/dev | grep %s" % iface)		data = data.split(':')[1].split()		in1 = int(data[0])		out1 = int(data[8])		time.sleep(1)		data = commands.getoutput("cat /proc/net/dev | grep %s" % iface)		data = data.split(':')[1].split()		in1 = (int(data[0]) - int(in1)) / 1024 		out1 = (int(data[8]) - int(out1)) / 1024		xchat.command("say Velocidade atual de download: %s KB/s e upload %s KB/s" % (in1,out1))	except IndexError:		print "Interface %s inválida" % iface		return xchat.EAT_ALL	return xchat.EAT_ALLxchat.hook_command("bw", bw, help="/bw interface")