def handle(self, migrator_slug=None, initial=None, continuous=None, cleanup=None, stats=None, erase_continuous_progress=None, **options): try: migrator = get_migrator_by_slug(migrator_slug) except KeyError: raise CommandError(USAGE) if not any( (initial, continuous, cleanup, stats, erase_continuous_progress)): raise CommandError('initial, continuous, cleanup, stats, or ' 'erase_continuous_progress must be set') if cleanup and (initial or continuous): raise CommandError('cleanup must be run alone') if stats: self.handle_stats(migrator) if initial: if migrator.last_seq: raise CommandError( MAYBE_YOU_WANT_TO_RUN_CONTINUOUS.format(migrator_slug)) self.handle_initial(migrator) if erase_continuous_progress: if not migrator.original_seq: CommandError( MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_erase_continuous_progress(migrator) if continuous: if not migrator.last_seq: raise CommandError( MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_continuous(migrator) if cleanup: confirmation = raw_input( "Cleanup will remove doc_types ({}) from db {}\n" "I recommend running './manage.py delete_doc_conflicts' " "first or some docs might not actually be deleted.\n" "Are you sure you want to proceed? [y/n]".format( ', '.join(migrator.doc_types), migrator.source_db)) if confirmation == 'y': if migrator.docs_are_replicating(): self.stdout.write( "It looks like replication is still happening, please track " "down and cancel before attempting to cleanup, lest you " "replicate the deletions. Yikes!") return self.handle_cleanup(migrator)
def handle(self, migrator_slug, initial=None, continuous=None, cleanup=None, stats=None, erase_continuous_progress=None, **options): try: migrator = get_migrator_by_slug(migrator_slug) except KeyError: raise CommandError(USAGE) if not any((initial, continuous, cleanup, stats, erase_continuous_progress)): raise CommandError('initial, continuous, cleanup, stats, or ' 'erase_continuous_progress must be set') if cleanup and (initial or continuous): raise CommandError('cleanup must be run alone') if stats: self.handle_stats(migrator) if initial: if migrator.last_seq: raise CommandError(MAYBE_YOU_WANT_TO_RUN_CONTINUOUS.format(migrator_slug)) self.handle_initial(migrator) if erase_continuous_progress: if not migrator.original_seq: CommandError(MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_erase_continuous_progress(migrator) if continuous: if not migrator.last_seq: raise CommandError(MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_continuous(migrator) if cleanup: confirmation = input( "Cleanup will remove doc_types ({}) from db {}\n" "I recommend running './manage.py delete_doc_conflicts' " "first or some docs might not actually be deleted.\n" "Are you sure you want to proceed? [y/n]" .format(', '.join(migrator.doc_types), migrator.source_db)) if confirmation == 'y': if migrator.docs_are_replicating(): self.stdout.write( "It looks like replication is still happening, please track " "down and cancel before attempting to cleanup, lest you " "replicate the deletions. Yikes!") return self.handle_cleanup(migrator)
def handle( self, migrator_slug=None, initial=None, continuous=None, cleanup=None, stats=None, erase_continuous_progress=None, **options ): try: migrator = get_migrator_by_slug(migrator_slug) except KeyError: raise CommandError(USAGE) if not any((initial, continuous, cleanup, stats, erase_continuous_progress)): raise CommandError("initial, continuous, cleanup, stats, or " "erase_continuous_progress must be set") if cleanup and (initial or continuous): raise CommandError("cleanup must be run alone") if stats: self.handle_stats(migrator) if initial: if migrator.last_seq: raise CommandError(MAYBE_YOU_WANT_TO_RUN_CONTINUOUS.format(migrator_slug)) self.handle_initial(migrator) if erase_continuous_progress: if not migrator.original_seq: CommandError(MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_erase_continuous_progress(migrator) if continuous: if not migrator.last_seq: raise CommandError(MAYBE_YOU_WANT_TO_RUN_INITIAL.format(migrator_slug)) if migrator.cleanup_complete: raise CommandError(CANNOT_RUN_CONTINUOUS_AFTER_CLEANUP) self.handle_continuous(migrator) if cleanup: confirmation = raw_input( "Cleanup will remove doc_types ({}) from db {}\n" "Are you sure you want to proceed? [y/n]".format(", ".join(migrator.doc_types), migrator.source_db) ) if confirmation == "y": self.handle_cleanup(migrator)