4 Print various items that may be of interest for SeaDAS and OCSSW
5 troubleshooting or forum posts.
8 from __future__
import print_function
15 import xml.etree.ElementTree
as ET
19 __version__ =
'0.0.3.devel'
23 Return the Python version, cleaned of extra text (especially relevant for
24 Anaconda installations. Return "Not found" if the Python version is not
25 found (although how that happens is a major mystery!).
29 if sys.version.upper().find(
'ANACONDA') != -1:
30 py_ver =
' '.join([sys.version.split(
' ')[0],
'(part of an Anaconda installation)'])
32 py_ver = sys.version.split(
' ')[0]
39 process = subprocess.Popen(command, shell=
False, stdout=subprocess.PIPE,
40 stderr=subprocess.PIPE)
41 stdout, stderr = process.communicate()
42 cmd_output = stdout.decode(
"utf-8") + stderr.decode(
"utf-8")
49 Returns env output, which is obtained by running env
56 env_output = output.splitlines()
62 Returns the version for various "l programs" (e.g. l2gen, l3bin)
64 lprog_ver =
'program not found'
65 exe_dirs = [
'bin',
'run/bin',
'run/bin/linux_64']
66 ver_args = [
'version',
'-version']
68 prog = os.path.join(ocssw_root, l_program)
69 if os.path.exists(prog):
72 for cand_dir
in exe_dirs:
73 prog = os.path.join(ocssw_root, cand_dir, l_program)
74 if os.path.exists(prog):
78 for ver_arg
in ver_args:
79 cmd_line = [prog, ver_arg]
82 ver_lines = out_txt.split(
'\n')
84 lprog_ver = ver_lines[-1].strip()
90 missionListPath = os.path.join(ocdata_root,
'common/missionList.xml')
91 if os.path.exists(missionListPath):
92 tree = ET.parse(missionListPath)
95 name = elem.get(
'name')
97 missionDir = subelem.text
98 pathAbs = os.path.join(ocdata_root, missionDir)
99 if os.path.exists(pathAbs):
100 missionInstalled.append(name)
101 return missionInstalled
105 Returns the java version, which is obtained by running java -version
108 java_ver =
'Not installed'
109 cmd = [
'java',
'-version']
111 if output
and output.upper().find(
'RUNTIME') != -1:
112 lines = output.split(
'\n')
113 java_ver = re.sub(
'(^[^"]+|(?<=")[^"]+$)',
'', lines[0]).strip(
'"')
118 Returns the distribution of the operating system.
122 uname_info = os.uname()
123 if uname_info[0] ==
'Linux':
124 with open(
'/etc/os-release',
'rt')
as os_rel_file:
125 rel_lines = os_rel_file.readlines()
127 rel_info_dict = dict()
128 for line
in rel_lines:
129 line_parts = line.split(
'=')
130 if len(line_parts) == 2:
131 if line_parts[0].strip():
132 rel_info_dict[line_parts[0].strip()] = line_parts[1].strip().strip(
'"')
133 if 'PRETTY_NAME' in rel_info_dict:
134 dist = rel_info_dict[
'PRETTY_NAME']
135 elif uname_info[0] ==
'Darwin':
136 dist =
'MacOS ' + platform.mac_ver()[0]
138 dist =
' '.join([uname_info[0], uname_info[2]])
143 Returns the python3 path, which is obtained by running which python3
147 cmd = [
'which',
'python3']
150 lines = output.split(
'\n')
152 python3_path = lines[-1].strip()
157 Returns the SeaDAS version as held in the VERSION.txt file in the
158 directory pointed to by the SEADAS_ROOT environment variable.
160 seadas_ver =
'Not installed'
161 ver_path = os.path.join(seadas_root,
'VERSION.txt')
162 if os.path.exists(ver_path):
163 with open(ver_path,
'rt')
as ver_file:
164 in_line = ver_file.readline()
165 if in_line.find(
'VERSION') != -1:
166 seadas_ver = in_line.split(
' ', 1)[1].strip()
171 Handle help or version being requested on the command line.
173 parser = argparse.ArgumentParser()
174 parser.add_argument(
"--AppDir", \
175 help=
"Application installation directory", \
177 args = parser.parse_args()
182 Print out the items of interest for the SeaDAS installation specified
183 by the seadas_root and ocssw_root parameters.
185 print(
'NASA Science Processing (OCSSW):')
186 print(
'OCSSWROOT={0}'.format(ocssw_root))
187 print(
'OCDATAROOT={0}'.format(ocdata_root))
198 Print out information about the system (OS, Python version, Java version).
200 print(
'General System and Software:')
206 printenvs = [
'CC',
'CXX',
'FC',
'OCSSW_ARCH',
'OCSSW_BIN',
'OCSSW_DEBUG',
'OCSSW_MODIS',
207 'OCVARROOT',
'ELEMENTS',
'EOS_LIB_PREFIX',
'GCC_TUNE',
'HDFEOS_LIB',
208 'HRPT_STATION_IDENTIFICATION_FILE',
'L2GEN_ANC',
'LIB3_BIN',
'LIB3_CHECK',
209 'LIB3_DIR',
'LIB3_INC',
'LIB3_LIB',
'NAVCTL',
'NAVQC',
'ORBCTL',
'PGSINC',
'PGSLIB',
210 'OCTS_REGISTRATION_TABLES',
'PROJ_DATA',
'PROJ_LIB',
'SWFTBL',
'SWTBL']
213 for line
in env_output:
214 key, value = line.split(
'=', 1)
216 print(
' {0}={1}'.format(key,value))
222 The program's main function - gets and prints items of interest.
224 if 'OCSSWROOT' in os.environ:
225 ocssw_root = os.environ[
'OCSSWROOT']
227 ocssw_root =
'Not defined'
228 if 'OCDATAROOT' in os.environ:
229 ocdata_root = os.environ[
'OCDATAROOT']
231 ocdata_root =
'Not defined'
236 if __name__ ==
'__main__':