diff --git a/api/demos/twitter-search-bot b/api/demos/twitter-search-bot index c33a66db07..2aa5d7dfa5 100755 --- a/api/demos/twitter-search-bot +++ b/api/demos/twitter-search-bot @@ -3,7 +3,6 @@ import os import sys import optparse import ConfigParser -from os import path import humbug diff --git a/api/integrations/git/post-receive b/api/integrations/git/post-receive index 988eb633c1..7061bd7fb1 100755 --- a/api/integrations/git/post-receive +++ b/api/integrations/git/post-receive @@ -32,7 +32,6 @@ import os import sys import subprocess -import time import os.path sys.path.insert(0, os.path.dirname(__file__)) diff --git a/api/integrations/nagios/nagios-notify-humbug b/api/integrations/nagios/nagios-notify-humbug index 66309bac65..059399d24a 100755 --- a/api/integrations/nagios/nagios-notify-humbug +++ b/api/integrations/nagios/nagios-notify-humbug @@ -1,7 +1,5 @@ #!/usr/bin/env python -import sys import optparse -import os.path import humbug # Nagios passes the notification details as command line options. diff --git a/api/integrations/svn/post-commit b/api/integrations/svn/post-commit index 6b85e9b0e4..beed91734e 100755 --- a/api/integrations/svn/post-commit +++ b/api/integrations/svn/post-commit @@ -31,8 +31,6 @@ import os import sys -import subprocess -import time import os.path import pysvn diff --git a/api/setup.py b/api/setup.py index eb326500b0..70be8e463b 100644 --- a/api/setup.py +++ b/api/setup.py @@ -3,7 +3,6 @@ import humbug -import glob import os from distutils.core import setup diff --git a/bots/check-mirroring b/bots/check-mirroring index 23651a3f9e..7b91c9501f 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -7,7 +7,6 @@ import random import logging import subprocess import hashlib -from os import path parser = optparse.OptionParser() parser.add_option('--verbose', diff --git a/bots/check-rabbitmq-consumers b/bots/check-rabbitmq-consumers index 17728414a9..f34e484c8b 100755 --- a/bots/check-rabbitmq-consumers +++ b/bots/check-rabbitmq-consumers @@ -1,7 +1,6 @@ #!/usr/bin/env python import sys -import subprocess import time import optparse from collections import defaultdict diff --git a/bots/check-rabbitmq-queue b/bots/check-rabbitmq-queue index 95513cfe2e..afeb45645c 100755 --- a/bots/check-rabbitmq-queue +++ b/bots/check-rabbitmq-queue @@ -1,7 +1,6 @@ #!/usr/bin/env python import sys -import subprocess import re import time diff --git a/bots/gcal-bot b/bots/gcal-bot index 41b708c03b..30dae5f208 100755 --- a/bots/gcal-bot +++ b/bots/gcal-bot @@ -1,8 +1,6 @@ #!/usr/bin/env python -import os import sys import time -import errno import datetime import optparse import urlparse diff --git a/bots/zephyr_mirror.py b/bots/zephyr_mirror.py index 7d35c5811d..44e06d50b8 100755 --- a/bots/zephyr_mirror.py +++ b/bots/zephyr_mirror.py @@ -23,8 +23,6 @@ import sys import subprocess -import time -import optparse import os import traceback import signal diff --git a/humbug/backends.py b/humbug/backends.py index 23abe4d0ef..751b0bad72 100644 --- a/humbug/backends.py +++ b/humbug/backends.py @@ -1,6 +1,5 @@ from zephyr.models import UserProfile, get_user_profile_by_id, \ get_user_profile_by_email -from django.conf import settings from openid.consumer.consumer import SUCCESS diff --git a/humbug/settings.py b/humbug/settings.py index 142e3c7e57..b20dc822b6 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -1,7 +1,6 @@ # Django settings for humbug project. import os import platform -import logging import time import re diff --git a/humbug/test_settings.py b/humbug/test_settings.py index 85853c7215..78b4359f9d 100644 --- a/humbug/test_settings.py +++ b/humbug/test_settings.py @@ -1,6 +1,5 @@ from settings import * import os -import logging DATABASES["default"] = {"NAME": "humbug_test", "USER": "humbug_test", diff --git a/servers/puppet/modules/humbug/files/nagios_plugins/check_send_receive_time b/servers/puppet/modules/humbug/files/nagios_plugins/check_send_receive_time index cc8dbef926..53159fe7ee 100755 --- a/servers/puppet/modules/humbug/files/nagios_plugins/check_send_receive_time +++ b/servers/puppet/modules/humbug/files/nagios_plugins/check_send_receive_time @@ -10,7 +10,6 @@ Django ORM. """ import datetime -import os import sys import optparse import random diff --git a/tools/generate-activity-metrics.py b/tools/generate-activity-metrics.py index 456dde81b4..eac6253390 100755 --- a/tools/generate-activity-metrics.py +++ b/tools/generate-activity-metrics.py @@ -7,7 +7,6 @@ import os, sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) import optparse -from itertools import dropwhile, takewhile from datetime import timedelta, datetime from zephyr.lib.timestamp import datetime_to_timestamp from zephyr.lib.utils import statsd_key diff --git a/tools/purge-deployments b/tools/purge-deployments index 8528dbccac..0d9ebaeecd 100755 --- a/tools/purge-deployments +++ b/tools/purge-deployments @@ -3,7 +3,7 @@ import os import logging import datetime import shutil -from humbug_tools import DEPLOYMENTS_DIR, LOCK_DIR, TIMESTAMP_FORMAT +from humbug_tools import DEPLOYMENTS_DIR, TIMESTAMP_FORMAT logging.basicConfig(format="%(asctime)s purge-deployments: %(message)s", level=logging.INFO) diff --git a/tools/restart-server b/tools/restart-server index 2d4dbe8170..f8d79a10a7 100755 --- a/tools/restart-server +++ b/tools/restart-server @@ -3,11 +3,9 @@ import os import sys import pwd import subprocess -import pylibmc -import traceback import logging import time -from humbug_tools import ENDC, WARNING, OKGREEN, DEPLOYMENTS_DIR +from humbug_tools import ENDC, OKGREEN, DEPLOYMENTS_DIR logging.basicConfig(format="%(asctime)s restart-server: %(message)s", level=logging.INFO) diff --git a/tools/review b/tools/review index 6102ca0a4b..73384f46b7 100755 --- a/tools/review +++ b/tools/review @@ -42,7 +42,6 @@ from StringIO import StringIO from email.message import Message from email.header import Header from shutil import rmtree, copyfile, copytree -from tempfile import NamedTemporaryFile from time import sleep from signal import SIGINT, SIGTERM from errno import EAGAIN diff --git a/tools/update-deployment b/tools/update-deployment index 657fd3b2d0..0a18fda77e 100755 --- a/tools/update-deployment +++ b/tools/update-deployment @@ -2,8 +2,6 @@ import os import sys import subprocess -import pylibmc -import traceback import logging from humbug_tools import DEPLOYMENTS_DIR, LOCK_DIR, TIMESTAMP_FORMAT, FAIL, ENDC import datetime diff --git a/zephyr/decorator.py b/zephyr/decorator.py index 4d5bd2269a..2d34e5235e 100644 --- a/zephyr/decorator.py +++ b/zephyr/decorator.py @@ -4,18 +4,14 @@ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from django.http import QueryDict from django.http.multipartparser import MultiPartParser -from zephyr.models import UserProfile, UserActivity, get_client, \ - get_user_profile_by_email -from zephyr.lib.response import json_success, json_error, HttpResponseUnauthorized +from zephyr.models import UserProfile, get_client, get_user_profile_by_email +from zephyr.lib.response import json_error, HttpResponseUnauthorized from django.utils.timezone import now -from django.db import transaction, IntegrityError from django.conf import settings import ujson from StringIO import StringIO -from zephyr.lib.cache import cache_with_key from zephyr.lib.queue import queue_json_publish from zephyr.lib.timestamp import datetime_to_timestamp -from zephyr.lib.cache import user_profile_by_email_cache_key from zephyr.lib.utils import statsd from zephyr.exceptions import RateLimited from zephyr.lib.rate_limiter import incr_ratelimit, is_ratelimited, \ diff --git a/zephyr/forms.py b/zephyr/forms.py index 6eabe23556..7f860b66fc 100644 --- a/zephyr/forms.py +++ b/zephyr/forms.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from django import forms -from django.core import validators from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe from django.contrib.auth.forms import SetPasswordForm diff --git a/zephyr/handlers.py b/zephyr/handlers.py index f4d1c00bea..d9b1d725ea 100644 --- a/zephyr/handlers.py +++ b/zephyr/handlers.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import sys import logging import traceback import platform @@ -44,7 +43,6 @@ class AdminHumbugHandler(logging.Handler): def emit(self, record): # We have to defer imports to avoid circular imports in settings.py. - from zephyr.models import Recipient from zephyr.lib.actions import internal_send_message diff --git a/zephyr/lib/bugdown/__init__.py b/zephyr/lib/bugdown/__init__.py index faf8f346f2..f6e17a05f3 100644 --- a/zephyr/lib/bugdown/__init__.py +++ b/zephyr/lib/bugdown/__init__.py @@ -5,9 +5,6 @@ import urlparse import re import os.path import glob -import urllib2 -import itertools -import ujson import twitter import platform import time @@ -634,7 +631,6 @@ def do_convert(md, realm): # https://trac.humbughq.com/ticket/345 return timeout(5, _md_engine.convert, md) except: - from zephyr.models import Recipient from zephyr.lib.actions import internal_send_message cleaned = _sanitize_for_log(md) diff --git a/zephyr/lib/logging_util.py b/zephyr/lib/logging_util.py index bcfce6dcca..2dc955685c 100644 --- a/zephyr/lib/logging_util.py +++ b/zephyr/lib/logging_util.py @@ -1,6 +1,4 @@ import logging -import traceback -from hashlib import sha256 from datetime import datetime, timedelta # Adapted http://djangosnippets.org/snippets/2242/ by user s29 (October 25, 2010) diff --git a/zephyr/lib/rate_limiter.py b/zephyr/lib/rate_limiter.py index 395c9c4567..4bcadc7730 100644 --- a/zephyr/lib/rate_limiter.py +++ b/zephyr/lib/rate_limiter.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from django.conf import settings -from zephyr.models import get_user_profile_by_id import redis import time diff --git a/zephyr/lib/utils.py b/zephyr/lib/utils.py index 2568f08379..a7cb86cd10 100644 --- a/zephyr/lib/utils.py +++ b/zephyr/lib/utils.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import hashlib -from time import sleep, time +from time import sleep from django.conf import settings def statsd_key(val, clean_periods=False): diff --git a/zephyr/management/commands/active_user_stats.py b/zephyr/management/commands/active_user_stats.py index 10be602c4c..6b321c6d6b 100644 --- a/zephyr/management/commands/active_user_stats.py +++ b/zephyr/management/commands/active_user_stats.py @@ -1,14 +1,12 @@ from __future__ import absolute_import from django.core.management.base import BaseCommand -from django.conf import settings -from zephyr.models import UserProfile, UserPresence, UserActivity +from zephyr.models import UserPresence, UserActivity from zephyr.lib.utils import statsd, statsd_key from datetime import datetime, timedelta from collections import defaultdict -import os, time class Command(BaseCommand): help = """Sends active user statistics to statsd. diff --git a/zephyr/management/commands/analyze_mit.py b/zephyr/management/commands/analyze_mit.py index 40c81e4d12..8c6339486a 100644 --- a/zephyr/management/commands/analyze_mit.py +++ b/zephyr/management/commands/analyze_mit.py @@ -2,9 +2,8 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand -from zephyr.models import Realm, UserProfile, Recipient, Message, get_client -import ujson -from zephyr.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime +from zephyr.models import Recipient, Message +from zephyr.lib.timestamp import timestamp_to_datetime import datetime import time import logging diff --git a/zephyr/management/commands/check_redis.py b/zephyr/management/commands/check_redis.py index c9cfbcdb44..b42d7d70f7 100644 --- a/zephyr/management/commands/check_redis.py +++ b/zephyr/management/commands/check_redis.py @@ -1,13 +1,13 @@ from __future__ import absolute_import -from zephyr.models import UserProfile, get_user_profile_by_id -from zephyr.lib.rate_limiter import redis_key, client, max_api_calls, max_api_window +from zephyr.models import get_user_profile_by_id +from zephyr.lib.rate_limiter import client, max_api_calls, max_api_window from django.core.management.base import BaseCommand from django.conf import settings from optparse import make_option -import os, time, logging +import time, logging class Command(BaseCommand): help = """Checks redis to make sure our rate limiting system hasn't grown a bug and left redis with a bunch of data diff --git a/zephyr/management/commands/copy_colors.py b/zephyr/management/commands/copy_colors.py index ff0f5ef2be..40c94bda17 100644 --- a/zephyr/management/commands/copy_colors.py +++ b/zephyr/management/commands/copy_colors.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from django.core.management.base import BaseCommand -from zephyr.models import StreamColor, Subscription +from zephyr.models import StreamColor class Command(BaseCommand): help = """Copies all colors from the StreamColor table to the Subscription table.""" diff --git a/zephyr/management/commands/deactivate_user.py b/zephyr/management/commands/deactivate_user.py index 12ac358c5d..d611495448 100644 --- a/zephyr/management/commands/deactivate_user.py +++ b/zephyr/management/commands/deactivate_user.py @@ -5,7 +5,7 @@ from optparse import make_option from django.core.management.base import BaseCommand from zephyr.lib.actions import do_deactivate, user_sessions -from zephyr.models import UserProfile, get_user_profile_by_email +from zephyr.models import get_user_profile_by_email class Command(BaseCommand): help = "Deactivate a user, including forcibly logging them out." diff --git a/zephyr/management/commands/dump_pointers.py b/zephyr/management/commands/dump_pointers.py index 6c33c45dbf..c732a12278 100755 --- a/zephyr/management/commands/dump_pointers.py +++ b/zephyr/management/commands/dump_pointers.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand -from zephyr.models import Realm, UserProfile, Message, UserMessage, \ +from zephyr.models import UserProfile, Message, UserMessage, \ get_user_profile_by_email from zephyr.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime import ujson diff --git a/zephyr/management/commands/dump_useractivity.py b/zephyr/management/commands/dump_useractivity.py index 890bdbc5c6..0b3626a799 100644 --- a/zephyr/management/commands/dump_useractivity.py +++ b/zephyr/management/commands/dump_useractivity.py @@ -2,8 +2,7 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand -from zephyr.models import Realm, UserActivity, get_client, \ - get_user_profile_by_email +from zephyr.models import UserActivity, get_client, get_user_profile_by_email import ujson from zephyr.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime diff --git a/zephyr/management/commands/fill_memcached_caches.py b/zephyr/management/commands/fill_memcached_caches.py index 3480d316b1..6695b8d98a 100644 --- a/zephyr/management/commands/fill_memcached_caches.py +++ b/zephyr/management/commands/fill_memcached_caches.py @@ -3,8 +3,6 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand from zephyr.lib.cache_helpers import fill_memcached_cache, cache_fillers -import subprocess -import os class Command(BaseCommand): option_list = BaseCommand.option_list + ( diff --git a/zephyr/management/commands/generate_invite_links.py b/zephyr/management/commands/generate_invite_links.py index fe3f39b8cf..0cee20bfbc 100644 --- a/zephyr/management/commands/generate_invite_links.py +++ b/zephyr/management/commands/generate_invite_links.py @@ -1,7 +1,5 @@ from __future__ import absolute_import -from optparse import make_option -from django.contrib.sites.models import Site from django.core.management.base import BaseCommand from confirmation.models import Confirmation from zephyr.models import UserProfile, PreregistrationUser, \ diff --git a/zephyr/management/commands/populate_db.py b/zephyr/management/commands/populate_db.py index 8ed4445c2d..bac3e14d13 100644 --- a/zephyr/management/commands/populate_db.py +++ b/zephyr/management/commands/populate_db.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from django.core.management.base import BaseCommand -from django.utils.timezone import utc, now +from django.utils.timezone import now from django.contrib.sites.models import Site from zephyr.models import Message, UserProfile, Stream, Recipient, Client, \ @@ -22,7 +22,6 @@ import ujson import datetime import random import glob -import sys import os from os import path from optparse import make_option diff --git a/zephyr/management/commands/process_user_activity.py b/zephyr/management/commands/process_user_activity.py index 53e9e742ba..bd307456ec 100644 --- a/zephyr/management/commands/process_user_activity.py +++ b/zephyr/management/commands/process_user_activity.py @@ -1,9 +1,6 @@ from __future__ import absolute_import -from optparse import make_option from django.core.management.base import BaseCommand -import ujson -import pika from zephyr.lib.actions import process_user_activity_event, \ process_user_presence_event from zephyr.lib.queue import SimpleQueueClient diff --git a/zephyr/management/commands/profile_request.py b/zephyr/management/commands/profile_request.py index 01445d38f4..d45346e09b 100644 --- a/zephyr/management/commands/profile_request.py +++ b/zephyr/management/commands/profile_request.py @@ -2,11 +2,9 @@ from __future__ import absolute_import from optparse import make_option from django.core.management.base import BaseCommand -from confirmation.models import Confirmation from zephyr.models import get_user_profile_by_email, UserMessage from zephyr.views import get_old_messages_backend import cProfile -import time import logging from zephyr.middleware import LogRequests diff --git a/zephyr/management/commands/rate_limit.py b/zephyr/management/commands/rate_limit.py index 9e0b4dafed..d8972533a0 100644 --- a/zephyr/management/commands/rate_limit.py +++ b/zephyr/management/commands/rate_limit.py @@ -4,13 +4,8 @@ from zephyr.models import UserProfile, get_user_profile_by_email from zephyr.lib.rate_limiter import block_user, unblock_user from django.core.management.base import BaseCommand -from django.conf import settings from optparse import make_option -from datetime import datetime, timedelta -from collections import defaultdict -import os, time - class Command(BaseCommand): help = """Manually block or unblock a user from accessing the API diff --git a/zephyr/management/commands/remove_users_from_stream.py b/zephyr/management/commands/remove_users_from_stream.py index 78e9eb30eb..425e3c4006 100644 --- a/zephyr/management/commands/remove_users_from_stream.py +++ b/zephyr/management/commands/remove_users_from_stream.py @@ -5,7 +5,7 @@ from optparse import make_option from django.core.management.base import BaseCommand from zephyr.lib.actions import do_remove_subscription -from zephyr.models import Realm, User, UserProfile, get_stream, \ +from zephyr.models import Realm, UserProfile, get_stream, \ get_user_profile_by_email class Command(BaseCommand): diff --git a/zephyr/management/commands/runtornado.py b/zephyr/management/commands/runtornado.py index 29716863fc..e3cbd434f2 100644 --- a/zephyr/management/commands/runtornado.py +++ b/zephyr/management/commands/runtornado.py @@ -16,7 +16,6 @@ import os import sys import tornado.web import logging -import time from tornado import ioloop from zephyr.lib.debug import interactive_debug_listen from zephyr.lib.response import json_response @@ -47,8 +46,7 @@ class Command(BaseCommand): interactive_debug_listen() import django - from django.core.handlers.wsgi import WSGIHandler - from tornado import httpserver, wsgi, web + from tornado import httpserver, web try: addr, port = addrport.split(':') diff --git a/zephyr/management/commands/send_missedmessage_reminders.py b/zephyr/management/commands/send_missedmessage_reminders.py index 7a35ff89e5..f996598049 100644 --- a/zephyr/management/commands/send_missedmessage_reminders.py +++ b/zephyr/management/commands/send_missedmessage_reminders.py @@ -1,12 +1,10 @@ from __future__ import absolute_import import time -import ujson from collections import defaultdict from django.core.management.base import BaseCommand -from django.conf import settings from zephyr.lib.queue import SimpleQueueClient from zephyr.lib.actions import handle_missedmessage_emails diff --git a/zephyr/management/commands/set_default_streams.py b/zephyr/management/commands/set_default_streams.py index ac6af2455a..3bc7756535 100644 --- a/zephyr/management/commands/set_default_streams.py +++ b/zephyr/management/commands/set_default_streams.py @@ -5,7 +5,6 @@ from zephyr.lib.actions import set_default_streams, log_event from optparse import make_option import sys -import time class Command(BaseCommand): help = """Set default streams for a realm diff --git a/zephyr/management/commands/set_message_flags.py b/zephyr/management/commands/set_message_flags.py index f3fa2aa053..c8e6984e63 100644 --- a/zephyr/management/commands/set_message_flags.py +++ b/zephyr/management/commands/set_message_flags.py @@ -6,7 +6,6 @@ import sys from django.core.management.base import BaseCommand -from zephyr.lib.actions import do_deactivate from zephyr.lib import utils from zephyr.models import UserMessage, get_user_profile_by_email from django.db import transaction, models diff --git a/zephyr/management/commands/set_unread_to_pointer.py b/zephyr/management/commands/set_unread_to_pointer.py index cbbd2000df..a43c1290a1 100644 --- a/zephyr/management/commands/set_unread_to_pointer.py +++ b/zephyr/management/commands/set_unread_to_pointer.py @@ -5,7 +5,6 @@ import logging from django.core.management.base import BaseCommand -from zephyr.lib.actions import do_deactivate from zephyr.lib import utils from zephyr.models import UserMessage, UserProfile, \ get_user_profile_by_email diff --git a/zephyr/management/commands/stream_stats.py b/zephyr/management/commands/stream_stats.py index aa4861dd7d..16d8d5bae7 100644 --- a/zephyr/management/commands/stream_stats.py +++ b/zephyr/management/commands/stream_stats.py @@ -1,6 +1,3 @@ -import datetime -import pytz - from django.core.management.base import BaseCommand from django.db.models import Q from zephyr.models import Realm, Stream, Message, Subscription, Recipient diff --git a/zephyr/management/commands/subscribe_new_users.py b/zephyr/management/commands/subscribe_new_users.py index 31c31e9f48..289c0f0102 100644 --- a/zephyr/management/commands/subscribe_new_users.py +++ b/zephyr/management/commands/subscribe_new_users.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import ujson from postmonkey import PostMonkey from django.core.management.base import BaseCommand from django.conf import settings diff --git a/zephyr/middleware.py b/zephyr/middleware.py index bdee7f8825..02b9bf5f4b 100644 --- a/zephyr/middleware.py +++ b/zephyr/middleware.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from django.conf import settings -from zephyr.decorator import RequestVariableMissingError, RequestVariableConversionError from zephyr.lib.response import json_error from django.db import connection from zephyr.lib.utils import statsd diff --git a/zephyr/models.py b/zephyr/models.py index ffd9be5bf7..b3dbc58174 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -7,13 +7,11 @@ from zephyr.lib.cache import cache_with_key, update_user_profile_cache, \ user_profile_by_id_cache_key, user_profile_by_email_cache_key, \ update_user_presence_cache from zephyr.lib.utils import make_safe_digest -import os from django.db import transaction, IntegrityError from zephyr.lib import bugdown from zephyr.lib.avatar import gravatar_hash, avatar_url from django.utils import timezone from django.contrib.sessions.models import Session -from django.utils.html import escape from zephyr.lib.timestamp import datetime_to_timestamp from django.db.models.signals import post_save import zlib diff --git a/zephyr/tests.py b/zephyr/tests.py index 4cdc7c0d75..a60b82ad4b 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -19,14 +19,11 @@ from zephyr.lib import bugdown from zephyr.lib.rate_limiter import clear_user_history from django.conf import settings -import optparse import os import random import re -import subprocess import sys import time -import traceback import ujson import urllib2 from StringIO import StringIO diff --git a/zephyr/tornado_callbacks.py b/zephyr/tornado_callbacks.py index d62f210ec2..63400bd040 100644 --- a/zephyr/tornado_callbacks.py +++ b/zephyr/tornado_callbacks.py @@ -7,9 +7,7 @@ from zephyr.models import Message, UserProfile, UserMessage, \ from zephyr.decorator import JsonableError from zephyr.lib.cache_helpers import cache_get_message from zephyr.lib.queue import queue_json_publish -from zephyr.lib.timestamp import timestamp_to_datetime -from zephyr.lib.event_queue import get_client_descriptors_for_user, \ - add_client_gc_hook, IDLE_EVENT_QUEUE_TIMEOUT_SECS +from zephyr.lib.event_queue import get_client_descriptors_for_user import os import sys diff --git a/zephyr/tornadoviews.py b/zephyr/tornadoviews.py index 30f554623b..7bba5188fb 100644 --- a/zephyr/tornadoviews.py +++ b/zephyr/tornadoviews.py @@ -1,14 +1,14 @@ from __future__ import absolute_import from django.conf import settings -from zephyr.models import UserActivity, get_client +from zephyr.models import get_client from zephyr.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, \ - JsonableError, authenticated_rest_api_view, REQ + authenticated_rest_api_view, REQ -from zephyr.lib.response import json_response, json_success, json_error +from zephyr.lib.response import json_success, json_error from zephyr.middleware import async_request_restart from zephyr.tornado_callbacks import \ get_user_pointer, fetch_stream_messages, fetch_user_messages, \ @@ -18,12 +18,8 @@ from zephyr.tornado_callbacks import \ from zephyr.lib.cache_helpers import cache_get_message from zephyr.lib.event_queue import allocate_client_descriptor, get_client_descriptor -import datetime import ujson import socket -import time -import sys -import logging @internal_notify_view def notify(request): diff --git a/zephyr/views.py b/zephyr/views.py index 746a3ca8e0..ce66261d18 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -21,7 +21,7 @@ from zephyr.models import Message, UserProfile, Stream, Subscription, \ MAX_SUBJECT_LENGTH, get_stream, UserPresence, \ get_recipient, valid_stream_name, to_dict_cache_key, to_dict_cache_key_id, \ extract_message_dict, stringify_message_dict, parse_usermessage_flags -from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \ +from zephyr.lib.actions import do_remove_subscription, \ do_change_password, create_mit_user_if_needed, 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, \ @@ -35,7 +35,7 @@ from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \ from zephyr.forms import RegistrationForm, HomepageForm, ToSForm, CreateBotForm, \ is_unique, is_inactive, isnt_mit from django.views.decorators.csrf import csrf_exempt -from django_openid_auth.views import default_render_failure, login_complete, parse_openid_response +from django_openid_auth.views import default_render_failure, login_complete from openid.consumer.consumer import SUCCESS as openid_SUCCESS from openid.extensions import ax @@ -43,14 +43,13 @@ from zephyr.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, RequestVariableMissingError, get_user_profile_by_email, \ - authenticated_rest_api_view, process_as_post, REQ, rate_limit, rate_limit_user + JsonableError, get_user_profile_by_email, \ + authenticated_rest_api_view, process_as_post, REQ, rate_limit_user from zephyr.lib.query import last_n from zephyr.lib.avatar import avatar_url from zephyr.lib.upload import upload_message_image, upload_avatar_image from zephyr.lib.response import json_success, json_error, json_response, json_method_not_allowed -from zephyr.lib.timestamp import datetime_to_timestamp -from zephyr.lib.cache import cache_with_key, cache_get_many, cache_set_many +from zephyr.lib.cache import cache_get_many, cache_set_many from zephyr.lib.unminify import SourceMap from zephyr.lib.queue import queue_json_publish from zephyr.lib.utils import statsd