mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	This is a preparatory commit for using isort for sorting all of our imports, merging changes to files where we can easily review the changes as something we're happy with. These are also files with relatively little active development, which means we don't expect much merge conflict risk from these changes.
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # -*- coding: utf-8 -*-
 | |
| import argparse
 | |
| import os
 | |
| from typing import Any
 | |
| 
 | |
| from django.core.management.base import BaseCommand
 | |
| from django.db import DEFAULT_DB_ALIAS
 | |
| 
 | |
| from scripts.lib.zulip_tools import get_dev_uuid_var_path
 | |
| from zerver.lib.test_fixtures import get_migration_status
 | |
| 
 | |
| 
 | |
| class Command(BaseCommand):
 | |
|     help = "Get status of migrations."
 | |
| 
 | |
|     def add_arguments(self, parser: argparse.ArgumentParser) -> None:
 | |
|         parser.add_argument('app_label', nargs='?',
 | |
|                             help='App label of an application to synchronize the state.')
 | |
| 
 | |
|         parser.add_argument('--database', action='store', dest='database',
 | |
|                             default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. '
 | |
|                             'Defaults to the "default" database.')
 | |
| 
 | |
|         parser.add_argument('--output', action='store',
 | |
|                             help='Path to store the status to (default to stdout).')
 | |
| 
 | |
|     def handle(self, *args: Any, **options: Any) -> None:
 | |
|         result = get_migration_status(**options)
 | |
|         if options['output'] is not None:
 | |
|             uuid_var_path = get_dev_uuid_var_path()
 | |
|             path = os.path.join(uuid_var_path, options['output'])
 | |
|             with open(path, 'w') as f:
 | |
|                 f.write(result)
 | |
|         else:
 | |
|             self.stdout.write(result)
 |