Index: spongenet/trunk/largo_mini_andi_query_config.py =================================================================== --- (revision ) +++ spongenet/trunk/largo_mini_andi_query_config.py (revision 383) @@ -1,0 +1,142 @@ +#!/usr/bin/env python + +"""Valid test configuration for the query module.""" + +import os + +NCDIR = "/seacoos/data/nccoos/level1/largo/mini_andi/nc" +CSVDIR = "/seacoos/data/nccoos/level1/largo/mini_andi/csv" +NCFILE_PATTERN = "%(location)s_%(platform)s_%(package)s_" \ + "[0-9][0-9][0-9][0-9]_[0-9][0-9].nc" +CSVFILE_PATTERN = "%(location)s_%(platform)s_%(month)s.csv" +LOCATION = "largo" +PLATFORM = "mini_andi" +PACKAGES = (('system', ['voltage', + 'memory', + 'interval', ]), + ('turbidity', ['turbidity', ]), + ('optode_127', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_167', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_169', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_170', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_171', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_172', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_173', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_175', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_176', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_178', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('optode_179', ['o2concentration', + 'airsaturation', + 'temperature', + 'calphase', + 'tcphase', + 'c1rph', + 'c2rph', + 'c1amp', + 'c2amp', + 'rawtemp', ]), + ('conductivity', ['conductivity', + 'temperature', ]), + ('pressure', ['pressure', + 'temperature', ]), + ('current', ['abs_speed', + 'direction', + 'v', + 'u', + 'heading', + 'tiltx', + 'tilty', + 'std_speed', + 'strength', + 'pings', ]), + ) Index: spongenet/trunk/spongenet/query.py =================================================================== --- spongenet/trunk/spongenet/query.py (revision 382) +++ spongenet/trunk/spongenet/query.py (revision 383) @@ -65,5 +65,6 @@ >>> _config_path = config_path() >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True @@ -76,5 +77,6 @@ >>> _config_path = config_path() >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True @@ -91,5 +93,6 @@ >>> _config_path = config_path() >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True @@ -106,5 +109,6 @@ >>> _config_path = config_path() >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True @@ -135,5 +139,6 @@ else: raise IOError("Incorrect number of arguments supplied.") - except IOError: + except IOError as e: + print e print USAGE return path @@ -176,5 +181,6 @@ config(_config_path) >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True >>> ncdir @@ -200,5 +206,6 @@ config(_config_path) >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True >>> ncdir @@ -368,24 +375,19 @@ namespace = {} - namespace["NCDIR"] = None - namespace["CSVDIR"] = None - namespace["NCFILE_PATTERN"] = None - namespace["CSVFILE_PATTERN"] = None - namespace["LOCATION"] = None - namespace["PLATFORM"] = None - namespace["PACKAGES"] = None try: execfile(path, globals(), namespace) - except IOError: + except IOError as e: + print e print USAGE - except SyntaxError: + except SyntaxError as e: + print e print USAGE - return (namespace["NCDIR"], - namespace["CSVDIR"], - namespace["NCFILE_PATTERN"], - namespace["CSVFILE_PATTERN"], - namespace["LOCATION"], - namespace["PLATFORM"], - namespace["PACKAGES"], + return (namespace.get("NCDIR"), + namespace.get("CSVDIR"), + namespace.get("NCFILE_PATTERN"), + namespace.get("CSVFILE_PATTERN"), + namespace.get("LOCATION"), + namespace.get("PLATFORM"), + namespace.get("PACKAGES"), ) @@ -525,5 +527,6 @@ >>> _main() >>> sys.stdout = save_stdout - >>> USAGE == temp_stdout.getvalue()[:-1] + >>> USAGE == "".join(temp_stdout.getvalue()[:-1]. + ... splitlines(True)[1:]) True """ @@ -532,8 +535,10 @@ if _config_path: _config = config(_config_path) - if all(_config): - query(*_config) - else: - print USAGE + if any(_config): + if all(_config): + query(*_config) + else: + print "Config file", _config_path, "does not contain all necessary parameters." + print USAGE return