+ try:
+ lesson = self.import_book(file_path, options, attachments,
+ ignore_incomplete=file_name in ignore_incomplete)
+ except Section.IncompleteError, e:
+ if file_name not in postponed or postponed[file_name] < files_imported:
+ # Push it back into the queue, maybe the missing lessons will show up.
+ if verbose > 0:
+ print self.style.NOTICE('Waiting for missing lessons.')
+ files.append(file_name)
+ postponed[file_name] = files_imported
+ elif options['ignore_incomplete'] and file_name not in ignore_incomplete:
+ files.append(file_name)
+ ignore_incomplete.add(file_name)
+ postponed[file_name] = files_imported
+ else:
+ # We're in a loop, nothing's being imported - some lesson is really missing.
+ raise e
+ except BaseException, e:
+ import traceback
+ traceback.print_exc()
+ files_skipped += 1
+ else:
+ files_imported += 1
+ if use_transaction:
+ transaction.commit()
+ if hasattr(lesson, 'level'):
+ levels.add(lesson.level)
+ finally:
+ if verbose > 0:
+ print
+
+
+ if levels:
+ print "Rebuilding level packages:"
+ for level in levels:
+ print level.name
+ level.build_packages()