File: __init__.py

package info (click to toggle)
montage-wrapper 0.9.9-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,092 kB
  • sloc: python: 8,325; makefile: 116; ansic: 88
file content (63 lines) | stat: -rw-r--r-- 2,033 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""
This is an Astropy affiliated package.
"""

# Affiliated packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *
# ----------------------------------------------------------------------------

# For egg_info test builds to pass, put package imports here.
if not _ASTROPY_SETUP_:

    from .commands import *
    from .wrappers import *
    from .mpi import set_mpi_command

    # Check whether Montage is installed
    installed = False
    for dir in os.environ['PATH'].split(':'):
        if os.path.exists(dir + '/mProject'):
            installed = True
            break

    # Check for Windows installation of Montage
    if not installed:
        for dir in os.environ['PATH'].split(';'):
            if os.path.exists(dir + '/mProject.exe'):
                installed = True
                break

    import textwrap

    error_wrap = textwrap.TextWrapper(initial_indent=" " * 11,
                                      subsequent_indent=" " * 11,
                                      width=72)

    MONTAGE_MISSING = """
    ERROR: Montage commands could not be found.

    In order to use the montage_wrapper module, you will first need to
    install the IPAC Montage software from:

        http://montage.ipac.caltech.edu

    and ensure that the Montage commands (e.g. mAdd, mProject, etc.) are in
    your $PATH. Your current $PATH variable contains the following paths,
    but none of them contain the Montage commands:

        PATH = {path}

    If the Montage commands are in one of these directories, then please
    report this as an issue with montage-wrapper.
    """.format(path=error_wrap.fill(os.environ['PATH']).strip())

    ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

    if not ON_RTD and not installed:
        print(MONTAGE_MISSING)
        import sys
        sys.exit(1)