/[shmookey]/portconf/login.py


UCC Code Repository

Contents of /portconf/login.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 120 - (show annotations) (download) (as text)
Thu Jun 5 07:30:56 2008 UTC (12 years, 5 months ago) by shmookey
File MIME type: text/x-python
File size: 2846 byte(s)
general improvements, beginning stump of a configuration interface

1 #!/usr/bin/python
2
3 import sys, re, pexpect
4 import Log, common
5
6 try:
7 from Config import libPaths, dbName, dbUser, dbPass, dbHost, dbPort
8 except:
9 Log.Message ("Error occured in finding basic configuration paramaters. Reverting to installer.", "index.py", "ERROR")
10 import install
11 sys.exit ()
12
13 for path in libPaths: sys.path.append (path)
14
15 try:
16 import pycisco, pyaaa
17 except:
18 Log.Message ("Couldn't import pycisco or pyaaa. Reverting to installer.", "index.py", "ERROR")
19 import install
20 sys.exit ()
21
22 import cgi, cgitb
23 cgitb.enable ()
24
25 def ShowDefaultPage ():
26 pageText = """
27 <p>Log-in to get started!</p>
28 <form class='loginform'>
29 <table border='0' cellpadding='2' cellspacing='0' class='rowset'>
30 <tr><td>Username:</td><td><input type='text' id='username'></input></td></tr>
31 <tr><td>Password:</td><td><input type='password' id='password'></input></td></tr>
32 <tr><td><input type='hidden' name='action' value='status' />
33 <input type='submit' value='Log-in' /></td></tr>
34 </table>
35 </form>
36
37 <script type='text/javascript'>
38 setLoginFormAction = function () {
39 username = $("#username").attr ("value");
40 password = $("#password").attr ("value");
41 $('form.loginform').html ("<table border='0' cellpadding='2' cellspacing='0' class='rowset'>Logging in...</table>");
42 $.getScript ("update-login.py?action=login&username=" + username + "&password=" + password, function () {
43 if (result == "success") {
44 $('form.loginform').html ("<table border='0' cellpadding='2' cellspacing='0' class='rowset'>Log-in successful.</table>");
45 window.location = "/";
46 } else {
47 if (result == "failure") errorText = "Login failed.";
48 else if (result == "dberror") errorText = "There was a problem with the database.";
49 $('form.loginform').html ("<table border='0' cellpadding='2' cellspacing='0' class='rowset'>" +
50 "<tr><td>" + errorText + "</td></tr>" +
51 "<tr><td>Username:</td><td><input type='text' id='username'></input></td></tr>" +
52 "<tr><td>Password:</td><td><input type='password' id='password'></input></td></tr>" +
53 "<tr><td><input type='hidden' name='action' value='status' />" +
54 "<input type='submit' value='Log-in' /></td></tr>" +
55 "</table>" );
56 $('form.loginform').submit (setLoginFormAction);
57 }
58 });
59 return false;
60 };
61 $('form.loginform').submit (setLoginFormAction);
62 </script>
63 """
64
65 return pageText
66
67
68 def GetBody ():
69 pageText = ShowDefaultPage ()
70
71 return pageText
72
73 def GetSidebar ():
74 pageText = """
75 <dt><a href="./">Navigation</a></dt>
76 <dd><ul>
77 <li><a href="./">Log-in</a></li>
78 </ul></dd>
79 """
80 return pageText
81
82 switchList = []
83 pageBuffer = ""
84 pageBuffer += "Content-Type: text/html\n\n"
85 pageBuffer += common.GetHeader ("Log-In - Port Administration Configuration Tool", GetSidebar ())
86 pageBuffer += GetBody ()
87 pageBuffer += common.GetFooter ()
88
89 print pageBuffer

Properties

Name Value
svn:executable *

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26