mypy: Annotate puppet/zulip_ops.

This commit is contained in:
Jason Le 2016-12-02 21:17:24 -05:00 committed by Tim Abbott
parent a6f91064a2
commit 144d82305d
5 changed files with 14 additions and 5 deletions

View File

@ -13,16 +13,17 @@ from __future__ import print_function
import os
import time
RESULTS_DIR = "/home/zulip/mirror_status"
RESULTS_DIR = "/home/zulip/mirror_status" # type: str
states = {
"OK": 0,
"WARNING": 1,
"CRITICAL": 2,
"UNKNOWN": 3
}
} # type: Dict[str, int]
def report(state, output):
# type: (str, str) -> None
print("%s\n%s" % (state, output))
exit(states[state])

View File

@ -27,14 +27,18 @@ django.setup()
from zerver.models import UserActivity
if False:
from typing import Any
states = {
"OK": 0,
"WARNING": 1,
"CRITICAL": 2,
"UNKNOWN": 3
}
} # type: Dict[str, int]
def report(state, short_msg, too_old=None):
# type: (str, str, Set[Any]) -> None
too_old_data = ""
if too_old:
too_old_data = "\nLast call to get_message for recently out of date mirrors:\n" + "\n".join(

View File

@ -20,9 +20,10 @@ states = {
"WARNING": 1,
"CRITICAL": 2,
"UNKNOWN": 3
}
} # type: Dict[str, int]
def report(state, data, last_check):
# type: (str, str, float) -> None
print("%s: Last test run completed at %s\n%s" % (
state, time.strftime("%Y-%m-%d %H:%M %Z", time.gmtime(last_check)),
data))

View File

@ -54,14 +54,18 @@ import sys
import boto.utils
import netifaces
from six.moves import range
if False:
from typing import Optional
def address_of(device_id):
# type: (int) -> Optional[str]
try:
return netifaces.ifaddresses("ens%i" % device_id)[netifaces.AF_INET][0]['addr']
except KeyError:
return None
def guess_gateway(device_id):
# type: (int) -> str
# This will not work if the default gateway isn't n.n.n.1.
address = address_of(device_id).split('.')
address[3] = '1'

View File

@ -40,7 +40,6 @@ api/zulip/__init__.py
bots/githook-post-receive
bots/jabber_mirror_backend.py
bots/zephyr_mirror_backend.py
puppet/zulip_ops
tools/deprecated/inject-messages/inject-messages
zproject/settings.py
zproject/test_settings.py