takeover.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import nstart
4 import config
5 import os, sys, string, time
6 import socket
7 
8 from pyclearsilver.log import *
9 
10 from pyclearsilver.CSPage import Context
11 import neo_cgi, neo_cs, neo_util
12 from MBPage import MBPage
13 from webui import config
14 
15 from auth import browserauth
16 from auth import cookieauth
17 from auth import db_auth
18 from auth import pwauth
19 
20 TAKEOVER_FILE = os.path.join(config.ROS_VAR_DIR, "takeover.dat")
21 
22 class SignInPage(MBPage):
23  def setup(self, hdf):
24  pass
25 
26  def display(self, hdf):
27  username = hdf.getValue("Query.username", "")
28  if not username: return
29 
30  ip_address = socket.gethostbyname(config.gLobbyHost)
31 
32  if hdf.getValue("CGI.RemoteAddress", "") != ip_address:
33  warn("request from lobby on %s does not match %s" % (hdf.getValue("CGI.RemoteAddress", ""), ip_address))
34  #return
35  else:
36  warn("ip address is authorized")
37 
38  if not os.path.exists(config.ROS_VAR_DIR):
39  os.umask(0)
40  os.mkdir(config.ROS_VAR_DIR, 0777)
41  takeover = open(TAKEOVER_FILE, "w")
42  takeover.write(username)
43  takeover.close()
44 
45 
46  def Action_Response(self, hdf):
47  if os.path.exists(TAKEOVER_FILE):
48  os.remove(TAKEOVER_FILE)
49 
50  if hdf.getValue("Query.Action.Response", "") == "allow":
51  self.redirectUri(config.gBaseURL + "login/signin.py?Action.Logout=1")
52  elif hdf.getValue("Query.Action.Response", "") == "deny":
53  self.redirectUri(config.gBaseURL + "app/texas_web_teleop/texas_web_teleop_mini/")
54 
55 
56 
57 
58 def run(context):
59  page = SignInPage(context, pagename="takeover", nologin=1)
60  return page
61 
62 def main(context):
63  page = run(context)
64  page.start()
65 
66 
67 if __name__ == "__main__":
68  main(Context())
69 


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24