Date: Sun, 7 Sep 2003 14:05:25 +0200 From: Alexander Leidinger <Alexander@Leidinger.net> To: Jeremy Messenger <mezz7@cox.net> Cc: gnome@freebsd.org Subject: Re: I've played around with gdesklets (patch included for interested parties) Message-ID: <20030907140525.601d62b4.Alexander@Leidinger.net> In-Reply-To: <opru3dzjxv8ckrg5@smtp.central.cox.net> References: <20030906164808.3cd86d76.Alexander@Leidinger.net> <opru3dzjxv8ckrg5@smtp.central.cox.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <mezz7@cox.net> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030907140525.601d62b4.Alexander>