From owner-freebsd-gnome@FreeBSD.ORG Sat Sep 6 07:46:35 2003 Return-Path: Delivered-To: freebsd-gnome@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8824B16A4BF for ; Sat, 6 Sep 2003 07:46:35 -0700 (PDT) Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by mx1.FreeBSD.org (Postfix) with ESMTP id 36F2C43FDD for ; Sat, 6 Sep 2003 07:46:34 -0700 (PDT) (envelope-from Alexander@Leidinger.net) Received: from fwd09.aul.t-online.de by mailout05.sul.t-online.com with smtp id 19veKf-0005wd-01; Sat, 06 Sep 2003 16:46:33 +0200 Received: from Andro-Beta.Leidinger.net (SO1RFZZlYeCoRt-S0zfDei238UTdf4arRV95xLAjdaIHWYOGxkcWrc@[217.83.31.47]) by fmrl09.sul.t-online.com with esmtp id 19veKQ-25fNr60; Sat, 6 Sep 2003 16:46:18 +0200 Received: from Magelan.Leidinger.net (Magelan [192.168.1.1]) h86ElKu8001387 for ; Sat, 6 Sep 2003 16:47:21 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Received: from Magelan.Leidinger.net (netchild@localhost [127.0.0.1]) by Magelan.Leidinger.net (8.12.9/8.12.9) with SMTP id h86Em8Io030948 for ; Sat, 6 Sep 2003 16:48:08 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Date: Sat, 6 Sep 2003 16:48:08 +0200 From: Alexander Leidinger To: gnome@freebsd.org Message-Id: <20030906164808.3cd86d76.Alexander@Leidinger.net> X-Mailer: Sylpheed version 0.9.3claws (GTK+ 1.2.10; i386-portbld-freebsd5.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Seen: false X-ID: SO1RFZZlYeCoRt-S0zfDei238UTdf4arRV95xLAjdaIHWYOGxkcWrc@t-dialin.net Subject: I've played around with gdesklets (patch included for interested parties) X-BeenThere: freebsd-gnome@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GNOME for FreeBSD -- porting and maintaining List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Sep 2003 14:46:35 -0000 Hi, I've played a little bit around, but I have no time to proceed further... Here's a patch for those which want to get useful numbers out of Psi's Network-0.1.4 tarball... at least it should spit out useful numbers, the Font desklet is missing, so I wasn't able to fully test it. ---snip--- --- /home/netchild/.gdesklets/Sensors/Network/__init__.py.orig Sat Sep 6 16:03:47 2003 +++ /home/netchild/.gdesklets/Sensors/Network/__init__.py Sat Sep 6 16:45:26 2003 @@ -18,7 +18,7 @@ class Network(Sensor): - def __init__(self, interface = "eth0", interval = "1000"): + def __init__(self, interface = "lo0", interval = "1000"): global _; _ = i18n.Translator("memory-sensor") @@ -45,7 +45,7 @@ self._add_thread(self.__command_thread) - fd = open("/proc/net/dev", "r") + fd = os.popen("ifconfig -a | grep mtu", "r") data = fd.read() fd.close() data = data.splitlines() @@ -60,7 +60,7 @@ continue def __get_net_ip(self,device) : - fd = open("/proc/net/arp", "r") + fd = popen("ifconfig " + device, "r") data = fd.read() fd.close() lines = data.splitlines() @@ -69,24 +69,22 @@ l = l.strip() fields = l.split() - if fields[5]==device: - return fields[0] + if fields[0]=="inet": + return fields[1] return "(no ip for this interface)" def __get_net_in_out(self,device) : - fd = open("/proc/net/dev", "r") + fd = popen("netstat -b -I " + device + " | grep Link", "r") data = fd.read() fd.close() lines = data.splitlines() for l in lines[:]: l = l.strip() - l = l.replace(":"," ") fields = l.split() - if fields[0]==device: - return int(fields[1]),int(fields[9]) + return int(fields[6]),int(fields[8]) print "device not found" return 0,0 ---snip--- Bye, Alexander. -- Secret hacker rule #11: hackers read manuals. http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7