* build: bump pylint to 2.17 Xref: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5062345 * fix pylint consider-using-f-string warnings pt 1: use flynt for automated fixes * fix pylint consider-using-f-string warnings pt 2: manual fixes * fix pylint consider-using-with warnings * fix pylint line-too-long warnings * fix pylint unspecified-encoding warnings * fix py lint consider-using-generator warning * fixup! fix pylint unspecified-encoding warnings * fix pylint line-too-long warnings
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			1.4 KiB
			
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			1.4 KiB
			
		
	
	
	
		
			Python
		
	
	
	
	
	
#!/usr/bin/env python3
 | 
						|
 | 
						|
import argparse
 | 
						|
import os
 | 
						|
import re
 | 
						|
import subprocess
 | 
						|
import sys
 | 
						|
 | 
						|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
 | 
						|
 | 
						|
 | 
						|
def main():
 | 
						|
  args = parse_args()
 | 
						|
 | 
						|
  chromedriver_name = {
 | 
						|
    'darwin': 'chromedriver',
 | 
						|
    'win32': 'chromedriver.exe',
 | 
						|
    'linux': 'chromedriver',
 | 
						|
    'linux2': 'chromedriver'
 | 
						|
}
 | 
						|
 | 
						|
  chromedriver_path = os.path.join(
 | 
						|
    args.source_root, args.build_dir, chromedriver_name[sys.platform])
 | 
						|
  with subprocess.Popen([chromedriver_path],
 | 
						|
                        stdout=subprocess.PIPE,
 | 
						|
                        universal_newlines=True) as proc:
 | 
						|
    try:
 | 
						|
      output = proc.stdout.readline()
 | 
						|
    except KeyboardInterrupt:
 | 
						|
      returncode = 0
 | 
						|
    finally:
 | 
						|
      proc.terminate()
 | 
						|
 | 
						|
  returncode = 0
 | 
						|
  match = re.search(
 | 
						|
    '^Starting ChromeDriver [0-9]+.[0-9]+.[0-9]+.[0-9]+ .* on port [0-9]+$',
 | 
						|
    output
 | 
						|
  )
 | 
						|
 | 
						|
  if match is None:
 | 
						|
    returncode = 1
 | 
						|
 | 
						|
  if returncode == 0:
 | 
						|
    print('ok ChromeDriver is able to be initialized.')
 | 
						|
 | 
						|
  return returncode
 | 
						|
 | 
						|
 | 
						|
def parse_args():
 | 
						|
    parser=argparse.ArgumentParser(description='Test ChromeDriver')
 | 
						|
    parser.add_argument('--source-root',
 | 
						|
                        default=SOURCE_ROOT,
 | 
						|
                        required=False)
 | 
						|
    parser.add_argument('--build-dir',
 | 
						|
                        default=None,
 | 
						|
                        required=True)
 | 
						|
    return parser.parse_args()
 | 
						|
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    sys.exit(main())
 |