astropy:docs

settings API Reference

Handle settings for Mo’Astro databases.

Settings are stored on disk as a JSON file located at $HOME/.moastro.json. Alternative locations can be set with the $MOASTROCONFIG environment variable.

A basic .moastro.json file looks like this:

{"servers":
    {"marvin": {"url": "localhost", "port": 27017}}
}

Server definitions are stored as a hash under the servers key. Here we define one server named marvin that is connected to as localhost:27017.

In the future we will add remote_url and remote_port to the settings schema to facilitate SSH port forwarding.

Functions

moastro.settings.locate_server(servername)[source]

Return the URL and port of a named server.

Parameters:

servername : str

Name of the server, matching that in the .moastro.json file.

Returns:

url : str

URL/hostname of the MongoDB server.

port : int

Port that the MongoDB server connects on.

moastro.settings.read_settings(path='/Users/jsick/.moastro.json')[source]

Read the Mo’Astro JSON configurations file.

Parameters:

path : str

Path to the .moastro.json file.

Returns:

settings : dict

The settings, as a dict. If the settings file is not found, an empty dictionary is returned.