Annotate remaining scripts.
This commit is contained in:
parent
43bf07bf15
commit
2ed9f15ff7
|
@ -27,6 +27,7 @@ lock_path = "/var/tmp/log2zulip.lock"
|
||||||
control_path = "/etc/log2zulip.conf"
|
control_path = "/etc/log2zulip.conf"
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
|
# type: (str) -> None
|
||||||
# Python doesn't have an analog to `mkdir -p` < Python 3.2.
|
# Python doesn't have an analog to `mkdir -p` < Python 3.2.
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
@ -37,6 +38,7 @@ def mkdir_p(path):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def send_log_zulip(file_name, count, lines, extra=""):
|
def send_log_zulip(file_name, count, lines, extra=""):
|
||||||
|
# type: (str, int, List[str], str) -> None
|
||||||
content = "%s new errors%s:\n```\n%s\n```" % (count, extra, "\n".join(lines))
|
content = "%s new errors%s:\n```\n%s\n```" % (count, extra, "\n".join(lines))
|
||||||
zulip_client.send_message({
|
zulip_client.send_message({
|
||||||
"type": "stream",
|
"type": "stream",
|
||||||
|
@ -46,6 +48,7 @@ def send_log_zulip(file_name, count, lines, extra=""):
|
||||||
})
|
})
|
||||||
|
|
||||||
def process_lines(raw_lines, file_name):
|
def process_lines(raw_lines, file_name):
|
||||||
|
# type: (List[str], str) -> None
|
||||||
lines = []
|
lines = []
|
||||||
for line in raw_lines:
|
for line in raw_lines:
|
||||||
# Add any filtering or modification code here
|
# Add any filtering or modification code here
|
||||||
|
@ -61,6 +64,7 @@ def process_lines(raw_lines, file_name):
|
||||||
send_log_zulip(file_name, len(lines), lines)
|
send_log_zulip(file_name, len(lines), lines)
|
||||||
|
|
||||||
def process_logs():
|
def process_logs():
|
||||||
|
# type: () -> None
|
||||||
for filename in log_files:
|
for filename in log_files:
|
||||||
data_file_path = "/var/tmp/log2zulip.state"
|
data_file_path = "/var/tmp/log2zulip.state"
|
||||||
mkdir_p(os.path.dirname(data_file_path))
|
mkdir_p(os.path.dirname(data_file_path))
|
||||||
|
|
|
@ -10,9 +10,12 @@ import unicodedata
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
|
||||||
import zulip
|
import zulip
|
||||||
|
|
||||||
|
from typing import Set
|
||||||
|
|
||||||
zulip_client = zulip.Client(client="ZulipSyncPublicStreamsBot/0.1")
|
zulip_client = zulip.Client(client="ZulipSyncPublicStreamsBot/0.1")
|
||||||
|
|
||||||
def fetch_public_streams():
|
def fetch_public_streams():
|
||||||
|
# type: () -> Set[str]
|
||||||
public_streams = set()
|
public_streams = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue