mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	import: Fix positional argument parsing.
This commit is contained in:
		@@ -18,9 +18,7 @@ class Command(BaseCommand):
 | 
			
		||||
    help = """Import Zulip database dump files into a fresh Zulip instance.
 | 
			
		||||
 | 
			
		||||
This command should be used only on a newly created, empty Zulip instance to
 | 
			
		||||
import a database dump from one or more JSON files.
 | 
			
		||||
 | 
			
		||||
Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty] <export path name> [<export path name>...]"""
 | 
			
		||||
import a database dump from one or more JSON files."""
 | 
			
		||||
 | 
			
		||||
    def add_arguments(self, parser):
 | 
			
		||||
        # type: (CommandParser) -> None
 | 
			
		||||
@@ -35,6 +33,10 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
 | 
			
		||||
                            default=False,
 | 
			
		||||
                            action="store_true",
 | 
			
		||||
                            help='Import into an existing nonempty database.')
 | 
			
		||||
 | 
			
		||||
        parser.add_argument('export_files', nargs='+',
 | 
			
		||||
                            metavar='<export file>',
 | 
			
		||||
                            help="list of JSON exports to import")
 | 
			
		||||
        parser.formatter_class = argparse.RawTextHelpFormatter
 | 
			
		||||
 | 
			
		||||
    def new_instance_check(self, model):
 | 
			
		||||
@@ -57,10 +59,6 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
 | 
			
		||||
                            Client, Message, UserMessage, Huddle, DefaultStream, RealmDomain,
 | 
			
		||||
                            RealmFilter]
 | 
			
		||||
 | 
			
		||||
        if len(args) == 0:
 | 
			
		||||
            print("Please provide at least one realm dump to import.")
 | 
			
		||||
            exit(1)
 | 
			
		||||
 | 
			
		||||
        if options["destroy_rebuild_database"]:
 | 
			
		||||
            print("Rebuilding the database!")
 | 
			
		||||
            db_name = settings.DATABASES['default']['NAME']
 | 
			
		||||
@@ -69,7 +67,7 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
 | 
			
		||||
            for model in models_to_import:
 | 
			
		||||
                self.new_instance_check(model)
 | 
			
		||||
 | 
			
		||||
        for path in args:
 | 
			
		||||
        for path in options['export_files']:
 | 
			
		||||
            if not os.path.exists(path):
 | 
			
		||||
                print("Directory not found: '%s'" % (path,))
 | 
			
		||||
                exit(1)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user