The config module contains functions to manage and access the persistent astropysics configuration. It also includes utilities to install recommended packages and set up the ipython environment.
Configuration files can be found in the directory returned by get_config_dir(), typically a subdirectory ‘.astropysics’ of the user’s home directory. The format for the files is that of the ` configobj<http://www.voidspace.org.uk/python/configobj.html>`_ package, although for most files this is as simple as:
name1=value
#maybe a comment
name2 = anothervalue
Bases: exceptions.Exception
Bases: exceptions.Exception
Bases: HTMLParser.HTMLParser
Represents a python package to be downloaded and installed.
Parameters: |
|
---|
Subclassing
If a package needs some additional install steps, the postInstall() and preInstall() methods can be overridden (default does nothing). If the package isn’t in PyPI, the getURL() method should be overridden to return the necessary URL.
Attempt to download this package
Parameters: | |
---|---|
Returns: | The full path to the downloaded file. |
Raises DownloadError: | |
If the pacakge could not be located |
Returns the URL to download to get this package. Override this to get a URL from somewhere other than PyPI.
Returns: | (url,fn) where url is the URL to the source distribution, and fn is the filename to use locally if None, the end of the URL will be used) |
---|
Download the package, if necessary, and install it.
Parameters: |
|
---|---|
Raises InstallError: | |
If the install fails (postInstall() will be called immediately before). |
Test if the package is installed.
Returns: | True if the module is installed, otherwise False. |
---|
Subclasses can override this method to do something after building and installing occurs. Only called if install succeeds.
Parameters: |
---|
Bases: exceptions.Exception
Add a new project to the project registry.
Parameters: |
|
---|---|
Returns: | A 2-tuple (projectdir,projectscriptfilename) |
Raises IOError: | If something is wrong with the file or directory. |
Unregisters the project with the specified name.
Returns a dictionary-like object that has the configuration information for the specified configuration file. To save the configuration data if it is modified, call write() on the object.
Parameters: | name (str) – The name of the configuration file (without any path). The file will be searched for in/written to the config directory. |
---|---|
Returns: | A ConfigObj object with the configuration information. |
Raises: |
|
Returns the astropysics configuration directory name.
Parameters: | create (bool) – If True, the directory will be created if it doesn’t exist. |
---|---|
Returns: | The absolute path to the config directory as a string |
Returns the directory name for data that astropysics downloads. See :func`astropysics.utils.io.get_data` to work with data in this directory.
Parameters: | create (bool) – If True, the directory will be created if it doesn’t exist. |
---|---|
Returns: | The absolute path to the data directory as a string. |
Returns all registered projects and their assoiciated directories and script files.
Returns: | A dictionary where the keys are the project names and the values are 2-tuples (projectdir,projectscriptfilename) |
---|
Starts the console-based interactive installation tool.
Parameters: | sudo – Determines whether or not the install step is prefixed by ‘sudo’. If True, sudo will be prefixed, if False, no prefix will be used. If ‘auto’, the platform will be examined to try to determine if sudo is necessary. If ‘toggleauto’, the opposite of whatever ‘auto’ gives will be used. |
---|
Note
The ‘auto’ option for sudo is nowhere close to perfect - it’s pretty much just a list of common platforms that require it... if you’re on an uncommon platform, you will probably have to set it manually.
Runs the console-based ipython setup tool.