mirror of https://github.com/zulip/zulip.git
Annotate the rest of scripts in tools/.
This commit is contained in:
parent
75daba345a
commit
172809d4e2
|
@ -2,9 +2,11 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from typing import Any, Dict, Iterable
|
||||||
import ujson
|
import ujson
|
||||||
|
|
||||||
def analyze_url_coverage():
|
def analyze_url_coverage():
|
||||||
|
# type: () -> None
|
||||||
fn = 'var/url_coverage.txt' # TODO: make path more robust, maybe use json suffix
|
fn = 'var/url_coverage.txt' # TODO: make path more robust, maybe use json suffix
|
||||||
calls = []
|
calls = []
|
||||||
for line in open(fn):
|
for line in open(fn):
|
||||||
|
@ -15,6 +17,7 @@ def analyze_url_coverage():
|
||||||
show_which_tests_ran_endpoints(calls)
|
show_which_tests_ran_endpoints(calls)
|
||||||
|
|
||||||
def show_slow_endpoints(calls):
|
def show_slow_endpoints(calls):
|
||||||
|
# type: (Iterable[Dict[str, Any]]) -> None
|
||||||
tups = []
|
tups = []
|
||||||
for call in calls:
|
for call in calls:
|
||||||
tups.append((call['delay'], call['url'], call['method']))
|
tups.append((call['delay'], call['url'], call['method']))
|
||||||
|
@ -30,6 +33,7 @@ def show_slow_endpoints(calls):
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def show_best_coverage(calls):
|
def show_best_coverage(calls):
|
||||||
|
# type: (Iterable[Dict[str, Any]]) -> None
|
||||||
count = defaultdict(int) # type: Dict[str, int]
|
count = defaultdict(int) # type: Dict[str, int]
|
||||||
|
|
||||||
for call in calls:
|
for call in calls:
|
||||||
|
@ -46,6 +50,7 @@ def show_best_coverage(calls):
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def show_which_tests_ran_endpoints(calls):
|
def show_which_tests_ran_endpoints(calls):
|
||||||
|
# type: (Iterable[Dict[str, Any]]) -> None
|
||||||
test_name_dct = defaultdict(list) # type: Dict[str, List[str]]
|
test_name_dct = defaultdict(list) # type: Dict[str, List[str]]
|
||||||
|
|
||||||
for call in calls:
|
for call in calls:
|
||||||
|
|
|
@ -15,6 +15,8 @@ import os
|
||||||
import optparse
|
import optparse
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
|
from typing import IO
|
||||||
|
|
||||||
usage = """show-last-messages --user=<bot's email address> --api-key=<bot's api key> --count=<count>
|
usage = """show-last-messages --user=<bot's email address> --api-key=<bot's api key> --count=<count>
|
||||||
|
|
||||||
Shows the last <count> messages on all public streams.
|
Shows the last <count> messages on all public streams.
|
||||||
|
@ -55,6 +57,7 @@ if result['result'] != 'success':
|
||||||
f = codecs.open("output-candidate.html", encoding='utf-8', mode="wb")
|
f = codecs.open("output-candidate.html", encoding='utf-8', mode="wb")
|
||||||
|
|
||||||
def uniwrite(f, s):
|
def uniwrite(f, s):
|
||||||
|
# type: (IO, str) -> None
|
||||||
f.write(s)
|
f.write(s)
|
||||||
|
|
||||||
uniwrite(f, """
|
uniwrite(f, """
|
||||||
|
|
|
@ -7,6 +7,7 @@ import json
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
def debug(obj):
|
def debug(obj):
|
||||||
|
# type: (Any) -> None
|
||||||
print(json.dumps(obj, indent=4))
|
print(json.dumps(obj, indent=4))
|
||||||
|
|
||||||
def parse_file(fn):
|
def parse_file(fn):
|
||||||
|
|
|
@ -5,6 +5,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
# Prepare a PDF of the entire codebase, ready for printing.
|
# Prepare a PDF of the entire codebase, ready for printing.
|
||||||
#
|
#
|
||||||
# Depends on:
|
# Depends on:
|
||||||
|
@ -131,6 +133,7 @@ doc.close()
|
||||||
|
|
||||||
with open('tools/print-all/tex/epilogue.tex', 'w') as f:
|
with open('tools/print-all/tex/epilogue.tex', 'w') as f:
|
||||||
def print_list(title, xs):
|
def print_list(title, xs):
|
||||||
|
# type: (str, Iterable[str]) -> None
|
||||||
f.write('\\section*{%s}\n\n' % (title,))
|
f.write('\\section*{%s}\n\n' % (title,))
|
||||||
for x in xs:
|
for x in xs:
|
||||||
f.write('%s\n\n' % (x.replace('_', r'\_'),))
|
f.write('%s\n\n' % (x.replace('_', r'\_'),))
|
||||||
|
|
|
@ -14,12 +14,14 @@ os.chdir(settings.DEPLOY_ROOT)
|
||||||
STATIC_PATH = 'static/'
|
STATIC_PATH = 'static/'
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
# write the file to disk
|
# type: () -> None
|
||||||
|
"""Builds for production, writing the output to disk"""
|
||||||
subprocess.check_call(['tools/node', 'node_modules/.bin/webpack'] +
|
subprocess.check_call(['tools/node', 'node_modules/.bin/webpack'] +
|
||||||
['--config', 'tools/webpack.production.config.js'])
|
['--config', 'tools/webpack.production.config.js'])
|
||||||
|
|
||||||
def run_watch(port):
|
def run_watch(port):
|
||||||
# watch and rebuild on changes, serve file from memory via webpack-dev-server
|
# type: (str) -> None
|
||||||
|
"""watches and rebuilds on changes, serving files from memory via webpack-dev-server"""
|
||||||
subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] +
|
subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] +
|
||||||
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
|
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue