Verify the checksum of the files described by the YAML. Return false of any of the file doesn't existed or checksum is different with the YAML.
(data_dir, yaml_path)
| 156 | |
| 157 | |
| 158 | def verifyChecksum(data_dir, yaml_path): |
| 159 | """Verify the checksum of the files described by the YAML. |
| 160 | |
| 161 | Return false of any of the file doesn't existed or checksum is different with the YAML. |
| 162 | """ |
| 163 | sample_data = _loadYAML(yaml_path) |
| 164 | logger.info("Verifying data files and their MD5 for %s", sample_data.sample) |
| 165 | |
| 166 | allGood = True |
| 167 | for f in sample_data.files: |
| 168 | fpath = os.path.join(data_dir, f.path) |
| 169 | if os.path.exists(fpath): |
| 170 | if _checkMD5(fpath, f.checksum): |
| 171 | logger.info("MD5 match for local copy %s", fpath) |
| 172 | else: |
| 173 | logger.error("Local file %s has a different checksum!", fpath) |
| 174 | allGood = False |
| 175 | else: |
| 176 | allGood = False |
| 177 | logger.error("Data file %s doesn't have a local copy", f.path) |
| 178 | |
| 179 | return allGood |
| 180 | |
| 181 | |
| 182 | def main(): |