Changeset 1535
- Timestamp:
- 23.04.2008 11:34:30 (3 weeks ago)
- Files:
-
- trunk/pylucid/media/PyLucid/internal_page/admin_menu/plugin_menu.html (added)
- trunk/pylucid/PyLucid/plugins_internal/show_internals/show_internals.py (modified) (2 diffs)
- trunk/pylucid/PyLucid/plugins_internal/show_internals/show_internals_cfg.py (modified) (1 diff)
- trunk/pylucid/PyLucid/plugins_internal/show_internals/system_info.py (modified) (6 diffs)
- trunk/pylucid/PyLucid/system/BasePlugin.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pylucid/PyLucid/plugins_internal/show_internals/show_internals.py
r1154 r1535 28 28 29 29 class show_internals(PyLucidBasePlugin): 30 def link( self ):31 return '<a href="%smenu">show_internals</a>' % self.URLs["action"]32 33 #_______________________________________________________________________34 35 def lucidTag(self):36 # url = self.URLs.actionLink("menu")37 url = "FIXME"38 self.response.write('<a href="%s">show internals</a>' % url)39 30 40 31 def menu(self): 41 self.response.write( 42 "<h4>show internals <small>(%s)</small></h4>" % \ 43 __version__.strip("$ ") 44 ) 45 self.response.write(self.module_manager.build_menu()) 32 self.build_menu() 46 33 47 34 #_______________________________________________________________________ … … 195 182 """ Allgemeine System Informationen """ 196 183 self.menu() 197 from PyLucid. buildin_plugins.show_internals.system_info \184 from PyLucid.plugins_internal.show_internals.system_info \ 198 185 import SystemInfo 199 s = SystemInfo(self. request, self.response)186 s = SystemInfo(self.context, self.response) 200 187 s.display_all() 201 188 trunk/pylucid/PyLucid/plugins_internal/show_internals/show_internals_cfg.py
r1103 r1535 29 29 "menu_description" : "System Info", 30 30 }, 31 "colubrid_debug": { 32 "must_login" : True, 33 "must_admin" : True, 34 }, 35 "session_data": { 36 "must_login" : True, 37 "must_admin" : True, 38 "menu_section" : "system", 39 "menu_description" : "Session data", 40 }, 41 "log_data": { 42 "must_login" : True, 43 "must_admin" : True, 44 "menu_section" : "system", 45 "menu_description" : "LOG data", 46 }, 47 "sql_status": { 48 "must_login" : True, 49 "must_admin" : True, 50 "menu_section" : "SQL", 51 "menu_description" : "SQL table status", 52 }, 53 "optimize_sql_tables": { 54 "must_login" : True, 55 "must_admin" : True, 56 }, 57 "python_modules": { 58 "must_login" : True, 59 "must_admin" : True, 60 "menu_section" : "misc", 61 "menu_description" : "Display all Python Modules", 62 }, 63 "debug_plugin_data": { 64 "must_login" : True, 65 "must_admin" : True, 66 "menu_section" : "Modules/Plugins", 67 "menu_description" : "Debug all installed module/plugin data", 68 }, 69 "module_info": { 70 "must_login" : True, 71 "must_admin" : True, 72 }, 31 # "session_data": { 32 # "must_login" : True, 33 # "must_admin" : True, 34 # "menu_section" : "system", 35 # "menu_description" : "Session data", 36 # }, 37 # "log_data": { 38 # "must_login" : True, 39 # "must_admin" : True, 40 # "menu_section" : "system", 41 # "menu_description" : "LOG data", 42 # }, 43 # "sql_status": { 44 # "must_login" : True, 45 # "must_admin" : True, 46 # "menu_section" : "SQL", 47 # "menu_description" : "SQL table status", 48 # }, 49 # "optimize_sql_tables": { 50 # "must_login" : True, 51 # "must_admin" : True, 52 # }, 53 # "python_modules": { 54 # "must_login" : True, 55 # "must_admin" : True, 56 # "menu_section" : "misc", 57 # "menu_description" : "Display all Python Modules", 58 # }, 59 # "debug_plugin_data": { 60 # "must_login" : True, 61 # "must_admin" : True, 62 # "menu_section" : "Modules/Plugins", 63 # "menu_description" : "Debug all installed module/plugin data", 64 # }, 65 # "module_info": { 66 # "must_login" : True, 67 # "must_admin" : True, 68 # }, 73 69 } trunk/pylucid/PyLucid/plugins_internal/show_internals/system_info.py
r1154 r1535 21 21 22 22 23 import sys, os, locale 24 23 import sys, os, locale, subprocess 24 25 from PyLucid.tools.subprocess2 import Subprocess2 25 26 from PyLucid.system.BasePlugin import PyLucidBasePlugin 26 27 … … 31 32 self.PyLucid_info() 32 33 self.system_info() 34 self.cmd_info() 35 self.proc_info() 33 36 self.encoding_info() 34 37 self.envion_info() 35 self.colubrid_debug_link()36 38 37 39 #_________________________________________________________________________ … … 43 45 self.response.write('<legend>PyLucid["URLs"]:</legend>') 44 46 self.response.write("<pre>") 45 for k,v in self.URLs.items(): 46 self.response.write("%15s: '%s'\n" % (k,v))47 self.response.write("</pre>") 48 self.response.write("</fieldset>")49 50 self.response.write('<fieldset id="system_info">') 51 self.response.write('<legend>self.i18n.debug():</legend>')52 self.response.write("<pre>")53 self.i18n.debug(response_out=True) 47 48 data = [(len(v), k, v) for k,v in self.URLs.items()] 49 50 max_len = max([len(k) for k in self.URLs]) 51 line = "%%%ss: '%%s'\n" % max_len 52 53 for _,k,v in sorted(data): 54 self.response.write(line % (k,v)) 55 54 56 self.response.write("</pre>") 55 57 self.response.write("</fieldset>") … … 65 67 self.response.write("<dd>%s</dd>" % " - ".join( os.uname() )) 66 68 69 try: 70 loadavg = os.getloadavg() 71 loadavg = ", ".join([str(round(i,2)) for i in loadavg]) 72 self.response.write("<dt>load average:</dt>") 73 self.response.write("<dd>%s</dd>" % loadavg) 74 except OSError: 75 # Not available 76 pass 77 67 78 self.response.write("<dt>sys.version:</dt>") 68 79 self.response.write("<dd>Python v%s</dd>" % sys.version) … … 77 88 self.response.write("</dl>") 78 89 79 #_____________________________________________________________________ 80 81 self.cmd_info( "uptime", "uptime" ) 82 self.cmd_info( "lokal Angemeldete Benutzer", "who -H -u --lookup" ) 83 self.cmd_info( "disk", "df -T -h" ) 84 self.cmd_info( "RAM", "free -m" ) 90 91 92 def proc_info(self): 93 """ 94 Dispaly some proc files 95 """ 96 files = ["/proc/meminfo", "/proc/stat", "/proc/loadavg"] 97 98 self.response.write("<h3>proc info</h3>") 99 100 self.response.write('<dl id="system_info">') 101 for proc_file in files: 102 self.response.write("<dt>'%s':</dt>" % proc_file) 103 try: 104 f = file(proc_file, "r") 105 except Exception, e: 106 self.response.write("<dd>Error: %s</dd>" % e) 107 else: 108 for line in f: 109 self.response.write("<dd>%s</dd>" % line) 110 f.close() 111 self.response.write("</dl>") 85 112 86 113 #_________________________________________________________________________ … … 170 197 #_________________________________________________________________________ 171 198 172 def cmd_info(self, info, command, cwd="/"): 173 self.response.write( 174 '<fieldset id="system_info"><legend>%s:</legend>' % info 175 ) 176 try: 177 process = self.tools.subprocess2(command, cwd, 5) 178 except Exception,e: 179 self.response.write("Can't get: %s" % e) 180 else: 181 self.response.write("<pre>%s</pre>" % process.out_data) 182 self.response.write("</fieldset>") 183 184 185 186 187 188 189 190 199 def cmd_info(self): 200 """ 201 Use some commandline programms and display the output 202 """ 203 commands = ("uptime", "who -H -u --lookup", "df -T -h", "free -m") 204 205 for command in commands: 206 self.response.write( 207 """<fieldset><legend>'%s':</legend>""" % command 208 ) 209 try: 210 p = Subprocess2(command, 211 stdout=subprocess.PIPE, 212 shell = True, 213 timeout = 1 214 ) 215 except Exception, e: 216 self.response.write("Error: %s" % e) 217 else: 218 if not p.killed: 219 # read only if process ended normaly, otherwise it blocked! 220 msg = "<pre>%s</pre>" % p.process.stdout.read() 221 else: 222 msg = "Proecess was killed. Returncode: %s" % ( 223 p.process.returncode 224 ) 225 self.response.write(msg) 226 227 self.response.write("</fieldset>") 228 229 230 231 232 233 234 235 trunk/pylucid/PyLucid/system/BasePlugin.py
r1532 r1535 98 98 ) 99 99 100 context = {101 "plugin_name": self.plugin_name,102 "version": plugin_config.__version__,103 "menu_data": menu_data, 104 }100 self.context["PAGE"].title = "%s (%s)" % ( 101 self.plugin_name.replace("_", " "), plugin_config.__version__ 102 ) 103 104 context = {"menu_data": menu_data,} 105 105 106 106 # Change the internal_page and use them from "admin_menu" plugin.
