f_name = "no file" if "--tablename" in commands.keys(): l_name = commands["--tablename"] else: l_name = "logger" if "--dir" in commands.keys(): d_name = commands["--dir"] else: d_name = "./" print action(c, commands["--action"], f_name, l_name, d_name) c.unlink() print exit_on_success() def action(c, command, f_name = "no file", l_name = "logger", d_name = "./"): """ preforms the action specifyed by command""" if command == "upload": ret = c.upload(f_name) if ret == 0: ret = c.progstart('CPU:' + f_name) elif ret == "File Error": ret = "File to upload was not found" else: ret = "upload error" elif command == "download":
for items in commands.get_missing_flags(): print_center(" ERROR: flag <" + items + "> is required ", "*") exit_on_failure() try: at_file = csvf.CsvFile(commands["--at_file"], True) p_in_file = csvf.CsvFile(commands["--precip_infile"], True) except IOError: print_center("ERROR: a required file was not found", '*') exit_on_failure() cutoff = commands.get_command_value("--cutoff", get_cutoff) interval = csvd.make_interval( commands.get_command_value("--startdate" , start_date), commands.get_command_value("--enddate" , end_date)) print interval p_in_file[1] = precip_check(p_in_file[0], p_in_file[1], at_file[0], at_file[1], interval, cutoff) if not p_in_file.append(commands["--precip_outfile"]): print_center("Old dates indcate no new data to be appended.") print_center("No data was written. ") exit_on_success() if __name__ == "__main__": main()