def testSetupStubs(self): """Sets up apiproxy stubs.""" class TestOptions: blobstore_path = 'blobstore' datastore = 'mongodb' http_port = 8080 internal_address = 'localhost:8770' login_url = '/_ah/login' logout_url = '/_ah/logout' rdbms_sqlite_path = os.path.join(tempfile.gettempdir(), 'test.db') server_name = 'localhost' smtp_host = 'localhost' smtp_port = 25 smtp_user = '' smtp_password = '' use_celery = False websocket_host = 'localhost' websocket_port = 8888 xmpp_host = 'localhost' memcache = '' typhoonae.setupStubs(self.conf, TestOptions())
def main(): """Initializes the server.""" op = optparse.OptionParser(description=DESCRIPTION, usage=USAGE) op.add_option("--auth_domain", dest="auth_domain", metavar="DOMAIN", help="use this value for the AUTH_DOMAIN environment " "variable", default='localhost') op.add_option("--blobstore_path", dest="blobstore_path", metavar="PATH", help="path to use for storing Blobstore file stub data", default=os.path.join('var', 'blobstore')) op.add_option("--current_version_id", dest="current_version_id", metavar="STRING", help="the current version id", default=None) op.add_option("--datastore", dest="datastore", metavar="NAME", help="use this Datastore backend (%s)" % '/'.join(sorted(typhoonae.SUPPORTED_DATASTORES)), default='mongodb') op.add_option("--debug", dest="debug_mode", action="store_true", help="enables debug mode", default=False) op.add_option("--email", dest="email", metavar="EMAIL", help="the username to use", default='') op.add_option("--http_port", dest="http_port", metavar="PORT", help="port for the HTTP server to listen on", default=8080) op.add_option("--internal_address", dest="internal_address", metavar="HOST:PORT", help="the internal application host and port", default='localhost:8770') op.add_option("--login_url", dest="login_url", metavar="URL", help="login URL", default='/_ah/login') op.add_option("--logout_url", dest="logout_url", metavar="URL", help="logout URL", default='/_ah/logout') op.add_option("--mysql_db", dest="mysql_db", metavar="STRING", help="connect to the given MySQL database", default='typhoonae') op.add_option("--mysql_host", dest="mysql_host", metavar="ADDR", help="connect to this MySQL database server", default='127.0.0.1') op.add_option("--mysql_passwd", dest="mysql_passwd", metavar="PASSWORD", help="use this password to connect to the MySQL database " "server", default='') op.add_option("--mysql_user", dest="mysql_user", metavar="USER", help="use this user to connect to the MySQL database server", default='root') op.add_option("--password", dest="password", metavar="PASSWORD", help="the password to use", default='') op.add_option("--rdbms_sqlite_path", dest="rdbms_sqlite_path", metavar="PATH", help="path to the sqlite3 file for the RDBMS API") op.add_option("--server_name", dest="server_name", metavar="STRING", help="use this server name", default='localhost') op.add_option("--server_software", dest="server_software", metavar="STRING", help="use this server software identifier", default=SERVER_SOFTWARE) op.add_option("--smtp_host", dest="smtp_host", metavar="ADDR", help="use this SMTP host", default='localhost') op.add_option("--smtp_port", dest="smtp_port", metavar="PORT", help="use this SMTP port", default=25) op.add_option("--smtp_user", dest="smtp_user", metavar="STRING", help="use this SMTP user", default='') op.add_option("--smtp_password", dest="smtp_password", metavar="STRING", help="use this SMTP password", default='') op.add_option("--upload_url", dest="upload_url", metavar="URI", help="use this upload URL for the Blobstore configuration " "(no leading '/')", default='upload/') op.add_option("--websocket_host", dest="websocket_host", metavar="ADDR", help="use this Web Socket host", default="localhost") op.add_option("--websocket_port", dest="websocket_port", metavar="PORT", help="use this Web Socket port", default=8888) op.add_option("--xmpp_host", dest="xmpp_host", metavar="ADDR", help="use this XMPP/Jabber host", default='localhost') op.add_option("--memcache", dest="memcache", metavar="ADDR:PORT", help="use a to configure the address of memcached servers", default=[], action="append") (options, args) = op.parse_args() if sys.argv[-1].startswith('-') or sys.argv[-1] == sys.argv[0]: op.print_usage() sys.exit(2) app_root = sys.argv[-1] logging.basicConfig(format=LOG_FORMAT) if options.debug_mode: logging.getLogger().setLevel(logging.DEBUG) else: logging.getLogger().setLevel(logging.INFO) # Change the current working directory to the application root and load # the application configuration os.chdir(app_root) sys.path.insert(0, app_root) conf = typhoonae.getAppConfig() # Inititalize API proxy stubs typhoonae.setupStubs(conf, options) # Serve the application serve(conf, options)