#!/usr/bin/env python3 import sys, time, subprocess try: log_file = sys.argv[1] how_often = float(sys.argv[2]) time_to_do_it = float(sys.argv[3]) except: print("rtfc :P") sys.exit(-1) try: f = open(log_file, "w") except: print("fake file.") sys.exit(-1) print("[i] file: %s\n\ [i] how often: %f\n\ [i] how long: %f" % (log_file, how_often, time_to_do_it)) start = time.time() now = time.time print("[i] we out here, yo", flush=True) while (start + time_to_do_it) > now(): # print("we out here, yo", flush=True) lat, lon, alt, sig = [float(x) for x in subprocess.getoutput("src/dirty_hack.sh").split(",")] sig /= 100 print("[i] %f: %f, %f, %f, %f" % (time.time_ns() / (10**9), lat, lon, alt, sig)) f.write("%f: %f, %f, %f, %f\n" % (time.time_ns() / (10**9), lat, lon, alt, sig)) f.flush() time.sleep(how_often) f.close()