3 code to take scan a directory of frame files and output it as a frame cache file between given
7 from __future__
import print_function
19 Usage: make_frame_cache [options]
21 -h, --help display this message
22 -d, --frame-dir directory of frame file
23 -s, --gps-start-time start time of frames to output
24 -e, --gps-end-time end time fo frames to output
25 -o, --output-file file to output frame cache to
27 print(msg, file=sys.stderr)
32 longop = [
"help",
"frame-dir=",
"gps-start-time=",
"gps-end-time=",
"output-file="]
35 opts, args = getopt.getopt(sys.argv[1:], shortop, longop)
36 except getopt.GetoptError:
43 if o
in (
"-h",
"--help"):
46 elif o
in (
"-d",
"--frame-dir"):
48 elif o
in (
"-s",
"--gps-start-time"):
50 elif o
in (
"-e",
"--gps-end-time"):
52 elif o
in (
"-o",
"--output-file"):
55 print(
"Unknown option: {}".format(o), file=sys.stderr)
61 files = os.listdir(frame_dir)
62 print(files[0], file=sys.stderr)
63 except Exception
as e:
64 print(
"Problem listing directory {}".format(frame_dir), file=sys.stderr)
70 except Exception
as e:
71 print(
"Can't open file {}".format(output), file=sys.stderr)
81 if ".gwf" in files[i]:
84 frinfo = files[i].split(
"-")
89 index1 = files[i].rfind(
"-")
91 index2 = files[i].rfind(
".")
93 duration =
int(files[i][index1 + 1 : index2])
96 if time + duration > start
and time <= end:
121 print(
"No frames files between {} and {}.".format(start, end), file=sys.stderr)