Make all scripts in scripts/ pass mypy check.

This commit is contained in:
Eklavya Sharma 2016-07-24 00:03:58 +05:30
parent eba2d470dc
commit 11732f9ab0
5 changed files with 8 additions and 11 deletions

View File

@ -34,9 +34,10 @@ parser.add_option('--min-threshold',
(options, args) = parser.parse_args()
output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'], shell=False)
output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'],
universal_newlines=True)
consumers = defaultdict(int)
consumers = defaultdict(int) # type: Dict[str, int]
for line in output.split('\n'):
parts = line.split('\t')

View File

@ -23,7 +23,7 @@ states = {
3: "UNKNOWN"
}
re = re.compile(r'(\w+)\t(\d+)')
pattern = re.compile(r'(\w+)\t(\d+)')
output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_queues'], shell=False)
status = 0
@ -35,7 +35,7 @@ if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
for line in output.split("\n"):
line = line.strip()
m = re.match(line)
m = pattern.match(line)
if m:
queue = m.group(1)
count = int(m.group(2))

View File

@ -16,7 +16,7 @@ logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
os.chdir(deploy_path)
if pwd.getpwuid(os.getuid())[0] != "zulip":
if pwd.getpwuid(os.getuid()).pw_name != "zulip":
logging.error("Must be run as user 'zulip'.")
sys.exit(1)

View File

@ -3,7 +3,7 @@
from __future__ import print_function
import sys
import subprocess
import six.moves.configparser
import six.moves.configparser as configparser
import re
force = False
@ -13,7 +13,7 @@ if len(extra_args) and extra_args[0] in ('-f', '--force'):
force = True
extra_args = extra_args[1:]
config = six.moves.configparser.RawConfigParser()
config = configparser.RawConfigParser()
config.read("/etc/zulip/zulip.conf")
puppet_config = """

View File

@ -59,9 +59,6 @@ bots/gcal-bot
bots/githook-post-receive
frontend_tests/run-casper
puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time
scripts/nagios/check-rabbitmq-consumers
scripts/nagios/check-rabbitmq-queue
scripts/zulip-puppet-apply
tools/check-templates
tools/compile-handlebars-templates
tools/deprecated/inject-messages/inject-messages
@ -82,7 +79,6 @@ puppet/zulip_internal/files/zulip-ec2-configure-interfaces
exclude_scripts_py3 = """
bots/process_ccache
scripts/restart-server
tools/post-receive
""".split()