NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 383

Show
Ignore:
Timestamp:
10/21/10 17:10:24
Author:
cbc
Message:

Improved error processing and production query configuration.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spongenet/trunk/spongenet/query.py

    r382 r383  
    6565    >>> _config_path = config_path() 
    6666    >>> sys.stdout = save_stdout 
    67     >>> USAGE == temp_stdout.getvalue()[:-1] 
     67    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     68    ...                  splitlines(True)[1:]) 
    6869    True 
    6970 
     
    7677    >>> _config_path = config_path() 
    7778    >>> sys.stdout = save_stdout 
    78     >>> USAGE == temp_stdout.getvalue()[:-1] 
     79    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     80    ...                  splitlines(True)[1:]) 
    7981    True 
    8082 
     
    9193    >>> _config_path = config_path() 
    9294    >>> sys.stdout = save_stdout 
    93     >>> USAGE == temp_stdout.getvalue()[:-1] 
     95    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     96    ...                  splitlines(True)[1:]) 
    9497    True 
    9598 
     
    106109    >>> _config_path = config_path() 
    107110    >>> sys.stdout = save_stdout 
    108     >>> USAGE == temp_stdout.getvalue()[:-1] 
     111    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     112    ...                  splitlines(True)[1:]) 
    109113    True 
    110114 
     
    135139        else: 
    136140            raise IOError("Incorrect number of arguments supplied.") 
    137     except IOError: 
     141    except IOError as e: 
     142        print e 
    138143        print USAGE 
    139144    return path 
     
    176181            config(_config_path) 
    177182    >>> sys.stdout = save_stdout 
    178     >>> USAGE == temp_stdout.getvalue()[:-1] 
     183    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     184    ...                  splitlines(True)[1:]) 
    179185    True 
    180186    >>> ncdir 
     
    200206            config(_config_path) 
    201207    >>> sys.stdout = save_stdout 
    202     >>> USAGE == temp_stdout.getvalue()[:-1] 
     208    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     209    ...                  splitlines(True)[1:]) 
    203210    True 
    204211    >>> ncdir 
     
    368375 
    369376    namespace = {} 
    370     namespace["NCDIR"] = None 
    371     namespace["CSVDIR"] = None 
    372     namespace["NCFILE_PATTERN"] = None 
    373     namespace["CSVFILE_PATTERN"] = None 
    374     namespace["LOCATION"] = None 
    375     namespace["PLATFORM"] = None 
    376     namespace["PACKAGES"] = None 
    377377    try: 
    378378        execfile(path, globals(), namespace) 
    379     except IOError: 
     379    except IOError as e: 
     380        print e 
    380381        print USAGE 
    381     except SyntaxError: 
     382    except SyntaxError as e: 
     383        print e 
    382384        print USAGE 
    383     return (namespace["NCDIR"]
    384             namespace["CSVDIR"]
    385             namespace["NCFILE_PATTERN"]
    386             namespace["CSVFILE_PATTERN"]
    387             namespace["LOCATION"]
    388             namespace["PLATFORM"]
    389             namespace["PACKAGES"]
     385    return (namespace.get("NCDIR")
     386            namespace.get("CSVDIR")
     387            namespace.get("NCFILE_PATTERN")
     388            namespace.get("CSVFILE_PATTERN")
     389            namespace.get("LOCATION")
     390            namespace.get("PLATFORM")
     391            namespace.get("PACKAGES")
    390392           ) 
    391393 
     
    525527    >>> _main() 
    526528    >>> sys.stdout = save_stdout 
    527     >>> USAGE == temp_stdout.getvalue()[:-1] 
     529    >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. 
     530    ...                  splitlines(True)[1:]) 
    528531    True 
    529532    """ 
     
    532535    if _config_path: 
    533536        _config = config(_config_path) 
    534         if all(_config): 
    535             query(*_config) 
    536         else: 
    537             print USAGE 
     537        if any(_config): 
     538            if all(_config): 
     539                query(*_config) 
     540            else: 
     541                print "Config file", _config_path, "does not contain all necessary parameters." 
     542                print USAGE 
    538543 
    539544    return