mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Make all scripts in scripts/ pass mypy check.
This commit is contained in:
		@@ -34,9 +34,10 @@ parser.add_option('--min-threshold',
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
(options, args) = parser.parse_args()
 | 
					(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'):
 | 
					for line in output.split('\n'):
 | 
				
			||||||
    parts = line.split('\t')
 | 
					    parts = line.split('\t')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@ states = {
 | 
				
			|||||||
    3: "UNKNOWN"
 | 
					    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)
 | 
					output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_queues'], shell=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
status = 0
 | 
					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"):
 | 
					for line in output.split("\n"):
 | 
				
			||||||
    line = line.strip()
 | 
					    line = line.strip()
 | 
				
			||||||
    m = re.match(line)
 | 
					    m = pattern.match(line)
 | 
				
			||||||
    if m:
 | 
					    if m:
 | 
				
			||||||
        queue = m.group(1)
 | 
					        queue = m.group(1)
 | 
				
			||||||
        count = int(m.group(2))
 | 
					        count = int(m.group(2))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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__), '..'))
 | 
					deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
 | 
				
			||||||
os.chdir(deploy_path)
 | 
					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'.")
 | 
					    logging.error("Must be run as user 'zulip'.")
 | 
				
			||||||
    sys.exit(1)
 | 
					    sys.exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
from __future__ import print_function
 | 
					from __future__ import print_function
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import six.moves.configparser
 | 
					import six.moves.configparser as configparser
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
force = False
 | 
					force = False
 | 
				
			||||||
@@ -13,7 +13,7 @@ if len(extra_args) and extra_args[0] in ('-f', '--force'):
 | 
				
			|||||||
    force = True
 | 
					    force = True
 | 
				
			||||||
    extra_args = extra_args[1:]
 | 
					    extra_args = extra_args[1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
config = six.moves.configparser.RawConfigParser()
 | 
					config = configparser.RawConfigParser()
 | 
				
			||||||
config.read("/etc/zulip/zulip.conf")
 | 
					config.read("/etc/zulip/zulip.conf")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
puppet_config = """
 | 
					puppet_config = """
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,9 +59,6 @@ bots/gcal-bot
 | 
				
			|||||||
bots/githook-post-receive
 | 
					bots/githook-post-receive
 | 
				
			||||||
frontend_tests/run-casper
 | 
					frontend_tests/run-casper
 | 
				
			||||||
puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time
 | 
					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/check-templates
 | 
				
			||||||
tools/compile-handlebars-templates
 | 
					tools/compile-handlebars-templates
 | 
				
			||||||
tools/deprecated/inject-messages/inject-messages
 | 
					tools/deprecated/inject-messages/inject-messages
 | 
				
			||||||
@@ -82,7 +79,6 @@ puppet/zulip_internal/files/zulip-ec2-configure-interfaces
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
exclude_scripts_py3 = """
 | 
					exclude_scripts_py3 = """
 | 
				
			||||||
bots/process_ccache
 | 
					bots/process_ccache
 | 
				
			||||||
scripts/restart-server
 | 
					 | 
				
			||||||
tools/post-receive
 | 
					tools/post-receive
 | 
				
			||||||
""".split()
 | 
					""".split()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user