diff options
author | netchild <netchild@FreeBSD.org> | 2003-09-26 11:02:10 +0000 |
---|---|---|
committer | netchild <netchild@FreeBSD.org> | 2003-09-26 11:02:10 +0000 |
commit | 064ffa9c19b92c807ba7b1bad0bf71b7421cbd8c (patch) | |
tree | 8cd03dc3badcb5f17adf668ee3c00c9dd80fad07 /deskutils/gdesklets/files | |
parent | 3c185a36ede433e0dd918d77d00b9a05af20abf2 (diff) | |
download | FreeBSD-ports-064ffa9c19b92c807ba7b1bad0bf71b7421cbd8c.zip FreeBSD-ports-064ffa9c19b92c807ba7b1bad0bf71b7421cbd8c.tar.gz |
Update to 0.22.
This update is a collaboration between the maintainer and myself, the
libdesklets part isn't finished and needs a little more debugging (RAM
and boottime display).
Unfortunately we also have a problem with threads (they get created, but
they don't run/start) which we can't track down, so it's not easy to
debug the remaining libdesklets bugs.
We decided to commit the port in the current incarnation as at least the
desklets which I will commit shortly after this update will work without
problems.
Submitted by: maintainer
Diffstat (limited to 'deskutils/gdesklets/files')
-rw-r--r-- | deskutils/gdesklets/files/patch-data::Makefile.in | 11 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::CPU.py | 104 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::Disk.py | 51 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::Memory.py | 122 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::Network.py | 149 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::Sys.py | 114 | ||||
-rw-r--r-- | deskutils/gdesklets/files/patch-libdesklets::__init__.py | 17 |
7 files changed, 568 insertions, 0 deletions
diff --git a/deskutils/gdesklets/files/patch-data::Makefile.in b/deskutils/gdesklets/files/patch-data::Makefile.in new file mode 100644 index 0000000..507a429 --- /dev/null +++ b/deskutils/gdesklets/files/patch-data::Makefile.in @@ -0,0 +1,11 @@ +--- data/Makefile.in.orig Wed Sep 17 18:19:06 2003 ++++ data/Makefile.in Wed Sep 17 18:20:02 2003 +@@ -190,7 +190,7 @@ + @USERINST_TRUE@mimedir = ~/.gnome/mime-info + mime_in_files = gdesklets.keys.in + mime_DATA = $(mime_in_files:.keys.in=.keys) gdesklets.mime +-@USERINST_FALSE@mimeicondir = $(datadir)/icons/gnome/48x48/mimetypes ++@USERINST_FALSE@mimeicondir = $(prefix)/share/icons/gnome/48x48/mimetypes + + @USERINST_TRUE@mimeicondir = ~/.icons/gnome/48x48/mimetypes + mimeicon_DATA = x-gdesklets-display.png diff --git a/deskutils/gdesklets/files/patch-libdesklets::CPU.py b/deskutils/gdesklets/files/patch-libdesklets::CPU.py new file mode 100644 index 0000000..940cece --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::CPU.py @@ -0,0 +1,104 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/CPU.py.orig Mon Sep 22 12:16:08 2003 ++++ libdesklets/CPU.py Mon Sep 22 12:22:32 2003 +@@ -1,5 +1,7 @@ + import polling + ++import os ++import libdesklets as lib + + # + # TODO: support SMP +@@ -21,8 +23,16 @@ + + self.get_load = polling.wrap(self.__poll_load, 0.2) + ++ platform = lib.sys.get_os() ++ + try: +- fd = open("/proc/cpuinfo", "r") ++ if platform == "FreeBSD": ++ fd = os.popen("grep -3 CPU /var/run/dmesg.boot | head -7 | tail -4", "r") ++ elif platform == "Linux": ++ fd = open("/proc/cpuinfo", "r") ++ else: ++ print "Unknown OS, strange things may happen." ++ return + except IOError, e: + import traceback; traceback.print_exc() + print e +@@ -40,15 +51,24 @@ + + def __poll_cpu(self): + +- import libdesklets as lib ++ import re + arch = lib.sys.get_arch() ++ platform = lib.sys.get_os() + if (arch in ["i386", "i486", "i586", "i686"]): +- fields = self.__lines[4].split() +- model_name = " ".join(fields[3:]) +- fields = self.__lines[6].split() +- cpu_mhz = fields[3] +- fields = self.__lines[7].split() +- cpu_cache = " ".join(fields[3:5]) ++ if ("FreeBSD" == platform): ++ m = re.search('^CPU: (.*) \(([0-9]+.*)-MHz [0-9]+-class CPU\)', self.__lines[0]) ++ model_name = m.group(1) # or sysctl hw.model ++ cpu_mhz = m.group(2) # or sysctl hw.clockrate ++ cpu_cache = " " # not available by default ++ elif ("Linux" == platform): ++ fields = self.__lines[4].split() ++ model_name = " ".join(fields[3:]) ++ fields = self.__lines[6].split() ++ cpu_mhz = fields[3] ++ fields = self.__lines[7].split() ++ cpu_cache = " ".join(fields[3:5]) ++ else: ++ pass + + elif (arch == "ppc"): + fields = self.__lines[0].split() +@@ -68,17 +88,34 @@ + + def __poll_load(self): + +- fd = open("/proc/stat", "r") ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ fd = os.popen("iostat -n 0", "r") ++ line = 2 ++ elif ("Linux" == platform): ++ fd = open("/proc/stat", "r") ++ line = 0 ++ else: ++ return + data = fd.read() + fd.close() + + data = data.splitlines() +- fields = data[0].split() ++ fields = data[line].split() + +- u = float(fields[1]) +- s = float(fields[2]) +- n = float(fields[3]) +- i = float(fields[4]) ++ if ("FreeBSD" == platform): ++ u = float(fields[2]) + float(fields[3]) ++ s = float(fields[4]) ++ n = float(fields[5]) ++ i = float(fields[6]) ++ elif ("Linux" == platform): ++ u = float(fields[1]) ++ s = float(fields[2]) ++ n = float(fields[3]) ++ i = float(fields[4]) ++ else: ++ pass + + total = ((u - self.__uT) + (s - self.__sT) + (n - self.__nT) + + (i - self.__iT)) diff --git a/deskutils/gdesklets/files/patch-libdesklets::Disk.py b/deskutils/gdesklets/files/patch-libdesklets::Disk.py new file mode 100644 index 0000000..9e62697 --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::Disk.py @@ -0,0 +1,51 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/Disk.py.orig Mon Sep 22 12:25:18 2003 ++++ libdesklets/Disk.py Mon Sep 22 12:28:28 2003 +@@ -3,7 +3,7 @@ + import time + import os + import statvfs +- ++import libdesklets as lib + + class Disk: + +@@ -19,21 +19,33 @@ + + def __poll_partitions(self): + ++ platform = lib.sys.get_os() ++ + # we don't have to reread the file if it hasn't changed +- if (self.__partitions_last_read >= os.path.getmtime("/etc/mtab")): ++ if (platform == "Linux" and self.__partitions_last_read >= os.path.getmtime("/etc/mtab")): + return self.__partitions + else: + self.__partitions_last_read = time.time() + + # /etc/mtab is more portable than /proc/mount, so we use it +- fd = open("/etc/mtab", "r") ++ if (platform == "Linux"): ++ fd = open("/etc/mtab", "r") ++ else: ++ fd = os.popen("mount", "r") + lines = fd.readlines() + fd.close() + + partitions = [] + for l in lines: + parts = l.split() +- device, mpoint, fstype = parts[:3] ++ if (platform == "Linux"): ++ device, mpoint, fstype = parts[:3] ++ elif (platform == "FreeBSD"): ++ device = parts[0] ++ mpoint = parts[2] ++ import re ++ m = re.search('\(([a-zA-Z]+)[,)]', parts[3]) ++ fstype = m.group(0) + # FIXME: is this OK? it might be better to check if the device + # actually is a file in /dev + if (fstype in ("ext2", "ext3", "msdos", "vfat", "ntfs", "hpfs" diff --git a/deskutils/gdesklets/files/patch-libdesklets::Memory.py b/deskutils/gdesklets/files/patch-libdesklets::Memory.py new file mode 100644 index 0000000..cbe2d7e --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::Memory.py @@ -0,0 +1,122 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/Memory.py.orig Sun Sep 21 14:08:18 2003 ++++ libdesklets/Memory.py Thu Sep 25 12:08:35 2003 +@@ -1,7 +1,7 @@ + import polling + + import os, stat +- ++import libdesklets as lib + + class Memory: + +@@ -17,39 +17,83 @@ + + def __poll_total_ram(self): + +- memtotal = os.stat("/proc/kcore")[stat.ST_SIZE] ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ fd = os.popen("sysctl hw.physmem") ++ physmem = fd.readline() ++ fd.close() ++ lines = physmem.splitlines() ++ memtotal = int(lines[0].split()[1]) ++ elif ("Linux" == platform): ++ memtotal = os.stat("/proc/kcore")[stat.ST_SIZE] ++ else: ++ memtotal = 0 ++ + return memtotal + + def __poll_mem(self, mode): + +- fd = open("/proc/meminfo", "r") +- mem = fd.read() +- fd.close() +- lines = mem.splitlines() ++ platform = lib.sys.get_os() + + # RAM + if (mode == 0): +- total = int(self.__get_total_ram()/1024) +- for l in lines: +- if (l.startswith("MemFree:")): +- value = l.split() +- free = int(value[1]) +- elif (l.startswith("Cached:")): +- value = l.split() +- free = free + int(value[1]) +- break +- used = total - free ++ if ("FreeBSD" == platform): ++ fd = os.popen("vmstat -n 0", "r") ++ elif ("Linux" == platform): ++ fd = open("/proc/meminfo", "r") ++ else: ++ return (0, 0) ++ mem = fd.read() ++ fd.close() ++ lines = mem.splitlines() ++ ++ if ("FreeBSD" == platform): ++ # this may be larger than total, as this is the active virtual ++ # memory, not the active physical memory ++ used = int(lines[2].split()[3])/1024 ++ total = int(self.__get_total_ram()/1024) ++ elif ("Linux" == platform): ++ total = int(self.__get_total_ram()/1024) ++ for l in lines: ++ if (l.startswith("MemFree:")): ++ value = l.split() ++ free = int(value[1]) ++ elif (l.startswith("Cached:")): ++ value = l.split() ++ free = free + int(value[1]) ++ break ++ used = total - free ++ else: ++ pass + + # Swap + elif (mode == 1): +- for l in lines: +- if (l.startswith("SwapTotal:")): +- value = l.split() +- total = int(value[1]) +- elif (l.startswith("SwapFree:")): +- value = l.split() +- free = int(value[1]) +- break +- used = total - free ++ if ("FreeBSD" == platform): ++ fd = os.popen("pstat -T", "r") ++ elif ("Linux" == platform): ++ fd = open("/proc/meminfo", "r") ++ else: ++ return (0, 0) ++ mem = fd.read() ++ fd.close() ++ lines = mem.splitlines() ++ ++ if ("FreeBSD" == platform): ++ used, total = lines[1].split()[0].split("/") ++ used = int(used[0:-2]) * 1024 * 1024 ++ total = int(total[0:-2]) * 1024 * 1024 ++ elif ("Linux" == platform): ++ for l in lines: ++ if (l.startswith("SwapTotal:")): ++ value = l.split() ++ total = int(value[1]) ++ elif (l.startswith("SwapFree:")): ++ value = l.split() ++ free = int(value[1]) ++ break ++ used = total - free ++ else: ++ pass + + return (total, used) diff --git a/deskutils/gdesklets/files/patch-libdesklets::Network.py b/deskutils/gdesklets/files/patch-libdesklets::Network.py new file mode 100644 index 0000000..17ee7c9 --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::Network.py @@ -0,0 +1,149 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/Network.py.orig Mon Sep 22 12:51:42 2003 ++++ libdesklets/Network.py Mon Sep 22 13:04:06 2003 +@@ -1,7 +1,9 @@ + import polling + + import commands ++import os + import time ++import libdesklets as lib + + class Network: + +@@ -25,22 +27,42 @@ + + def __poll_devices(self): + +- fd = open("/proc/net/dev", "r") ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ fd = os.popen("ifconfig -a | grep mtu", "r") ++ elif ("Linux" == platform): ++ fd = open("/proc/net/dev", "r") ++ else: ++ return [] + data = fd.readlines() + fd.close() + + devices = [] +- for lines in data[2:]: +- l = lines.strip() +- l = l.replace(":", " ") +- fields = l.split() + +- if (fields[0] == "lo"): +- continue +- else: # (fields[0].startswith("eth")): +- device = fields[0] +- devices.append(device) +- #end for ++ if ("FreeBSD" == platform): ++ for lines in data: ++ fields = lines.strip().strip(":") ++ ++ if (fields[0] == "lo"): ++ continue ++ else: ++ device = fields[0] ++ devices.append(device) ++ elif ("Linux" == platform): ++ for lines in data[2:]: ++ l = lines.strip() ++ l = l.replace(":", " ") ++ fields = l.split() ++ ++ if (fields[0] == "lo"): ++ continue ++ else: # (fields[0].startswith("eth")): ++ device = fields[0] ++ devices.append(device) ++ #end for ++ else: ++ pass + + return devices + +@@ -48,13 +70,15 @@ + + def __poll_ipaddr(self, dev): + +- data = commands.getoutput("/sbin/ifconfig " + dev) +- lines = data.splitlines() +- for l in lines: ++ fd = os.popen("/sbin/ifconfig " + dev, "r") ++ data = fd.readlines() ++ fd.close() ++ for l in data: + l = l.strip() + fields = l.split() + +- if (fields[0] == "inet"): return fields[1].split(":")[1] ++ if (fields[0] == "inet"): ++ return fields[1] + #end for + + #fd = open("/proc/net/rt_cache", "r") +@@ -78,6 +102,8 @@ + + def __poll_in_out(self, dev): + ++ platform = lib.sys.get_os() ++ + t = time.time() + interval = t - self.__time + self.__time = t +@@ -88,24 +114,40 @@ + speed_in = 0 + speed_out = 0 + +- fd = open("/proc/net/dev", "r") ++ if ("FreeBSD" == platform): ++ fd = os.popen("netstat -b -I " + dev + " | grep Link", "r") ++ elif ("Linux" == platform): ++ fd = open("/proc/net/dev", "r") ++ else: ++ return (bytes_in, bytes_out, pack_in, pack_out, speed_in, speed_out) + data = fd.read() + fd.close() + lines = data.splitlines() + + # look for the device + found = 0 +- for l in lines: +- l.strip() +- l = l.replace(":", " ") +- fields = l.split() +- if (fields[0] == dev): +- bytes_in, pack_in, bytes_out, pack_out = \ +- long(fields[1]), long(fields[2]), \ +- long(fields[9]), long(fields[10]) ++ if ("FreeBSD" == platform): ++ for l in lines: + found = 1 ++ fields = l.strip().split() ++ bytes_in, pack_in, bytes_out, pack_out = \ ++ long(fields[6]), long(fields[4]), \ ++ long(fields[9]), long(fields[7]) + break +- #end for ++ elif ("Linux" == platform): ++ for l in lines: ++ l.strip() ++ l = l.replace(":", " ") ++ fields = l.split() ++ if (fields[0] == dev): ++ bytes_in, pack_in, bytes_out, pack_out = \ ++ long(fields[1]), long(fields[2]), \ ++ long(fields[9]), long(fields[10]) ++ found = 1 ++ break ++ #end for ++ else: ++ pass + + # warn if we didn't find the device + if (not found): print ("WARNING:: Device %(dev)s not found!") % vars() diff --git a/deskutils/gdesklets/files/patch-libdesklets::Sys.py b/deskutils/gdesklets/files/patch-libdesklets::Sys.py new file mode 100644 index 0000000..71ba38f --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::Sys.py @@ -0,0 +1,114 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/Sys.py.orig Mon Sep 22 13:06:41 2003 ++++ libdesklets/Sys.py Mon Sep 22 13:13:11 2003 +@@ -2,7 +2,8 @@ + + import commands + import time +- ++import os ++import libdesklets as lib + + class Sys: + +@@ -31,17 +32,25 @@ + + def __poll_os(self): + +- os = commands.getoutput("uname -o") +- return os ++ platform = commands.getoutput("uname -s") ++ return platform + + + def __poll_uptime(self, mode): + +- fd = open("/proc/uptime", "r") +- data = fd.readlines() +- fd.close() +- +- uptime, idletime = data[0].split() ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ bt = commands.getoutput("sysctl kern.boottime") ++ boottime = int(bt.strip().split()[4].strip(",")) ++ uptime = int(time.time() - float(boottime)) ++ idletime = 0 ++ elif ("Linux" == platform): ++ fd = open("/proc/uptime", "r") ++ data = fd.readlines() ++ fd.close() ++ uptime, idletime = data[0].split() ++ boottime = int(time.time() - float(uptime)) + + # uptime + if (mode == 0): +@@ -51,16 +60,32 @@ + return int(float(idletime)) + # sys start + elif (mode == 2): +- now = time.time() +- return int(now - float(uptime)) ++ return boottime + + + def __poll_load_avg(self, mode): + +- fd = open("/proc/loadavg", "r") ++ import re ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ fd = os.popen("uptime") ++ elif ("Linux" == platform): ++ fd = open("/proc/loadavg", "r") ++ else: ++ return float(0.0) + data = fd.readlines() + fd.close() +- load1, load5, load15, t, d = data[0].split() ++ ++ if ("FreeBSD" == platform): ++ m = re.search('load averages: ([0-9]\.[0-9]+), ([0-9]\.[0-9]+), ([0-9]\.[0-9]+)', data[0]) ++ load1 = m.group(1) ++ load5 = m.group(2) ++ load15 = m.group(3) ++ elif ("Linux" == platform): ++ load1, load5, load15, t, d = data[0].split() ++ else: ++ pass + + # avg over 1 minute + if (mode == 0): +@@ -76,11 +101,25 @@ + + def __poll_tasks(self): + +- fd = open("/proc/loadavg", "r") ++ platform = lib.sys.get_os() ++ ++ if ("FreeBSD" == platform): ++ fd = os.popen("vmstat -n 0") ++ elif ("Linux" == platform): ++ fd = open("/proc/loadavg", "r") ++ else: ++ return (int(0), int(0)) + data = fd.readlines() + fd.close() + +- parts = data[0].split() +- running, tasks = parts[3].split("/") ++ if ("FreeBSD" == platform): ++ parts = data[2].split() ++ running = parts[0] ++ tasks = parts[0] + parts[1] + parts[2] ++ elif ("Linux" == platform): ++ parts = data[0].split() ++ running, tasks = parts[3].split("/") ++ else: ++ pass + + return (int(tasks), int(running)) diff --git a/deskutils/gdesklets/files/patch-libdesklets::__init__.py b/deskutils/gdesklets/files/patch-libdesklets::__init__.py new file mode 100644 index 0000000..7ce5ad8 --- /dev/null +++ b/deskutils/gdesklets/files/patch-libdesklets::__init__.py @@ -0,0 +1,17 @@ +# Many thanks to Alexander Leidinger <netchild@FreeBSD.org> for +# help and create those patches. + +--- libdesklets/__init__.py.orig Mon Sep 22 13:15:25 2003 ++++ libdesklets/__init__.py Mon Sep 22 13:15:30 2003 +@@ -52,10 +52,10 @@ + from Sys import Sys + + ++sys = Sys() + convert = Convert() + cpu = CPU() + disk = Disk() + memory = Memory() + net = Network() +-sys = Sys() + print "INIT libdesklets (should happen only once)" |