mirror of https://github.com/zulip/zulip.git
Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import
Refer #256
This commit is contained in:
parent
3e7827358e
commit
c59185e119
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from os import path
|
from os import path
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -46,9 +47,9 @@ parser.add_option('--new-short-name')
|
||||||
|
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.create_user({
|
print(client.create_user({
|
||||||
'email': options.new_email,
|
'email': options.new_email,
|
||||||
'password': options.new_password,
|
'password': options.new_password,
|
||||||
'full_name': options.new_full_name,
|
'full_name': options.new_full_name,
|
||||||
'short_name': options.new_short_name
|
'short_name': options.new_short_name
|
||||||
})
|
}))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -53,4 +54,4 @@ if options.subject != "":
|
||||||
message_data["subject"] = options.subject
|
message_data["subject"] = options.subject
|
||||||
if options.content != "":
|
if options.content != "":
|
||||||
message_data["content"] = options.content
|
message_data["content"] = options.content
|
||||||
print client.update_message(message_data)
|
print(client.update_message(message_data))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -43,4 +44,4 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
|
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.get_streams(include_public=True, include_subscribed=False)
|
print(client.get_streams(include_public=True, include_subscribed=False))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -42,4 +43,4 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
for user in client.get_members()["members"]:
|
for user in client.get_members()["members"]:
|
||||||
print user["full_name"], user["email"]
|
print(user["full_name"], user["email"])
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -42,4 +43,4 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
|
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.list_subscriptions()
|
print(client.list_subscriptions())
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -43,7 +44,7 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
def print_event(event):
|
def print_event(event):
|
||||||
print event
|
print(event)
|
||||||
|
|
||||||
# This is a blocking call, and will continuously poll for new events
|
# This is a blocking call, and will continuously poll for new events
|
||||||
# Note also the filter here is messages to the stream Denmark; if you
|
# Note also the filter here is messages to the stream Denmark; if you
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -43,7 +44,7 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
def print_message(message):
|
def print_message(message):
|
||||||
print message
|
print(message)
|
||||||
|
|
||||||
# This is a blocking call, and will continuously poll for new messages
|
# This is a blocking call, and will continuously poll for new messages
|
||||||
client.call_on_each_message(print_message)
|
client.call_on_each_message(print_message)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -42,4 +43,4 @@ parser.add_option_group(zulip.generate_option_group(parser))
|
||||||
|
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
print client.get_messages({})
|
print(client.get_messages({}))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -54,4 +55,4 @@ message_data = {
|
||||||
"subject": options.subject,
|
"subject": options.subject,
|
||||||
"to": args,
|
"to": args,
|
||||||
}
|
}
|
||||||
print client.send_message(message_data)
|
print(client.send_message(message_data))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -45,8 +46,8 @@ parser.add_option('--streams', default='')
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.streams == "":
|
if options.streams == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print("Usage:", parser.usage, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print client.add_subscriptions([{"name": stream_name} for stream_name in
|
print(client.add_subscriptions([{"name": stream_name} for stream_name in
|
||||||
options.streams.split()])
|
options.streams.split()]))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -45,7 +46,7 @@ parser.add_option('--streams', default='')
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.streams == "":
|
if options.streams == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print("Usage:", parser.usage, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print client.remove_subscriptions(options.streams.split())
|
print(client.remove_subscriptions(options.streams.split()))
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#
|
#
|
||||||
# python-dateutil is a dependency for this script.
|
# python-dateutil is a dependency for this script.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import base64
|
import base64
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
@ -45,8 +46,8 @@ try:
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import dateutil.tz
|
import dateutil.tz
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print >>sys.stderr, e
|
print(e, file=sys.stderr)
|
||||||
print >>sys.stderr, "Please install the python-dateutil package."
|
print("Please install the python-dateutil package.", file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(__file__))
|
sys.path.insert(0, os.path.dirname(__file__))
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#
|
#
|
||||||
# python-dateutil is a dependency for this script.
|
# python-dateutil is a dependency for this script.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
@ -41,8 +42,8 @@ from datetime import datetime, timedelta
|
||||||
try:
|
try:
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print >>sys.stderr, e
|
print(e, file=sys.stderr)
|
||||||
print >>sys.stderr, "Please install the python-dateutil package."
|
print("Please install the python-dateutil package.", file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(__file__))
|
sys.path.insert(0, os.path.dirname(__file__))
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import calendar
|
import calendar
|
||||||
import errno
|
import errno
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -97,7 +98,7 @@ try:
|
||||||
mkdir_p(opts.data_dir)
|
mkdir_p(opts.data_dir)
|
||||||
except OSError:
|
except OSError:
|
||||||
# We can't write to the logfile, so just print and give up.
|
# We can't write to the logfile, so just print and give up.
|
||||||
print >>sys.stderr, "Unable to store RSS data at %s." % (opts.data_dir,)
|
print("Unable to store RSS data at %s." % (opts.data_dir,), file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
log_file = os.path.join(opts.data_dir, "rss-bot.log")
|
log_file = os.path.join(opts.data_dir, "rss-bot.log")
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -112,7 +113,7 @@ api = twitter.Api(consumer_key=consumer_key,
|
||||||
user = api.VerifyCredentials()
|
user = api.VerifyCredentials()
|
||||||
|
|
||||||
if not user.GetId():
|
if not user.GetId():
|
||||||
print "Unable to log in to twitter with supplied credentials. Please double-check and try again"
|
print("Unable to log in to twitter with supplied credentials. Please double-check and try again")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -154,7 +155,7 @@ for status in statuses[::-1][:options.limit_tweets]:
|
||||||
|
|
||||||
if ret['result'] == 'error':
|
if ret['result'] == 'error':
|
||||||
# If sending failed (e.g. no such stream), abort and retry next time
|
# If sending failed (e.g. no such stream), abort and retry next time
|
||||||
print "Error sending message to zulip: %s" % ret['msg']
|
print("Error sending message to zulip: %s" % ret['msg'])
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
since_id = status.GetId()
|
since_id = status.GetId()
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -138,8 +139,8 @@ api = twitter.Api(consumer_key=consumer_key,
|
||||||
user = api.VerifyCredentials()
|
user = api.VerifyCredentials()
|
||||||
|
|
||||||
if not user.GetId():
|
if not user.GetId():
|
||||||
print "Unable to log in to Twitter with supplied credentials.\
|
print("Unable to log in to Twitter with supplied credentials.\
|
||||||
Please double-check and try again."
|
Please double-check and try again.")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
client = zulip.Client(
|
client = zulip.Client(
|
||||||
|
@ -182,7 +183,7 @@ for status in statuses[::-1][:opts.limit_tweets]:
|
||||||
|
|
||||||
if ret['result'] == 'error':
|
if ret['result'] == 'error':
|
||||||
# If sending failed (e.g. no such stream), abort and retry next time
|
# If sending failed (e.g. no such stream), abort and retry next time
|
||||||
print "Error sending message to zulip: %s" % ret['msg']
|
print("Error sending message to zulip: %s" % ret['msg'])
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
since_id = status.GetId()
|
since_id = status.GetId()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -8,4 +9,4 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
print getattr(settings, sys.argv[1])
|
print(getattr(settings, sys.argv[1]))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -100,7 +101,7 @@ def print_status_and_exit(status):
|
||||||
# e.g. true success and punting due to a SERVNAK, result in a
|
# e.g. true success and punting due to a SERVNAK, result in a
|
||||||
# non-alert case, so to give us something unambiguous to check in
|
# non-alert case, so to give us something unambiguous to check in
|
||||||
# Nagios, print the exit status.
|
# Nagios, print the exit status.
|
||||||
print status
|
print(status)
|
||||||
sys.exit(status)
|
sys.exit(status)
|
||||||
|
|
||||||
def send_zulip(message):
|
def send_zulip(message):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -15,7 +16,7 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
|
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
|
||||||
print "This script must be run as the root or rabbitmq user"
|
print("This script must be run as the root or rabbitmq user")
|
||||||
|
|
||||||
|
|
||||||
usage = """Usage: check-rabbitmq-consumers --queue=[queue-name] --min-threshold=[min-threshold]"""
|
usage = """Usage: check-rabbitmq-consumers --queue=[queue-name] --min-threshold=[min-threshold]"""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
@ -30,7 +31,7 @@ max_count = 0
|
||||||
warn_queues = []
|
warn_queues = []
|
||||||
|
|
||||||
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
|
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
|
||||||
print "This script must be run as the root or rabbitmq user"
|
print("This script must be run as the root or rabbitmq user")
|
||||||
|
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -99,7 +100,7 @@ def send_reminders():
|
||||||
key = (uid, start)
|
key = (uid, start)
|
||||||
if key not in sent:
|
if key not in sent:
|
||||||
line = '%s starts at %s' % (title, start.strftime('%H:%M'))
|
line = '%s starts at %s' % (title, start.strftime('%H:%M'))
|
||||||
print 'Sending reminder:', line
|
print('Sending reminder:', line)
|
||||||
messages.append(line)
|
messages.append(line)
|
||||||
keys.add(key)
|
keys.add(key)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -62,7 +63,7 @@ def process_logs():
|
||||||
file_data = last_data.get(log_file, {})
|
file_data = last_data.get(log_file, {})
|
||||||
if not os.path.exists(log_file):
|
if not os.path.exists(log_file):
|
||||||
# If the file doesn't exist, log an error and then move on to the next file
|
# If the file doesn't exist, log an error and then move on to the next file
|
||||||
print "Log file does not exist or could not stat log file: %s" % (log_file,)
|
print("Log file does not exist or could not stat log file: %s" % (log_file,))
|
||||||
continue
|
continue
|
||||||
length = int(subprocess.check_output(["wc", "-l", log_file]).split()[0])
|
length = int(subprocess.check_output(["wc", "-l", log_file]).split()[0])
|
||||||
if file_data.get("last") is None:
|
if file_data.get("last") is None:
|
||||||
|
@ -82,7 +83,7 @@ def process_logs():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if os.path.exists(lock_path):
|
if os.path.exists(lock_path):
|
||||||
print "Log2zulip lock held; not doing anything"
|
print("Log2zulip lock held; not doing anything")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -91,7 +92,7 @@ if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
log_files = ujson.loads(file(control_path, "r").read())
|
log_files = ujson.loads(file(control_path, "r").read())
|
||||||
except Exception:
|
except Exception:
|
||||||
print "Could not load control data from %s" % (control_path,)
|
print("Could not load control data from %s" % (control_path,))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
process_logs()
|
process_logs()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -80,18 +81,18 @@ try:
|
||||||
cmd += ' '.join(test_files)
|
cmd += ' '.join(test_files)
|
||||||
else:
|
else:
|
||||||
cmd += 'frontend_tests/casper_tests'
|
cmd += 'frontend_tests/casper_tests'
|
||||||
print "Running %s" % (cmd,)
|
print("Running %s" % (cmd,))
|
||||||
ret = subprocess.call(cmd, shell=True)
|
ret = subprocess.call(cmd, shell=True)
|
||||||
finally:
|
finally:
|
||||||
assert_server_running()
|
assert_server_running()
|
||||||
server.terminate()
|
server.terminate()
|
||||||
|
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print >>sys.stderr, """
|
print("""
|
||||||
Oops, the frontend tests failed. Tips for debugging:
|
Oops, the frontend tests failed. Tips for debugging:
|
||||||
* Check the frontend test server logs at frontend_tests/casper_tests/server.log
|
* Check the frontend test server logs at frontend_tests/casper_tests/server.log
|
||||||
* Check the screenshots of failed tests at /tmp/casper-failure*.png
|
* Check the screenshots of failed tests at /tmp/casper-failure*.png
|
||||||
* Try remote debugging the test web browser as described in docs/testing.rst
|
* Try remote debugging the test web browser as described in docs/testing.rst
|
||||||
"""
|
""", file=sys.stderr)
|
||||||
|
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"""
|
"""
|
||||||
Nagios plugin to check that none of our queue workers have reported errors.
|
Nagios plugin to check that none of our queue workers have reported errors.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('/home/zulip/deployments/current')
|
sys.path.append('/home/zulip/deployments/current')
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"""
|
"""
|
||||||
Nagios plugin to check the length of the FTS update log.
|
Nagios plugin to check the length of the FTS update log.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def report(state, num):
|
def report(state, num):
|
||||||
print "%s: %s rows in fts_update_log table" % (state, num)
|
print("%s: %s rows in fts_update_log table" % (state, num))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
conn = psycopg2.connect("user=zulip")
|
conn = psycopg2.connect("user=zulip")
|
||||||
|
|
|
@ -8,6 +8,7 @@ This script works by just monitoring the files under
|
||||||
mirrors when they receive the messages sent every minute by
|
mirrors when they receive the messages sent every minute by
|
||||||
/etc/cron.d/test_zephyr_personal_mirrors
|
/etc/cron.d/test_zephyr_personal_mirrors
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -22,7 +23,7 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def report(state, output):
|
def report(state, output):
|
||||||
print "%s\n%s" % (state, output)
|
print("%s\n%s" % (state, output))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
output = ""
|
output = ""
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
Nagios plugin to check the difference between the primary and
|
Nagios plugin to check the difference between the primary and
|
||||||
secondary Postgres servers' xlog location.
|
secondary Postgres servers' xlog location.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
@ -16,7 +17,7 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def report(state, msg):
|
def report(state, msg):
|
||||||
print "%s: %s" % (state, msg)
|
print("%s: %s" % (state, msg))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
def get_loc_over_ssh(host, func):
|
def get_loc_over_ssh(host, func):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import pytz
|
import pytz
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -13,7 +14,7 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def report(state, msg):
|
def report(state, msg):
|
||||||
print "%s: %s" % (state, msg)
|
print("%s: %s" % (state, msg))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
if subprocess.check_output(['psql', 'postgres', '-t', '-c',
|
if subprocess.check_output(['psql', 'postgres', '-t', '-c',
|
||||||
|
|
|
@ -8,6 +8,7 @@ which is generated by bots/check-rabbitmq-consumers.
|
||||||
|
|
||||||
It is run by cron and can be found at bots/rabbitmq-numconsumers-crontab
|
It is run by cron and can be found at bots/rabbitmq-numconsumers-crontab
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -15,12 +16,12 @@ sys.path.append('/home/zulip/deployments/current')
|
||||||
from bots.cron_file_helper import nagios_from_file
|
from bots.cron_file_helper import nagios_from_file
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "Please pass the name of the consumer file to check"
|
print("Please pass the name of the consumer file to check")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
RESULTS_FILE = "/var/lib/nagios_state/check-rabbitmq-consumers-%s" % (sys.argv[1])
|
RESULTS_FILE = "/var/lib/nagios_state/check-rabbitmq-consumers-%s" % (sys.argv[1])
|
||||||
|
|
||||||
ret, result = nagios_from_file(RESULTS_FILE)
|
ret, result = nagios_from_file(RESULTS_FILE)
|
||||||
|
|
||||||
print result
|
print(result)
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -9,6 +9,7 @@ which is generated by bots/check-rabbitmq-queue.
|
||||||
|
|
||||||
It is run by cron and can be found at bots/rabbitmq-queuesize-crontab
|
It is run by cron and can be found at bots/rabbitmq-queuesize-crontab
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -18,5 +19,5 @@ from bots.cron_file_helper import nagios_from_file
|
||||||
RESULTS_FILE = "/var/lib/nagios_state/check-rabbitmq-results"
|
RESULTS_FILE = "/var/lib/nagios_state/check-rabbitmq-results"
|
||||||
ret, result = nagios_from_file(RESULTS_FILE)
|
ret, result = nagios_from_file(RESULTS_FILE)
|
||||||
|
|
||||||
print result
|
print(result)
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -8,6 +8,7 @@ It supports both munin and nagios outputs
|
||||||
It must be run on a machine that is using the live database for the
|
It must be run on a machine that is using the live database for the
|
||||||
Django ORM.
|
Django ORM.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
|
@ -42,23 +43,22 @@ parser.add_option('--munin',
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not options.nagios and not options.munin:
|
if not options.nagios and not options.munin:
|
||||||
print 'No output options specified! Please provide --munin or --nagios'
|
print('No output options specified! Please provide --munin or --nagios')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if len(args) > 2:
|
if len(args) > 2:
|
||||||
print usage
|
print(usage)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if options.munin:
|
if options.munin:
|
||||||
if len(args) and args[0] == 'config':
|
if len(args) and args[0] == 'config':
|
||||||
print \
|
print("""graph_title Send-Receive times
|
||||||
"""graph_title Send-Receive times
|
|
||||||
graph_info The number of seconds it takes to send and receive a message from the server
|
graph_info The number of seconds it takes to send and receive a message from the server
|
||||||
graph_args -u 5 -l 0
|
graph_args -u 5 -l 0
|
||||||
graph_vlabel RTT (seconds)
|
graph_vlabel RTT (seconds)
|
||||||
sendreceive.label Send-receive round trip time
|
sendreceive.label Send-receive round trip time
|
||||||
sendreceive.warning 3
|
sendreceive.warning 3
|
||||||
sendreceive.critical 5"""
|
sendreceive.critical 5""")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
sys.path.append('/home/zulip/deployments/current/api')
|
sys.path.append('/home/zulip/deployments/current/api')
|
||||||
|
@ -81,9 +81,9 @@ states = {
|
||||||
|
|
||||||
def report(state, time, msg=None):
|
def report(state, time, msg=None):
|
||||||
if msg:
|
if msg:
|
||||||
print "%s: %s" % (state, msg)
|
print("%s: %s" % (state, msg))
|
||||||
else:
|
else:
|
||||||
print "%s: send time was %s" % (state, time)
|
print("%s: send time was %s" % (state, time))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
def send_zulip(sender, message):
|
def send_zulip(sender, message):
|
||||||
|
@ -148,7 +148,7 @@ while msg_to_send not in msg_content:
|
||||||
|
|
||||||
msg_content = [m['content'] for m in messages]
|
msg_content = [m['content'] for m in messages]
|
||||||
|
|
||||||
print zulip_recipient.deregister(queue_id)
|
print(zulip_recipient.deregister(queue_id))
|
||||||
|
|
||||||
if options.nagios:
|
if options.nagios:
|
||||||
if time_diff.seconds > 3:
|
if time_diff.seconds > 3:
|
||||||
|
@ -157,6 +157,6 @@ if options.nagios:
|
||||||
report('CRITICAL', time_diff)
|
report('CRITICAL', time_diff)
|
||||||
|
|
||||||
if options.munin:
|
if options.munin:
|
||||||
print "sendreceive.value %s" % total_seconds(time_diff)
|
print("sendreceive.value %s" % total_seconds(time_diff))
|
||||||
elif options.nagios:
|
elif options.nagios:
|
||||||
report('OK', time_diff)
|
report('OK', time_diff)
|
||||||
|
|
|
@ -6,6 +6,7 @@ Nagios plugin to check that our MIT users' Zephyr mirrors are running.
|
||||||
It must be run on a machine that is using the live database for the
|
It must be run on a machine that is using the live database for the
|
||||||
Django ORM.
|
Django ORM.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
@ -37,7 +38,7 @@ def report(state, short_msg, too_old=None):
|
||||||
user.last_visit.strftime("%Y-%m-%d %H:%M %Z")
|
user.last_visit.strftime("%Y-%m-%d %H:%M %Z")
|
||||||
) for user in too_old]
|
) for user in too_old]
|
||||||
)
|
)
|
||||||
print "%s: %s%s" % (state, short_msg, too_old_data)
|
print("%s: %s%s" % (state, short_msg, too_old_data))
|
||||||
|
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ itself lives in api/bots/check-mirroring and should be run out of cron.
|
||||||
|
|
||||||
See bots/zephyr-mirror-crontab for the crontab details.
|
See bots/zephyr-mirror-crontab for the crontab details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -22,9 +23,9 @@ states = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def report(state, data, last_check):
|
def report(state, data, last_check):
|
||||||
print "%s: Last test run completed at %s\n%s" % (
|
print("%s: Last test run completed at %s\n%s" % (
|
||||||
state, time.strftime("%Y-%m-%d %H:%M %Z", time.gmtime(last_check)),
|
state, time.strftime("%Y-%m-%d %H:%M %Z", time.gmtime(last_check)),
|
||||||
data)
|
data))
|
||||||
exit(states[state])
|
exit(states[state])
|
||||||
|
|
||||||
data = file(RESULTS_FILE).read().strip()
|
data = file(RESULTS_FILE).read().strip()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -12,7 +13,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', ".."))
|
||||||
from zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path
|
from zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC
|
print(FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
tarball_path = sys.argv[1]
|
tarball_path = sys.argv[1]
|
||||||
|
@ -27,5 +28,5 @@ subprocess.check_call(["ln", "-nsf", "/etc/zulip/settings.py",
|
||||||
os.path.join(deploy_path, "zproject/local_settings.py")])
|
os.path.join(deploy_path, "zproject/local_settings.py")])
|
||||||
subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "next")])
|
subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "next")])
|
||||||
|
|
||||||
print deploy_path
|
print(deploy_path)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
@ -20,7 +21,7 @@ if os.getuid() != 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC
|
print(FAIL + "Usage: %s <tarball>" % (sys.argv[0],) + ENDC)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
tarball_path = sys.argv[1]
|
tarball_path = sys.argv[1]
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# version of Zulip to the new version. upgrade-zulip-stage-2 is
|
# version of Zulip to the new version. upgrade-zulip-stage-2 is
|
||||||
# always run from the new version of Zulip, so any bug fixes take
|
# always run from the new version of Zulip, so any bug fixes take
|
||||||
# effect on the very next upgrade.
|
# effect on the very next upgrade.
|
||||||
|
from __future__ import print_function
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -22,7 +23,7 @@ if os.getuid() != 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print FAIL + "Usage: %s <deploy path>" % (sys.argv[0],) + ENDC
|
print(FAIL + "Usage: %s <deploy path>" % (sys.argv[0],) + ENDC)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
deploy_path = sys.argv[1]
|
deploy_path = sys.argv[1]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pwd
|
import pwd
|
||||||
|
@ -42,4 +43,4 @@ if using_sso.strip() == 'True':
|
||||||
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])
|
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])
|
||||||
|
|
||||||
logging.info("Done!")
|
logging.info("Done!")
|
||||||
print OKGREEN + "Application restarted successfully!" + ENDC
|
print(OKGREEN + "Application restarted successfully!" + ENDC)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
@ -36,12 +37,12 @@ def run_forever():
|
||||||
changed = True
|
changed = True
|
||||||
mtimes[fn] = new_mtime
|
mtimes[fn] = new_mtime
|
||||||
if changed:
|
if changed:
|
||||||
print 'Recompiling templates'
|
print('Recompiling templates')
|
||||||
try:
|
try:
|
||||||
run()
|
run()
|
||||||
print 'done'
|
print('done')
|
||||||
except:
|
except:
|
||||||
print '\n\n\nPLEASE FIX!!\n\n'
|
print('\n\n\nPLEASE FIX!!\n\n')
|
||||||
time.sleep(0.200)
|
time.sleep(0.200)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
### (to static/third/gemoji/images/)
|
### (to static/third/gemoji/images/)
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('zulip')
|
sys.path.append('zulip')
|
||||||
import os
|
import os
|
||||||
|
@ -35,7 +36,7 @@ parser.add_option('--count', default=5)
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.streams == "":
|
if options.streams == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print("Usage:", parser.usage, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
client.add_subscriptions([{"name": stream_name} for stream_name in
|
client.add_subscriptions([{"name": stream_name} for stream_name in
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# This is tool for injecting messages during a usability study. It's
|
# This is tool for injecting messages during a usability study. It's
|
||||||
# likely useless for other applications.
|
# likely useless for other applications.
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -68,15 +69,15 @@ def send_message(character, text, subject):
|
||||||
'subject': truncate(subject, 60)}
|
'subject': truncate(subject, 60)}
|
||||||
response = client.send_message(request)
|
response = client.send_message(request)
|
||||||
if response['result'] != 'success':
|
if response['result'] != 'success':
|
||||||
print "Could not send message (API Key " + characters[character]["api-key"] + "):"
|
print("Could not send message (API Key " + characters[character]["api-key"] + "):")
|
||||||
print " Request:", request
|
print(" Request:", request)
|
||||||
print " Response:", response
|
print(" Response:", response)
|
||||||
exit(1)
|
exit(1)
|
||||||
last_character = character
|
last_character = character
|
||||||
|
|
||||||
num_messages_sent += 1
|
num_messages_sent += 1
|
||||||
if num_messages_sent % 100 == 0:
|
if num_messages_sent % 100 == 0:
|
||||||
print "Sent %s messages" % (num_messages_sent,)
|
print("Sent %s messages" % (num_messages_sent,))
|
||||||
|
|
||||||
def maybe_assign_character(character):
|
def maybe_assign_character(character):
|
||||||
global characters
|
global characters
|
||||||
|
@ -115,4 +116,4 @@ for line in play:
|
||||||
send_message(next_character, next_message, subject)
|
send_message(next_character, next_message, subject)
|
||||||
next_message = ''
|
next_message = ''
|
||||||
|
|
||||||
print "Sent %s messages" % (num_messages_sent,)
|
print("Sent %s messages" % (num_messages_sent,))
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
# Author: Greg Price <price@ksplice.com>
|
# Author: Greg Price <price@ksplice.com>
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
## CC_EMAIL: All review requests will be CC'd here.
|
## CC_EMAIL: All review requests will be CC'd here.
|
||||||
CC_EMAIL = 'listname@example.com'
|
CC_EMAIL = 'listname@example.com'
|
||||||
|
@ -172,22 +173,22 @@ def make_header(repo, opts, revs):
|
||||||
always=True).split()
|
always=True).split()
|
||||||
local_name = unicode(local_name, "utf-8")
|
local_name = unicode(local_name, "utf-8")
|
||||||
if local_name == "undefined":
|
if local_name == "undefined":
|
||||||
print >>sys.stderr, "ERROR: Can't find this commit in remote or identify local branch!"
|
print("ERROR: Can't find this commit in remote or identify local branch!", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
email_basename = get_current_user_email(repo).split("@")[0]
|
email_basename = get_current_user_email(repo).split("@")[0]
|
||||||
if local_name.startswith("%s-" % (email_basename,)):
|
if local_name.startswith("%s-" % (email_basename,)):
|
||||||
# Try to push the local branch to the remote automatically
|
# Try to push the local branch to the remote automatically
|
||||||
try:
|
try:
|
||||||
print "Attempting to push %s to remote %s" % (local_name, remote)
|
print("Attempting to push %s to remote %s" % (local_name, remote))
|
||||||
repo.git.push(remote, local_name)
|
repo.git.push(remote, local_name)
|
||||||
tip_name = '%s (%s)' % (local_name, revs[-1].hexsha[:7])
|
tip_name = '%s (%s)' % (local_name, revs[-1].hexsha[:7])
|
||||||
except git.GitCommandError as e:
|
except git.GitCommandError as e:
|
||||||
print >>sys.stderr, "ERROR: Couldn't push %s to remote" % (local_name,)
|
print("ERROR: Couldn't push %s to remote" % (local_name,), file=sys.stderr)
|
||||||
print >>sys.stderr, e
|
print(e, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, "ERROR: Can't find this commit in remote -- did you push %s?" % (local_name)
|
print("ERROR: Can't find this commit in remote -- did you push %s?" % (local_name), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
objective_summary = '%d commit(s) to %s' % (len(revs), tip_name)
|
objective_summary = '%d commit(s) to %s' % (len(revs), tip_name)
|
||||||
|
@ -204,44 +205,44 @@ def make_header(repo, opts, revs):
|
||||||
def write_template(target, repo, opts):
|
def write_template(target, repo, opts):
|
||||||
me = get_current_user(repo)
|
me = get_current_user(repo)
|
||||||
|
|
||||||
print >>target, 'Dear %s,' % ", ".join(opts.reviewers)
|
print('Dear %s,' % ", ".join(opts.reviewers), file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
print >>target, 'At your convenience, please review the following commits.'
|
print('At your convenience, please review the following commits.', file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
if opts.message:
|
if opts.message:
|
||||||
print >>target, opts.message
|
print(opts.message, file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
print >>target, 'Testing:'
|
print('Testing:', file=target)
|
||||||
if opts.testing:
|
if opts.testing:
|
||||||
print >>target, opts.testing
|
print(opts.testing, file=target)
|
||||||
else:
|
else:
|
||||||
print >>target, '(No formal testing done, or none specified.)'
|
print('(No formal testing done, or none specified.)', file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
print >>target, 'Thanks,'
|
print('Thanks,', file=target)
|
||||||
print >>target, me
|
print(me, file=target)
|
||||||
|
|
||||||
|
|
||||||
def write_commitmsg(target, repo, opts, revs):
|
def write_commitmsg(target, repo, opts, revs):
|
||||||
|
|
||||||
if opts.format == 'oneline':
|
if opts.format == 'oneline':
|
||||||
for r in revs:
|
for r in revs:
|
||||||
print >>target, unicode(repo.git.log('-n1', '--oneline', r), 'utf-8', 'replace')
|
print(unicode(repo.git.log('-n1', '--oneline', r), 'utf-8', 'replace'), file=target)
|
||||||
elif opts.format == 'message' or opts.format is None and len(revs) > 1:
|
elif opts.format == 'message' or opts.format is None and len(revs) > 1:
|
||||||
for r in revs:
|
for r in revs:
|
||||||
if opts.first_parent:
|
if opts.first_parent:
|
||||||
print >>target, unicode(repo.git.log('-n1', r), 'utf-8', 'replace')
|
print(unicode(repo.git.log('-n1', r), 'utf-8', 'replace'), file=target)
|
||||||
print >>target, unicode(repo.git.diff('--stat', str(r)+'^', r), 'utf-8', 'replace')
|
print(unicode(repo.git.diff('--stat', str(r)+'^', r), 'utf-8', 'replace'), file=target)
|
||||||
else:
|
else:
|
||||||
print >>target, unicode(repo.git.log('-n1', '--stat', r), 'utf-8', 'replace')
|
print(unicode(repo.git.log('-n1', '--stat', r), 'utf-8', 'replace'), file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
elif opts.format == 'patch' or opts.format is None and len(revs) == 1:
|
elif opts.format == 'patch' or opts.format is None and len(revs) == 1:
|
||||||
for r in revs:
|
for r in revs:
|
||||||
if opts.first_parent:
|
if opts.first_parent:
|
||||||
print >>target, unicode(repo.git.log('-n1', r), 'utf-8', 'replace')
|
print(unicode(repo.git.log('-n1', r), 'utf-8', 'replace'), file=target)
|
||||||
print >>target, unicode(repo.git.diff('--stat', '-p', str(r)+'^', r), 'utf-8', 'replace')
|
print(unicode(repo.git.diff('--stat', '-p', str(r)+'^', r), 'utf-8', 'replace'), file=target)
|
||||||
else:
|
else:
|
||||||
print >>target, unicode(repo.git.log('-n1', '--stat', '-p', r), 'utf-8', 'replace')
|
print(unicode(repo.git.log('-n1', '--stat', '-p', r), 'utf-8', 'replace'), file=target)
|
||||||
print >>target
|
print(file=target)
|
||||||
else:
|
else:
|
||||||
raise Exception("Bad format option.")
|
raise Exception("Bad format option.")
|
||||||
|
|
||||||
|
@ -257,15 +258,15 @@ def edit(repo, opts, revs, headers):
|
||||||
|
|
||||||
# Prepare editable buffer.
|
# Prepare editable buffer.
|
||||||
|
|
||||||
print >>temp, """# This is an editable review request. All lines beginning with # will
|
print("""# This is an editable review request. All lines beginning with # will
|
||||||
# be ignored. To abort the commit, remove all lines from this buffer."""
|
# be ignored. To abort the commit, remove all lines from this buffer.""", file=temp)
|
||||||
print >>temp, "#"
|
print("#", file=temp)
|
||||||
for (key, value) in headers:
|
for (key, value) in headers:
|
||||||
print >>temp, u"# %s: %s" % (key, value)
|
print(u"# %s: %s" % (key, value), file=temp)
|
||||||
print >>temp
|
print(file=temp)
|
||||||
print >>temp, template.getvalue()
|
print(template.getvalue(), file=temp)
|
||||||
for line in commitmsg.getvalue().splitlines():
|
for line in commitmsg.getvalue().splitlines():
|
||||||
print >>temp, "# " + line
|
print("# " + line, file=temp)
|
||||||
temp.flush()
|
temp.flush()
|
||||||
|
|
||||||
# Open EDITOR to edit buffer.
|
# Open EDITOR to edit buffer.
|
||||||
|
@ -276,7 +277,7 @@ def edit(repo, opts, revs, headers):
|
||||||
# Check if buffer is empty, and if so abort.
|
# Check if buffer is empty, and if so abort.
|
||||||
|
|
||||||
if (os.path.getsize(temp.name) == 0):
|
if (os.path.getsize(temp.name) == 0):
|
||||||
print >>sys.stderr, "Aborting due to empty buffer."
|
print("Aborting due to empty buffer.", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
# Reopen temp file, slurp it in, and reconstruct mail.
|
# Reopen temp file, slurp it in, and reconstruct mail.
|
||||||
|
@ -301,7 +302,7 @@ def edit(repo, opts, revs, headers):
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def clone_to_tmp(repo, tmp_path, test_existence_only=False):
|
def clone_to_tmp(repo, tmp_path, test_existence_only=False):
|
||||||
print "Cloning into", tmp_path
|
print("Cloning into", tmp_path)
|
||||||
assert not os.path.exists(tmp_path), \
|
assert not os.path.exists(tmp_path), \
|
||||||
'Path ' + tmp_path + ' exists. Either another test is running there ' \
|
'Path ' + tmp_path + ' exists. Either another test is running there ' \
|
||||||
'or it was left there so that you could view the testing log. If you are sure ' \
|
'or it was left there so that you could view the testing log. If you are sure ' \
|
||||||
|
@ -313,7 +314,7 @@ def clone_to_tmp(repo, tmp_path, test_existence_only=False):
|
||||||
return clone
|
return clone
|
||||||
|
|
||||||
def cleanup_tmp(cloned_repo):
|
def cleanup_tmp(cloned_repo):
|
||||||
print "Cleaning up..."
|
print("Cleaning up...")
|
||||||
assert os.path.exists(cloned_repo.working_tree_dir), "could not find " + cloned_repo.working_tree_dir
|
assert os.path.exists(cloned_repo.working_tree_dir), "could not find " + cloned_repo.working_tree_dir
|
||||||
rmtree(cloned_repo.working_tree_dir)
|
rmtree(cloned_repo.working_tree_dir)
|
||||||
return
|
return
|
||||||
|
@ -337,7 +338,7 @@ def run_test_script(repo, tmp_path):
|
||||||
os.environ["PWD"] = os.getcwd()
|
os.environ["PWD"] = os.getcwd()
|
||||||
log = open("test.log", 'w')
|
log = open("test.log", 'w')
|
||||||
log_path = os.getcwd() + "/" + log.name
|
log_path = os.getcwd() + "/" + log.name
|
||||||
print "Testing [log=%s] ..." % (log_path,)
|
print("Testing [log=%s] ..." % (log_path,))
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(TEST_SCRIPT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=sys.stdin)
|
proc = subprocess.Popen(TEST_SCRIPT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=sys.stdin)
|
||||||
# Set the proc.stdout.read() to be non-blocking
|
# Set the proc.stdout.read() to be non-blocking
|
||||||
|
@ -358,8 +359,8 @@ def run_test_script(repo, tmp_path):
|
||||||
continue
|
continue
|
||||||
sleep(.5)
|
sleep(.5)
|
||||||
except KeyboardInterrupt as e:
|
except KeyboardInterrupt as e:
|
||||||
print "\nkilling tests..."
|
print("\nkilling tests...")
|
||||||
print "You may find the testing log in", log_path
|
print("You may find the testing log in", log_path)
|
||||||
proc.send_signal(SIGINT)
|
proc.send_signal(SIGINT)
|
||||||
sleep(2)
|
sleep(2)
|
||||||
proc.send_signal(SIGTERM)
|
proc.send_signal(SIGTERM)
|
||||||
|
@ -372,8 +373,8 @@ def run_test_script(repo, tmp_path):
|
||||||
sys.stdout.write(buf)
|
sys.stdout.write(buf)
|
||||||
log.write(buf)
|
log.write(buf)
|
||||||
if proc.returncode!=0:
|
if proc.returncode!=0:
|
||||||
print TEST_SCRIPT, "exited with status code", proc.returncode
|
print(TEST_SCRIPT, "exited with status code", proc.returncode)
|
||||||
print "You may find the testing log in", log_path
|
print("You may find the testing log in", log_path)
|
||||||
else:
|
else:
|
||||||
os.chdir(working_dir)
|
os.chdir(working_dir)
|
||||||
os.environ["PWD"] = os.getcwd()
|
os.environ["PWD"] = os.getcwd()
|
||||||
|
@ -385,19 +386,19 @@ def main(args):
|
||||||
repo = git.Repo()
|
repo = git.Repo()
|
||||||
revs = parse_revs(repo, opts, args[1:])
|
revs = parse_revs(repo, opts, args[1:])
|
||||||
if not revs:
|
if not revs:
|
||||||
print >>sys.stderr, '%s: no revisions specified' % os.path.basename(args[0])
|
print('%s: no revisions specified' % os.path.basename(args[0]), file=sys.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
if not opts.stdout:
|
if not opts.stdout:
|
||||||
client = zulip.Client(verbose=True, client="ZulipReview/0.1")
|
client = zulip.Client(verbose=True, client="ZulipReview/0.1")
|
||||||
|
|
||||||
if 'staging' in client.base_url:
|
if 'staging' in client.base_url:
|
||||||
print '''
|
print('''
|
||||||
|
|
||||||
HEY! You still have your .zuliprc pointing to staging.
|
HEY! You still have your .zuliprc pointing to staging.
|
||||||
ABORTING
|
ABORTING
|
||||||
|
|
||||||
'''
|
''')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Attempt to catch permissions/invalid paths early for tmp_dir
|
# Attempt to catch permissions/invalid paths early for tmp_dir
|
||||||
|
@ -438,15 +439,15 @@ def main(args):
|
||||||
if testing_status_code != 0:
|
if testing_status_code != 0:
|
||||||
commit_message_path = opts.tmp_dir + "/commit.msg"
|
commit_message_path = opts.tmp_dir + "/commit.msg"
|
||||||
open(commit_message_path, 'w').write(msg.get_payload(decode=True))
|
open(commit_message_path, 'w').write(msg.get_payload(decode=True))
|
||||||
print "You may find your commit message at", commit_message_path
|
print("You may find your commit message at", commit_message_path)
|
||||||
|
|
||||||
print "Processing review message..."
|
print("Processing review message...")
|
||||||
# Send or print the message, as appropriate.
|
# Send or print the message, as appropriate.
|
||||||
if opts.stdout:
|
if opts.stdout:
|
||||||
for (key, value) in msg.items():
|
for (key, value) in msg.items():
|
||||||
print >>sys.stdout, u"%s: %s" % (key, value)
|
print(u"%s: %s" % (key, value), file=sys.stdout)
|
||||||
print >>sys.stdout
|
print(file=sys.stdout)
|
||||||
print >>sys.stdout, msg.get_payload(decode=True),
|
print(msg.get_payload(decode=True), end=' ', file=sys.stdout)
|
||||||
else:
|
else:
|
||||||
reviewer_usernames = [x.split("@")[0] for x in opts.reviewers]
|
reviewer_usernames = [x.split("@")[0] for x in opts.reviewers]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
@ -98,9 +99,9 @@ def parse_file(fn):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for fn in sys.argv[1:]:
|
for fn in sys.argv[1:]:
|
||||||
print '===', fn
|
print('===', fn)
|
||||||
root = parse_file(fn)
|
root = parse_file(fn)
|
||||||
debug(root)
|
debug(root)
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -127,10 +128,10 @@ def custom_check_file(fn, rules, skip_rules=[]):
|
||||||
try:
|
try:
|
||||||
if re.search(rule['pattern'], line.strip(rule.get('strip', None))):
|
if re.search(rule['pattern'], line.strip(rule.get('strip', None))):
|
||||||
sys.stdout.write(rule['description'] + ' at %s line %s:\n' % (fn, i+1))
|
sys.stdout.write(rule['description'] + ' at %s line %s:\n' % (fn, i+1))
|
||||||
print line
|
print(line)
|
||||||
failed = True
|
failed = True
|
||||||
except Exception:
|
except Exception:
|
||||||
print "Exception with %s at %s line %s" % (rule['pattern'], fn, i+1)
|
print("Exception with %s at %s line %s" % (rule['pattern'], fn, i+1))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return failed
|
return failed
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# Minifies JavaScripts, creating source maps
|
# Minifies JavaScripts, creating source maps
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -48,7 +49,7 @@ def get_changed_source_files(other_checkout):
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If git returned an error, assume we can't reuse any files, and
|
# If git returned an error, assume we can't reuse any files, and
|
||||||
# regenerate everything.
|
# regenerate everything.
|
||||||
print "Warning: git returned an error when comparing to the previous"
|
print("Warning: git returned an error when comparing to the previous")
|
||||||
print ("deploy in %s. Will re-minify JavaScript instead of reusing"
|
print ("deploy in %s. Will re-minify JavaScript instead of reusing"
|
||||||
% (other_checkout,))
|
% (other_checkout,))
|
||||||
return None
|
return None
|
||||||
|
@ -82,8 +83,8 @@ CLOSURE_BINARY = '/usr/bin/closure-compiler'
|
||||||
if not os.path.exists(CLOSURE_BINARY):
|
if not os.path.exists(CLOSURE_BINARY):
|
||||||
CLOSURE_BINARY = 'tools/closure-compiler/run'
|
CLOSURE_BINARY = 'tools/closure-compiler/run'
|
||||||
if not os.path.exists(CLOSURE_BINARY):
|
if not os.path.exists(CLOSURE_BINARY):
|
||||||
print "closure-compiler not installed; the Vagrant provision.py installs it via apt "\
|
print("closure-compiler not installed; the Vagrant provision.py installs it via apt "\
|
||||||
"or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to tools/closure-compiler"
|
"or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to tools/closure-compiler")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Where to put minified JS and source maps
|
# Where to put minified JS and source maps
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#
|
#
|
||||||
# see contrib/hooks/ for a sample
|
# see contrib/hooks/ for a sample
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -73,6 +74,6 @@ for ln in sys.stdin:
|
||||||
commits = subprocess.check_output(["git", "log", "%s..%s" % (oldrev, newrev)])
|
commits = subprocess.check_output(["git", "log", "%s..%s" % (oldrev, newrev)])
|
||||||
|
|
||||||
if '[schema]' in commits:
|
if '[schema]' in commits:
|
||||||
print
|
print()
|
||||||
print FAIL + "Schema change detected! Please make the appropriate changes manually." + ENDC
|
print(FAIL + "Schema change detected! Please make the appropriate changes manually." + ENDC)
|
||||||
print
|
print()
|
||||||
|
|
|
@ -81,6 +81,7 @@ Qual a diferen
|
||||||
São enviados os cabeçalhos HTTP "Proxy-agent" e "HTTP_X_FORWARDED_FOR".
|
São enviados os cabeçalhos HTTP "Proxy-agent" e "HTTP_X_FORWARDED_FOR".
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import socket, thread, select
|
import socket, thread, select
|
||||||
PORT = 8085
|
PORT = 8085
|
||||||
|
@ -115,7 +116,7 @@ class ConnectionHandler:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def method_CONNECT(self):
|
def method_CONNECT(self):
|
||||||
print 'self.path', self.path
|
print('self.path', self.path)
|
||||||
self._connect_target(self.path)
|
self._connect_target(self.path)
|
||||||
self.client.send(HTTPVER+' 200 Connection established\n'+
|
self.client.send(HTTPVER+' 200 Connection established\n'+
|
||||||
'Proxy-agent: %s\n\n'%VERSION)
|
'Proxy-agent: %s\n\n'%VERSION)
|
||||||
|
@ -123,28 +124,28 @@ class ConnectionHandler:
|
||||||
self._read_write()
|
self._read_write()
|
||||||
|
|
||||||
def method_others(self):
|
def method_others(self):
|
||||||
print
|
print()
|
||||||
print '====================================='
|
print('=====================================')
|
||||||
print 'method', self.method
|
print('method', self.method)
|
||||||
print 'protocol', self.protocol
|
print('protocol', self.protocol)
|
||||||
print 'self.path', self.path
|
print('self.path', self.path)
|
||||||
print
|
print()
|
||||||
|
|
||||||
horking = False
|
horking = False
|
||||||
if horking:
|
if horking:
|
||||||
if self.path.endswith('.js'):
|
if self.path.endswith('.js'):
|
||||||
print 'HORKING JS!!!!!!!'
|
print('HORKING JS!!!!!!!')
|
||||||
print
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.path.endswith('.png'):
|
if self.path.endswith('.png'):
|
||||||
print 'HORKING PNG!!!!!!!'
|
print('HORKING PNG!!!!!!!')
|
||||||
print
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.path.endswith('.css'):
|
if self.path.endswith('.css'):
|
||||||
print 'HORKING CSS!!!!!!!'
|
print('HORKING CSS!!!!!!!')
|
||||||
print
|
print()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._connect_target()
|
self._connect_target()
|
||||||
|
@ -160,7 +161,7 @@ class ConnectionHandler:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
print repr(line)
|
print(repr(line))
|
||||||
field, value = line.split(':', 1)
|
field, value = line.split(':', 1)
|
||||||
if line.startswith('Host:'):
|
if line.startswith('Host:'):
|
||||||
line = line.replace(str(PORT), '9991')
|
line = line.replace(str(PORT), '9991')
|
||||||
|
@ -173,10 +174,10 @@ class ConnectionHandler:
|
||||||
buf = buf.replace('\n', '\r\n')
|
buf = buf.replace('\n', '\r\n')
|
||||||
self.target.send(buf)
|
self.target.send(buf)
|
||||||
if rest:
|
if rest:
|
||||||
print 'REST'
|
print('REST')
|
||||||
print repr(self.client_buffer)
|
print(repr(self.client_buffer))
|
||||||
print repr(buf)
|
print(repr(buf))
|
||||||
print repr(rest)
|
print(repr(rest))
|
||||||
self.target.send(rest)
|
self.target.send(rest)
|
||||||
|
|
||||||
self.client_buffer = ''
|
self.client_buffer = ''
|
||||||
|
@ -187,9 +188,9 @@ class ConnectionHandler:
|
||||||
port = 9991
|
port = 9991
|
||||||
(soc_family, _, _, _, address) = socket.getaddrinfo(host, port)[0]
|
(soc_family, _, _, _, address) = socket.getaddrinfo(host, port)[0]
|
||||||
self.target = socket.socket(soc_family)
|
self.target = socket.socket(soc_family)
|
||||||
print 'Connecting...', host, port
|
print('Connecting...', host, port)
|
||||||
self.target.connect(address)
|
self.target.connect(address)
|
||||||
print 'Connected'
|
print('Connected')
|
||||||
|
|
||||||
def _read_write(self):
|
def _read_write(self):
|
||||||
time_out_max = self.timeout/3
|
time_out_max = self.timeout/3
|
||||||
|
@ -207,19 +208,19 @@ class ConnectionHandler:
|
||||||
out = self.target
|
out = self.target
|
||||||
else:
|
else:
|
||||||
if data:
|
if data:
|
||||||
print
|
print()
|
||||||
print 'OUT'
|
print('OUT')
|
||||||
print 'path =', self.path
|
print('path =', self.path)
|
||||||
print len(data)
|
print(len(data))
|
||||||
print repr(data)
|
print(repr(data))
|
||||||
print
|
print()
|
||||||
out = self.client
|
out = self.client
|
||||||
# super hacky and fragile
|
# super hacky and fragile
|
||||||
data = data.replace('9991', str(PORT))
|
data = data.replace('9991', str(PORT))
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
if '400 Bad Request' in data:
|
if '400 Bad Request' in data:
|
||||||
print 'DONE!'
|
print('DONE!')
|
||||||
import sys; sys.exit(1)
|
import sys; sys.exit(1)
|
||||||
out.send(data)
|
out.send(data)
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -235,7 +236,7 @@ def start_server(host='localhost', port=PORT, IPv6=False, timeout=60,
|
||||||
soc = socket.socket(soc_type)
|
soc = socket.socket(soc_type)
|
||||||
soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
soc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
soc.bind((host, port))
|
soc.bind((host, port))
|
||||||
print "Serving on %s:%d." % (host, port) #debug
|
print("Serving on %s:%d." % (host, port)) #debug
|
||||||
soc.listen(0)
|
soc.listen(0)
|
||||||
while True:
|
while True:
|
||||||
thread.start_new_thread(handler, soc.accept()+(timeout,))
|
thread.start_new_thread(handler, soc.accept()+(timeout,))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -14,7 +15,7 @@ logging.basicConfig(format="%(asctime)s update-deployment: %(message)s",
|
||||||
level=logging.INFO)
|
level=logging.INFO)
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print FAIL + "Usage: update-deployment refname" + ENDC
|
print(FAIL + "Usage: update-deployment refname" + ENDC)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
refname = sys.argv[1]
|
refname = sys.argv[1]
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -48,7 +49,7 @@ parser.add_option('--stream', default='')
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
if options.stream == "":
|
if options.stream == "":
|
||||||
print >>sys.stderr, "Usage:", parser.usage
|
print("Usage:", parser.usage, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
client.add_subscriptions([{"name": options.stream}])
|
client.add_subscriptions([{"name": options.stream}])
|
||||||
|
@ -56,7 +57,7 @@ queue = client.register(event_types=['message'])
|
||||||
client._register('get_old_messages', method='GET', url='messages')
|
client._register('get_old_messages', method='GET', url='messages')
|
||||||
max_id = queue['max_message_id']
|
max_id = queue['max_message_id']
|
||||||
messages = []
|
messages = []
|
||||||
print "Fetching messages..."
|
print("Fetching messages...")
|
||||||
result = client.get_old_messages({'anchor': 0,
|
result = client.get_old_messages({'anchor': 0,
|
||||||
'num_before': 0,
|
'num_before': 0,
|
||||||
'num_after': max_id,
|
'num_after': max_id,
|
||||||
|
@ -64,8 +65,8 @@ result = client.get_old_messages({'anchor': 0,
|
||||||
'operand': options.stream}],
|
'operand': options.stream}],
|
||||||
'apply_markdown': False})
|
'apply_markdown': False})
|
||||||
if result['result'] != 'success':
|
if result['result'] != 'success':
|
||||||
print "Unfortunately, there was an error fetching some old messages."
|
print("Unfortunately, there was an error fetching some old messages.")
|
||||||
print result
|
print(result)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
for msg in result['messages']:
|
for msg in result['messages']:
|
||||||
if msg['type'] != 'stream':
|
if msg['type'] != 'stream':
|
||||||
|
@ -81,5 +82,5 @@ filename = "zulip-%s.json" % (options.stream,)
|
||||||
f = codecs.open(filename, encoding='utf-8', mode="wb")
|
f = codecs.open(filename, encoding='utf-8', mode="wb")
|
||||||
f.write(json.dumps(messages, indent=0, sort_keys=False))
|
f.write(json.dumps(messages, indent=0, sort_keys=False))
|
||||||
f.close()
|
f.close()
|
||||||
print "%d messages exported to %s" % (len(messages), filename,)
|
print("%d messages exported to %s" % (len(messages), filename,))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue