From 68dcc760c33a2633e1b34baec32f700f61de9663 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 4 Nov 2013 11:22:58 -0500 Subject: [PATCH] Clean up some unused imports. (imported from commit 0c5d8e2a55ba1b8909ba807fee3afe863dcdc226) --- .../codebase/zulip_codebase_mirror | 1 - bots/irc-mirror.py | 2 -- bots/process_ccache | 1 - tools/check-handlebar-templates | 2 -- zerver/forms.py | 1 - zerver/lib/actions.py | 4 +-- zerver/lib/alert_words.py | 6 ----- zerver/lib/ccache.py | 6 ----- zerver/lib/event_queue.py | 1 - zerver/lib/mention.py | 5 ---- zerver/lib/push_notifications.py | 4 +-- zerver/lib/statistics.py | 4 +-- zerver/lib/upload.py | 1 - .../commands/analyze_user_activity.py | 6 ++--- .../management/commands/check_apns_tokens.py | 5 ---- .../commands/enqueue_followup_emails.py | 1 - .../commands/gravatar_to_user_avatar.py | 3 +-- zerver/management/commands/knight.py | 5 +--- zerver/management/commands/purge_queue.py | 1 - zerver/management/commands/realm_emoji.py | 2 +- .../commands/render_old_messages.py | 2 +- .../management/commands/set_message_flags.py | 2 +- zerver/models.py | 2 +- zerver/tornadoviews.py | 2 +- zerver/views/__init__.py | 26 +++++++++---------- zerver/views/webhooks.py | 5 ++-- zerver/worker/queue_processors.py | 3 +-- .../management/commands/create_deployment.py | 1 - zilencer/views.py | 5 ++-- zproject/local_settings_template.py | 3 --- 30 files changed, 31 insertions(+), 81 deletions(-) diff --git a/api/integrations/codebase/zulip_codebase_mirror b/api/integrations/codebase/zulip_codebase_mirror index 15bc77a5f1..babe13cfa5 100755 --- a/api/integrations/codebase/zulip_codebase_mirror +++ b/api/integrations/codebase/zulip_codebase_mirror @@ -31,7 +31,6 @@ import requests import logging -import calendar import time import sys import os diff --git a/bots/irc-mirror.py b/bots/irc-mirror.py index 4073f2d4af..9742969cef 100644 --- a/bots/irc-mirror.py +++ b/bots/irc-mirror.py @@ -10,9 +10,7 @@ import irc.bot import irc.strings from irc.client import ip_numstr_to_quad, ip_quad_to_numstr import zulip -import time import optparse -import sys def zulip_sender(sender_string): nick = sender_string.split("!")[0] diff --git a/bots/process_ccache b/bots/process_ccache index 8d404cdd90..091f946c80 100755 --- a/bots/process_ccache +++ b/bots/process_ccache @@ -1,6 +1,5 @@ #!/usr/bin/python import sys -import os import subprocess import base64 diff --git a/tools/check-handlebar-templates b/tools/check-handlebar-templates index e5a8224919..82bbeed3ac 100755 --- a/tools/check-handlebar-templates +++ b/tools/check-handlebar-templates @@ -1,8 +1,6 @@ #!/usr/bin/env python import os import sys -import re -import glob sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from zulip_tools import check_output diff --git a/zerver/forms.py b/zerver/forms.py index 9e63fc896c..35cc8a95e7 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -5,7 +5,6 @@ from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe from django.contrib.auth.forms import SetPasswordForm -from zproject import settings from zerver.models import Realm, get_user_profile_by_email, UserProfile, \ completely_open from zerver.lib.actions import do_change_password diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 4162b0e1e4..16dc647b50 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -20,7 +20,7 @@ from django.core.exceptions import ValidationError from django.utils.importlib import import_module from django.template import loader from django.core.mail import EmailMultiAlternatives, EmailMessage -from django.utils.timezone import utc, is_naive, now +from django.utils.timezone import now from confirmation.models import Confirmation @@ -45,8 +45,6 @@ from zerver.lib.alert_words import user_alert_words, add_user_alert_words, \ remove_user_alert_words, set_user_alert_words from zerver.lib.push_notifications import num_push_devices_for_user, send_apple_push_notification -import confirmation.settings - from zerver import tornado_callbacks import DNS diff --git a/zerver/lib/alert_words.py b/zerver/lib/alert_words.py index 995fe48d92..cd6745f84b 100644 --- a/zerver/lib/alert_words.py +++ b/zerver/lib/alert_words.py @@ -1,13 +1,7 @@ from __future__ import absolute_import -import re - import zerver.models - from zerver.lib.cache import cache_with_key, realm_alert_words_cache_key - -import itertools -import logging import ujson @cache_with_key(realm_alert_words_cache_key, timeout=3600*24) diff --git a/zerver/lib/ccache.py b/zerver/lib/ccache.py index ba3fa125f2..9d9f193f5c 100644 --- a/zerver/lib/ccache.py +++ b/zerver/lib/ccache.py @@ -25,14 +25,8 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - import base64 -import json -import os -import readline import struct -import subprocess -import sys # Some DER encoding stuff. Bleh. This is because the ccache contains a # DER-encoded krb5 Ticket structure, whereas Webathena deserializes diff --git a/zerver/lib/event_queue.py b/zerver/lib/event_queue.py index f3d546df9c..2cafe8b01e 100644 --- a/zerver/lib/event_queue.py +++ b/zerver/lib/event_queue.py @@ -16,7 +16,6 @@ import tornado import random from zerver.lib.utils import statsd from zerver.middleware import async_request_restart -from zerver.models import get_client # The idle timeout used to be a week, but we found that in that # situation, queues from dead browser sessions would grow quite large diff --git a/zerver/lib/mention.py b/zerver/lib/mention.py index 04e4902df8..b575f74604 100644 --- a/zerver/lib/mention.py +++ b/zerver/lib/mention.py @@ -1,10 +1,5 @@ from __future__ import absolute_import -import re - -from django.db.models import F, Q -import zerver.models - # Match multi-word string between @** ** or match any one-word # sequences after @ find_mentions = r'(?" diff --git a/zerver/management/commands/realm_emoji.py b/zerver/management/commands/realm_emoji.py index 98c7af249f..815612b49f 100644 --- a/zerver/management/commands/realm_emoji.py +++ b/zerver/management/commands/realm_emoji.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand -from zerver.models import RealmEmoji, Realm +from zerver.models import Realm from zerver.lib.actions import do_add_realm_emoji, do_remove_realm_emoji import sys diff --git a/zerver/management/commands/render_old_messages.py b/zerver/management/commands/render_old_messages.py index 2f3cbb074e..183500d57a 100644 --- a/zerver/management/commands/render_old_messages.py +++ b/zerver/management/commands/render_old_messages.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from django.core.management.base import BaseCommand -from zerver.models import UserProfile, Message, get_user_profile_by_email +from zerver.models import Message import datetime import time diff --git a/zerver/management/commands/set_message_flags.py b/zerver/management/commands/set_message_flags.py index 5a623f254e..d18c3e3e41 100644 --- a/zerver/management/commands/set_message_flags.py +++ b/zerver/management/commands/set_message_flags.py @@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand from zerver.lib import utils from zerver.models import UserMessage, get_user_profile_by_email -from django.db import transaction, models +from django.db import models class Command(BaseCommand): diff --git a/zerver/models.py b/zerver/models.py index 9d0ed78bc7..e32b3af4ef 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -9,7 +9,7 @@ from zerver.lib.cache import cache_with_key, update_user_profile_cache, \ generic_bulk_cached_fetch, cache_set, \ display_recipient_cache_key, active_user_dicts_in_realm_cache_key from zerver.lib.utils import make_safe_digest, generate_random_token -from django.db import transaction, IntegrityError +from django.db import transaction from zerver.lib import bugdown from zerver.lib.avatar import gravatar_hash, get_avatar_url from django.utils import timezone diff --git a/zerver/tornadoviews.py b/zerver/tornadoviews.py index 4b3b6aa4e9..608851d8f1 100644 --- a/zerver/tornadoviews.py +++ b/zerver/tornadoviews.py @@ -7,7 +7,7 @@ from zerver.models import get_client from zerver.decorator import asynchronous, authenticated_api_view, \ authenticated_json_post_view, internal_notify_view, RespondAsynchronously, \ has_request_variables, to_non_negative_int, json_to_bool, json_to_list, \ - authenticated_rest_api_view, REQ + REQ from zerver.lib.response import json_success, json_error from zerver.middleware import async_request_restart diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 298ec999eb..585ed36852 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponseForbidden from django.shortcuts import render_to_response, redirect from django.template import RequestContext, loader -from django.utils.timezone import now, utc +from django.utils.timezone import now from django.utils.html import mark_safe from django.utils.cache import patch_cache_control from django.core.exceptions import ValidationError @@ -16,35 +16,35 @@ from django.contrib.auth.views import login as django_login_page, \ logout_then_login as django_logout_then_login from django.db.models import Q, F from django.core.mail import send_mail, mail_admins, EmailMessage -from django.db import transaction, IntegrityError +from django.db import transaction from zerver.models import Message, UserProfile, Stream, Subscription, \ Recipient, Realm, UserMessage, bulk_get_recipients, \ PreregistrationUser, get_client, MitUser, UserActivity, UserActivityInterval, \ - MAX_SUBJECT_LENGTH, get_stream, bulk_get_streams, UserPresence, \ - get_recipient, valid_stream_name, to_dict_cache_key, to_dict_cache_key_id, \ + get_stream, bulk_get_streams, UserPresence, \ + get_recipient, valid_stream_name, to_dict_cache_key_id, \ extract_message_dict, stringify_message_dict, parse_usermessage_flags, \ email_to_domain, email_to_username, get_realm, completely_open, \ is_super_user, AppleDeviceToken, get_active_user_dicts_in_realm -from zerver.lib.actions import do_remove_subscription, bulk_remove_subscriptions, \ +from zerver.lib.actions import bulk_remove_subscriptions, \ do_change_password, create_mirror_user_if_needed, compute_irc_user_fullname, \ compute_jabber_user_fullname, do_change_full_name, \ do_change_enable_desktop_notifications, do_change_enter_sends, do_change_enable_sounds, \ - do_send_confirmation_email, do_activate_user, do_create_user, check_send_message, \ + do_activate_user, do_create_user, check_send_message, \ do_change_subscription_property, internal_send_message, \ - create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \ + create_stream_if_needed, gather_subscriptions, \ update_user_presence, bulk_add_subscriptions, do_update_message_flags, \ recipient_for_emails, extract_recipients, do_events_register, \ get_status_dict, do_change_enable_offline_email_notifications, \ do_update_message, internal_prep_message, \ - do_send_messages, do_add_subscription, get_default_subs, do_deactivate, \ + do_send_messages, get_default_subs, do_deactivate, \ user_email_is_unique, do_invite_users, do_refer_friend, compute_mit_user_fullname, \ do_add_alert_words, do_remove_alert_words, do_set_alert_words, get_subscriber_emails, \ - update_user_activity_interval, do_set_muted_topics, do_rename_stream, \ + do_set_muted_topics, do_rename_stream, \ notify_for_streams_by_default, do_change_enable_offline_push_notifications from zerver.lib.create_user import random_api_key from zerver.lib.push_notifications import num_push_devices_for_user from zerver.forms import RegistrationForm, HomepageForm, ToSForm, CreateBotForm, \ - is_inactive, not_mit_mailing_list + is_inactive from django.views.decorators.csrf import csrf_exempt, csrf_protect from django_openid_auth.views import default_render_failure, login_complete from openid.consumer.consumer import SUCCESS as openid_SUCCESS @@ -56,16 +56,14 @@ from zerver.decorator import require_post, \ authenticated_api_view, authenticated_json_post_view, \ has_request_variables, authenticated_json_view, \ to_non_negative_int, json_to_dict, json_to_list, json_to_bool, \ - JsonableError, get_user_profile_by_email, \ - authenticated_rest_api_view, process_as_post, REQ, rate_limit_user, \ + JsonableError, get_user_profile_by_email, process_as_post, REQ, \ zulip_internal from zerver.lib.query import last_n from zerver.lib.avatar import avatar_url from zerver.lib.upload import upload_message_image_through_web_client, upload_avatar_image, \ get_signed_upload_url from zerver.lib.response import json_success, json_error, json_response, json_method_not_allowed -from zerver.lib.cache import cache_get_many, cache_set_many, \ - generic_bulk_cached_fetch +from zerver.lib.cache import generic_bulk_cached_fetch from zerver.lib.unminify import SourceMap from zerver.lib.queue import queue_json_publish from zerver.lib.utils import statsd, generate_random_token diff --git a/zerver/views/webhooks.py b/zerver/views/webhooks.py index e74c3661b5..6dc9644005 100644 --- a/zerver/views/webhooks.py +++ b/zerver/views/webhooks.py @@ -5,10 +5,10 @@ from __future__ import absolute_import from django.conf import settings from django.views.decorators.csrf import csrf_exempt from zerver.models import UserProfile, get_client, MAX_SUBJECT_LENGTH, \ - get_user_profile_by_email, Realm + get_user_profile_by_email from zerver.lib.actions import check_send_message from zerver.lib.response import json_success, json_error -from zerver.decorator import rate_limit_user, authenticated_api_view, REQ, \ +from zerver.decorator import authenticated_api_view, REQ, \ has_request_variables, json_to_dict, authenticated_rest_api_view, \ api_key_only_webhook_view from zerver.views import send_message_backend @@ -20,7 +20,6 @@ import base64 import logging import re import ujson -import markdown.inlinepatterns from functools import wraps def github_generic_subject(noun, repository, blob): diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index 5dedaa9f7d..18307385b4 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from django.conf import settings from postmonkey import PostMonkey, MailChimpException -from zerver.models import UserActivityInterval, get_user_profile_by_email, \ +from zerver.models import get_user_profile_by_email, \ get_user_profile_by_id, get_prereg_user_by_email, get_client from zerver.lib.context_managers import lockfile from zerver.lib.queue import SimpleQueueClient, queue_json_publish @@ -18,7 +18,6 @@ from confirmation.models import Confirmation import os import sys import ujson -import traceback from collections import defaultdict import time import datetime diff --git a/zilencer/management/commands/create_deployment.py b/zilencer/management/commands/create_deployment.py index 25032d1165..b4183b82e8 100644 --- a/zilencer/management/commands/create_deployment.py +++ b/zilencer/management/commands/create_deployment.py @@ -1,6 +1,5 @@ from __future__ import absolute_import from optparse import make_option -import re import sys from django.core.management.base import BaseCommand diff --git a/zilencer/views.py b/zilencer/views.py index f2e6f3faf8..0c197166f1 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -1,13 +1,12 @@ from django.http import HttpResponse -from django.views.decorators.csrf import csrf_exempt, csrf_protect +from django.views.decorators.csrf import csrf_exempt from zerver.decorator import has_request_variables, REQ, json_to_dict from zerver.lib.actions import internal_send_message from zerver.lib.response import json_success, json_error, json_response, json_method_not_allowed from zerver.lib.rest import rest_dispatch as _rest_dispatch from zerver.models import get_realm, get_user_profile_by_email, email_to_domain, \ - UserProfile, Realm -from zilencer.models import Deployment + UserProfile rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs))) diff --git a/zproject/local_settings_template.py b/zproject/local_settings_template.py index 5c425810ac..afc32e5690 100644 --- a/zproject/local_settings_template.py +++ b/zproject/local_settings_template.py @@ -1,7 +1,4 @@ # Template for Django settings for the Zulip local servers -import os -import platform -import re # This is the user-accessible Zulip hostname for this installation EXTERNAL_HOST = ''