forked from cxcsds/ciao-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_runtool.footer
67 lines (57 loc) · 2.73 KB
/
mk_runtool.footer
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
64
65
66
67
# Add the routines to the module symbol table
#
__all__ = ["get_pfiles", "set_pfiles",
"new_tmpdir", "new_pfiles_environment",
"add_tool_history",
"list_tools", "make_tool"]
for toolname in list_tools():
setattr(sys.modules[__name__], toolname, make_tool(toolname))
__all__.append(toolname)
# Now, some tools added that don't use par files and are thus not
# handled by this tool.
# However, that's a fine distinction that users might not appreciate.
# Thus, we add them here, so that least there is a helpful message
# if they try to use it.
# The list of tools is manually curated and believed to be correct
# as of COA 4.14 (see https://github.com/cxcsds/ciao-contrib/issues/643#issue-1419049281)
# We are not adding all scripts, just those that a casual user might expect here.
# In particular, ds9* and install_marx clearly interact with non-Python systems
# and as such we believe that users would not look for thme here.
no_par_file_tools = [
'acis_clear_status_bits',
'check_ciao_caldb',
'check_ciao_version',
'convert_xspec_script',
'convert_xspec_user_model',
'splitroi',
'summarize_status_bits',
'tg_bkg'
]
def make_no_par_file_message(toolname):
'''Make a dummy function that raises an error with a helpful message when called.'''
def no_parfile(*args, **kwargs):
'''CIAO tools without parameter file.
This is a dummy function that will raise an error when called and
advice to call the CIAO tool using
`subprocess.run()` from the Python standard library.
'''
raise NotImplementedError(f"{toolname} does not use a parameter file and thus is not handled " +
"by ciao_contrib.runtool. Use `subprocess.run` instead " +
f"(see https://docs.python.org/3/library/subprocess.html) to call {toolname}.")
return no_parfile
for toolname in no_par_file_tools:
if toolname not in dir(sys.modules[__name__]):
setattr(sys.modules[__name__], toolname, make_no_par_file_message(toolname))
__all__.append(toolname)
__all__.extend(['no_par_file_tools', 'make_no_par_file_message'])
# And this one is special, so list individually.
def download_chandra_obsid(*args, **kwargs):
'''Dummy function that raises an error when called.
The error message tells the user to use
`ciao_contrib.cda.data.download_chandra_obsids`
instead to download Chandra data.
'''
raise NotImplementedError(f"download_chandra_obsid does not use a parameter file and thus is not handled " +
"by ciao_contrib.runtool. " +
"Use ciao_contrib.cda.data.download_chandra_obsids instead.")
__all__ = tuple(__all__)