All pastes #473535 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-06 09:39 UTC
rendered paste body
Index: www/css/admin.css
===================================================================
--- www/css/admin.css	(revision 57)
+++ www/css/admin.css	(working copy)
@@ -1,74 +1,66 @@
-* {
-	font-family: sans-serif;
-}
+/*
+    Bongo web administration interface (aka Hawkeye) stylesheet
+    (c) 2007 Alexander Hixon <hixon.alexander@mediati.org> - see COPYING for details
+    Last modified: Sunday May 6, 2007
+*/
 
-html, body { 
-	overflow: auto;
-	margin: 0;
-	padding: 0;
-	border: 0; 
-} 
-
 body {
-	border-top: 2px solid #d4dceb;
-        background-color: #627aa3; /* #b4c5e1; */
+    background-color: #eeeeec;
+    font-size: 12px;
+    font-family: Verdana, Arial, Helvetica, SunSans-Regular, Sans-Serif;
+    color:#2e3436;
+    padding:0px;
+    margin:0px;
+    
+    height: 100%;   /* Blasted IE! */
 }
 
-img#logo {
-	position: absolute;
-	top: 40px;
-	left: 40px;
-	width: 339px;
-	height: 59px;
+#login { 	
+    position:absolute;
+    height:200px; 
+    width:400px;
+    margin:-100px 0px 0px -200px;
+    top: 50%; 
+    left: 50%;
+    
+    text-align: center;
+    padding: 0px;
+    background-image: url('../img/login-pane.png');
+    background-repeat: no-repeat; /* Make sure this doesn't actually happen. */
+    overflow: none;
 }
 
