Skip to content

Commit 0792fb3

Browse files
committed
Added scripts used to run the BBP on Quakeworx
1 parent 2e00754 commit 0792fb3

File tree

9 files changed

+1659
-0
lines changed

9 files changed

+1659
-0
lines changed

bbp/utils/batch/bbp_quakeworx_scenario.py

Lines changed: 629 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env python3
2+
"""
3+
BSD 3-Clause License
4+
5+
Copyright (c) 2025, University of Southern California
6+
All rights reserved.
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
1. Redistributions of source code must retain the above copyright notice, this
12+
list of conditions and the following disclaimer.
13+
14+
2. Redistributions in binary form must reproduce the above copyright notice,
15+
this list of conditions and the following disclaimer in the documentation
16+
and/or other materials provided with the distribution.
17+
18+
3. Neither the name of the copyright holder nor the names of its
19+
contributors may be used to endorse or promote products derived from
20+
this software without specific prior written permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
33+
Program to validate the BBP SRC file provided by the Quakeworx gateway
34+
"""
35+
from __future__ import division, print_function
36+
37+
# Works for both Python 2 and 3
38+
try: input = raw_input
39+
except NameError: pass
40+
41+
# Import Python modules
42+
import os
43+
import sys
44+
import optparse
45+
46+
# Import Broadband modules
47+
import bband_utils
48+
49+
SRC_MAX_FILE_SIZE_KB = 2
50+
51+
def main():
52+
"""
53+
Parse command line options and create the needed files/directories
54+
"""
55+
prog_base = os.path.basename(sys.argv[0])
56+
usage = "usage: %s [options]" % (prog_base)
57+
parser = optparse.OptionParser(usage)
58+
parser.add_option("-i", "--input-file", type="string", action="store",
59+
dest="input_file",
60+
help="Input file")
61+
parser.add_option("-o", "--output-file", type="string", action="store",
62+
dest="output_file",
63+
help="Output file")
64+
(options, _) = parser.parse_args()
65+
66+
input_file = options.input_file
67+
output_file = options.output_file
68+
69+
# Check file size
70+
try:
71+
file_size = os.path.getsize(input_file)
72+
# Convert from bytes to kb
73+
file_size = file_size / 1024
74+
if file_size > SRC_MAX_FILE_SIZE_KB:
75+
raise bband_utils.ParameterError("Input SRC file larger than %d Kb!" % (SRC_MAX_FILE_SIZE_KB))
76+
except OSError as e:
77+
raise bband_utils.ProcessingError("Cannot get size for file %s!" % (input_file))
78+
79+
# Parse input file
80+
src_props = bband_utils.parse_properties(input_file)
81+
82+
# Create output
83+
output = ""
84+
for key in src_props:
85+
output = output + "%s = %s\n" % (key.upper(), src_props[key])
86+
outfile = open(output_file, 'w')
87+
outfile.write(output)
88+
outfile.close()
89+
90+
if __name__ == "__main__":
91+
main()
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python3
2+
"""
3+
BSD 3-Clause License
4+
5+
Copyright (c) 2025, University of Southern California
6+
All rights reserved.
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
1. Redistributions of source code must retain the above copyright notice, this
12+
list of conditions and the following disclaimer.
13+
14+
2. Redistributions in binary form must reproduce the above copyright notice,
15+
this list of conditions and the following disclaimer in the documentation
16+
and/or other materials provided with the distribution.
17+
18+
3. Neither the name of the copyright holder nor the names of its
19+
contributors may be used to endorse or promote products derived from
20+
this software without specific prior written permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
33+
Program to validate the BBP station file provided by the Quakeworx gateway
34+
"""
35+
from __future__ import division, print_function
36+
37+
# Works for both Python 2 and 3
38+
try: input = raw_input
39+
except NameError: pass
40+
41+
# Import Python modules
42+
import os
43+
import sys
44+
import optparse
45+
46+
# Import Broadband modules
47+
import bband_utils
48+
from station_list import StationList
49+
50+
STL_MAX_FILE_SIZE_KB = 10
51+
52+
def main():
53+
"""
54+
Parse command line options and create the needed files/directories
55+
"""
56+
prog_base = os.path.basename(sys.argv[0])
57+
usage = "usage: %s [options]" % (prog_base)
58+
parser = optparse.OptionParser(usage)
59+
parser.add_option("-i", "--input-file", type="string", action="store",
60+
dest="input_file",
61+
help="Input file")
62+
parser.add_option("-o", "--output-file", type="string", action="store",
63+
dest="output_file",
64+
help="Output file")
65+
(options, _) = parser.parse_args()
66+
67+
input_file = options.input_file
68+
output_file = options.output_file
69+
70+
# Check file size
71+
try:
72+
file_size = os.path.getsize(input_file)
73+
# Convert from bytes to kb
74+
file_size = file_size / 1024
75+
if file_size > STL_MAX_FILE_SIZE_KB:
76+
raise bband_utils.ParameterError("Input station file larger than %d Kb!" % (STL_MAX_FILE_SIZE_KB))
77+
except OSError as e:
78+
raise bband_utils.ProcessingError("Cannot get size for file %s!" % (input_file))
79+
80+
# Parse input file
81+
station_list_object = StationList(input_file)
82+
site_list = station_list_object.get_station_list()
83+
station_list_object.build(site_list, output_file)
84+
85+
if __name__ == "__main__":
86+
main()

0 commit comments

Comments
 (0)