@@ -53,25 +53,10 @@ def debug_wrapper(func):
5353 :raises Exception: If an error occurs during the function call.
5454 :raises TypeError: If the function is not callable.
5555 :raises ValueError: If the function is not found.
56- :raises NameError: If the function is not defined.
5756 :raises AttributeError: If the function does not have the
5857 specified attribute.
59- :raises ImportError: If the function cannot be imported.
60- :raises RuntimeError: If the function cannot be run.
61- :raises KeyError: If the function does not have the
62- specified key.
6358 :raises IndexError: If the function does not have the
6459 specified index.
65- :raises IOError: If the function cannot be opened.
66- :raises OSError: If the function cannot be accessed.
67- :raises EOFError: If the function cannot be read.
68- :raises MemoryError: If the function cannot be allocated.
69- :raises OverflowError: If the function cannot be overflowed.
70- :raises ZeroDivisionError: If the function cannot be divided by zero.
71- :raises StopIteration: If the function cannot be stopped.
72- :raises KeyboardInterrupt: If the function cannot be interrupted.
73- :raises SystemExit: If the function cannot be exited.
74- :raises AssertionError: If the function cannot be asserted.
7560 """
7661
7762 @functools .wraps (func )
@@ -319,7 +304,7 @@ def main():
319304 global debug
320305
321306 if not args .list_files and not args .directory_name :
322- print ('Error : You must specify either -list or a directory.' )
307+ print (f' { Red } ERROR : You must specify either -list or a directory.{ Nclr } ' )
323308 sys .exit (1 )
324309
325310 base_dir = 'https://data.nas.nasa.gov'
@@ -362,30 +347,39 @@ def main():
362347 # )
363348 fv3_urls = [f'{ fv3_data_url } ' ]
364349
365- print (f'\n Searching for available directories...' )
366- print (f'--------------------------------------' )
367- for url in legacy_urls :
368- legacy_dir_option = url .split ('legacygcmdata/' )[1 ]
369- print (f'{ "(Legacy MGCM)" :<17} { legacy_dir_option :<20} '
370- f'{ Cyan } { url } { Nclr } ' )
371-
372- # NOTE: See above comment for the FV3-based MGCM data note
373- # for url in fv3_urls:
374- # fv3_dir_option = url.split('fv3betaout1data/')[1]
375- # print(f'{"(FV3-based MGCM)":<17} {fv3_dir_option:<17} '
376- # f'{Cyan}{url}{Nclr}')
377- print (f'{ "(FV3-based MGCM)" :<17} { "FV3BETAOUT1" :<20} '
378- f'{ Cyan } { fv3_home_url } { Nclr } ' )
379- print (f'---------------------\n ' )
380-
350+ print (f'\n Searching for available directories...\n ' )
351+ if legacy_urls != []:
352+ for url in legacy_urls :
353+ legacy_dir_option = url .split ('legacygcmdata/' )[1 ]
354+ print (f'{ "(Legacy MGCM)" :<17} { legacy_dir_option :<20} '
355+ f'{ Cyan } { url } { Nclr } ' )
356+
357+ # NOTE: See above comment for the FV3-based MGCM data note
358+ # for url in fv3_urls:
359+ # fv3_dir_option = url.split('fv3betaout1data/')[1]
360+ # print(f'{"(FV3-based MGCM)":<17} {fv3_dir_option:<17} '
361+ # f'{Cyan}{url}{Nclr}')
362+ print (f'{ "(FV3-based MGCM)" :<17} { "FV3BETAOUT1" :<20} '
363+ f'{ Cyan } { fv3_home_url } { Nclr } ' )
364+
365+ print (f'{ Yellow } \n You can list the files in a directory by using '
366+ f'the -list option with a directory name, e.g.\n '
367+ f'> MarsPull -list ACTIVECLDS{ Nclr } \n ' )
368+
369+ else :
370+ print (f'{ Red } No directories were found. This may be because the '
371+ f'file system is unavailable or unresponsive.\n Check the '
372+ f'URL below to confirm. Otherwise, run with --debug for '
373+ f'more info.\n \n { Nclr } Check URL: '
374+ f'{ Cyan } https://data.nas.nasa.gov/mcmcref{ Nclr } \n ' )
375+
381376 if args .directory_name :
382377 # If a directory is provided, list the files in that directory
383378 portal_dir = args .directory_name
384379 if portal_dir == 'FV3BETAOUT1' :
385380 # FV3-based MGCM
386381 print (f'\n { Green } Selected: (FV3-based MGCM) FV3BETAOUT1{ Nclr } ' )
387- print (f'\n Searching for available files...' )
388- print (f'--------------------------------' )
382+ print (f'\n Searching for available files...\n ' )
389383 fv3_dir_url = f'{ fv3_home_url } '
390384 fv3_data = requests .get (fv3_dir_url )
391385 fv3_file_text = fv3_data .text
@@ -434,7 +428,10 @@ def main():
434428 if fv3_files_available :
435429 print_file_list (fv3_files_available )
436430 else :
437- print ('No .nc files found. Run with --debug for more info' )
431+ print (f'{ Red } No .nc files found. This may be because the '
432+ f'file system is unavailable or unresponsive.\n '
433+ f'Check the URL below to confirm. Otherwise, run '
434+ f'with --debug for more info.{ Nclr } ' )
438435 if debug :
439436 # Try a different approach for debugging
440437 table_rows = re .findall (
@@ -446,24 +443,23 @@ def main():
446443 if '.nc' in row :
447444 print (f'Debug - Found row with .nc: { row } ' )
448445
449- print (f'---------------' )
450446 # The download URL differs from the listing URL
451447 print (f'{ Cyan } ({ fv3_dir_url } ){ Nclr } \n ' )
452448
453- print (f'{ Yellow } You can download files using the -f '
454- f'option with the directory name, e.g.\n '
455- f'> MarsPull FV3BETAOUT1 -f 03340.fixed.nc\n '
456- f'> MarsPull FV3BETAOUT1 -f 03340.fixed.nc '
457- f'03340.atmos_average.nc{ Nclr } \n ' )
449+ if fv3_files_available :
450+ print (f'{ Yellow } \n You can download files using the -f '
451+ f'option with the directory name, e.g.\n '
452+ f'> MarsPull FV3BETAOUT1 -f 03340.fixed.nc\n '
453+ f'> MarsPull FV3BETAOUT1 -f 03340.fixed.nc '
454+ f'03340.atmos_average.nc{ Nclr } \n ' )
458455
459456 elif portal_dir in [
460457 'ACTIVECLDS' , 'INERTCLDS' , 'NEWBASE_ACTIVECLDS' ,
461458 'ACTIVECLDS_NCDF'
462459 ]:
463460 # Legacy MGCM
464461 print (f'\n { Green } Selected: (Legacy MGCM) { portal_dir } { Nclr } ' )
465- print (f'\n Available files:' )
466- print (f'---------------' )
462+ print (f'\n Searching for available files...\n ' )
467463 legacy_dir_url = (f'{ legacy_data_url } ' + portal_dir + r'/' )
468464 legacy_data = requests .get (legacy_dir_url )
469465 legacy_file_text = legacy_data .text
@@ -495,28 +491,30 @@ def main():
495491 )
496492 legacy_files_available = href_files
497493
498- print_file_list (legacy_files_available )
499- print (f'---------------' )
494+ # Print the files
495+ if legacy_files_available :
496+ print_file_list (legacy_files_available )
497+ else :
498+ print (f'{ Red } No fort.11 files found. This may be because '
499+ f'the file system is unavailable or unresponsive.\n '
500+ f'Check the URL below to confirm. Otherwise, run '
501+ f'with --debug for more info.{ Nclr } ' )
502+
500503 print (f'{ Cyan } ({ legacy_dir_url } ){ Nclr } \n ' )
501504
502- print (f'{ Yellow } You can download these files using the '
503- f'-f or -ls options with the directory name, e.g.\n '
504- f'> MarsPull ACTIVECLDS -f fort.11_0690\n '
505- f'> MarsPull ACTIVECLDS -f fort.11_0700 fort.11_0701 \n '
506- f'> MarsPull ACTIVECLDS -ls 90\n '
507- f'> MarsPull ACTIVECLDS -ls 90 180{ Nclr } \n ' )
505+ if legacy_files_available :
506+ print (f'{ Yellow } \n You can download these files using the '
507+ f'-f or -ls options with the directory name, e.g.\n '
508+ f'> MarsPull ACTIVECLDS -f fort.11_0690\n '
509+ f'> MarsPull ACTIVECLDS -f fort.11_0700 fort.11_0701 \n '
510+ f'> MarsPull ACTIVECLDS -ls 90\n '
511+ f'> MarsPull ACTIVECLDS -ls 90 180{ Nclr } \n ' )
508512
509513 else :
510- print (f'Error : Directory { portal_dir } does not exist.' )
514+ print (f'{ Red } ERROR : Directory { portal_dir } does not exist.{ Nclr } ' )
511515 sys .exit (1 )
512516 sys .exit (0 )
513517
514- else :
515- # If no directory is provided, exit with an error
516- print (f'{ Yellow } You can list the files in a directory by using '
517- f'the -list option with a directory name, e.g.\n '
518- f'> MarsPull -list ACTIVECLDS{ Nclr } \n ' )
519-
520518 if args .directory_name and not args .list_files :
521519 portal_dir = args .directory_name
522520 if portal_dir in [
@@ -527,7 +525,7 @@ def main():
527525 requested_url = (f'{ fv3_data_url } ' )
528526
529527 if not (args .ls or args .filename ):
530- print (f'{ Yellow } ERROR No file requested. Use [-ls --ls] or '
528+ print (f'{ Red } ERROR No file requested. Use [-ls --ls] or '
531529 f'[-f --filename] to specify a file to download.{ Nclr } ' )
532530 sys .exit (1 ) # Return a non-zero exit code
533531 portal_dir = args .directory_name
@@ -587,7 +585,7 @@ def main():
587585
588586 elif not args .list_files :
589587 # If no directory is provided and its not a -list request
590- print (f'{ Yellow } ERROR: A directory must be specified unless using '
588+ print (f'{ Red } ERROR: A directory must be specified unless using '
591589 f'-list.{ Nclr } ' )
592590 sys .exit (1 )
593591
0 commit comments