mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Switch to using Python 3 style division everywhere.
Also add testing for this to our Python 3 compatibility test suite.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from zerver.lib.statistics import seconds_usage_between
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import datetime
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from django.db import connection
|
||||
from django.template import RequestContext, loader
|
||||
from django.utils.html import mark_safe
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
import sys
|
||||
import six
|
||||
from six.moves import input
|
||||
@@ -2921,7 +2922,7 @@ class P4Sync(Command, P4UserMap):
|
||||
b = b[len(self.projectName):]
|
||||
self.createdBranches.add(b)
|
||||
|
||||
self.tz = "%+03d%02d" % (- time.timezone / 3600, ((- time.timezone % 3600) / 60))
|
||||
self.tz = "%+03d%02d" % (- time.timezone / 3600, ((- time.timezone % 3600) // 60))
|
||||
|
||||
self.importProcess = subprocess.Popen(["git", "fast-import"],
|
||||
stdin=subprocess.PIPE,
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
import simplejson
|
||||
import requests
|
||||
import time
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python2.7
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
import datetime
|
||||
import monthdelta
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
import os, sys
|
||||
from six.moves import range
|
||||
|
||||
|
@@ -29,6 +29,7 @@ libfuturize.fixes.fix_next_call
|
||||
libfuturize.fixes.fix_print_with_import
|
||||
libfuturize.fixes.fix_raise
|
||||
libmodernize.fixes.fix_basestring
|
||||
libfuturize.fixes.fix_division_safe
|
||||
libmodernize.fixes.fix_file
|
||||
libmodernize.fixes.fix_filter
|
||||
libmodernize.fixes.fix_imports_six
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
||||
from zerver.models import UserProfile, UserActivity, UserActivityInterval, Message
|
||||
|
||||
@@ -84,7 +85,7 @@ def calculate_stats(data, all_users):
|
||||
return {"# data points": 0}
|
||||
|
||||
active_user_count = len([x for x in data if x > 1])
|
||||
mean_data = sum(data) / active_user_count
|
||||
mean_data = sum(data) // active_user_count
|
||||
median_data = median([x for x in data if x > 1])
|
||||
|
||||
return {'active users': active_user_count,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
||||
import logging
|
||||
import time
|
||||
@@ -68,7 +69,7 @@ class InstrumentedPoll(object):
|
||||
total = t1 - self._times[0][0]
|
||||
in_poll = sum(b-a for a, b in self._times)
|
||||
if total > 0:
|
||||
percent_busy = 100 * (1 - in_poll/total)
|
||||
percent_busy = 100 * (1 - in_poll / total)
|
||||
if settings.PRODUCTION or percent_busy > 20:
|
||||
logging.info('Tornado %5.1f%% busy over the past %4.1f seconds'
|
||||
% (percent_busy, total))
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
@@ -59,7 +60,7 @@ def run_in_batches(all_list, batch_size, callback, sleep_time = 0, logger = None
|
||||
if len(all_list) == 0:
|
||||
return
|
||||
|
||||
limit = (len(all_list) / batch_size) + 1;
|
||||
limit = (len(all_list) // batch_size) + 1;
|
||||
for i in range(limit):
|
||||
start = i*batch_size
|
||||
end = (i+1) * batch_size
|
||||
@@ -99,4 +100,4 @@ def log_statsd_event(name):
|
||||
statsd.incr(event_name)
|
||||
|
||||
def generate_random_token(length):
|
||||
return base64.b16encode(os.urandom(length / 2)).lower()
|
||||
return base64.b16encode(os.urandom(length // 2)).lower()
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
@@ -167,7 +168,7 @@ class Command(BaseCommand):
|
||||
threads = options["threads"]
|
||||
jobs = []
|
||||
for i in range(threads):
|
||||
count = options["num_messages"] / threads
|
||||
count = options["num_messages"] // threads
|
||||
if i < options["num_messages"] % threads:
|
||||
count += 1
|
||||
jobs.append((count, personals_pairs, options, self.stdout.write))
|
||||
|
Reference in New Issue
Block a user