From owner-freebsd-gnome@FreeBSD.ORG Sun Sep 7 05:04:02 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 F25AA16A4BF for ; Sun, 7 Sep 2003 05:04:01 -0700 (PDT) Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com [194.25.134.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 52DA243F3F for ; Sun, 7 Sep 2003 05:04:00 -0700 (PDT) (envelope-from Alexander@Leidinger.net) Received: from fwd08.aul.t-online.de by mailout06.sul.t-online.com with smtp id 19vyGs-0004X7-00; Sun, 07 Sep 2003 14:03:58 +0200 Received: from Andro-Beta.Leidinger.net (rXByYwZegexDbWw0teXA6cmjR1j-bcaC3IvkBCiBA5KxxtsV8tcdo9@[80.131.111.47]) by fmrl08.sul.t-online.com with esmtp id 19vyGS-1RKy8m0; Sun, 7 Sep 2003 14:03:32 +0200 Received: from Magelan.Leidinger.net (Magelan [192.168.1.1]) h87C4Zu8004117; Sun, 7 Sep 2003 14:04:36 +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 h87C5PeV065302; Sun, 7 Sep 2003 14:05:26 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Date: Sun, 7 Sep 2003 14:05:25 +0200 From: Alexander Leidinger To: Jeremy Messenger Message-Id: <20030907140525.601d62b4.Alexander@Leidinger.net> In-Reply-To: References: <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: multipart/mixed; boundary="Multipart_Sun__7_Sep_2003_14:05:25_+0200_09174200" X-Seen: false X-ID: rXByYwZegexDbWw0teXA6cmjR1j-bcaC3IvkBCiBA5KxxtsV8tcdo9@t-dialin.net cc: gnome@freebsd.org Subject: Re: 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: Sun, 07 Sep 2003 12:04:02 -0000 This is a multi-part message in MIME format. --Multipart_Sun__7_Sep_2003_14:05:25_+0200_09174200 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 06 Sep 2003 14:05:33 -0500 Jeremy Messenger wrote: > What's version of FreeBSD do you have? Here on 5.1-CURRENT, a day before > ATAng went in the tree. I am having the problem with the refresh here, I > had to do it manual. Your patch works great, but I have to refresh > weather, network and others by manual. Strange, the clock is only one that > doesn't has the refresh problem. I can't figure how I can get them fix. The __command_thread() doesn't run. I've also fixed a little bug (the first 2 interfaces aren't choosable) and added some "debug" code to __command_thread(). Bye, Alexander. -- It is easier to fix Unix than to live with NT. http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7 --Multipart_Sun__7_Sep_2003_14:05:25_+0200_09174200 Content-Type: text/plain; name="net.diff" Content-Disposition: attachment; filename="net.diff" Content-Transfer-Encoding: 8bit --- __init__.py.orig Sat Sep 6 16:03:47 2003 +++ __init__.py Sun Sep 7 13:53:16 2003 @@ -18,10 +18,13 @@ class Network(Sensor): - def __init__(self, interface = "eth0", interval = "1000"): + def __init__(self, interface = "lo0", interval = "1000"): global _; _ = i18n.Translator("memory-sensor") + if "eth0" == interface: + interface = "lo0" + self.__in_1 = 0 self.__out_1 = 0 self.__in_2 = 0 @@ -45,12 +48,12 @@ 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() - for l in data[2:] : + for l in data[:] : l = l.strip() l = l.replace(":"," ") fields = l.split() @@ -58,9 +61,13 @@ targ = fields[0] self.__targets.append([targ,targ]) continue + + self.__ip = self.__get_net_ip(interface) + self.__in_1,self.__out_1 = self.__get_net_in_out(interface) + self.__in_1,self.__out_1 = self.__in_2,self.__out_2 def __get_net_ip(self,device) : - fd = open("/proc/net/arp", "r") + fd = os.popen("ifconfig " + device, "r") data = fd.read() fd.close() lines = data.splitlines() @@ -69,24 +76,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 = os.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 @@ -128,8 +133,13 @@ return configurator def __command_thread(self): + print "__command_thread called" while (1): - if (self._is_stopped()): break + if (self._is_stopped()): + print "stopped" + time.sleep(self._get_config("update")*0.001) + continue + print "not stopped" # if the interface just changed then avoid calculating the speed #(to avoid -xxB/s when changing from eth0 to lo for instance or @@ -175,6 +185,7 @@ self.__in_1,self.__out_1 = self.__in_2,self.__out_2 + print "sleeping now..." time.sleep(self._get_config("update")*0.001) def new_sensor(args): return apply(Network, args) --Multipart_Sun__7_Sep_2003_14:05:25_+0200_09174200--