3 # Copyright (C) 2012 Kipp Cannon
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 """Manipulate the GraceDB false-alarm rate upload threshold of running
20 gstlal_ll_inspiral processes via their web interfaces."""
24 # =============================================================================
28 # =============================================================================
32 from optparse
import OptionParser
38 # This program queries running gstlal_inspiral jobs and displays or updates the gracedb FAR threshold; See gstlal_ll_inspiral_gracedb_threshold for more details
41 # =============================================================================
45 # =============================================================================
49 def parse_command_line():
50 parser = OptionParser(
51 usage =
"%prog [options] registry1.txt ...",
54 parser.add_option(
"--gracedb-far-threshold", metavar =
"Hertz", type =
"float", help =
"Set the GraceDB false-alarm rate upload threshold to Hertz (default = retrieve and print the false-alarm rate threshold).")
55 parser.add_option(
"-v",
"--verbose", action =
"store_true", help =
"Be verbose (optional).")
57 options, filenames = parser.parse_args()
59 if len(filenames) < 1:
60 raise ValueError(
"must provide the name of at least one registry file")
62 return options, filenames
66 # =============================================================================
70 # =============================================================================
79 options, filenames = parse_command_line()
82 if options.gracedb_far_threshold is not None:
83 post_data = urllib.urlencode({
"rate": options.gracedb_far_threshold})
89 # Iterate over servers
95 urls =
set(
"%sgracedb_far_threshold.txt" % url.strip()
for filename in filenames
for url in open(filename))
97 for url in sorted(urls):
99 for line in urllib.urlopen(url, data = post_data):
100 OK &=
"error" not in line
101 print
"\t%s" % line.strip()