forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify-chromedriver.py
61 lines (46 loc) · 1.38 KB
/
verify-chromedriver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import re
import shlex
import subprocess
import sys
import time
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
args = parse_args()
chromedriver_name = {
'darwin': 'chromedriver',
'win32': 'chromedriver.exe',
'linux2': 'chromedriver'
}
chromedriver_path = os.path.join(
args.source_root, args.build_dir, chromedriver_name[sys.platform])
proc = subprocess.Popen([chromedriver_path],
stdout=subprocess.PIPE, universal_newlines=True)
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 == 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())