mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
import os
 | 
						|
import signal
 | 
						|
import subprocess
 | 
						|
import sys
 | 
						|
import time
 | 
						|
from typing import Tuple
 | 
						|
 | 
						|
from lib import sanity_check
 | 
						|
 | 
						|
sanity_check.check_venv(__file__)
 | 
						|
 | 
						|
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
 | 
						|
 | 
						|
def start_server(logfile_name: str) -> Tuple[bool, str]:
 | 
						|
    failure = True
 | 
						|
    key = "Quit the server with CTRL-C."
 | 
						|
    datalog = []
 | 
						|
    with open(logfile_name, 'rb', buffering=0) as logfile:
 | 
						|
        for i in range(200):
 | 
						|
            time.sleep(0.5)
 | 
						|
            print(f"{i}. Polling run-dev...")
 | 
						|
            new_data = logfile.read().decode()
 | 
						|
            if new_data:
 | 
						|
                datalog.append(new_data)
 | 
						|
 | 
						|
            if key in ''.join(datalog):
 | 
						|
                failure = False
 | 
						|
                break
 | 
						|
 | 
						|
    return failure, ''.join(datalog)
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    print("Testing development server start!")
 | 
						|
 | 
						|
    logfile_name = '/tmp/run-dev-output'
 | 
						|
    with open(logfile_name, 'wb', buffering=0) as logfile:
 | 
						|
        run_dev = subprocess.Popen(
 | 
						|
            [os.path.join(TOOLS_DIR, "run-dev.py")],
 | 
						|
            stdout=logfile, stderr=subprocess.STDOUT)
 | 
						|
        failure, log = start_server(logfile_name)
 | 
						|
 | 
						|
    run_dev.send_signal(signal.SIGINT)
 | 
						|
    run_dev.wait()
 | 
						|
 | 
						|
    if 'Traceback' in log:
 | 
						|
        failure = True
 | 
						|
 | 
						|
    if failure:
 | 
						|
        print("Development server is not working properly:")
 | 
						|
        print(log)
 | 
						|
        sys.exit(1)
 | 
						|
    else:
 | 
						|
        print("Development server is working properly.")
 | 
						|
        sys.exit(0)
 |