Author: jerome
Date: 2009-03-14 15:19:36 +0100 (Sat, 14 Mar 2009)
New Revision: 4072
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/branches/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/tags/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/executables/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/executables/tuxdroid-gadget-system.py
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.pot
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.xml
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/monitor.png
Log:
* Added Linux version of tuxdroid-gadget-system.
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/executables/tuxdroid-gadget-system.py
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/executables/tuxdroid-gadget-system.py
(rev 0)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/executables/tuxdroid-gadget-system.py
2009-03-14 14:19:36 UTC (rev 4072)
@@ -0,0 +1,187 @@
+'''
+This file is part of "tuxdroid-gadget-system".
+ * Copyright 2008, kysoh
+ * Author : Conan Jerome
+ * eMail : [email protected]
+ * Site : http://www.kysoh.com/
+ *
+ * "tuxdroid-gadget-system" 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "tuxdroid-gadget-system" 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 "tuxdroid-gadget-system"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ '''
+
+import commands
+import os
+import platform
+import string
+from time import sleep
+
+
+class pcMonitor(object):
+ '''
+ This class manage the tuxdroid-gadget-pcMoitor.
+ '''
+
+ #User parameters.
+ tgp_giveCPU = True
+ tgp_giveMem = True
+ tgp_useCpuThreshold = False
+ tgp_useMemThreshold = False
+ tgp_cpuThreshold = "90"
+ tgp_memThreshold = "90"
+
+
+ if "tgp_giveCPU" in os.environ:
+ tgp_giveCPU = os.environ["tgp_giveCPU"]
+
+ if "tgp_giveMem" in os.environ:
+ tgp_giveMem = os.environ["tgp_giveMem"]
+
+ if "tgp_useCpuThreshold" in os.environ:
+ if os.environ["tgp_useCpuThreshold"] == "true":
+ tgp_useCpuThreshold = True
+ else:
+ tgp_useCpuThreshold = False
+
+
+ if "tgp_useMemThreshold" in os.environ:
+ if os.environ["tgp_useMemThreshold"] == "true":
+ tgp_useMemThreshold = True
+ else:
+ tgp_useMemThreshold = False
+
+ if "tgp_cpuThreshold" in os.environ:
+ tgp_cpuThreshold = os.environ["tgp_cpuThreshold"]
+ tgp_cpuThreshold = string.replace(tgp_cpuThreshold, r"%", "")
+
+ if "tgp_memThreshold" in os.environ:
+ tgp_memThreshold = os.environ["tgp_memThreshold"]
+ tgp_memThreshold = string.replace(tgp_memThreshold, r"%", "")
+
+
+
+ def __init__(self):
+ '''
+ Init the gadget.
+ '''
+ if self.tgp_giveCPU :
+
+ cpu = self.__getCPULoad()
+
+ if self.tgp_useCpuThreshold:
+ #check threshold.
+ if (float(cpu) > float(self.tgp_cpuThreshold)):
+ print("message \"c p u meltdown\"")
+ else:
+ print("message \"Your c p u load is over\"")
+ print("message \"" + str(cpu) + "%\"")
+
+
+ if self.tgp_giveMem:
+
+ memory = self.__getMemoryUsage()
+
+ if self.tgp_useMemThreshold:
+ if (float(memory) > float(self.tgp_memThreshold)):
+ print("message \"memory is up\"")
+ else:
+ print("message \"Your used memory is over\"")
+ print("message \"" + str(memory) + "%\"")
+
+
+
+
+ def __getPlatform(self):
+ '''
+ Return the plateform name of this current computer.
+ '''
+ return platform.system()
+
+
+
+
+ def isWindows(self):
+ '''
+ Return true if plateform is windows.
+ '''
+ platform = self.__getPlatform()
+ return (platform == 'Windows' ) or (platform == 'windows') or
(platform == "Microsoft")
+
+
+
+
+ def __getCPULoad(self):
+ '''
+ Return the current cpu load.
+ '''
+ if not self.isWindows():
+ data = commands.getoutput("cat /proc/stat")
+ u1 = float( data.split()[1] )
+ n1 = float( data.split()[2] )
+ s1 = float( data.split()[3] )
+ i1 = float( data.split()[4] )
+ sleep(2)
+ datas = commands.getoutput("cat /proc/stat")
+ u2 = float( datas.split()[1] )
+ n2 = float( datas.split()[2] )
+ s2 = float( datas.split()[3] )
+ i2 = float( datas.split()[4] )
+ usage = (u2-u1) + (n2 - n1) + (s2 - s1)
+ total = (u2-u1) + (n2 - n1) + (s2 - s1) + (i2 -i1)
+ lo = (usage/total)* 100
+ return lo
+
+ else:
+ return 'todo'
+
+
+
+
+ def __getMemoryUsage(self):
+ '''
+ Return the current memory usage.
+ '''
+ def get_freemem():
+ """
+ Get free memory
+ """
+ cached = commands.getoutput("""cat /proc/meminfo | grep Cached |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ buffers = commands.getoutput("""cat /proc/meminfo | grep Buffers |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ free = commands.getoutput("""cat /proc/meminfo | grep MemFree |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ return str(int(cached.split()[0])/1024 + int(buffers)/1024 +
int(free)/1024)
+
+
+ def get_usedmem():
+ """
+ Get used memory
+ """
+ total = commands.getoutput("""cat /proc/meminfo | grep MemTotal |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ cached = commands.getoutput("""cat /proc/meminfo | grep Cached |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ buffers = commands.getoutput("""cat /proc/meminfo | grep Buffers |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ free = commands.getoutput("""cat /proc/meminfo | grep MemFree |
awk 'BEGIN {FS=":"} {print $2}' | awk '{print $1, $9}'""")
+ return str(int(total)/1024 - int(cached.split()[0])/1024 -
int(buffers)/1024 - int(free)/1024)
+
+
+ if not self.isWindows():
+ free = get_freemem()
+ used = get_usedmem()
+
+ return str(float((float(used) / (float(used) + float(free))) *
100.0))
+
+ else:
+ return "todo"
+
+
+tuxdroid_gadget_pcMonitor = pcMonitor()
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.pot
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.pot
(rev 0)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.pot
2009-03-14 14:19:36 UTC (rev 4072)
@@ -0,0 +1,38 @@
+msgid "System gadget"
+msgstr ""
+
+msgid "The system gadget will give you some information about your system
state"
+msgstr ""
+
+msgid "Give memory state"
+msgstr ""
+
+msgid "Give CPU state"
+msgstr ""
+
+msgid "Give system informations."
+msgstr ""
+
+msgid "Your c p u load is over"
+msgstr ""
+
+msgid "Your used memory is over"
+msgstr ""
+
+msgid "Make use of cpu threshold"
+msgstr ""
+
+msgid "CPU threshold"
+msgstr ""
+
+msgid "Make use of memory threshold"
+msgstr ""
+
+msgid "Memory threshold"
+msgstr ""
+
+msgid "c p u meltdown"
+msgstr ""
+
+msgid "memory is up"
+msgstr ""
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.xml
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.xml
(rev 0)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/gadget.xml
2009-03-14 14:19:36 UTC (rev 4072)
@@ -0,0 +1,64 @@
+<gadget>
+ <interpreter
+ kind="python">
+ <executable>executables/tuxdroid-gadget-system.py</executable>
+ </interpreter>
+ <description>
+ <name>System gadget</name>
+ <description>The system gadget will give you some information
about your system state</description>
+ <author>Jérôme Conan</author>
+ <version>0.1</version>
+ <iconFile>resources/monitor.png</iconFile>
+ <executionMode>command</executionMode>
+ <uuid>8349ed52-572d-4c3f-a7b8-aad4a4ae1d2</uuid>
+ </description>
+ <parameters>
+ <parameter
+ category="Options"
+ name="giveMem"
+ description="Give memory state"
+ type="boolean"
+ defaultValue="true"
+ />
+ <parameter
+ category="Options"
+ name="giveCPU"
+ description="Give CPU state"
+ type="boolean"
+ defaultValue="true"
+ />
+ <parameter
+ category="Options"
+ name="useCpuThreshold"
+ description="Make use of cpu threshold"
+ type="boolean"
+ defaultValue="false"
+ />
+ <parameter
+ category="Options"
+ name="cpuThreshold"
+ description="CPU threshold"
+ type="enum(10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%)"
+ defaultValue="90%"
+ />
+ <parameter
+ category="Options"
+ name="useMemThreshold"
+ description="Make use of memory threshold"
+ type="boolean"
+ defaultValue="false"
+ />
+ <parameter
+ category="Options"
+ name="memThreshold"
+ description="Memory threshold"
+ type="enum(10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%)"
+ defaultValue="90%"
+ />
+ </parameters>
+ <commands>
+ <commands
+ name="run"
+ description="Give system informations." />
+ </commands>
+</gadget>
Added:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/monitor.png
===================================================================
(Binary files differ)
Property changes on:
software_suite_v2/software/gadgets/tuxdroid-gadget-system/trunk/tuxdroid-gadget-system/resources/monitor.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn