def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( "--db-uri", default=app.config["DB_URI"], help="DB URI, e.g. mongodb://localhost/lathermail, sqlite:////tmp/my.db" ) parser.add_argument("--api-host", default=app.config["API_HOST"], help="API Host") parser.add_argument("--api-port", default=app.config["API_PORT"], type=int, help="API port") parser.add_argument("--smtp-host", default=app.config["SMTP_HOST"], help="SMTP host") parser.add_argument("--smtp-port", default=app.config["SMTP_PORT"], type=int, help="SMTP port") args = parser.parse_args() app.config["DB_URI"] = args.db_uri init_app() t = Thread(target=serve_smtp, kwargs=dict(handler=message_handler, host=args.smtp_host, port=args.smtp_port)) t.daemon = True t.start() app.run(debug=False, threaded=True, host=args.api_host, port=args.api_port)
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( "--db-uri", default=app.config["DB_URI"], help="DB URI, e.g. mongodb://localhost/lathermail, sqlite:////tmp/my.db", ) parser.add_argument("--api-host", default=app.config["API_HOST"], help="API Host") parser.add_argument("--api-port", default=app.config["API_PORT"], type=int, help="API port") parser.add_argument("--smtp-host", default=app.config["SMTP_HOST"], help="SMTP host") parser.add_argument("--smtp-port", default=app.config["SMTP_PORT"], type=int, help="SMTP port") parser.add_argument("--debug", action="store_true", help="Run in debug mode") parser.add_argument("--debug-smtp", action="store_true", help="Turn on SMTP debug info") args = parser.parse_args() if args.debug_smtp: import smtpd smtpd.DEBUGSTREAM = sys.stderr app.config["DB_URI"] = args.db_uri app.config["DEBUG_MODE"] = args.debug init_app() t = Thread( target=serve_smtp, kwargs=dict(handler=db.engine.message_handler, host=args.smtp_host, port=args.smtp_port) ) t.daemon = True t.start() app.run(debug=False, threaded=True, host=args.api_host, port=args.api_port)
def setUpClass(cls): conf = lathermail.app.config if os.getenv("LATHERMAIL_TEST_DB_TYPE", "sqlite") == "mongo": conf["DB_URI"] = conf["SQLALCHEMY_DATABASE_URI"] = "mongodb://localhost/%s" % cls.db_name else: conf["DB_URI"] = conf["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:" lathermail.init_app() cls.c = lathermail.app.test_client() super(BaseTestCase, cls).setUpClass() cls.server = SmtpServerRunner(cls.db_name) cls.server.start(cls.port)
def setUpClass(cls): conf = lathermail.app.config if os.getenv("LATHERMAIL_TEST_DB_TYPE", "sqlite") == "mongo": conf["DB_URI"] = conf[ "SQLALCHEMY_DATABASE_URI"] = "mongodb://localhost/%s" % cls.db_name else: conf["DB_URI"] = conf[ "SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:" lathermail.init_app() cls.c = lathermail.app.test_client() super(BaseTestCase, cls).setUpClass() cls.server = SmtpServerRunner(cls.db_name) cls.server.start(cls.port)
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( "--db-uri", default=app.config["DB_URI"], help="DB URI, e.g. mongodb://localhost/lathermail, sqlite:////tmp/my.db" ) parser.add_argument("--api-host", default=app.config["API_HOST"], help="API Host") parser.add_argument("--api-port", default=app.config["API_PORT"], type=int, help="API port") parser.add_argument("--smtp-host", default=app.config["SMTP_HOST"], help="SMTP host") parser.add_argument("--smtp-port", default=app.config["SMTP_PORT"], type=int, help="SMTP port") parser.add_argument("--debug", action="store_true", help="Run in debug mode") parser.add_argument("--debug-smtp", action="store_true", help="Turn on SMTP debug info") args = parser.parse_args() if args.debug_smtp: import smtpd smtpd.DEBUGSTREAM = sys.stderr app.config["DB_URI"] = args.db_uri app.config["DEBUG_MODE"] = args.debug init_app() t = Thread(target=serve_smtp, kwargs=dict(handler=db.engine.message_handler, host=args.smtp_host, port=args.smtp_port)) t.daemon = True t.start() app.run(debug=False, threaded=True, host=args.api_host, port=args.api_port)
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( "--db-uri", default=app.config["DB_URI"], help="DB URI, e.g. mongodb://localhost/lathermail, sqlite:////tmp/my.db" ) parser.add_argument("--api-host", default=app.config["API_HOST"], help="API Host") parser.add_argument("--api-port", default=app.config["API_PORT"], type=int, help="API port") parser.add_argument("--smtp-host", default=app.config["SMTP_HOST"], help="SMTP host") parser.add_argument("--smtp-port", default=app.config["SMTP_PORT"], type=int, help="SMTP port") args = parser.parse_args() app.config["DB_URI"] = args.db_uri init_app() t = Thread(target=serve_smtp, kwargs=dict(handler=message_handler, host=args.smtp_host, port=args.smtp_port)) t.daemon = True t.start() app.run(debug=False, threaded=True, host=args.api_host, port=args.api_port)