Changeset 8259 in genesis
- Timestamp:
- Aug 8, 2010, 11:21:39 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/gformat.py
r8258 r8259 29 29 def print_title(nodelist): 30 30 """ Main overview page """ 31 items = {'root' : os.environ['SCRIPT_NAME']}31 items = {'root' : "." } 32 32 print """ 33 33 <html> … … 43 43 <body> 44 44 <center> 45 <form type="GET" action=" ">45 <form type="GET" action="%(root)s"> 46 46 <input type="hidden" name="action" value="update"> 47 47 <input type="submit" value="Update Configuration Database (SVN)"> … … 331 331 form = cgi.FieldStorage() 332 332 if form.getvalue("action") == "update": 333 print "Refresh: 5; url= %s" % os.environ['SCRIPT_NAME']333 print "Refresh: 5; url=." 334 334 print "Content-type:text/plain\r\n\r\n", 335 335 print "[INFO] Updating subverion, please wait..." … … 354 354 assert False, "Invalid option" 355 355 356 357 358 def usage(): 359 print """Usage: %s <standalone [port] |test [test arguments]> 360 Examples: 361 \tstandalone = Run configurator webserver [default port=8000] 362 \ttest CNodeRick dnsmasq.conf = Receive output of CGI script 363 \t for arguments CNodeRick/dnsmasq.conf 364 """ 365 exit(0) 366 367 368 356 369 # Allow easy hacking using the CLI 357 370 if not os.environ.has_key('PATH_INFO'): 358 os.environ['PATH_INFO'] = "/".join(sys.argv[1:]) 359 os.environ['SCRIPT_NAME'] = __file__ 360 361 process_cgi_request() 371 if len(sys.argv) < 2: 372 usage() 373 374 if sys.argv[1] == "standalone": 375 import SocketServer 376 import CGIHTTPServer 377 try: 378 PORT = int(sys.argv[2]) 379 except (IndexError,ValueError): 380 PORT = 8000 381 382 class MyCGIHTTPRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler): 383 """ Serve this CGI from the root of the webserver """ 384 def is_cgi(self): 385 if "favicon" in self.path: 386 return False 387 388 self.cgi_info = (__file__, self.path) 389 self.path = '' 390 return True 391 handler = MyCGIHTTPRequestHandler 392 httpd = SocketServer.TCPServer(("", PORT), handler) 393 httpd.server_name = 'localhost' 394 httpd.server_port = PORT 395 396 print "serving at port", PORT 397 httpd.serve_forever() 398 elif sys.argv[1] == "test": 399 os.environ['PATH_INFO'] = "/".join(sys.argv[2:]) 400 os.environ['SCRIPT_NAME'] = __file__ 401 process_cgi_request() 402 else: 403 usage() 404 else: 405 process_cgi_request()
Note:
See TracChangeset
for help on using the changeset viewer.