Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services/console/interface/xo
diff options
context:
space:
mode:
Diffstat (limited to 'services/console/interface/xo')
-rw-r--r--services/console/interface/xo/Makefile.am6
-rw-r--r--services/console/interface/xo/battery.py15
-rw-r--r--services/console/interface/xo/cpu.py10
-rw-r--r--services/console/interface/xo/nandflash.py121
-rw-r--r--services/console/interface/xo/xo.py25
5 files changed, 154 insertions, 23 deletions
diff --git a/services/console/interface/xo/Makefile.am b/services/console/interface/xo/Makefile.am
index 202b14b..be9be79 100644
--- a/services/console/interface/xo/Makefile.am
+++ b/services/console/interface/xo/Makefile.am
@@ -4,7 +4,5 @@ sugar_PYTHON = \
xo.py \
cpu.py \
system.py \
- battery.py
-
-
-
+ battery.py \
+ nandflash.py
diff --git a/services/console/interface/xo/battery.py b/services/console/interface/xo/battery.py
index a5bff6b..98b7b82 100644
--- a/services/console/interface/xo/battery.py
+++ b/services/console/interface/xo/battery.py
@@ -27,7 +27,8 @@ class XO_Battery(gtk.Fixed):
def __init__(self):
gtk.Fixed.__init__(self)
- self.frame = gtk.Frame('Battery Status')
+ self._frame_text = 'Battery Status'
+ self.frame = gtk.Frame(self._frame_text)
self.set_border_width(10)
self._battery_charge = self._get_battery_status()
@@ -76,20 +77,16 @@ class XO_Battery(gtk.Fixed):
self.add(self.frame)
self.show_all()
- # Update every 2 seconds
- gobject.timeout_add(2000, self._update_battery_status)
-
- def _update_battery_status(self):
+ def update_status(self):
new_charge = self._get_battery_status()
-
+ frame_label = str(self._battery_charge) + '%'
+
if new_charge != self._battery_charge:
self._battery_charge = self._get_battery_status()
- self.label_charge_value.set_text(str(self._battery_charge) + '%')
+ self.label_charge_value.set_text(frame_label)
self._battery_box.set_capacity(self._battery_charge)
- return True
-
def _get_battery_status(self):
battery_class_path = '/sys/class/battery/psu_0/'
capacity_path = battery_class_path + 'capacity_percentage'
diff --git a/services/console/interface/xo/cpu.py b/services/console/interface/xo/cpu.py
index 520725c..827a2a5 100644
--- a/services/console/interface/xo/cpu.py
+++ b/services/console/interface/xo/cpu.py
@@ -75,7 +75,7 @@ class CPU_Usage:
self._times +=1
self._last_jiffies = used_jiffies
-
+
return pcpu
class XO_CPU(gtk.Frame):
@@ -85,7 +85,6 @@ class XO_CPU(gtk.Frame):
gtk.Frame.__init__(self, 'System CPU Usage')
self.set_border_width(10)
- self._updated = False
width = (gtk.gdk.screen_width() * 99 / 100) - 50
height = (gtk.gdk.screen_height() * 15 / 100) - 20
@@ -100,15 +99,16 @@ class XO_CPU(gtk.Frame):
self.add(fixed)
self._DRW_CPU = CPU_Usage()
- self._DRW_CPU.frequency = 1000 # 1 Second
+ self._DRW_CPU.frequency = 1200 # 1 Second
gobject.timeout_add(self._DRW_CPU.frequency, self._update_cpu_usage)
def _update_cpu_usage(self):
+ print "update XO CPU"
self._cpu = self._DRW_CPU._get_CPU_usage()
- self._updated = True
-
self.set_label('System CPU Usage: ' + str(self._cpu) + '%')
+
# Draw the value into the graphic
self._graphic.draw_value(self._cpu)
+
return True
diff --git a/services/console/interface/xo/nandflash.py b/services/console/interface/xo/nandflash.py
new file mode 100644
index 0000000..1049f41
--- /dev/null
+++ b/services/console/interface/xo/nandflash.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2007, Eduardo Silva (edsiper@gmail.com).
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gtk
+import gobject
+
+from os import statvfs
+from label import Label
+from graphics.box import *
+
+class XO_NandFlash(gtk.Fixed):
+ _MOUNT_POINT = '/'
+
+ def __init__(self):
+ gtk.Fixed.__init__(self)
+
+ self._frame_text = 'Nand Flash'
+ self._frame = gtk.Frame(self._frame_text)
+ self.set_border_width(10)
+
+
+ self._nandflash_box = BoxGraphic(color_mode=COLOR_MODE_REVERSE)
+ self._nandflash_box.set_size_request(70, 150)
+
+ fixed = gtk.Fixed();
+ fixed.set_border_width(10)
+ fixed.add(self._nandflash_box)
+
+ hbox = gtk.HBox(False, 0)
+ hbox.pack_start(fixed, False, False, 4)
+
+ # Battery info
+ table = gtk.Table(2, 3)
+ table.set_border_width(5)
+ table.set_col_spacings(7)
+ table.set_row_spacings(7)
+
+ label_total_size = Label('Total: ' , Label.DESCRIPTION)
+ self._label_total_value = Label('0 KB', Label.DESCRIPTION)
+
+ label_used_size = Label('Used: ' , Label.DESCRIPTION)
+ self._label_used_value = Label('0 KB', Label.DESCRIPTION)
+
+ label_free_size = Label('Free: ' , Label.DESCRIPTION)
+ self._label_free_value = Label('0 KB', Label.DESCRIPTION)
+
+ # Total
+ table.attach(label_total_size, 0, 1, 0, 1)
+ table.attach(self._label_total_value, 1,2, 0,1)
+ # Used
+ table.attach(label_used_size, 0, 2, 1, 2)
+ table.attach(self._label_used_value, 1,3, 1,2)
+ # Free
+ table.attach(label_free_size, 0, 3, 2, 3)
+ table.attach(self._label_free_value, 1,4, 2,3)
+
+ alignment = gtk.Alignment(0,0,0,0)
+ alignment.add(table)
+
+ hbox.pack_start(alignment, False, False, 0)
+ self._frame.add(hbox)
+ self.add(self._frame)
+ self.show()
+ self.update_status()
+
+ def update_status(self):
+ nand = StorageDevice(self._MOUNT_POINT)
+
+ # Byte values
+ total = (nand.f_bsize*nand.f_blocks)
+ free = (nand.f_bsize*nand.f_bavail)
+ used = (total - free)
+
+ self._label_total_value.set_label(str(total/1024) + ' KB')
+ self._label_used_value.set_label(str(used/1024) + ' KB')
+ self._label_free_value.set_label(str(free/1024) + ' KB')
+ self._usage_percent = ((used*100)/total)
+
+ frame_label = self._frame_text + ': ' + str(self._usage_percent) + '%'
+ self._frame.set_label(frame_label)
+ self._nandflash_box.set_capacity(self._usage_percent)
+
+class StorageDevice:
+ f_bsize = 0
+ f_frsize = 0
+ f_blocks = 0
+ f_bfree = 0
+ f_bavail = 0
+ f_files = 0
+ f_ffree = 0
+ f_favail = 0
+ f_flag = 0
+ f_namemax = 0
+
+ def __init__(self, mount_point):
+ self.f_bsize, self.f_frsize, self.f_blocks, self.f_bfree, \
+ self.f_bavail, self.f_files, self.f_ffree, \
+ self.f_favail, self.f_flag, self.f_namemax = statvfs(mount_point)
+
+"""
+w = gtk.Window()
+a = XO_NandFlash()
+w.add(a)
+w.show_all()
+gtk.main()
+""" \ No newline at end of file
diff --git a/services/console/interface/xo/xo.py b/services/console/interface/xo/xo.py
index 525ff71..487b965 100644
--- a/services/console/interface/xo/xo.py
+++ b/services/console/interface/xo/xo.py
@@ -26,13 +26,13 @@ import string
from cpu import XO_CPU
from system import XO_System
from battery import XO_Battery
+from nandflash import XO_NandFlash
class Interface:
def __init__(self):
-
self.widget = self.vbox = gtk.VBox(False, 3)
-
+
# System information
xo_system = XO_System()
self.vbox.pack_start(xo_system, False, False, 0)
@@ -41,8 +41,23 @@ class Interface:
xo_cpu = XO_CPU()
self.vbox.pack_start(xo_cpu, False, False, 0)
- # Battery Status / Graph
- xo_battery = XO_Battery()
- self.vbox.pack_start(xo_battery, False, False, 0)
+ # Graphics: Battery Status, NandFlash
+ self._xo_battery = XO_Battery()
+ self._xo_nandflash = XO_NandFlash()
+
+ hbox = gtk.HBox(False, 2)
+ hbox.pack_start(self._xo_battery, False, False, 0)
+ hbox.pack_start(self._xo_nandflash, False, False, 0)
+ self.vbox.pack_start(hbox, False, False, 0)
self.vbox.show_all()
+
+ # Update every 5 seconds
+ gobject.timeout_add(5000, self._update_components)
+
+ def _update_components(self):
+ self._xo_battery.update_status()
+ self._xo_nandflash.update_status()
+
+ return True
+