Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
def webserver_command(config='./geobox.ini'):
    from geobox.appstate import GeoBoxState
    from geobox.defaults import GeoBoxConfig

    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'), threaded=True)
Пример #4
0
 def __init__(self, config=None):
     if config is None:
         appname = GeoBoxConfig.defaults["app"]["name"]
         config_fname = self.user_data_path(appname.lower() + ".ini", appname=appname, make_dirs=True)
         config = GeoBoxConfig.from_file(config_fname)
     self.config = config
     try:
         config.get("web", "secret_key")
     except KeyError:
         config.set("web", "secret_key", uuid.uuid4().get_hex())
         config.write()
     self.engine, self.db_filename = self._user_data_db_engine()
     self.migrate_db(self.engine)
     Base.metadata.create_all(self.engine)
     self.user_db_session = sessionmaker(self.engine)
     self._should_terminate = threading.Event()
     self._temp_dir = None
     self._translations = None
     self._port_lock = threading.Lock()
     self._ports = set()
     self.new_home_server = None
     self.tilebox = TileBoxServer(self)
Пример #5
0
 def __init__(self, config=None):
     if config is None:
         appname = GeoBoxConfig.defaults['app']['name']
         config_fname = self.user_data_path(appname.lower() + '.ini',
                                            appname=appname,
                                            make_dirs=True)
         config = GeoBoxConfig.from_file(config_fname)
     self.config = config
     try:
         config.get('web', 'secret_key')
     except KeyError:
         config.set('web', 'secret_key', uuid.uuid4().get_hex())
         config.write()
     self.engine, self.db_filename = self._user_data_db_engine()
     self.migrate_db(self.engine)
     Base.metadata.create_all(self.engine)
     self.user_db_session = sessionmaker(self.engine)
     self._should_terminate = threading.Event()
     self._temp_dir = None
     self._translations = None
     self._port_lock = threading.Lock()
     self._ports = set()
     self.new_home_server = None
     self.tilebox = TileBoxServer(self)
Пример #6
0
 def initialize(cls):
     # XXX olt: default .ini path
     config = GeoBoxConfig.from_file("./geobox.ini")
     return cls(config)
Пример #7
0
 def initialize(cls):
     # XXX olt: default .ini path
     config = GeoBoxConfig.from_file('./geobox.ini')
     return cls(config)