def update_components(sequence_id, sequence_data): sequence_file, status_log_file, attachments = None, None, [] try: zip_data = io.BytesIO(sequence_data) sequence_zipped = zipfile.ZipFile(zip_data) sequence_file, status_log_file, attachments = parse_zipped_sequence_structure( sequence_zipped) except zipfile.BadZipfile: sequence_file = sequence_data try: imported_sequence = json.loads(sequence_file) comps = Component.do_import(imported_sequence, sequence_id) except ValueError: raise SequenceImportException("The .sequence file is corrupted")
def import_sequence_file(sequence_file, owner_id, data): imported_sequence = json.loads(sequence_file) imported_sequence['sequence']['userid'] = owner_id seq = Sequence.do_import(imported_sequence, data) comps = Component.do_import(imported_sequence, seq.SequenceID) return seq