-ul.navigation {
-	position: absolute;
-	top: 110px;
-	left: 40px;
-	width: 150px;
-	background-color: white;
-	padding: 10px;
-	border: 1px solid #555;
-	margin: 0;
+form {
+    padding: 16px;
+    padding-top: 6.5em;
 }
 
-ul.navigation li {
-	list-style: none;
-	margin: 0;
-	text-align: left;
+.inputbox {
+    margin-bottom: 2px;
 }
 
-ul.navigation li a {
-	display: block;
-	text-decoration: none;
-	padding: .25em;
-	color: black;
-	border-bottom: 1px solid #555;
+.submit {
+    padding-top: 2em;
+    padding-bottom: 0px;
+    margin-bottom: 0px;
 }
 
-ul.navigation li a:hover {
-	background-color: #ddd;
+input {
+    color: #555753;
+    border: 1px solid #2e3436;
 }
 
-div#content {
-	position: absolute;
-	top: 110px;
-	right: 20px;
-	left: 220px;
-	border: 1px solid #555;
-	background-color: white;
-	padding: 10px;
+.username {
+    background-image: url('../img/user.png');
 }
 
-div#login {
-	position: absolute;
-	top: 200px;
-	left: 220px;
-	width: 500px;
-	height: 250px;
-	background-color: white;
-	padding: 20px;
-	text-align: right;
-	border: 1px solid #555;
+.password {
+    background-image: url('../img/locked.png');
 }
+
+.password, .username {
+    padding-left: 22px;
+    min-height: 18px;
+    background-color: #eeeeec;
+    background-repeat: no-repeat;
+}
Index: www/hawkeye/agents/index.tpl
===================================================================
--- www/hawkeye/agents/index.tpl	(revision 0)
+++ www/hawkeye/agents/index.tpl	(revision 0)
@@ -0,0 +1,10 @@
+%(include|header.tpl)s
+
+<h1>Agents</h1>
+
+<ul>
+<li>TODO: List different agent pages here.</li>
+<li><a href="%(url|/)sserver/">Enable/Disable Agents</a></li>
+</ul>
+
+%(include|footer.tpl)s
Index: www/hawkeye/root/login.tpl
===================================================================
--- www/hawkeye/root/login.tpl	(revision 57)
+++ www/hawkeye/root/login.tpl	(working copy)
@@ -1,28 +1,21 @@
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<title>Bongo Web Administration</title>
-	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Bongo Web Administration &rsaquo; Login</title>
 	<link rel="icon" href="/img/bongo-favicon.ico" type="image/ico">
 	<link rel="icon" href="/img/bongo-favicon.png" type="image/png">
-	<style type="text/css" media="screen">
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <style type="text/css" media="screen">
         @import url(/css/admin.css);
-	</style>
+    </style>
 </head>
-<body>
-
-<img id="logo" src="/img/login-logo.png" alt="Bongo" />
-
+<body onload="document.forms[0].elements[0].focus();">
 <div id="login">
-
-<h1>Login Required</h1>
-
-<form method="post">
-<p>User name: <input type="text" name="bongo-username" /></p>
-<p>Password: <input type="password" name="bongo-password" /></p>
-<input type="submit" value="Login" />
-</form>
-
+    <form method="post">
+        <input type="text" name="bongo-username" class="username inputbox" />
+        <input type="password" name="bongo-password" class="password inputbox"/>
+        <div class="submit"><input type="submit" value="Log in"></div>
+    </form>
 </div>
-
 </body>
 </html>
Index: www/hawkeye/system/index.tpl
===================================================================
--- www/hawkeye/system/index.tpl	(revision 0)
+++ www/hawkeye/system/index.tpl	(revision 0)
@@ -0,0 +1,9 @@
+%(include|header.tpl)s
+
+<h1>System</h1>
+
+<ul>
+<li><a href="%(url|/)sbackup/">Backup and Restore</a></li>
+</ul>
+
+%(include|footer.tpl)s
Index: www/hawkeye/server/index.tpl
===================================================================
--- www/hawkeye/server/index.tpl	(revision 57)
+++ www/hawkeye/server/index.tpl	(working copy)
@@ -1,6 +1,6 @@
 %(include|header.tpl)s
 
-<h1>Server Settings</h1>
+<h1>Enable/Disable Agents</h1>
 
 <p tal:condition="message" tal:content="message">No message.</p>
 
@@ -12,7 +12,7 @@
 <div tal:condition="success">
 <form method="post">
 	<input type="hidden" name="command" value="agentstatus" />
-	<table border="1">
+	<table class="htable">
 	<tr>
 		<th>Enabled?</th>
 		<th>Agent Name</th>
Index: www/hawkeye/footer.tpl
===================================================================
--- www/hawkeye/footer.tpl	(revision 57)
+++ www/hawkeye/footer.tpl	(working copy)
@@ -1,5 +1,5 @@
 
-
 </div>
+</div>
 </body>
 </html>
Index: www/Bongo.rules
===================================================================
--- www/Bongo.rules	(revision 57)
+++ www/Bongo.rules	(working copy)
@@ -16,6 +16,7 @@
 	src/www/css/composer.css		\
 	src/www/css/contacts.css		\
 	src/www/css/conversation.css		\
+	src/www/css/hawkeye.css         \
 	src/www/css/interpreter.css		\
 	src/www/css/layout.css			\
 	src/www/css/login.css			\
@@ -180,7 +181,21 @@
 	src/www/img/toolbar/16/format-text-italic.png	     \
 	src/www/img/toolbar/16/format-text-strikethrough.png \
 	src/www/img/toolbar/16/format-text-underline.png     \
-	src/www/img/toolbar/16/mail-attachment.png
+	src/www/img/toolbar/16/mail-attachment.png  \
+	src/www/img/bg.png  \
+	src/www/img/Bongo-logo.png \
+	src/www/img/cbg.png \
+	src/www/img/dialog-warning.png \
+	src/www/img/help-browser.png \
+	src/www/img/locked.png \
+	src/www/img/login-pane.png \
+	src/www/img/network-server.png \
+	src/www/img/sel.png \
+	src/www/img/system-installer.png \
+	src/www/img/system-users.png \
+	src/www/img/user.png \
+	src/www/img/user-desktop.png \
+	src/www/img/welcome-box.png
 
 
 jsdir = $(htdocsdir)/js
@@ -287,10 +302,12 @@
 pkgpythonhawkeye_PYTHON :=			\
 	src/www/bongo/hawkeye/__init__.py	\
 	src/www/bongo/hawkeye/AgentsView.py      \
+	src/www/bongo/hawkeye/AgentView.py  \
 	src/www/bongo/hawkeye/Auth.py		\
 	src/www/bongo/hawkeye/BackupView.py      \
 	src/www/bongo/hawkeye/HawkeyeHandler.py	\
 	src/www/bongo/hawkeye/HawkeyePath.py	\
+	src/www/bongo/hawkeye/SystemView.py \
 	src/www/bongo/hawkeye/RootView.py	\
 	src/www/bongo/hawkeye/Server.py		\
 	src/www/bongo/hawkeye/ServerView.py	\
@@ -311,6 +328,14 @@
 hawkeyetplserverdir = $(htdocsdir)/hawkeye/server
 dist_hawkeyetplserver_DATA :=			\
         src/www/hawkeye/server/index.tpl
+        
+hawkeyetplsystemdir = $(htdocsdir)/hawkeye/system
+dist_hawkeyetplsystem_DATA :=			\
+        src/www/hawkeye/system/index.tpl
+        
+hawkeyetplagentsdir = $(htdocsdir)/hawkeye/agents
+dist_hawkeyetplagents_DATA :=			\
+        src/www/hawkeye/agents/index.tpl
 
 hawkeyetpldir = $(htdocsdir)/hawkeye
 dist_hawkeyetpl_DATA :=			\
Index: www/bongo/hawkeye/SummaryView.py
===================================================================
--- www/bongo/hawkeye/SummaryView.py	(revision 57)
+++ www/bongo/hawkeye/SummaryView.py	(working copy)
@@ -1,3 +1,4 @@
+import os
 import bongo.dragonfly
 from HawkeyeHandler import HawkeyeHandler
 
@@ -2,3 +3,35 @@
 class SummaryHandler(HawkeyeHandler):
+    _proc_status = '/proc/%d/status' % os.getpid()  # Linux only?
+    _scale = {'kB': 1024.0, 'mB': 1024.0*1024.0,
+       'KB': 1024.0, 'MB': 1024.0*1024.0}
+
+    def _VmB(VmKey):
+        global _scale
+        try: # get the /proc/<pid>/status pseudo file
+            t = open(_proc_status)
+            v = [v for v in t.readlines() if v.startswith(VmKey)]
+            t.close()
+             # convert Vm value to bytes
+            if len(v) == 1:
+               t = v[0].split()  # e.g. 'VmRSS:  9999  kB'
+               if len(t) == 3:  ## and t[0] == VmKey:
+                   return float(t[1]) * _scale.get(t[2], 0.0)
+        except:
+            pass
+        return 0.0
+
+    def memory(since=0.0):
+        '''Return process memory usage in bytes.
+        '''
+        return _VmB('VmSize:') - since
+
+    def stacksize(since=0.0):
+        '''Return process stack size in bytes.
+        '''
+        return _VmB('VmStk:') - since 
+
     def index_GET(self, req, rp):
+        self.SetVariable("mem", memory())
+        self.SetVariable("breadcrumb", "Desktop")
+        self.SetVariable("dsktab", "selecteditem")
         return self.SendTemplate(req, rp, "index.tpl", vars)
Index: www/bongo/hawkeye/AgentView.py
===================================================================
--- www/bongo/hawkeye/AgentView.py	(revision 0)
+++ www/bongo/hawkeye/AgentView.py	(revision 0)
@@ -0,0 +1,9 @@
+import bongo.dragonfly
+from HawkeyeHandler import HawkeyeHandler
+
+class AgentHandler(HawkeyeHandler):
+
+    def index_GET(self, req, rp):
+        self.SetVariable("breadcrumb", "Agents")
+        self.SetVariable("agntab", "selecteditem")
+        return self.SendTemplate(req, rp, "index.tpl")
Index: www/bongo/hawkeye/HawkeyePath.py
===================================================================
--- www/bongo/hawkeye/HawkeyePath.py	(revision 57)
+++ www/bongo/hawkeye/HawkeyePath.py	(working copy)
@@ -8,10 +8,13 @@
 import RootView
 import BackupView
 import ServerView
+import SystemView
 
 views = {
     "root" : RootView.RootHandler(),
+    "agents" : AgentView.AgentHandler(),
     "backup" : BackupView.BackupHandler(),
+    "system" : SystemView.SystemHandler(),
     "server" : ServerView.ServerHandler()
     }
 
Index: www/bongo/hawkeye/RootView.py
===================================================================
--- www/bongo/hawkeye/RootView.py	(revision 57)
+++ www/bongo/hawkeye/RootView.py	(working copy)
@@ -1,4 +1,5 @@
 import bongo.dragonfly
+import os
 import bongo.dragonfly.BongoUtil
 from HawkeyeHandler import HawkeyeHandler
 import bongo.hawkeye.Auth as Auth
@@ -10,7 +11,34 @@
         else:
             return True
 
+    def memory(self, VmKey):
+        '''Return process memory usage in bytes.
+        '''
+        _scale = {'kB': 1024.0, 'mB': 1024.0*1024.0,
+       'KB': 1024.0, 'MB': 1024.0*1024.0}
+
+        try: # get the /proc/<pid>/status pseudo file
+            t = open('/proc/meminfo')
+            v = [v for v in t.readlines() if v.startswith(VmKey)]
+            t.close()
+
+             # convert Vm value to bytes
+            if len(v) == 1:
+               t = v[0].split()  # e.g. 'VmRSS:  9999  kB'
+               if len(t) == 3:  ## and t[0] == VmKey:
+                   return float(t[1]) * _scale.get(t[2], 0.0)
+        except:
+            pass
+        return 0.0
+
     def index_GET(self, req, rp):
+        cm = self.memory("MemTotal:")
+        used = cm - self.memory("MemFree:")
+	used = used / 1024 / 1024
+	cm = cm / 1024 / 1024
+        self.SetVariable("mem", str(round(used, 2)) + "MB / " + str(round(cm, 2)) + "MB")
+        self.SetVariable("breadcrumb", "Desktop")
+        self.SetVariable("dsktab", "selecteditem")
         return self.SendTemplate(req, rp, "index.tpl")
 
     def test_GET(self, req, rp):
Index: www/bongo/hawkeye/SystemView.py
===================================================================
--- www/bongo/hawkeye/SystemView.py	(revision 0)
+++ www/bongo/hawkeye/SystemView.py	(revision 0)
@@ -0,0 +1,10 @@
+import os
+import bongo.dragonfly
+from HawkeyeHandler import HawkeyeHandler
+
+class SystemHandler(HawkeyeHandler):
+
+    def index_GET(self, req, rp):
+        self.SetVariable("breadcrumb", "System")
+        self.SetVariable("systab", "selecteditem")
+        return self.SendTemplate(req, rp, "index.tpl")
Index: www/bongo/hawkeye/BackupView.py
===================================================================
--- www/bongo/hawkeye/BackupView.py	(revision 57)
+++ www/bongo/hawkeye/BackupView.py	(working copy)
@@ -13,6 +13,8 @@
     def index_GET(self, req, rp):
         today = datetime.date.today()
         self.SetVariable("set", today.strftime("%y%m%d"))
+        self.SetVariable("breadcrumb", "System &#187 Backup and Restore");
+        self.SetVariable("systab", "selecteditem");
         return self.SendTemplate(req, rp, "index.tpl")
 
     def download_GET(self, req, rp):
Index: www/bongo/hawkeye/ServerView.py
===================================================================
--- www/bongo/hawkeye/ServerView.py	(revision 57)
+++ www/bongo/hawkeye/ServerView.py	(working copy)
@@ -22,6 +22,9 @@
         else:
             self.SetVariable("success", 0)
 
+        self.SetVariable("breadcrumb", "Agents &#187 Enable/Disable Agents");
+        self.SetVariable("agntab", "selecteditem");
+
         return self.SendTemplate(req, rp, "index.tpl")
 
     def index_POST(self, req, rp):