4 Created on Tue Sep 18 11:08:27 2018
9 from operator
import indexOf
22 from email.message
import EmailMessage
28 MANIFEST_BASENAME =
"manifest.json"
29 BUNDLELIST_BASENAME =
"bundleList.json"
30 INSTALL_OCSSW_BASENAME =
"install_ocssw.json"
32 baseUrl =
"https://oceandata.sci.gsfc.nasa.gov/manifest/tags"
33 manifestCommand = os.path.dirname(__file__) +
"/manifest.py"
43 {
"name":
"root",
"dir":
".",
"help":
"random files in the root dir",
"extra":
"--exclude . --include bundleList.json --include OCSSW_bash.env --include OCSSW.env",
"commandLine":
True},
44 {
"name":
"bin_linux_64",
"dir":
"bin_linux_64",
"help":
"executables for Linux",
"commandLine":
False},
45 {
"name":
"bin_macosx_intel",
"dir":
"bin_macosx_intel",
"help":
"executables for Mac",
"commandLine":
False},
46 {
"name":
"bin_odps",
"dir":
"bin_odps",
"help":
"executables for ODPS",
"commandLine":
False},
47 {
"name":
"lib_linux_64",
"dir":
"lib_linux_64",
"help":
"shared libraries for Linux",
"commandLine":
False},
48 {
"name":
"lib_macosx_intel",
"dir":
"lib_macosx_intel",
"help":
"shared libraries for Mac",
"commandLine":
False},
49 {
"name":
"lib_odps",
"dir":
"lib_odps",
"help":
"shared libraries for ODPS",
"commandLine":
False},
50 {
"name":
"opt_linux_64",
"dir":
"opt_linux_64",
"help":
"3rd party library for Linux",
"extra":
"--exclude src",
"commandLine":
False},
51 {
"name":
"opt_macosx_intel",
"dir":
"opt_macosx_intel",
"help":
"3rd party library for Mac",
"extra":
"--exclude src",
"commandLine":
False},
52 {
"name":
"opt_odps",
"dir":
"opt_odps",
"help":
"3rd party library for ODPS",
"extra":
"--exclude src",
"commandLine":
False},
54 {
"name":
"ocssw_src",
"dir":
"ocssw_src",
"help":
"OCSSW source code",
"commandLine":
False},
55 {
"name":
"opt_src",
"dir":
"opt/src",
"help":
"3rd party library sources",
"extra":
"--exclude .buildit.db",
"commandLine":
True},
57 {
"name":
"afrt",
"dir":
"share/afrt",
"help":
"Ahmad-Fraser RT data",
"commandLine":
True},
58 {
"name":
"aquaverse",
"dir":
"share/aquaverse",
"help":
"Algorithm based on Mixture Density Networks",
"commandLine":
True},
59 {
"name":
"avhrr",
"dir":
"share/avhrr",
"help":
"AVHRR",
"commandLine":
True},
60 {
"name":
"aviris",
"dir":
"share/aviris",
"help":
"AVIRIS",
"commandLine":
True},
61 {
"name":
"common",
"dir":
"share/common",
"help":
"common",
"commandLine":
True},
62 {
"name":
"czcs",
"dir":
"share/czcs",
"help":
"CZCS",
"commandLine":
True},
63 {
"name":
"eval",
"dir":
"share/eval",
"help":
"evaluation",
"commandLine":
True},
64 {
"name":
"goci",
"dir":
"share/goci",
"help":
"GOCI",
"commandLine":
True},
65 {
"name":
"hawkeye",
"dir":
"share/hawkeye",
"help":
"Hawkeye",
"commandLine":
True},
66 {
"name":
"hico",
"dir":
"share/hico",
"help":
"HICO",
"commandLine":
True},
67 {
"name":
"l5tm",
"dir":
"share/l5tm",
"help":
"l5tm",
"commandLine":
True},
68 {
"name":
"l7etmp",
"dir":
"share/l7etmp",
"help":
"l7etmp",
"commandLine":
True},
69 {
"name":
"meris",
"dir":
"share/meris",
"help":
"MERIS",
"commandLine":
True},
70 {
"name":
"misr",
"dir":
"share/misr",
"help":
"MISR",
"commandLine":
True},
71 {
"name":
"modis",
"dir":
"share/modis",
"help":
"MODIS common",
"extra":
"--exclude aqua --exclude terra",
"commandLine":
False},
72 {
"name":
"modisa",
"dir":
"share/modis/aqua",
"help":
"MODIS AQUA",
"commandLine":
True},
73 {
"name":
"modist",
"dir":
"share/modis/terra",
"help":
"MODIS TERRA",
"commandLine":
True},
74 {
"name":
"mos",
"dir":
"share/mos",
"help":
"MOS",
"commandLine":
True},
75 {
"name":
"msi",
"dir":
"share/msi",
"help":
"MSI Sentinel 2 common",
"extra":
"--exclude s2a --exclude s2b",
"commandLine":
False},
76 {
"name":
"msis2a",
"dir":
"share/msi/s2a",
"help":
"MSI Sentinel 2A",
"commandLine":
True},
77 {
"name":
"msis2b",
"dir":
"share/msi/s2b",
"help":
"MSI Sentinel 2B",
"commandLine":
True},
78 {
"name":
"oci",
"dir":
"share/oci",
"help":
"PACE OCI",
"commandLine":
True},
79 {
"name":
"ocia",
"dir":
"share/ocia",
"help":
"PACE OCI AVIRIS",
"commandLine":
True},
80 {
"name":
"ocip",
"dir":
"share/ocip",
"help":
"PACE OCI PRISM",
"commandLine":
True},
81 {
"name":
"ocis",
"dir":
"share/ocis",
"help":
"PACE OCI Simulated data",
"commandLine":
True},
82 {
"name":
"ocm1",
"dir":
"share/ocm1",
"help":
"OCM1",
"commandLine":
True},
83 {
"name":
"ocm2",
"dir":
"share/ocm2",
"help":
"OCM2",
"commandLine":
True},
84 {
"name":
"ocrvc",
"dir":
"share/ocrvc",
"help":
"OC Virtual Constellation",
"commandLine":
True},
85 {
"name":
"octs",
"dir":
"share/octs",
"help":
"OCTS",
"commandLine":
True},
86 {
"name":
"olci",
"dir":
"share/olci",
"help":
"OLCI Sentinel 3 common",
"extra":
"--exclude s3a --exclude s3b",
"commandLine":
False},
87 {
"name":
"olcis3a",
"dir":
"share/olci/s3a",
"help":
"OLCI Sentinel 3A",
"commandLine":
True},
88 {
"name":
"olcis3b",
"dir":
"share/olci/s3b",
"help":
"OLCI Sentinel 3B",
"commandLine":
True},
89 {
"name":
"oli",
"dir":
"share/oli",
"help":
"OLI Landsat",
"extra":
"--exclude l8 --exclude l9",
"commandLine":
False},
90 {
"name":
"olil8",
"dir":
"share/oli/l8",
"help":
"OLI Landsat 8",
"commandLine":
True},
91 {
"name":
"olil9",
"dir":
"share/oli/l9",
"help":
"OLI Landsat 9",
"commandLine":
True},
92 {
"name":
"osmi",
"dir":
"share/osmi",
"help":
"OSMI",
"commandLine":
True},
93 {
"name":
"prism",
"dir":
"share/prism",
"help":
"PRISM",
"commandLine":
True},
94 {
"name":
"sabiamar",
"dir":
"share/sabiamar",
"help":
"Sabiamar",
"commandLine":
True},
95 {
"name":
"seawifs",
"dir":
"share/seawifs",
"help":
"SeaWiFS",
"commandLine":
True},
96 {
"name":
"sgli",
"dir":
"share/sgli",
"help":
"SGLI",
"commandLine":
True},
97 {
"name":
"spexone_remotap",
"dir":
"share/spexone/remotap",
"help":
"SPEX One RemoTAP",
"commandLine":
True},
98 {
"name":
"viirs",
"dir":
"share/viirs",
"extra":
"--exclude dem --exclude j1 --exclude j2 --exclude npp",
"help":
"VIIRS common",
"commandLine":
False},
99 {
"name":
"viirsdem",
"dir":
"share/viirs/dem",
"help":
"VIIRS Digital Elevation",
"commandLine":
True},
100 {
"name":
"viirsj1",
"dir":
"share/viirs/j1",
"help":
"VIIRS JPSS1",
"commandLine":
True},
101 {
"name":
"viirsj2",
"dir":
"share/viirs/j2",
"help":
"VIIRS JPSS2",
"commandLine":
True},
102 {
"name":
"viirsn",
"dir":
"share/viirs/npp",
"help":
"VIIRS NPP",
"commandLine":
True},
103 {
"name":
"wv3",
"dir":
"share/wv3",
"help":
"WV3",
"commandLine":
True},
104 {
"name":
"aerosol",
"dir":
"share/aerosol",
"help":
"aerosol processing with dtdb",
"commandLine":
True},
105 {
"name":
"cloud",
"dir":
"share/cloud",
"help":
"cloud properties processing",
"commandLine":
True},
106 {
"name":
"benchmark",
"dir":
"benchmark",
"help":
"benchmark MOSIS Aqua, level0 -> level3 Mapped",
"commandLine":
True},
107 {
"name":
"viirs_l1_benchmark",
"dir":
"viirs_l1_benchmark",
"help":
"VIIRS benchmark data",
"commandLine":
True},
108 {
"name":
"viirs_l1_bin_macosx_intel",
"dir":
"viirs_l1_bin_macosx_intel",
"help":
"Subset of binary files for VIIRS",
"commandLine":
False},
109 {
"name":
"viirs_l1_bin_linux_64",
"dir":
"viirs_l1_bin_linux_64",
"help":
"Subset of binary files for VIIRS",
"commandLine":
False},
110 {
"name":
"viirs_l1_bin_odps",
"dir":
"viirs_l1_bin_odps",
"help":
"Subset of binary files for VIIRS",
"commandLine":
False}
114 lutBundles = [
"seawifs",
"modisa",
"modist",
"viirsn",
"viirsj1"]
118 for bundleInfo
in bundleList:
119 if bundleInfo[
"name"] == bundleName:
125 Return the system arch string.
127 (sysname, _, _, _, machine) = os.uname()
128 if sysname ==
'Darwin':
129 if machine ==
'x86_64' or machine ==
'i386':
130 return 'macosx_intel'
131 print(
"unsupported Mac machine =", machine)
133 if sysname ==
'Linux':
134 if machine ==
'x86_64':
136 print(
"Error: can only install OCSSW software on 64bit Linux")
138 if sysname ==
'Windows':
139 print(
"Error: can not install OCSSW software on Windows")
141 print(
'***** unrecognized system =', sysname,
', machine =', machine)
142 print(
'***** defaulting to linux_64')
147 proc = subprocess.run(command, stdout=subprocess.PIPE, shell=shellVal)
149 proc = subprocess.run(command, shell=shellVal)
150 if proc.returncode != 0:
151 print(
"Error: trying to run = ", command)
157 manifest_options = mf.create_default_options()
158 manifest_options.wget = options.wget
159 mf.list_tags(manifest_options,
None)
162 manifest_options = mf.create_default_options()
163 manifest_options.tag = options.tag
164 manifest_options.wget = options.wget
165 if not mf.check_tag(manifest_options,
None):
166 print(
"tag=%s," % (options.tag),
"Does not exist.")
171 installInfo[
"tag"] = options.tag
172 installInfo[
"version"] = versionString
173 installInfo[
"install_date"] = datetime.datetime.now().isoformat(timespec=
"seconds")
176 if not os.path.isdir(options.install_dir):
177 os.makedirs(options.install_dir)
179 fileName =
"%s/%s" % (options.install_dir, INSTALL_OCSSW_BASENAME)
180 with open(fileName,
'w')
as outfile:
181 json.dump(installInfo, outfile, indent=4, sort_keys=
True)
184 installOcsswFilename =
"%s/%s" % (options.install_dir, INSTALL_OCSSW_BASENAME)
187 with open(installOcsswFilename,
'rb')
as installOcsswFile:
188 installInfo = json.load(installOcsswFile)
189 return installInfo[
"tag"]
193 manifestFilename =
"%s/%s" % (options.install_dir, MANIFEST_BASENAME)
194 with open(manifestFilename,
'rb')
as manifestFile:
195 manifest = json.load(manifestFile)
196 return manifest[
"tags"][-1]
208 print(
"Installing (" +
str(currentThing),
"of",
str(totalNumThings) +
") -", bundleInfo[
"name"], flush=
True)
211 manifest_options = mf.create_default_options()
212 manifest_options.verbose = options.verbose
213 manifest_options.name = bundleInfo[
"name"]
214 manifest_options.tag = options.tag
215 manifest_options.dest_dir =
"%s/%s" % (options.install_dir, bundleInfo[
"dir"])
216 manifest_options.save_dir = options.save_dir
217 manifest_options.local_dir = options.local_dir
218 manifest_options.wget = options.wget
220 mf.download(manifest_options,
None)
223 command =
"%s clean %s/%s" % (manifestCommand, options.install_dir, bundleInfo[
"dir"])
224 if "extra" in bundleInfo:
225 command +=
" " + bundleInfo[
"extra"]
229 runner = options.install_dir +
"/bin/ocssw_runner"
230 if not os.path.isfile(runner):
231 print(
"Error - bin directory needs to be installed.")
235 print(
"Installing lut -", lut)
236 command =
"%s --ocsswroot %s update_luts %s" % (runner, options.install_dir, lut)
241 with open(manifestFilename,
'rb')
as manifestFile:
242 manifest = json.load(manifestFile)
243 return manifest[
'files'][BUNDLELIST_BASENAME][
'tag']
244 except json.JSONDecodeError:
245 print(manifestFilename,
"is not a manifest file")
247 except FileNotFoundError:
248 print(manifestFilename,
"Not found")
251 print(manifestFilename,
"is corrupt")
253 print(
"could not find bundeList tag in", manifestFilename)
260 print(
"\nWARNING: --tag is required to get the proper bundle list.\n")
261 bundleList = initialBundleList
266 tempDir = tempfile.TemporaryDirectory(prefix=
"install_ocssw-")
267 tempBundleFilePath = dest =
"%s/%s" % (tempDir.name, BUNDLELIST_BASENAME)
268 if options.local_dir:
269 manifestFilename =
"%s/%s/root/%s" % (options.local_dir, options.tag, MANIFEST_BASENAME)
270 bundleFilename =
"%s/%s/root/%s" % (options.local_dir,
getBundleListTag(manifestFilename),BUNDLELIST_BASENAME)
271 if not os.path.isfile(bundleFilename):
272 print(bundleFilename,
"file does not exist")
274 shutil.copy(bundleFilename, tempBundleFilePath)
276 command =
"cd %s; wget -q %s/%s/root/%s" % (tempDir.name, options.base_url, options.tag, MANIFEST_BASENAME)
278 manifestFilename =
"%s/%s" % (tempDir.name, MANIFEST_BASENAME)
279 bundleListUrl =
"%s/%s/root/%s" % (options.base_url,
getBundleListTag(manifestFilename), BUNDLELIST_BASENAME)
280 command =
"cd %s; wget -q %s" % (tempDir.name, bundleListUrl)
283 manifestUrl =
"%s/%s/root/%s" % (options.base_url, options.tag, MANIFEST_BASENAME)
284 parts = urllib.parse.urlparse(manifestUrl)
287 status = mf.httpdl(host, request, localpath=tempDir.name, outputfilename=MANIFEST_BASENAME, force_download=
True)
289 print(
"Error downloading", manifestUrl,
": return code =", status)
291 manifestFilename =
"%s/%s" % (tempDir.name, MANIFEST_BASENAME)
292 bundleListUrl =
"%s/%s/root/%s" % (options.base_url,
getBundleListTag(manifestFilename), BUNDLELIST_BASENAME)
293 parts = urllib.parse.urlparse(bundleListUrl)
296 status = mf.httpdl(host, request, localpath=tempDir.name, outputfilename=BUNDLELIST_BASENAME, force_download=
True)
298 print(
"Error downloading", bundleListUrl,
": return code =", status)
300 with open(tempBundleFilePath,
'rb')
as bundleListFile:
301 bundleList = json.load(bundleListFile)
305 dest =
"%s/%s" % (destDir, fileName)
306 dest_dir = os.path.dirname(dest)
307 if not os.path.isdir(dest_dir):
308 os.makedirs(dest_dir)
310 if options.local_dir:
311 src =
"%s/%s/%s/%s" % (options.local_dir, options.tag, bundleInfo[
"name"], fileName)
313 print(
"Copying %s from %s" % (fileName, src))
314 shutil.copy(src, dest)
317 url =
"%s/%s/%s/%s" % (baseUrl, tag, bundleInfo[
"name"], fileName)
319 print(
"Downloading %s from %s" % (fileName, url))
321 if os.path.isfile(dest):
323 command =
"cd %s; wget -q %s" % (dest_dir, url)
326 parts = urllib.parse.urlparse(url)
329 status = mf.httpdl(host, request, localpath=dest_dir,
330 outputfilename=os.path.basename(dest),
331 verbose=options.verbose,
334 print(
"Error downloading", dest,
": return code =", status)
338 def bundleStatus(options, bundleInfo, fileLst_chg, fileLst_relPath_chg, fileLst_del):
340 statusTag =
"tempStatusTag"
344 tempDir = tempfile.TemporaryDirectory(prefix=
"install_ocssw-")
345 currentManifestFilename =
"%s/%s" % (tempDir.name, MANIFEST_BASENAME)
346 if downloadFile(options, options.tag, bundleInfo, MANIFEST_BASENAME, tempDir.name):
347 with open(currentManifestFilename,
'rb')
as manifestFile:
348 currentManifest = json.load(manifestFile)
350 command =
"cd %s; " % (options.install_dir)
351 command += manifestCommand +
" generate"
352 command +=
" -n " + bundleInfo[
"name"]
353 command +=
" -t " + statusTag
354 command +=
" -b " + currentManifestFilename
355 command +=
" " + bundleInfo[
"dir"]
356 if "extra" in bundleInfo:
357 command +=
" " + bundleInfo[
"extra"]
366 statusManifest = json.loads(
runCommand(command, pipe=
True, shellVal=
True))
368 if "tags" in currentManifest:
369 tagList = currentManifest[
"tags"]
372 versionStr += tagList[0] +
".."
373 versionStr += tagList[-1] +
")"
374 print(bundleInfo[
"name"], versionStr)
376 print(bundleInfo[
"name"])
382 for f, info
in statusManifest[
"files"].items():
383 if (
"files" not in currentManifest)
or (f
not in currentManifest[
"files"]):
385 if options.create_change:
386 fileLst_chg.append(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], f))
387 fileLst_relPath_chg.append(
"%s/%s" % (bundleInfo[
"dir"], f))
392 print(
" %s/%s" % (bundleInfo[
"dir"], f))
396 for f, info
in statusManifest[
"files"].items():
397 if (
"files" in currentManifest)
and (f
in currentManifest[
"files"]):
398 if info[
"tag"] != currentManifest[
"files"][f][
"tag"]:
400 if options.create_change:
401 fileLst_chg.append(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], f))
402 fileLst_relPath_chg.append(
"%s/%s" % (bundleInfo[
"dir"], f))
405 print(
" Modified Files:")
407 print(
" %s/%s" % (bundleInfo[
"dir"], f))
410 if re.search(
'root', bundleInfo[
"name"]):
411 localFilename =
"%s/%s" % (options.install_dir, f)
413 localFilename =
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], f)
414 with open(localFilename)
as file_1:
415 file_1_text = file_1.readlines()
416 remoteFilename =
"%s/%s" % (tempDir.name, f)
417 file_tag = currentManifest[
"files"][f][
"tag"]
418 if downloadFile(options, file_tag, bundleInfo, f, tempDir.name):
419 if options.difftool
is not None:
420 command =
"%s %s %s" % (options.difftool, remoteFilename, localFilename)
421 subprocess.run(command, shell=
True)
423 print(
"diff %s remote..local" % (f))
424 command =
"diff %s %s" % (remoteFilename, localFilename)
425 subprocess.run(command, shell=
True)
432 if "files" in currentManifest:
433 for f, info
in currentManifest[
"files"].items():
434 if f
not in statusManifest[
"files"]:
436 if options.create_change:
438 fileLst_del.append(
"%s/%s" % (bundleInfo[
"dir"], f))
441 print(
" Deleted Files:")
443 print(
" %s/%s" % (bundleInfo[
"dir"], f))
460 fileList_relPath_change = []
465 for bundleInfo
in bundleList:
466 if hasattr(options, bundleInfo[
"name"])
and getattr(options, bundleInfo[
"name"]):
468 if not theInstalledTag:
470 print(
"installedTag =", theInstalledTag)
473 options.tag = theInstalledTag
474 if os.path.exists(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], MANIFEST_BASENAME)):
476 if not bundleStatus(options, bundleInfo, fileList_change, fileList_relPath_change, fileList_delete):
480 startingDir = os.path.abspath(os.getcwd())
481 for bundleInfo
in bundleList:
482 bundleDir = os.path.abspath(os.path.join(options.install_dir, bundleInfo[
"dir"]))
483 if startingDir
not in bundleDir:
485 if not re.search(
"root", bundleInfo[
"name"]):
486 if not theInstalledTag:
488 print(
"installedTag =", theInstalledTag)
491 options.tag = theInstalledTag
493 if os.path.exists(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], MANIFEST_BASENAME)):
495 if not bundleStatus(options, bundleInfo, fileList_change, fileList_relPath_change, fileList_delete):
501 print(
"installedTag =", theInstalledTag)
504 options.tag = theInstalledTag
506 for bundleInfo
in bundleList:
507 if os.path.exists(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], MANIFEST_BASENAME)):
509 if not bundleStatus(options, bundleInfo, fileList_change, fileList_relPath_change, fileList_delete):
512 if options.create_change:
514 date = datetime.date.today().strftime(
"%Y-%m-%d")
515 if len(fileList_change) != 0:
516 file_name = options.tag +
"_" + date +
"_" +
str(uid,
'UTF-8').strip()
517 tar_filename = file_name +
".tar"
518 tar = tarfile.open(file_name +
".tar",
"w")
519 print(
"Creating " + tar_filename)
520 for index, name
in enumerate(fileList_change):
521 tar.add(name, fileList_relPath_change[index])
524 if len(fileList_delete) != 0:
525 remove_filename = file_name +
".remove"
526 print(
"Creating " + remove_filename)
527 with open(file_name +
".remove",
"w")
as fp:
528 for name
in fileList_delete:
530 fp.write(
"%s\n" % name)
532 if options.deliver_change
or options.deliver_email_from
is not None:
533 glusteruser_dir =
"/glusteruser/analyst/share_delivery"
535 if(os.path.exists(glusteruser_dir)):
536 if len(fileList_change) != 0:
537 print(
"Copying .tar to /glusteruser/analyst/share_delivery")
538 shutil.copyfile(tar_filename, os.path.join(glusteruser_dir, tar_filename))
539 if len(fileList_delete) != 0:
540 print(
"Copying .remove files to /glusteruser/analyst/share_delivery")
541 shutil.copyfile(remove_filename, os.path.join(glusteruser_dir, remove_filename))
543 if len(fileList_change) != 0
or len(fileList_delete) != 0:
544 message = EmailMessage()
545 if len(fileList_delete) == 0:
546 print(
"Sending email to swdevels@oceancolor.gsfc.nasa.gov notifying the delivery of the .tar files")
547 message.set_content(tar_filename)
548 message[
'Subject'] =
'.tar file copied to /glusteruser/analyst/share_delivery'
549 elif len(fileList_change) == 0:
550 print(
"Sending email to swdevels@oceancolor.gsfc.nasa.gov notifying the delivery of the .remove files")
551 message.set_content(remove_filename)
552 message[
'Subject'] =
'.remove file copied to /glusteruser/analyst/share_delivery'
554 print(
"Sending email to swdevels@oceancolor.gsfc.nasa.gov notifying the delivery of the .tar and .remove files")
555 message.set_content(tar_filename +
"\n" + remove_filename)
556 message[
'Subject'] =
'.tar and.remove file copied to /glusteruser/analyst/share_delivery'
558 if options.deliver_email_from
is not None:
559 message[
'From'] = options.deliver_email_from
560 elif options.deliver_change:
561 install_ocssw_config_filename = os.path.join(os.path.expanduser(
'~'),
".install_ocssw")
562 with open(install_ocssw_config_filename,
"r")
as file_email:
563 message[
'From'] = file_email.readlines()[0].strip().split(
'deliver_email_from=')[1]
564 message[
'To'] =
'swdevels@oceancolor.gsfc.nasa.gov'
566 smtp_server = smtplib.SMTP(
'localhost')
567 smtp_server.send_message(message)
570 print(
"You do not have access to /glusteruser/analyst/share_dir")
577 global totalNumThings
580 print(
"installedTag =", theInstalledTag)
584 for bundleInfo
in bundleList:
585 if os.path.exists(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], MANIFEST_BASENAME)):
588 for bundleInfo
in bundleList:
589 if os.path.exists(
"%s/%s/%s" % (options.install_dir, bundleInfo[
"dir"], MANIFEST_BASENAME)):
595 global totalNumThings
599 parser = argparse.ArgumentParser(description=
"Install OCSSW bundles", add_help=
False)
600 parser.add_argument(
"-t",
"--tag", default=
None,
601 help=
"tag that you want to install")
602 parser.add_argument(
"-b",
"--base_url", default=baseUrl,
603 help=
"remote url for the bundle server")
604 parser.add_argument(
"-l",
"--local_dir", default=
None,
605 help=
"local directory to use for bundle source instead of the bundle server")
606 parser.add_argument(
"--wget", default=
False, action=
"store_true",
607 help=
"use wget for file download")
608 parser.add_argument(
"--list_tags", default=
False, action=
"store_true",
609 help=
"list the tags that exist on the server")
610 parser.add_argument(
"--version", default=
False, action=
"store_true",
611 help=
"print this program's version")
613 options1 = parser.parse_known_args()
614 if not options1[0].list_tags
and not options1[0].version:
618 The content of the config file ~/.install_ocssw --
619 deliver_email_from=a valid email address that is on the list of swdevels@oceancolor.gsfc.nasa.gov
622 parser = argparse.ArgumentParser(description=
"Install OCSSW bundles", epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter,)
623 parser.add_argument(
"--version", default=
False, action=
"store_true",
624 help=
"print this program's version")
625 parser.add_argument(
"--list_tags", default=
False, action=
"store_true",
626 help=
"list the tags that exist on the server")
627 parser.add_argument(
"--installed_tag", default=
False, action=
"store_true",
628 help=
"list the currently installed tag")
629 parser.add_argument(
"--status", default=
False, action=
"store_true",
630 help=
"compare the main tag manifest to the files in the bundle directories")
631 parser.add_argument(
"--update", default=
False, action=
"store_true",
632 help=
"update all installed bundles to the tag given")
633 parser.add_argument(
"--diff", default=
False, action=
"store_true",
634 help=
"show the difference between the old and new text files")
635 parser.add_argument(
"--difftool", default=
None,
636 help=
"show the difference between the old and new text files using diff tool such as meld")
637 parser.add_argument(
"--create_change", default=
False, action=
"store_true",
638 help=
"create a tar file of new and modified files and a text file with a list of files to be deleted")
639 parser.add_argument(
"--deliver_change", default=
False, action=
"store_true",
640 help=
"create and copy to /glusteruser/analyst/share_delivery/ a tar file of new and modified files and a text file with a list of files to be deleted, and email to swdevels@oceancolor.gsfc.nasa.gov from the email address stored in .install_ocssw")
641 parser.add_argument(
"--deliver_email_from", default=
None,
642 help=
"create and copy to /glusteruser/analyst/share_delivery/ a tar file of new and modified files and a text file with a list of files to be deleted, and email to swdevels@oceancolor.gsfc.nasa.gov from the email address you provide")
643 parser.add_argument(
"-t",
"--tag", default=
None,
644 help=
"tag that you want to install")
645 parser.add_argument(
"-i",
"--install_dir", default=os.environ.get(
"OCSSWROOT",
None),
646 help=
"root directory for bundle installation (default=$OCSSWROOT)")
647 parser.add_argument(
"-b",
"--base_url", default=baseUrl,
648 help=
"remote url for the bundle server")
649 parser.add_argument(
"-l",
"--local_dir", default=
None,
650 help=
"local directory to use for bundle source instead of the bundle server")
651 parser.add_argument(
"-s",
"--save_dir", default=
None,
652 help=
"local directory to save a copy of the downloaded bundles")
653 parser.add_argument(
"-c",
"--clean", default=
False, action=
"store_true",
654 help=
"delete extra files in the destination directory")
655 parser.add_argument(
"--wget", default=
False, action=
"store_true",
656 help=
"use wget for file download")
657 parser.add_argument(
"-a",
"--arch", default=
None,
658 help=
"use this architecture instead of guessing the local machine (linux_64 macosx_intel odps)")
659 parser.add_argument(
"-v",
"--verbose", action=
"count", default=0, help=
"increase output verbosity")
662 parser.add_argument(
"--bin", default=
False, action=
"store_true",
663 help=
"install binary executables")
664 parser.add_argument(
"--opt", default=
False, action=
"store_true",
665 help=
"install 3rd party programs and libs")
666 parser.add_argument(
"--src", default=
False, action=
"store_true",
667 help=
"install source files")
668 parser.add_argument(
"--luts", default=
False, action=
"store_true",
669 help=
"install LUT files")
670 parser.add_argument(
"--viirs_l1_bin", default=
False, action=
"store_true",
671 help=
"install VIIRS binary executables subset")
674 for bundleInfo
in bundleList:
675 if bundleInfo[
"commandLine"]:
676 parser.add_argument(
"--" + bundleInfo[
"name"], default=
False, action=
"store_true",
677 help=
"install " + bundleInfo[
"help"] +
" files")
680 parser.add_argument(
"--direct_broadcast", default=
False, action=
"store_true",
681 help=
"toggle on bundles needed for MODIS direct broadcast")
682 parser.add_argument(
"--seadas", default=
False, action=
"store_true",
683 help=
"toggle on the base set of bundles for SeaDAS")
684 parser.add_argument(
"--odps", default=
False, action=
"store_true",
685 help=
"toggle on the base set of bundles for ODPS systems")
686 parser.add_argument(
"--viirs_l1", default=
False, action=
"store_true",
687 help=
"install everything to run and test the VIIRS executables")
688 parser.add_argument(
"--all", default=
False, action=
"store_true",
689 help=
"toggle on all satellite bundles")
691 options = parser.parse_args()
695 print(os.path.basename(sys.argv[0]), versionString)
698 if options.list_tags:
702 if options.installed_tag:
709 options.arch =
"odps"
714 bundleName =
"bin_" + options.arch
716 bundleInfo[
"dir"] =
"bin"
719 bundleName =
"lib_" + options.arch
721 bundleInfo[
"dir"] =
"lib"
724 bundleName =
"opt_" + options.arch
726 bundleInfo[
"dir"] =
"opt"
730 options.create_change =
False
736 if options.difftool
is not None:
745 if options.deliver_change
or options.deliver_email_from
is not None:
746 options.create_change =
True
748 if options.create_change:
755 print(
"--tag is required")
758 if not options.install_dir:
759 print(
"--install_dir is required if OCSSWROOT enviroment variable is not set")
767 if options.benchmark:
768 options.seadas =
True
769 options.modisa =
True
773 options.viirs_l1_bin =
True
774 options.viirs_l1_benchmark =
True
777 options.common =
True
779 options.viirsn =
True
780 options.viirsj1 =
True
781 options.viirsdem =
True
783 if options.direct_broadcast:
784 options.seadas =
True
785 options.modisa =
True
786 options.modist =
True
793 options.common =
True
800 options.common =
True
805 for bundleInfo
in bundleList:
806 if bundleInfo[
"commandLine"]:
807 if "share/" in bundleInfo[
"dir"]:
808 setattr(options, bundleInfo[
"name"],
True)
812 options.opt_src =
False
813 if hasattr(options,
"benchmark"):
814 options.benchmark =
False
815 if hasattr(options,
"afrt"):
817 if hasattr(options,
"aquaverse"):
818 options.aquaverse =
False
819 options.avhrr =
False
820 options.aviris =
False
822 options.l7etmp =
False
823 if hasattr(options,
"misr"):
827 if hasattr(options,
"msis2a"):
828 options.msis2a =
False
829 options.msis2b =
False
835 if hasattr(options,
"olil8"):
836 options.olil8 =
False
837 options.olil9 =
False
839 options.prism =
False
840 options.sabiamar =
False
842 if hasattr(options,
"spexone_remotap"):
843 options.spexone_remotap =
False
845 options.benchmark =
False
846 if hasattr(options,
"viirs_l1_benchmark"):
847 options.viirs_l1_benchmark =
False
850 if options.modisa
or options.modist:
852 if hasattr(options,
"msis2a"):
853 if options.msis2a
or options.msis2b:
855 if options.viirsn
or options.viirsj1:
857 if hasattr(options,
"viirsj2"):
860 if hasattr(options,
"olcis3a"):
861 if options.olcis3a
or options.olcis3b:
863 if hasattr(options,
"olil8"):
864 if options.olil8
or options.olil9:
869 if options.bin
and options.viirs_l1_bin:
870 print(
"Error: Can not install --bin and --viirs_l1_bin")
875 for bundleInfo
in bundleList:
876 if hasattr(options, bundleInfo[
"name"])
and getattr(options, bundleInfo[
"name"]):
884 if options.viirs_l1_bin:
896 if totalNumThings > 0:
903 bundleName =
"bin_" + options.arch
907 if options.viirs_l1_bin:
908 bundleName =
"viirs_l1_bin_" + options.arch
911 print(
"Error: tag does not contain the viirs_l1_bin bundles")
915 if options.bin
or options.viirs_l1_bin:
916 bundleName =
"lib_" + options.arch
921 bundleName =
"opt_" + options.arch
932 for bundleInfo
in bundleList:
933 if hasattr(options, bundleInfo[
"name"])
and getattr(options, bundleInfo[
"name"]):
938 commonUpdated =
False
939 for bundleInfo
in bundleList:
940 if hasattr(options, bundleInfo[
"name"])
and getattr(options, bundleInfo[
"name"]):
941 if bundleInfo[
"name"]
in lutBundles:
945 if not commonUpdated:
950 if __name__ ==
"__main__":