mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	Annotate most Zulip management commands.
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| from __future__ import absolute_import | ||||
| from typing import Any, Dict | ||||
|  | ||||
| from django.http import HttpRequest, HttpResponse | ||||
| from optparse import make_option | ||||
| from django.core.management.base import BaseCommand | ||||
| from zerver.models import get_user_profile_by_email, UserMessage | ||||
| @@ -13,10 +14,12 @@ request_logger = LogRequests() | ||||
|  | ||||
| class MockSession(object): | ||||
|     def __init__(self): | ||||
|         # type: () -> None | ||||
|         self.modified = False | ||||
|  | ||||
| class MockRequest(object): | ||||
| class MockRequest(HttpRequest): | ||||
|     def __init__(self, email): | ||||
|         # type: (str) -> None | ||||
|         self.user = get_user_profile_by_email(email) | ||||
|         self.path = '/' | ||||
|         self.method = "POST" | ||||
| @@ -28,9 +31,11 @@ class MockRequest(object): | ||||
|         self.session = MockSession() | ||||
|  | ||||
|     def get_full_path(self): | ||||
|         # type: () -> str | ||||
|         return self.path | ||||
|  | ||||
| def profile_request(request): | ||||
|     # type: (HttpRequest) -> HttpResponse | ||||
|     request_logger.process_request(request) | ||||
|     prof = cProfile.Profile() | ||||
|     prof.enable() | ||||
| @@ -48,4 +53,5 @@ class Command(BaseCommand): | ||||
|         ) | ||||
|  | ||||
|     def handle(self, *args, **options): | ||||
|         # type: (*Any, **Any) -> None | ||||
|         profile_request(MockRequest(options["email"])) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user