Skip to content

Commit e89bb01

Browse files
committed
fixes for binarypath arg
1 parent 08c0939 commit e89bb01

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

browserstack/local.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import subprocess, os, time, json,logging
1+
import subprocess, os, time, json, logging, re
22
import psutil
33

44
from browserstack.local_binary import LocalBinary
@@ -70,7 +70,16 @@ def start(self, **kwargs):
7070
del self.options['key']
7171

7272
if 'binarypath' in self.options:
73-
self.binary_path = self.options['binarypath']
73+
candidate = os.path.realpath(self.options['binarypath'])
74+
if not os.path.isfile(candidate):
75+
raise BrowserStackLocalError('binarypath does not point to a file')
76+
try:
77+
version_output = subprocess.check_output([candidate, '--version']).decode('utf-8')
78+
except (subprocess.SubprocessError, OSError) as e:
79+
raise BrowserStackLocalError('binarypath failed verification: {}'.format(e))
80+
if not re.match(r'BrowserStack Local version \d+\.\d+', version_output):
81+
raise BrowserStackLocalError('binarypath failed verification')
82+
self.binary_path = candidate
7483
del self.options['binarypath']
7584
else:
7685
l = LocalBinary(self.key)

0 commit comments

Comments
 (0)