61 start = float(lines[0][
'Elapsed_Time'])
65 env = row[
'environment'].strip()
66 act = row[
'Activity'].strip()
76 spreadsheet_timestamp = Reliability2Parser.get_row_timestamp(row, start)
77 child_code = Reliability2Parser.get_child_code(row)
79 result_set = db.select(
'tests2',
81 'spreadsheet_timestamp=? AND child_code=?',
82 [spreadsheet_timestamp, child_code]
84 if int(result_set[0][0]) > 0:
87 self.
parse_dict[env][act][
'unused'].append(row)
89 if not act
in acts_dict:
92 self.
acts = acts_dict.keys()
93 self.
envs = self.parse_dict.keys()
115 dirs = glob.glob(root_dir +
'*' + os.path.sep)
119 if os.path.exists(root_dir + os.path.sep + wav_filename):
120 path = root_dir + os.path.sep + wav_filename
124 target_dir = root_dir + os.path.sep + wav_filename[:-4] + os.path.sep
125 if os.path.exists(target_dir):
127 dirs.remove(target_dir)
130 while not path
and i < len(dirs):
151 def pick_rows(self, check2, alt_wav_locate_fcn, include_used):
154 check2_envs = check2.environments
156 check2_acts = check2.activities
159 for env
in check2_envs:
160 for act
in check2_acts:
163 blocks = blocks + self.
parse_dict[env][act][
'used']
165 indices = range(len(blocks))
166 random.shuffle(indices)
167 indices = indices[:check2.blocks_per_activity]
170 short_wav_filename = Reliability2Parser.get_child_code(row) +
'.wav'
171 full_wav_filename = self.
locate_wavfile(short_wav_filename, check2.wav_foldername + os.path.sep)
172 if not full_wav_filename:
173 full_wav_filename = alt_wav_locate_fcn(short_wav_filename)
174 if not full_wav_filename:
175 raise Exception(
'Unable to locate wav file: "%s"' % (short_wav_filename))
180 Reliability2Parser.get_child_code(row),
181 Reliability2Parser.get_row_timestamp(row),
183 sel_test2s.append(test2)
195 month = BackendUtils.pad_num_str(row[
'month'])
196 day = BackendUtils.pad_num_str(row[
'day'])
198 return '%s %s %s %f' % (day, month, year, row_offset_sec)
206 month = BackendUtils.pad_num_str(row[
'month'])
207 day = BackendUtils.pad_num_str(row[
'day'])
208 child_code = row[
'child_id']
210 return '%s_%s%s%s' % (child_code, year, month, day)
225 table_str =
'{0:10} {1:25} {2}\n'.format(
'Env',
'Act',
'Count')
227 while i < len(check2.environments):
228 env = check2.environments[i]
229 enough = enough
and ( env
in self.
parse_dict )
232 while j < len(check2.activities):
233 act = check2.activities[j]
235 enough = enough
and ( act
in self.
parse_dict[env]
and (len(self.
parse_dict[env][act][
'unused']) + len(self.
parse_dict[env][act][
'used'])) >= check2.blocks_per_activity )
237 enough = enough
and ( act
in self.
parse_dict[env]
and len(self.
parse_dict[env][act][
'unused']) >= check2.blocks_per_activity )
239 table_str +=
'{0:10} {1:25} {2}\n'.format(
242 '%d total - %d used = %d unused' % (
252 return enough, table_str