@@ -74,10 +74,10 @@ def start(self, **kwargs):
7474 if not os .path .isfile (candidate ):
7575 raise BrowserStackLocalError ('binarypath does not point to a file' )
7676 try :
77- version_output = subprocess .check_output ([candidate , '--version' ]).decode ('utf-8' )
77+ version_output = subprocess .check_output ([candidate , '--version' ], timeout = 10 ).decode ('utf-8' )
7878 except (subprocess .SubprocessError , OSError ) as e :
7979 raise BrowserStackLocalError ('binarypath failed verification: {}' .format (e ))
80- if not re .match (r'BrowserStack Local version \d+\.\d+' , version_output ):
80+ if not re .match (LocalBinary . VERSION_REGEX , version_output ):
8181 raise BrowserStackLocalError ('binarypath failed verification' )
8282 self .binary_path = candidate
8383 del self .options ['binarypath' ]
@@ -99,9 +99,6 @@ def start(self, **kwargs):
9999 if 'source' in self .options :
100100 del self .options ['source' ]
101101
102- self .proc = subprocess .Popen (self ._generate_cmd (), stdout = subprocess .PIPE , stderr = subprocess .PIPE )
103- (out , err ) = self .proc .communicate ()
104-
105102 logfile_dir = os .path .dirname (self .local_logfile_path )
106103 if logfile_dir :
107104 os .makedirs (logfile_dir , exist_ok = True )
@@ -110,6 +107,10 @@ def start(self, **kwargs):
110107 f .write ('' )
111108 except OSError as e :
112109 raise BrowserStackLocalError ('Unable to open logfile: {}' .format (e ))
110+
111+ self .proc = subprocess .Popen (self ._generate_cmd (), stdout = subprocess .PIPE , stderr = subprocess .PIPE )
112+ (out , err ) = self .proc .communicate ()
113+
113114 try :
114115 if out :
115116 output_string = out .decode ()
0 commit comments