takeover.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import nstart
00004 import config
00005 import os, sys, string, time
00006 import socket
00007 
00008 from pyclearsilver.log import *
00009 
00010 from pyclearsilver.CSPage import Context
00011 import neo_cgi, neo_cs, neo_util
00012 from MBPage import MBPage
00013 from webui import config
00014 
00015 from auth import browserauth
00016 from auth import cookieauth
00017 from auth import db_auth
00018 from auth import pwauth
00019 
00020 TAKEOVER_FILE = os.path.join(config.ROS_VAR_DIR, "takeover.dat")
00021 
00022 class SignInPage(MBPage):
00023     def setup(self, hdf):
00024         pass
00025     
00026     def display(self, hdf):
00027         username = hdf.getValue("Query.username", "")
00028         if not username: return
00029 
00030         ip_address = socket.gethostbyname(config.gLobbyHost)
00031 
00032         if hdf.getValue("CGI.RemoteAddress", "") != ip_address:
00033             warn("request from lobby on %s does not match %s" % (hdf.getValue("CGI.RemoteAddress", ""), ip_address))
00034             #return
00035         else:
00036             warn("ip address is authorized")
00037 
00038         if not os.path.exists(config.ROS_VAR_DIR):
00039             os.umask(0)
00040             os.mkdir(config.ROS_VAR_DIR, 0777)
00041         takeover = open(TAKEOVER_FILE, "w")
00042         takeover.write(username)
00043         takeover.close()
00044 
00045 
00046     def Action_Response(self, hdf):
00047         if os.path.exists(TAKEOVER_FILE):
00048             os.remove(TAKEOVER_FILE)
00049 
00050         if hdf.getValue("Query.Action.Response", "") == "allow":
00051             self.redirectUri(config.gBaseURL + "login/signin.py?Action.Logout=1")
00052         elif hdf.getValue("Query.Action.Response", "") == "deny":
00053             self.redirectUri(config.gBaseURL + "app/texas_web_teleop/texas_web_teleop_mini/")
00054 
00055             
00056 
00057 
00058 def run(context):
00059     page = SignInPage(context, pagename="takeover", nologin=1)
00060     return page
00061 
00062 def main(context):
00063   page = run(context)
00064   page.start()
00065   
00066 
00067 if __name__ == "__main__":
00068     main(Context())
00069 


webui
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Wed Apr 23 2014 10:36:00