def main(config_filename=None): import optparse requests_log = logging.getLogger("requests") requests_log.setLevel(logging.WARNING) logging.basicConfig(level=logging.DEBUG) parser = optparse.OptionParser() parser.description = 'Deploy the GBI-Client CouchApp to a CouchDB.' parser.add_option('--couchurl', help='url of couchdb', default='http://localhost:5984') parser.add_option('--dbname', help='database name') parser.add_option('--appname', help='name of couchapp, as in /dbname/_design/appname') options, args = parser.parse_args() if not options.dbname or not options.appname: parser.print_help() print >>sys.stderr, '\nERROR: --dbname and --appname required' sys.exit(1) if config_filename: config = GeoBoxConfig.from_file(config_filename) if not config: sys.exit(1) app_state = GeoBoxState(config) else: app_state = GeoBoxState() app = create_app(app_state) create_offline_editor(app, options.couchurl, options.dbname, options.appname)
def main(config_filename=None): import optparse requests_log = logging.getLogger("requests") requests_log.setLevel(logging.WARNING) logging.basicConfig(level=logging.DEBUG) parser = optparse.OptionParser() parser.description = 'Deploy the GBI-Client CouchApp to a CouchDB.' parser.add_option('--couchurl', help='url of couchdb', default='http://localhost:5984') parser.add_option('--dbname', help='database name') parser.add_option('--appname', help='name of couchapp, as in /dbname/_design/appname') options, args = parser.parse_args() if not options.dbname or not options.appname: parser.print_help() print >> sys.stderr, '\nERROR: --dbname and --appname required' sys.exit(1) if config_filename: config = GeoBoxConfig.from_file(config_filename) if not config: sys.exit(1) app_state = GeoBoxState(config) else: app_state = GeoBoxState() app = create_app(app_state) create_offline_editor(app, options.couchurl, options.dbname, options.appname)
def app_server_thread(app_state): """Webserver background thread""" from geobox.web import create_app from geobox.lib.webserver import WebServerThread host = app_state.config.get('app', 'host') port = app_state.config.get_int('web', 'port') app = create_app(app_state) return WebServerThread(host, port, app, logger_name='geobox.web.server')
def app_server_thread(app_state): """Webserver background thread""" from geobox.web import create_app from geobox.lib.webserver import WebServerThread host = app_state.config.get("app", "host") port = app_state.config.get_int("web", "port") app = create_app(app_state) return WebServerThread(host, port, app, logger_name="geobox.web.server")
def webserver_command(config='./geobox.ini'): from geobox.config import GeoBoxConfig, GeoBoxState config = GeoBoxConfig.from_file(config) if not config: sys.exit(1) app_state = GeoBoxState(config) app = create_app(app_state) # scriptine removed sub-command from argv, # but Flask reloader needs complete sys.argv sys.argv[1:1] = ['webserver'] app.run(port=config.get('web', 'port'))