def startServer(): """Set the server running and allow it to close normally (with no exception).""" import myserver print "Starting server...press CTRL+C to stop." print "" # This lets the server be stopped with CTRL+C # As it runs to finish, exit handlers are called try: myserver.getServer().start() except KeyboardInterrupt: pass
def setupServer(): """ Set up the server and print relevant information. This should be called after the config is set up. It gets and sets config values. """ import myserver import authentication myserver.getServer().setup() print "Now you can log on to the server with the following credentials:" print "" print "Location: http://localhost:" + str(config.getSettings("server")["port"]) if authentication.active(): print "User: "******"Password: <You should know>" print "" print "If I displayed the password back to you then the small amount of security during the input would be wasted." print "(You can just read it in the config file though, that's a problem.)"
# Ask only if we're looking at a new file from getpass import getpass password = getpass("Please give a passkey for accessing the interface (Blank for none): ") if password: authentication.addUser(pb.app_user, password) else: authentication.clear() show_break() # Start server import myserver myserver.getServer().setup() print "Now you can log on to the server with the following credentials:" print "" print "Location: http://localhost:" + str(config.getSettings("server")["port"]) if authentication.active(): print "User: "******"Password: <You should know>" print "" print "If I displayed the password back to you then the small amount of security during the input would be wasted." print "(You can just read it in the config file though, that's a problem.)" show_break() config.saveConfig() print "Config written to disk"