X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/cd8813f7be8e11b18b7e23d217dd6404e26d07d4..07096ee18c78a330205e0f0a656dee1378ceb8c2:/catalogue/management/commands/importlessons.py diff --git a/catalogue/management/commands/importlessons.py b/catalogue/management/commands/importlessons.py index 6252fb5..43823bb 100755 --- a/catalogue/management/commands/importlessons.py +++ b/catalogue/management/commands/importlessons.py @@ -12,7 +12,7 @@ from django.core.management.color import color_style from django.core.files import File from librarian import IOFile -from catalogue.models import Lesson +from catalogue.models import Lesson, Section #from search import Index @@ -73,9 +73,24 @@ class Command(BaseCommand): sys.stdout.flush() # Import book files - self.import_book(file_path, options) - files_imported += 1 - transaction.commit() + try: + self.import_book(file_path, options) + files_imported += 1 + transaction.commit() + except Section.IncompleteError: + 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 + else: + # We're in a loop, nothing's being imported - some lesson is really missing. + raise e + except BaseException, e: + import trackback + trackback.print_exc() + files_skipped += 1 # Print results print