9331
|
1 |
diff -Nrup gDesklets-old/configure.in gDesklets-0.35.3/configure.in
|
|
2 |
--- gDesklets-old/configure.in 2006-01-11 04:37:54.000000000 +0800
|
|
3 |
+++ gDesklets-0.35.3/configure.in 2007-02-14 14:39:40.805129000 +0800
|
9174
|
4 |
@@ -136,6 +136,7 @@ libdesklets/system/Linux/Makefile
|
|
5 |
libdesklets/system/Makefile
|
|
6 |
libdesklets/system/NetBSD/Makefile
|
|
7 |
libdesklets/system/OpenBSD/Makefile
|
|
8 |
+libdesklets/system/Solaris/Makefile
|
|
9 |
main/Makefile
|
|
10 |
plugin/Makefile
|
|
11 |
po/Makefile.in
|
9331
|
12 |
diff -Nrup gDesklets-old/libdesklets/system/ArchFactory.py gDesklets-0.35.3/libdesklets/system/ArchFactory.py
|
|
13 |
--- gDesklets-old/libdesklets/system/ArchFactory.py 2005-01-22 23:33:31.000000000 +0800
|
|
14 |
+++ gDesklets-0.35.3/libdesklets/system/ArchFactory.py 2007-02-14 14:53:05.619030000 +0800
|
|
15 |
@@ -10,7 +10,7 @@ def __detect_arch():
|
|
16 |
if (HAVE_WIN32):
|
|
17 |
import Windows
|
|
18 |
return Windows.Win32()
|
|
19 |
-
|
|
20 |
+
|
|
21 |
import os
|
|
22 |
uname = os.uname()
|
|
23 |
|
|
24 |
@@ -49,7 +49,18 @@ def __detect_arch():
|
|
25 |
import NetBSD
|
|
26 |
|
|
27 |
return NetBSD.Generic()
|
|
28 |
-
|
|
29 |
+
|
|
30 |
+ elif (uname[0] == 'SunOS'):
|
|
31 |
+
|
|
32 |
+ import Solaris
|
|
33 |
+ r = os.popen('/usr/bin/uname -p').read()
|
|
34 |
+ if (r[:-1] in ('i386')):
|
|
35 |
+ return Solaris.X86()
|
|
36 |
+
|
|
37 |
+ if (r[:-1] in ('sparc')):
|
|
38 |
+ return Solaris.Sparc()
|
|
39 |
+
|
|
40 |
+ return Solaris.Generic()
|
|
41 |
|
|
42 |
log("OS/Architecture not found!")
|
|
43 |
|
|
44 |
diff -Nrup gDesklets-old/libdesklets/system/Makefile.am gDesklets-0.35.3/libdesklets/system/Makefile.am
|
|
45 |
--- gDesklets-old/libdesklets/system/Makefile.am 2005-08-01 05:29:36.000000000 +0800
|
|
46 |
+++ gDesklets-0.35.3/libdesklets/system/Makefile.am 2007-02-14 14:40:27.794268000 +0800
|
9174
|
47 |
@@ -20,6 +20,7 @@ SUBDIRS = \
|
|
48 |
Linux \
|
|
49 |
FreeBSD \
|
|
50 |
NetBSD \
|
|
51 |
+ Solaris \
|
|
52 |
OpenBSD
|
|
53 |
|
|
54 |
|
9331
|
55 |
diff -Nrup gDesklets-old/libdesklets/system/Solaris/Generic.py gDesklets-0.35.3/libdesklets/system/Solaris/Generic.py
|
|
56 |
--- gDesklets-old/libdesklets/system/Solaris/Generic.py 1970-01-01 08:00:00.000000000 +0800
|
|
57 |
+++ gDesklets-0.35.3/libdesklets/system/Solaris/Generic.py 2007-02-14 14:40:15.314517000 +0800
|
9174
|
58 |
@@ -0,0 +1,62 @@
|
|
59 |
+from libdesklets.system.Arch import Arch
|
|
60 |
+
|
|
61 |
+import re
|
|
62 |
+import struct
|
|
63 |
+import os
|
|
64 |
+
|
|
65 |
+class Generic(Arch):
|
|
66 |
+
|
|
67 |
+ def __init__(self):
|
|
68 |
+
|
|
69 |
+ Arch.__init__(self)
|
|
70 |
+
|
|
71 |
+ self.__bogomips = re.compile('^bogomips\s+:\s+(\d+\.\d+)$', re.M)
|
9331
|
72 |
+ self.__net_devices = re.compile('^\s*(\w+):.*mtu', re.M).findall( os.popen('/usr/sbin/ifconfig -a').read())
|
9174
|
73 |
+
|
|
74 |
+
|
|
75 |
+
|
|
76 |
+ def net_devices(self):
|
|
77 |
+ """
|
|
78 |
+ @return : all available network devices
|
|
79 |
+ @rtype : list
|
|
80 |
+ """
|
|
81 |
+
|
9331
|
82 |
+ return self.__net_devices
|
9174
|
83 |
+
|
|
84 |
+
|
|
85 |
+
|
|
86 |
+ def cpu_bogomips(self):
|
|
87 |
+ """
|
|
88 |
+ @return : bogomips of installed processor
|
|
89 |
+ @rtype : float
|
|
90 |
+ """
|
|
91 |
+
|
9331
|
92 |
+ return float(5000)
|
9174
|
93 |
+
|
|
94 |
+
|
|
95 |
+
|
|
96 |
+ def users(self):
|
|
97 |
+ """
|
|
98 |
+ @return : number of connected users
|
|
99 |
+ @rtype : int
|
|
100 |
+ """
|
|
101 |
+
|
|
102 |
+ # man utmp
|
|
103 |
+ # don't know if
|
|
104 |
+ # sizeof(struct utmp) == 384
|
|
105 |
+ # sizeof(short) == 2
|
|
106 |
+ # on every Linux arch
|
|
107 |
+ # http://gnomesupport.org/forums/viewtopic.php?p=33686
|
|
108 |
+ # X86, X86_64 : ok
|
|
109 |
+
|
|
110 |
+ count = 0
|
|
111 |
+ data = open('/var/adm/utmpx', 'rb').read()
|
|
112 |
+
|
|
113 |
+ for i in range(0, len(data), 384):
|
|
114 |
+
|
|
115 |
+ ut_type = struct.unpack('h', data[i:i+2])[0]
|
|
116 |
+
|
|
117 |
+ if (ut_type == 7):
|
|
118 |
+ count += 1
|
|
119 |
+
|
|
120 |
+ return count
|
9331
|
121 |
diff -Nrup gDesklets-old/libdesklets/system/Solaris/Makefile.am gDesklets-0.35.3/libdesklets/system/Solaris/Makefile.am
|
|
122 |
--- gDesklets-old/libdesklets/system/Solaris/Makefile.am 1970-01-01 08:00:00.000000000 +0800
|
|
123 |
+++ gDesklets-0.35.3/libdesklets/system/Solaris/Makefile.am 2007-02-14 14:40:15.325847000 +0800
|
9174
|
124 |
@@ -0,0 +1,11 @@
|
|
125 |
+installdir = ${coredir}/libdesklets/system/Solaris
|
|
126 |
+
|
|
127 |
+install_DATA = \
|
|
128 |
+ __init__.py \
|
|
129 |
+ Generic.py \
|
|
130 |
+ Sparc.py \
|
|
131 |
+ X86.py
|
|
132 |
+
|
|
133 |
+EXTRA_DIST = $(install_DATA)
|
|
134 |
+install_PYTHON = $(install_DATA)
|
|
135 |
+CLEANFILES = *.pyc
|
9331
|
136 |
diff -Nrup gDesklets-old/libdesklets/system/Solaris/Sparc.py gDesklets-0.35.3/libdesklets/system/Solaris/Sparc.py
|
|
137 |
--- gDesklets-old/libdesklets/system/Solaris/Sparc.py 1970-01-01 08:00:00.000000000 +0800
|
|
138 |
+++ gDesklets-0.35.3/libdesklets/system/Solaris/Sparc.py 2007-02-14 14:40:15.326112000 +0800
|
|
139 |
@@ -0,0 +1,67 @@
|
9174
|
140 |
+from Generic import Generic
|
|
141 |
+
|
|
142 |
+import os
|
|
143 |
+import re
|
|
144 |
+
|
|
145 |
+
|
|
146 |
+class Sparc(Generic):
|
|
147 |
+
|
|
148 |
+ def __init__(self):
|
|
149 |
+
|
|
150 |
+ Generic.__init__(self)
|
|
151 |
+
|
|
152 |
+ def _get_model():
|
|
153 |
+ r = re.compile('brand\s+(.+)$', re.M)
|
|
154 |
+ m = r.findall( self._read_cpuinfo() )
|
|
155 |
+ return m[0]
|
|
156 |
+
|
|
157 |
+ def _get_cache():
|
9331
|
158 |
+ r = re.compile('^\s+ecache-size:+\s+(.+)$',re.M)
|
|
159 |
+ m = r.findall(os.popen('/usr/sbin/prtconf -vp').read())
|
|
160 |
+ m_int = int(m[0],16)
|
|
161 |
+ return int(round(m_int/1000))
|
|
162 |
+
|
|
163 |
+ def _read_cpu_speed():
|
|
164 |
+ r = re.compile('clock_MHz\s+(\d+)$', re.M)
|
|
165 |
+ m = r.findall(self._read_cpuinfo())
|
|
166 |
+ return float(int(m[0]))
|
9174
|
167 |
+
|
|
168 |
+ # CPU model and cache size never changes
|
|
169 |
+ self.__model_name = _get_model()
|
|
170 |
+ self.__cache_size = _get_cache()
|
|
171 |
+
|
|
172 |
+ # the cpu speed might change (laptops have mobile CPUs)
|
9331
|
173 |
+ self.__speed = _read_cpu_speed()
|
9174
|
174 |
+
|
9331
|
175 |
+ def _read_cpuinfo(self):
|
|
176 |
+ """
|
|
177 |
+ @return : content of cpu_info
|
|
178 |
+ @rtype : str
|
|
179 |
+ """
|
|
180 |
+ return os.popen('/usr/bin/kstat cpu_info').read()
|
9174
|
181 |
+
|
|
182 |
+ def cpu_speed(self):
|
|
183 |
+ """
|
|
184 |
+ @return : current clock of installed processor
|
|
185 |
+ @rtype : float
|
|
186 |
+ """
|
|
187 |
+
|
9331
|
188 |
+ return self.__speed
|
9174
|
189 |
+
|
|
190 |
+
|
9331
|
191 |
+ def cpu_cache(self):
|
|
192 |
+ """
|
|
193 |
+ @return : 2nd level cache of installed processor
|
|
194 |
+ @rtype : int
|
|
195 |
+ """
|
|
196 |
+
|
|
197 |
+ return self.__cache_size
|
|
198 |
+
|
9174
|
199 |
+
|
|
200 |
+ def cpu_model(self):
|
|
201 |
+ """
|
|
202 |
+ @return : model/type of installed processor
|
|
203 |
+ @rtype : str
|
|
204 |
+ """
|
|
205 |
+
|
|
206 |
+ return self.__model_name
|
9331
|
207 |
diff -Nrup gDesklets-old/libdesklets/system/Solaris/X86.py gDesklets-0.35.3/libdesklets/system/Solaris/X86.py
|
|
208 |
--- gDesklets-old/libdesklets/system/Solaris/X86.py 1970-01-01 08:00:00.000000000 +0800
|
|
209 |
+++ gDesklets-0.35.3/libdesklets/system/Solaris/X86.py 2007-02-14 14:40:15.326279000 +0800
|
|
210 |
@@ -0,0 +1,96 @@
|
9174
|
211 |
+from Generic import Generic
|
|
212 |
+
|
|
213 |
+import re
|
|
214 |
+import struct
|
|
215 |
+import os
|
|
216 |
+
|
|
217 |
+# Also works for x86_64
|
|
218 |
+# it seems that there's no difference
|
|
219 |
+
|
|
220 |
+class X86(Generic):
|
|
221 |
+
|
|
222 |
+ def __init__(self):
|
|
223 |
+
|
|
224 |
+ Generic.__init__(self)
|
|
225 |
+
|
|
226 |
+
|
|
227 |
+ def _get_model():
|
|
228 |
+ r = re.compile('^.*brand-string.*\n\s+value=(.+)$', re.M)
|
|
229 |
+ m = r.findall( self._read_cpuinfo() )
|
|
230 |
+ return m[0]
|
|
231 |
+
|
|
232 |
+ def _get_cache():
|
|
233 |
+ r = re.compile('^.*l2-cache-size.*\n\s+value=(.+)$', re.M)
|
|
234 |
+ m = r.findall( self._read_cpuinfo())
|
|
235 |
+ m_int = int(m[0],16)
|
|
236 |
+ return int(round(m_int/1000))
|
|
237 |
+
|
9331
|
238 |
+ def _read_cpu_speed():
|
|
239 |
+
|
|
240 |
+ r = re.compile('^.*cpu-mhz.*\n\s+value=(.+)$', re.M)
|
|
241 |
+ m = r.findall(self._read_cpuinfo())
|
|
242 |
+ return float(int(m[0],16))
|
|
243 |
+
|
9174
|
244 |
+ # CPU model and cache size never changes
|
|
245 |
+ self.__model_name = _get_model()
|
|
246 |
+ self.__cache_size = _get_cache()
|
|
247 |
+
|
|
248 |
+ # the cpu speed might change (laptops have mobile CPUs)
|
9331
|
249 |
+ self.__speed = _read_cpu_speed()
|
|
250 |
+
|
9174
|
251 |
+
|
|
252 |
+ def _read_cpuinfo(self):
|
|
253 |
+ """
|
|
254 |
+ @return : content of cpu_info
|
|
255 |
+ @rtype : str
|
|
256 |
+ """
|
|
257 |
+ return os.popen('/usr/sbin/prtconf -v').read()
|
|
258 |
+
|
|
259 |
+ def cpu_cache(self):
|
|
260 |
+ """
|
|
261 |
+ @return : 2nd level cache of installed processor
|
|
262 |
+ @rtype : int
|
|
263 |
+ """
|
|
264 |
+
|
|
265 |
+ return self.__cache_size
|
|
266 |
+
|
|
267 |
+
|
|
268 |
+
|
|
269 |
+ def cpu_model(self):
|
|
270 |
+ """
|
|
271 |
+ @return : model/type of installed processor
|
|
272 |
+ @rtype : str
|
|
273 |
+ """
|
|
274 |
+
|
|
275 |
+ return self.__model_name
|
|
276 |
+
|
|
277 |
+
|
|
278 |
+
|
|
279 |
+ def cpu_speed(self):
|
|
280 |
+ """
|
|
281 |
+ @return : current clock of installed processor
|
|
282 |
+ @rtype : float
|
|
283 |
+ """
|
9331
|
284 |
+ return self.__speed
|
9174
|
285 |
+
|
|
286 |
+
|
|
287 |
+
|
|
288 |
+ def users(self):
|
|
289 |
+
|
|
290 |
+ # man utmp
|
|
291 |
+ # don't know if
|
|
292 |
+ # sizeof(struct utmp) == 384
|
|
293 |
+ # sizeof(short) == 2
|
|
294 |
+ # on every Linux arch
|
|
295 |
+ # http://gnomesupport.org/forums/viewtopic.php?p=33686
|
|
296 |
+ # X86, X86_64 : ok
|
|
297 |
+
|
|
298 |
+ count = 0
|
|
299 |
+ data = open('/var/adm/utmpx', 'rb').read()
|
|
300 |
+
|
|
301 |
+ for i in range(0, len(data), 384):
|
|
302 |
+ ut_type = struct.unpack('h', data[i:i+2])[0]
|
|
303 |
+ if (ut_type == 7): count += 1
|
|
304 |
+
|
|
305 |
+ return count
|
|
306 |
+
|
9331
|
307 |
diff -Nrup gDesklets-old/libdesklets/system/Solaris/__init__.py gDesklets-0.35.3/libdesklets/system/Solaris/__init__.py
|
|
308 |
--- gDesklets-old/libdesklets/system/Solaris/__init__.py 1970-01-01 08:00:00.000000000 +0800
|
|
309 |
+++ gDesklets-0.35.3/libdesklets/system/Solaris/__init__.py 2007-02-14 14:40:15.326454000 +0800
|
9174
|
310 |
@@ -0,0 +1,3 @@
|
|
311 |
+from X86 import X86
|
|
312 |
+from Sparc import Sparc
|
|
313 |
+from Generic import Generic
|
9331
|
314 |
diff -Nrup gDesklets-old/shell/plugins/Shell/__init__.py gDesklets-0.35.3/shell/plugins/Shell/__init__.py
|
|
315 |
--- gDesklets-old/shell/plugins/Shell/__init__.py 2005-03-23 10:07:29.000000000 +0800
|
|
316 |
+++ gDesklets-0.35.3/shell/plugins/Shell/__init__.py 2007-02-20 11:51:00.589517000 +0800
|
9174
|
317 |
@@ -150,5 +150,5 @@ try:
|
|
318 |
except:
|
|
319 |
pass
|
|
320 |
|
|
321 |
-gtk.threads_init()
|
|
322 |
+gtk.gdk.threads_init()
|
|
323 |
|